/* Felt & Fold — layout, table and cards. No framework, no build step. */

:root {
  --felt-1: #1a6647;
  --felt-2: #0c3325;
  --rail: #2b1c13;
  --bg: #0a0d0c;
  --panel: #121916;
  --panel-2: #18211d;
  --line: rgba(244, 241, 232, 0.12);
  --text: #f2efe6;
  --muted: #9aa8a0;
  --gold: #e3b23c;
  --gold-soft: rgba(227, 178, 60, 0.16);
  --red: #d8463c;
  --green: #48c78e;
  --blue: #4c9be8;
  --card-radius: 7px;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --tabular: "Menlo", "SF Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* A display rule on one of these would otherwise keep it painted. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(120% 90% at 50% -10%, #16231d 0%, var(--bg) 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ layout */

.app {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 19rem;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "top   log"
    "table log"
    "ctrl  log";
  gap: 0;
}

.topbar    { grid-area: top; }
.table-wrap{ grid-area: table; min-height: 0; }
.controls  { grid-area: ctrl; }
.log-panel { grid-area: log; min-height: 0; }

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.7rem clamp(0.75rem, 2vw, 1.5rem);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.01)),
    #0d1311;
  box-shadow: 0 10px 24px -18px rgba(0, 0, 0, 0.9);
}
/* Gold hairline, the one piece of trim that ties the chrome to the felt. */
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent, rgba(227, 178, 60, 0.45) 22%, rgba(227, 178, 60, 0.45) 78%, transparent);
}

.brand { display: flex; align-items: center; gap: 0.6rem; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.25rem; height: 2.25rem;
  border-radius: 11px;
  background:
    radial-gradient(120% 100% at 30% 10%, rgba(255, 255, 255, 0.22), transparent 55%),
    linear-gradient(160deg, #26805a, var(--felt-2));
  border: 1px solid rgba(227, 178, 60, 0.35);
  box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.9), inset 0 -3px 6px rgba(0, 0, 0, 0.35);
  font-size: 1.15rem;
  color: #f6f2e6;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
  letter-spacing: 0.01em;
}

.tagline {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta {
  display: flex;
  gap: clamp(0.75rem, 2vw, 1.75rem);
  margin: 0 0 0 auto;
}

.meta div { text-align: right; }
.meta dt {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.meta dd {
  margin: 0.1rem 0 0;
  font-family: var(--tabular);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: #fbf6e8;
}
.meta div:last-child dd { color: var(--gold); }

.topbar-actions { display: flex; gap: 0.4rem; }

.ghost {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-radius: 9px;
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ghost:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.28); }
.ghost[aria-pressed="true"] { color: var(--gold); border-color: var(--gold-soft); background: var(--gold-soft); }

/* ------------------------------------------------------------------- table */

.table-wrap {
  display: grid;
  place-items: center;
  padding: clamp(0.5rem, 1.6vw, 1.25rem);
  overflow: auto;
}

/* The rail: a dark leather ring with a lit top edge and a stitched inner lip. */
.table {
  position: relative;
  width: min(100%, 60rem);
  aspect-ratio: 16 / 9.6;
  border-radius: 46% / 52%;
  padding: clamp(0.9rem, 2.6%, 1.9rem);
  background:
    linear-gradient(178deg,
      #6b5136 0%,
      #4a3521 18%,
      #33220f 52%,
      #1b1108 100%);
  box-shadow:
    0 30px 60px -20px rgba(0, 0, 0, 0.75),
    0 2px 0 rgba(255, 233, 196, 0.16) inset,
    0 -14px 26px -14px rgba(0, 0, 0, 0.9) inset;
}

/* Specular sweep across the rail, brightest at the top left. */
.table::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(120% 70% at 30% -8%, rgba(255, 236, 202, 0.3), transparent 55%),
    radial-gradient(80% 50% at 80% 108%, rgba(255, 216, 160, 0.09), transparent 60%);
  pointer-events: none;
}

.table-felt {
  position: absolute;
  inset: clamp(0.9rem, 2.6%, 1.9rem);
  border-radius: inherit;
  background-color: var(--felt-2);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E"),
    radial-gradient(62% 68% at 50% 26%, #24845c 0%, var(--felt-1) 42%, var(--felt-2) 86%);
  background-blend-mode: soft-light, normal;
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, 0.6),
    inset 0 0 0 2px rgba(0, 0, 0, 0.45),
    inset 0 0 0 4px rgba(227, 178, 60, 0.22),
    inset 0 14px 26px -14px rgba(0, 0, 0, 0.85);
}

/* The betting line, and the house monogram printed under the board. */
.table-felt::before {
  content: "";
  position: absolute;
  inset: 9% 7%;
  border-radius: 46% / 52%;
  border: 1px solid rgba(244, 241, 232, 0.09);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

/* House print, low on the felt where nothing is dealt. */
.table-felt::after {
  content: "FELT \0026 FOLD";
  position: absolute;
  left: 50%;
  top: 74%;
  transform: translate(-50%, -50%);
  font-size: clamp(0.5rem, 1.1vw, 0.78rem);
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  color: rgba(244, 241, 232, 0.09);
  white-space: nowrap;
  font-family: var(--font-display);
}

/* Centre of the table: pot, board, street name. */
.board {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  width: 78%;
  z-index: 1;
}

.pot {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.22rem 0.85rem 0.22rem 0.5rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(8, 20, 14, 0.82), rgba(4, 10, 7, 0.9));
  border: 1px solid rgba(227, 178, 60, 0.35);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.pot-label {
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
.pot-value {
  font-family: var(--tabular);
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.community {
  display: flex;
  gap: clamp(0.25rem, 1%, 0.55rem);
  min-height: calc(var(--card-w-board) * 1.4);
  align-items: center;
}
.community .card { --w: var(--card-w-board); }

.street-label {
  margin: 0;
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(242, 239, 230, 0.5);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ------------------------------------------------------------------- chips */

.chips {
  display: inline-flex;
  align-items: center;
  flex: none;
}
.chips .chip + .chip { margin-left: -42%; }

.chip {
  --chip-size: 1.05rem;
  --cf: #f2efe6;
  --ce: #c9c4b6;
  position: relative;
  display: block;
  width: var(--chip-size);
  height: var(--chip-size);
  border-radius: 50%;
  background: repeating-conic-gradient(var(--cf) 0 22.5deg, var(--ce) 22.5deg 45deg);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.chip::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: var(--cf);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22);
}

.chip.c-1   { --cf: #efece2; --ce: #b9b4a5; }
.chip.c-5   { --cf: #cf3a34; --ce: #f6f1e7; }
.chip.c-10  { --cf: #2f6fd0; --ce: #f6f1e7; }
.chip.c-25  { --cf: #1f9e63; --ce: #f6f1e7; }
.chip.c-100 { --cf: #2a2d33; --ce: #f6f1e7; }
.chip.c-500 { --cf: #7040c0; --ce: #f6f1e7; }

/* -------------------------------------------------------------------- seats */

/* Three card sizes: the opponents' are smallest, the board sits between, and
   your own hand is the largest thing on the table. */
.table {
  --card-w: clamp(32px, 4.8vw, 52px);
  --card-w-board: clamp(40px, 6.2vw, 66px);
  --card-w-hero: clamp(44px, 6.8vw, 74px);
}

.seat {
  position: absolute;
  width: 10rem;
  transform: translate(-50%, -50%);
  z-index: 2;
}

/* The top seat stacks the other way up so its cards fall towards the felt
   instead of hanging off the rail. */
.seat[data-seat="2"] .seat-inner { flex-direction: column-reverse; }

.seat[data-seat="1"] { left: 14%; top: 36%; }
.seat[data-seat="2"] { left: 50%; top: 13%; }
.seat[data-seat="3"] { left: 86%; top: 36%; }
.seat[data-seat="0"] { left: 50%; top: 90%; }

.seat-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.player {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.32rem 0.28rem 0.3rem;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(38, 50, 44, 0.97) 0%, rgba(14, 21, 18, 0.98) 100%);
  border: 1px solid rgba(244, 241, 232, 0.14);
  width: 100%;
  box-shadow:
    0 10px 22px -8px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.avatar {
  display: grid;
  place-items: center;
  width: 1.95rem; height: 1.95rem;
  flex: none;
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  color: #0c1410;
  background: linear-gradient(155deg, #e6e1d2 0%, #b3b0a2 55%, #8d958b 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -2px 4px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(0, 0, 0, 0.35);
}
.seat-hero .avatar {
  background: linear-gradient(155deg, #f3d489 0%, var(--gold) 45%, #a9762a 100%);
}

.player-text { display: grid; gap: 0.05rem; line-height: 1.15; min-width: 0; }

.player-name {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-style { font-size: 0.6rem; color: var(--muted); letter-spacing: 0.04em; }
/* The stack sits in its own little tray, like a chip rack. */
.player-stack {
  font-family: var(--tabular);
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
  color: var(--gold);
  margin-left: auto;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  box-shadow: inset 0 0 0 1px rgba(227, 178, 60, 0.22);
  white-space: nowrap;
}

.player.is-turn {
  border-color: var(--gold);
  box-shadow:
    0 0 0 1px rgba(227, 178, 60, 0.45),
    0 0 26px rgba(227, 178, 60, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  animation: turn-pulse 1.8s ease-in-out infinite;
}
@keyframes turn-pulse {
  50% { box-shadow: 0 0 0 1px rgba(227,178,60,0.7), 0 0 34px rgba(227,178,60,0.55), inset 0 1px 0 rgba(255,255,255,0.14); }
}
/* Fade the seat's own details, not the pill, so the action badge sitting on it
   stays readable. */
.player.is-folded .avatar,
.player.is-folded .player-text,
.player.is-folded .player-stack { opacity: 0.4; }
.player.is-out { opacity: 0.25; }
.player.is-winner {
  border-color: var(--green);
  box-shadow:
    0 0 0 1px rgba(72, 199, 142, 0.35),
    0 0 30px rgba(72, 199, 142, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* Turn clock: a thin bar that drains while a bot thinks. */
.turn-bar {
  position: absolute;
  left: 50%;
  bottom: -0.35rem;
  transform: translateX(-50%);
  width: 8rem;
  height: 2px;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}
.turn-bar:empty { opacity: 0; }
.turn-bar span {
  display: block;
  height: 100%;
  background: var(--gold);
  transform-origin: left center;
  animation: drain var(--think, 1s) linear forwards;
}
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Slight fan, so a pair of cards reads as a hand rather than two rectangles. */
.hole-cards { display: flex; gap: calc(var(--card-w) * 0.08); min-height: calc(var(--card-w) * 1.4); }
.hole-cards .card:first-child { transform: rotate(-3deg); }
.hole-cards .card:last-child { transform: rotate(3deg); }
.hole-cards .card.winning:first-child { transform: rotate(-3deg) translateY(-6px); }
.hole-cards .card.winning:last-child { transform: rotate(3deg) translateY(-6px); }

.seat-hero .hole-cards {
  gap: calc(var(--card-w-hero) * 0.08);
  min-height: calc(var(--card-w-hero) * 1.4);
}
.seat-hero .hole-cards .card { --w: var(--card-w-hero); }

/* Anchored to the player pill, so it does not float where the cards used to be
   once a hand is mucked. Each seat puts it on whichever side its cards are not. */
.seat[data-seat="1"] .badge,
.seat[data-seat="3"] .badge { top: auto; bottom: -0.62rem; }
.seat[data-seat="0"] .badge {
  top: 50%;
  right: auto;
  left: calc(100% + 0.5rem);
  transform: translateY(-50%);
}

.badge {
  position: absolute;
  top: -0.62rem;
  right: -0.15rem;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #2c3a33, #18221d);
  border: 1px solid rgba(244, 241, 232, 0.16);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}
.badge-fold  { color: var(--muted); }
.badge-check { color: var(--blue); }
.badge-call  { color: var(--text); }
.badge-bet, .badge-raise { color: var(--gold); border-color: var(--gold-soft); }
.badge-allin { color: #fff; background: var(--red); border-color: transparent; }

.dealer-button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 1.35rem; height: 1.35rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #ffffff, #ded8c8 60%, #b5ae9c);
  color: #12160f;
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 700;
  border: 1px solid rgba(0,0,0,0.4);
  box-shadow: 0 3px 8px rgba(0,0,0,0.6), inset 0 -2px 3px rgba(0,0,0,0.18);
  top: 50%;
  left: -0.6rem;
  transform: translateY(-50%);
}

/* Chips a player has pushed out on the current street. */
.bet-stack {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 0.32rem;
  font-family: var(--tabular);
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  padding: 0.14rem 0.5rem 0.14rem 0.2rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(10, 18, 14, 0.85), rgba(3, 8, 6, 0.9));
  border: 1px solid rgba(227, 178, 60, 0.28);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}
.bet-stack.bet-in { animation: bet-in 0.22s ease; }

/* Clones used for the sweep into the pot. */
.bet-stack.flying {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  margin: 0;
}

.pot.pot-fly {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  margin: 0;
}

.pot.pot-bump { animation: pot-bump 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
@keyframes pot-bump {
  35% { transform: scale(1.12); border-color: rgba(227, 178, 60, 0.85); }
  to  { transform: scale(1); }
}
@keyframes bet-in { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.seat[data-seat="0"] .bet-stack { top: -1.9rem; left: 50%; transform: translateX(-50%); }
.seat[data-seat="2"] .bet-stack { top: 2.7rem; left: calc(100% - 2.2rem); }
/* Side seats push their chips out below the pill; the dealer button then has
   the pill's inner edge to itself and stays on the felt. */
.seat[data-seat="1"] .bet-stack,
.seat[data-seat="3"] .bet-stack {
  top: auto;
  bottom: -1.7rem;
  left: 50%;
  transform: translateX(-50%);
}
.seat[data-seat="1"] .dealer-button { left: auto; right: -0.6rem; }
.seat[data-seat="3"] .dealer-button { left: -0.6rem; right: auto; }

.chip-dot {
  width: 0.85rem; height: 0.85rem;
  border-radius: 50%;
  background: repeating-conic-gradient(var(--red) 0 25%, #fff 0 50%);
  border: 1px solid rgba(0,0,0,0.4);
  flex: none;
}

/* -------------------------------------------------------------------- cards */

.card {
  --w: var(--card-w);
  position: relative;
  width: var(--w);
  height: calc(var(--w) * 1.4);
  border-radius: calc(var(--w) * 0.08);
  background:
    linear-gradient(200deg, #ffffff 0%, #fbf9f2 45%, #ece7d9 100%);
  color: #16181a;
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.3),
    0 6px 14px -4px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.9),
    inset 0 0 0 2px rgba(20, 20, 20, 0.07);
  flex: none;
  overflow: hidden;
  user-select: none;
  animation: deal-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.25) backwards;
}

@keyframes deal-in {
  from { transform: translateY(-40px) scale(0.55) rotate(-9deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.card.red   { color: #c8102e; }
.card.black { color: #1b1d21; }

/* Corner indices: rank over suit, repeated upside down in the far corner. */
.idx {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.92;
  font-family: var(--font-display);
  font-weight: 700;
}
.idx b { font-size: calc(var(--w) * 0.21); }
.idx i { font-size: calc(var(--w) * 0.17); font-style: normal; }
.idx-wide b { font-size: calc(var(--w) * 0.175); letter-spacing: -0.03em; }
.idx-tl { top: calc(var(--w) * 0.05); left: calc(var(--w) * 0.06); }
.idx-br {
  bottom: calc(var(--w) * 0.05);
  right: calc(var(--w) * 0.06);
  transform: rotate(180deg);
}

/* The pip field sits inside the two indices. */
.face {
  position: absolute;
  inset: calc(var(--w) * 0.15) calc(var(--w) * 0.17);
}

.pip {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: calc(var(--w) * 0.26);
  line-height: 1;
}
.pip.flipped { transform: translate(-50%, -50%) rotate(180deg); }

.face-ace { display: grid; place-items: center; }
.pip-ace {
  position: static;
  transform: none;
  font-size: calc(var(--w) * 0.72);
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Court cards get a framed monogram rather than a cartoon: the letter between
   two suit marks, the lower one printed upside down like the corner indices. */
.face-court {
  inset: calc(var(--w) * 0.12) calc(var(--w) * 0.15);
  display: grid;
  place-items: stretch;
}
.court {
  display: grid;
  align-content: space-between;
  justify-items: center;
  padding: calc(var(--w) * 0.05) 0;
  border-radius: calc(var(--w) * 0.05);
  border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
  background:
    linear-gradient(150deg,
      color-mix(in srgb, currentColor 11%, transparent) 0%,
      color-mix(in srgb, currentColor 3%, transparent) 48%,
      color-mix(in srgb, currentColor 10%, transparent) 100%);
  box-shadow:
    inset 0 0 0 calc(var(--w) * 0.018) rgba(255, 255, 255, 0.6),
    inset 0 0 calc(var(--w) * 0.1) rgba(0, 0, 0, 0.06);
}
.court-letter {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: calc(var(--w) * 0.52);
  line-height: 0.82;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}
.court-suit { font-size: calc(var(--w) * 0.19); line-height: 1; }
.court-suit-flipped { transform: rotate(180deg); }

/* Backs: a lattice weave under a rimmed medallion. */
.card.back {
  background: linear-gradient(165deg, #9c2733 0%, #7a1a26 45%, #551119 100%);
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.35),
    0 6px 14px -4px rgba(0, 0, 0, 0.6),
    inset 0 0 0 calc(var(--w) * 0.045) #f3efe4,
    inset 0 0 0 calc(var(--w) * 0.06) rgba(0, 0, 0, 0.3);
}
.back-weave {
  position: absolute;
  inset: calc(var(--w) * 0.09);
  border-radius: calc(var(--w) * 0.05);
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.13) 0 1.5px, transparent 1.5px 6px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.22) 0 1.5px, transparent 1.5px 6px);
}
.back-medallion {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--w) * 0.5);
  height: calc(var(--w) * 0.5);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.22), transparent 65%);
  display: grid;
  place-items: center;
}
.back-medallion::after {
  content: "\2660";
  font-size: calc(var(--w) * 0.26);
  color: rgba(255, 245, 235, 0.6);
}

.card.dim { opacity: 0.38; }

.card.winning {
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 22px rgba(227, 178, 60, 0.55),
    0 12px 22px -8px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(255, 255, 255, 0.9);
  transform: translateY(-7px);
  z-index: 1;
}
/* At a showdown the hands that lost stay visible but stop competing. */
.is-showdown .card:not(.winning):not(.back) { filter: saturate(0.55) brightness(0.82); }

.card.placeholder {
  background: rgba(255, 255, 255, 0.025);
  border: 1px dashed rgba(244, 241, 232, 0.14);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.25);
  animation: none;
}

/* ----------------------------------------------------------------- controls */

.controls {
  position: relative;
  display: grid;
  gap: 0.55rem;
  justify-items: center;
  padding: 0.8rem clamp(0.75rem, 2vw, 1.5rem) max(0.9rem, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.25)),
    #0d1311;
}
.controls::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent, rgba(227, 178, 60, 0.3) 25%, rgba(227, 178, 60, 0.3) 75%, transparent);
}

.controls-message {
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 1.1rem;
  text-align: center;
  letter-spacing: 0.01em;
}
.controls-message strong { color: var(--gold); font-weight: 600; }

.action-row { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 11px;
  padding: 0.68rem 1.15rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  color: #0c1210;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 6.5rem;
  justify-content: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 0 rgba(0, 0, 0, 0.18),
    0 3px 0 var(--btn-edge, rgba(0, 0, 0, 0.35)),
    0 8px 18px -8px rgba(0, 0, 0, 0.9);
  transition: transform 0.1s ease, filter 0.15s ease, box-shadow 0.1s ease;
}
.btn:hover { filter: brightness(1.07); }
.btn:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 1px 0 var(--btn-edge, rgba(0, 0, 0, 0.35));
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; filter: none; }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.btn kbd {
  font-family: var(--tabular);
  font-size: 0.62rem;
  opacity: 0.55;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 0.25rem;
}
.btn .amount { font-family: var(--tabular); font-variant-numeric: tabular-nums; }

.btn-fold  { background: linear-gradient(175deg, #f2eee2, #cfc9b8); --btn-edge: #9b9583; }
.btn-check { background: linear-gradient(175deg, #6fb4f2, #3a86d6); color: #04131f; --btn-edge: #1f5f9f; }
.btn-call  { background: linear-gradient(175deg, #6bdcaa, #2fac79); color: #04170f; --btn-edge: #1b7c55; }
.btn-raise { background: linear-gradient(175deg, #f0c968, #c9922c); --btn-edge: #8d6318; }
.btn-next  { background: linear-gradient(175deg, #f0c968, #c9922c); --btn-edge: #8d6318; }

.raise-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: min(100%, 34rem);
}

#raise-slider {
  flex: 1 1 auto;
  min-width: 0;
  appearance: none;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--gold) var(--fill, 0%), rgba(255,255,255,0.14) var(--fill, 0%));
  cursor: pointer;
}
#raise-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #2b1c13;
  cursor: grab;
}
#raise-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #2b1c13;
}

.presets { display: flex; gap: 0.3rem; flex: none; }

.chip-btn {
  appearance: none;
  border: 1px solid rgba(244, 241, 232, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  color: var(--text);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chip-btn:hover {
  background: linear-gradient(180deg, rgba(227, 178, 60, 0.28), rgba(227, 178, 60, 0.12));
  border-color: rgba(227, 178, 60, 0.5);
  color: #fff6e2;
}

/* --------------------------------------------------------------- log panel */

.log-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-left: 1px solid rgba(244, 241, 232, 0.08);
  background: linear-gradient(180deg, #111816 0%, #0c110f 100%);
}

.log-panel h2 {
  margin: 0;
  background: var(--panel);
  padding: 0.75rem 1rem 0.5rem;
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.log {
  margin: 0;
  padding: 0 1rem 1rem;
  list-style: none;
  overflow-y: auto;
  font-size: 0.78rem;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.log li { color: var(--muted); animation: log-in 0.2s ease; }
.log li b { color: #e8e4d8; font-weight: 600; }
.log li:last-child { color: #d3dbd5; }
.log li.street {
  color: var(--gold);
  border-top: 1px solid var(--line);
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.log li.result {
  color: #7fe0b3;
  background: rgba(72, 199, 142, 0.08);
  border-left: 2px solid rgba(72, 199, 142, 0.5);
  margin: 0.15rem -0.5rem 0.15rem -0.6rem;
  padding: 0.12rem 0.5rem 0.12rem 0.5rem;
  border-radius: 0 4px 4px 0;
}
@keyframes log-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------------- overlay */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 8, 6, 0.72);
  padding: 1rem;
  z-index: 50;
}
.overlay[hidden] { display: none; }

.dialog {
  width: min(34rem, 100%);
  max-height: 82vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}
.dialog h2 { margin: 0 0 0.8rem; font-family: var(--font-display); font-size: 1.3rem; }
.dialog h3 { margin: 1.1rem 0 0.35rem; font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.dialog p, .dialog li { font-size: 0.85rem; line-height: 1.55; color: #cfd6d0; }
.dialog ol, .dialog ul { padding-left: 1.1rem; margin: 0.3rem 0; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 1.2rem; }

.rank-list { list-style: none; padding: 0; margin: 0.3rem 0 0; display: grid; gap: 0.15rem; }
.rank-list li { display: flex; justify-content: space-between; gap: 1rem; }
.rank-list span:last-child { color: var(--muted); font-size: 0.78rem; }

/* ------------------------------------------------------------- responsive */

@media (max-width: 950px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "top" "table" "ctrl" "log";
  }
  .log-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 7.5rem;
  }
  .log-panel h2 { padding: 0.5rem 1rem 0.25rem; }
  .meta div:nth-child(2) { display: none; }
}

@media (max-width: 720px) {
  /* One knob for the whole phone layout: everything below is in rem. */
  html { font-size: 14px; }

  .table-wrap { padding: 0.4rem 0.4rem 0.2rem; }
  /* Fill the height instead of leaving a band of background above and below. */
  .table {
    width: 100%;
    height: 100%;
    max-height: 36rem;
    aspect-ratio: auto;
    border-radius: 42% / 46%;
    --card-w: clamp(26px, 8.6vw, 40px);
  }
  .seat { width: 8.4rem; }
  .seat[data-seat="1"] { left: 23%; top: 33%; }
  .seat[data-seat="2"] { left: 50%; top: 10%; }
  .seat[data-seat="3"] { left: 77%; top: 33%; }
  .seat[data-seat="0"] { left: 50%; top: 87%; }
  .seat-inner { gap: 0.25rem; }

  .player { padding: 0.22rem 0.45rem 0.22rem 0.22rem; gap: 0.3rem; }
  .avatar { width: 1.5rem; height: 1.5rem; font-size: 0.75rem; }
  .player-name { font-size: 0.72rem; }
  .player-style { display: none; }
  .player-stack { font-size: 0.7rem; padding-left: 0.25rem; }
  .badge { font-size: 0.55rem; top: -0.5rem; }
  .dealer-button { width: 1.1rem; height: 1.1rem; font-size: 0.55rem; left: -0.5rem; }
  .bet-stack { font-size: 0.68rem; padding: 0.1rem 0.4rem 0.1rem 0.15rem; }
  .chip-dot { width: 0.7rem; height: 0.7rem; }

  .seat[data-seat="1"] .bet-stack,
  .seat[data-seat="3"] .bet-stack {
    top: auto; bottom: -1.5rem; left: 50%; right: auto;
    transform: translateX(-50%);
  }
  .seat[data-seat="2"] .bet-stack { top: 2.1rem; left: calc(100% - 1.8rem); }

  .board { width: 96%; top: 57%; gap: 0.35rem; }
  .pot { padding: 0.15rem 0.6rem; }
  .pot-value { font-size: 0.95rem; }

  .topbar { gap: 0.6rem; padding: 0.5rem 0.75rem; }
  .brand h1 { font-size: 0.95rem; white-space: nowrap; }
  .brand .tagline { display: none; }
  .brand-mark { width: 1.8rem; height: 1.8rem; }
  .meta { gap: 0.75rem; }
  .meta div:first-child, .meta div:nth-child(2) { display: none; }
  .ghost { padding: 0.35rem 0.5rem; font-size: 0.75rem; }

  .controls { gap: 0.4rem; padding: 0.55rem 0.75rem max(0.7rem, env(safe-area-inset-bottom)); }
  .controls-message { font-size: 0.75rem; }
  .btn { min-width: 0; padding: 0.6rem 0.75rem; font-size: 0.85rem; flex: 1 1 auto; }
  .btn kbd { display: none; }
  .action-row { width: 100%; gap: 0.4rem; }
  .raise-row { flex-wrap: wrap; gap: 0.45rem; }
  #raise-slider { flex-basis: 100%; }
  .presets { width: 100%; justify-content: stretch; gap: 0.35rem; }
  .chip-btn { flex: 1; padding: 0.3rem 0.2rem; }

  .log-panel { max-height: 6.5rem; }
  .log { font-size: 0.72rem; padding: 0 0.75rem 0.5rem; }
  .log-panel h2 { padding: 0.4rem 0.75rem 0.25rem; }
}

/* Landscape phones: the table would not fit above the buttons at all. */
@media (max-height: 520px) and (orientation: landscape) {
  .topbar { padding-block: 0.3rem; }
  .log-panel { display: none; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "table" "ctrl"; }
  .table { aspect-ratio: 16 / 8.2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
