/* Casino War — game.css
   Every rule is scoped under .cwr- (or #cwr- ids) so this file can neither
   leak into nor be overridden by the shared site stylesheet. No external
   images — card faces, chips and glyphs are all CSS/text (♠ ♥ ♦ ♣). */

:root {
  --cwr-felt-1: #5c0f16;
  --cwr-felt-2: #7a151d;
  --cwr-felt-edge: #340a0e;
  --cwr-panel: #241012;
  --cwr-panel-raised: #331619;
  --cwr-ink: #f7efec;
  --cwr-ink-dim: #cba9a6;
  --cwr-gold: #e8c25e;
  --cwr-gold-bright: #ffe08a;
  --cwr-red: #ff6b6b;
  --cwr-green-ok: #55c98a;
  --cwr-card-white: #f8f5ec;
  --cwr-card-back-1: #6b1319;
  --cwr-card-back-2: #430b0f;
  --cwr-shadow: rgba(0, 0, 0, 0.45);
  --cwr-radius-lg: 18px;
  --cwr-radius-md: 12px;
  --cwr-radius-sm: 8px;
  --cwr-safe-top: env(safe-area-inset-top, 0px);
  --cwr-safe-bottom: env(safe-area-inset-bottom, 0px);
  --cwr-safe-left: env(safe-area-inset-left, 0px);
  --cwr-safe-right: env(safe-area-inset-right, 0px);
}

/* Playing state: hide the shared site chrome while a hand is in progress,
   same pattern as the rest of the platform. */
body:has(.cwr-root.is-playing) .cwr-site-header,
body:has(.cwr-root.is-playing) #footer {
  display: none;
}

.cwr-root {
  --cwr-max-width: 520px;
  position: relative;
  min-height: 100dvh;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--cwr-felt-2) 0%, var(--cwr-felt-1) 55%, var(--cwr-felt-edge) 100%);
  color: var(--cwr-ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
  padding-left: var(--cwr-safe-left);
  padding-right: var(--cwr-safe-right);
  box-sizing: border-box;
}

.cwr-root * {
  box-sizing: border-box;
}

.cwr-root button {
  font-family: inherit;
}

/* ---------- Screens ---------- */

.cwr-screen {
  min-height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--cwr-safe-top)) 16px calc(24px + var(--cwr-safe-bottom));
}

.cwr-screen[aria-hidden="true"] {
  display: none;
}

/* ---------- Loading ---------- */

.cwr-loading-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.cwr-loading-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--cwr-gold);
  margin-bottom: 20px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.cwr-progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--cwr-panel);
  border: 1px solid rgba(232, 194, 94, 0.25);
  overflow: hidden;
}

.cwr-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cwr-gold), var(--cwr-gold-bright));
  transition: width 0.25s ease;
}

.cwr-loading-hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--cwr-ink-dim);
}

/* ---------- Menu ---------- */

.cwr-menu-card {
  width: 100%;
  max-width: var(--cwr-max-width);
  background: linear-gradient(180deg, var(--cwr-panel-raised), var(--cwr-panel));
  border: 1px solid rgba(232, 194, 94, 0.2);
  border-radius: var(--cwr-radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 50px var(--cwr-shadow);
}

.cwr-title {
  margin: 0 0 6px;
  font-size: 34px;
  font-weight: 800;
  color: var(--cwr-gold);
  letter-spacing: 0.01em;
}

.cwr-tagline {
  margin: 0 0 24px;
  color: var(--cwr-ink-dim);
  font-size: 15px;
}

.cwr-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cwr-fineprint {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--cwr-ink-dim);
  opacity: 0.8;
}

/* ---------- Buttons ---------- */

.cwr-btn {
  appearance: none;
  border: none;
  border-radius: var(--cwr-radius-md);
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
  touch-action: manipulation;
}

.cwr-btn:active {
  transform: scale(0.97);
}

.cwr-btn-primary {
  background: linear-gradient(180deg, var(--cwr-gold-bright), var(--cwr-gold));
  color: #23180a;
  box-shadow: 0 8px 18px rgba(232, 194, 94, 0.25);
}

.cwr-btn-primary:hover {
  filter: brightness(1.05);
}

.cwr-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--cwr-ink);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.cwr-btn-disabled,
.cwr-btn:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: var(--cwr-ink-dim);
  cursor: not-allowed;
  opacity: 0.7;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.cwr-btn:disabled:active {
  transform: none;
}

.cwr-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.12);
  color: var(--cwr-ink-dim);
  padding: 3px 8px;
  border-radius: 999px;
}

.cwr-icon-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--cwr-ink);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Help / Paytable ---------- */

.cwr-help-card {
  width: 100%;
  max-width: var(--cwr-max-width);
  background: linear-gradient(180deg, var(--cwr-panel-raised), var(--cwr-panel));
  border: 1px solid rgba(232, 194, 94, 0.2);
  border-radius: var(--cwr-radius-lg);
  padding: 24px;
  box-shadow: 0 20px 50px var(--cwr-shadow);
}

.cwr-help-title {
  margin: 0 0 10px;
  color: var(--cwr-gold);
  font-size: 22px;
  font-weight: 800;
}

.cwr-help-copy {
  margin: 0 0 16px;
  color: var(--cwr-ink-dim);
  font-size: 14px;
  line-height: 1.5;
}

.cwr-help-copy-small {
  font-size: 12px;
  margin-top: 4px;
}

.cwr-table-wrap {
  overflow-x: auto;
  border-radius: var(--cwr-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.cwr-paytable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 280px;
}

.cwr-paytable th,
.cwr-paytable td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.cwr-paytable th {
  color: var(--cwr-gold);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.2);
}

.cwr-paytable td:last-child,
.cwr-paytable th:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--cwr-gold-bright);
  font-weight: 700;
}

.cwr-paytable tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- Play screen layout ---------- */

.cwr-screen-play {
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  padding-top: calc(12px + var(--cwr-safe-top));
  padding-bottom: calc(12px + var(--cwr-safe-bottom));
  max-width: var(--cwr-max-width);
  margin: 0 auto;
  gap: 12px;
}

.cwr-play-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cwr-balance-chip {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(232, 194, 94, 0.25);
  border-radius: 999px;
  padding: 8px 16px;
}

.cwr-balance-label {
  font-size: 11px;
  color: var(--cwr-ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cwr-balance-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--cwr-gold-bright);
  font-variant-numeric: tabular-nums;
}

.cwr-balance-currency {
  font-size: 11px;
  color: var(--cwr-ink-dim);
}

/* ---------- Table felt ---------- */

.cwr-table-felt {
  position: relative;
  border-radius: var(--cwr-radius-lg);
  background:
    radial-gradient(120% 140% at 50% 0%, var(--cwr-felt-2) 0%, var(--cwr-felt-1) 60%, var(--cwr-felt-edge) 100%);
  border: 6px solid #3a2211;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45), 0 12px 30px var(--cwr-shadow);
  padding: 18px 12px 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

/* A round (dealer / VS / player) is a plain content-sized flex row — no
   flex-grow, no forced min-height, no centering wrapper stretching it to
   fill the felt. It simply sizes to its cards. */
.cwr-round {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.cwr-round-dim {
  opacity: 0.35;
  filter: grayscale(0.4);
}

.cwr-lane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 96px;
}

.cwr-lane-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cwr-gold);
  font-weight: 700;
}

.cwr-vs {
  font-size: 13px;
  font-weight: 800;
  color: var(--cwr-ink-dim);
  letter-spacing: 0.08em;
}

/* ---------- Cards ---------- */

.cwr-card {
  width: 96px;
  aspect-ratio: 2 / 3;
  perspective: 800px;
}

.cwr-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.cwr-card.is-flipped .cwr-card-inner {
  transform: rotateY(180deg);
}

.cwr-card.is-winning .cwr-card-inner {
  animation: cwr-card-pop 0.5s ease 0.1s 1;
}

.cwr-card.is-losing .cwr-card-front {
  filter: saturate(0.5) brightness(0.85);
}

.cwr-card-back,
.cwr-card-front {
  position: absolute;
  inset: 0;
  border-radius: 7px;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cwr-card-back {
  background:
    repeating-linear-gradient(45deg, var(--cwr-card-back-1) 0 6px, var(--cwr-card-back-2) 6px 12px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.cwr-card-back::after {
  content: '';
  width: 55%;
  height: 55%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
}

.cwr-card-front {
  background: var(--cwr-card-white);
  color: #1a1a1a;
  transform: rotateY(180deg);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  flex-direction: column;
  padding: 6% 6%;
  position: absolute;
}

.cwr-card-front.cwr-suit-red {
  color: var(--cwr-red);
}

.cwr-card-rank-top,
.cwr-card-rank-bottom {
  position: absolute;
  font-size: clamp(13px, 4vw, 18px);
  font-weight: 800;
  line-height: 1;
}

.cwr-card-rank-top {
  top: 8%;
  left: 8%;
}

.cwr-card-rank-bottom {
  bottom: 8%;
  right: 8%;
  transform: rotate(180deg);
}

.cwr-card-suit-big {
  font-size: clamp(24px, 8vw, 40px);
}

.cwr-card-empty .cwr-card-suit-big {
  opacity: 0.15;
}

@keyframes cwr-card-pop {
  0% { transform: rotateY(180deg) scale(1); }
  40% { transform: rotateY(180deg) scale(1.12); }
  100% { transform: rotateY(180deg) scale(1); }
}

/* ---------- War round ---------- */

.cwr-round-war {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Native [hidden] defaults to display:none, but .cwr-round-war above sets
   display:flex unconditionally — that would win over the browser default
   and leave the whole War round visible (and its buttons/cards live)
   even when the [hidden] attribute is present. This guard restores the
   correct behavior. */
.cwr-round-war[hidden] {
  display: none;
}

.cwr-burn-row {
  display: flex;
  gap: 6px;
}

.cwr-burn-card {
  width: 22px;
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  background:
    repeating-linear-gradient(45deg, var(--cwr-card-back-1) 0 4px, var(--cwr-card-back-2) 4px 8px);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  opacity: 0.8;
}

/* ---------- War choice panel ---------- */

.cwr-war-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(232, 194, 94, 0.3);
  border-radius: var(--cwr-radius-md);
  padding: 16px;
  text-align: center;
}

/* Same [hidden] guard as .cwr-round-war above — required because this
   class also carries an unconditional display:flex. */
.cwr-war-panel[hidden] {
  display: none;
}

.cwr-war-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--cwr-gold-bright);
}

.cwr-war-copy {
  margin: 0;
  font-size: 13px;
  color: var(--cwr-ink-dim);
}

.cwr-war-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.cwr-war-actions .cwr-btn {
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cwr-war-sub {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.8;
}

/* ---------- Result ---------- */

.cwr-result {
  min-height: 24px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--cwr-ink-dim);
}

.cwr-result.cwr-result-win {
  color: var(--cwr-green-ok);
}

.cwr-result.cwr-result-lose {
  color: var(--cwr-ink-dim);
}

/* ---------- Stats row ---------- */

.cwr-stats-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.cwr-stat {
  flex: 1;
  max-width: 160px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--cwr-radius-sm);
  padding: 8px 10px;
  text-align: center;
}

.cwr-stat-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cwr-ink-dim);
}

.cwr-stat-value {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: var(--cwr-ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- Controls ---------- */

.cwr-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 4px;
}

.cwr-bet-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 6px 10px;
}

.cwr-bet-label {
  font-size: 11px;
  color: var(--cwr-ink-dim);
  text-transform: uppercase;
  padding-left: 4px;
}

.cwr-bet-btn {
  appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--cwr-ink);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.cwr-bet-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cwr-bet-value {
  min-width: 56px;
  text-align: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.cwr-btn-deal {
  flex: 1;
  font-size: 18px;
  letter-spacing: 0.04em;
  padding: 16px 20px;
}

.cwr-btn-deal:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Small screens ---------- */

@media (max-width: 380px) {
  .cwr-lane {
    width: 78px;
  }
  .cwr-card {
    width: 78px;
  }
  .cwr-title {
    font-size: 28px;
  }
  .cwr-round {
    gap: 10px;
  }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .cwr-card-inner,
  .cwr-progress-bar,
  .cwr-card.is-winning .cwr-card-inner {
    animation: none !important;
    transition: none !important;
  }
}
