/* ==========================================================================
   Midnight Hold'em
   Layout idea: the page is a column (top bar, table stage, action dock).
   The stage is a size container, so every size inside the table (cards,
   seats, chips) is computed from the room the table really has, not from
   the window. Wide stages use a landscape seat layout, tall stages a
   portrait one.
   ========================================================================== */

:root {
  --bg0: #050813;
  --bg1: #0b1230;
  --panel: rgba(11, 18, 42, 0.82);
  --panel-solid: #0e1636;
  --line: rgba(255, 255, 255, 0.11);
  --text: #e9eeff;
  --muted: #8f9cc6;
  --gold: #f3c969;
  --gold-deep: #c8912c;
  --teal: #2fd3b3;
  --coral: #ff6b7a;
  --blue: #5aa2ff;
  --felt-hi: #17717f;
  --felt-mid: #0c3d4b;
  --felt-lo: #06222d;
  --rail-hi: #3a2a66;
  --rail-lo: #150e30;
  --ink-s: #131a2d;
  --ink-h: #d3263f;
  --ink-d: #d3263f;
  --ink-c: #131a2d;
  --topbar-h: 52px;
  --radius: 14px;
  color-scheme: dark;
}

[data-fourcolor="on"] {
  --ink-d: #1c6ee0;
  --ink-c: #0f8f58;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 50% -10%, #17224f 0%, transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ---------- top bar ---------- */

.topbar {
  flex: none;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 8, 19, 0.55);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 24px; height: 24px; flex: none;
  background: linear-gradient(145deg, var(--gold), var(--gold-deep));
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}
.brand-name { font-weight: 800; letter-spacing: 0.01em; white-space: nowrap; }
.brand-name em { font-style: normal; color: var(--gold); font-weight: 600; }

.meta { display: flex; gap: 8px; align-items: center; min-width: 0; overflow: hidden; }
.chip-pill {
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 5px 10px; border-radius: 99px; white-space: nowrap;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.chip-pill.net.up { color: var(--teal); }
.chip-pill.net.down { color: var(--coral); }

.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: 10px; color: var(--muted);
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }

/* ---------- stage ---------- */

.stage {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  container: stage / size;
}

.stage-inner {
  position: absolute;
  inset: 0;
  /* --u is the basic length for seats and chips, --cw the width of a board card */
  --u: clamp(8.5px, min(1.05cqw, 1.95cqh), 16px);
  --cw: clamp(34px, min(6.4cqw, 12.5cqh), 86px);
  --bw: calc(var(--u) * 3.7);       /* opponent hole card width */
  --hw: calc(var(--cw) * 1.08);     /* your hole card width */
  font-size: var(--u);
}

/* tall or narrow stage: portrait layout */
@container stage (max-aspect-ratio: 23/20) {
  .stage-inner {
    --u: clamp(7.5px, min(2.5cqw, 1.9cqh), 15px);
    --cw: clamp(30px, min(15cqw, 10.2cqh), 84px);
    --bw: calc(var(--u) * 3.9);
    --hw: calc(var(--cw) * 1.12);
  }
}

/*
 * Seat positions, as percentages of the stage.
 *   --x / --y   centre of the name panel (seats 0 and 3 are pinned to the stage edge instead, see below)
 * Seats go clockwise from the bottom: 0 you, 1 lower left, 2 upper left, 3 top, 4 upper right, 5 lower right.
 *
 * A seat's bet is a child of its name panel and sits on the side that faces the table, so it always
 * scales with the seat. Each seat picks a side with the --b* variables (see "bets" further down):
 *   R right of the panel, L left of it, D below the seat's cards, U above them.
 */
[data-pos="0"] { --x: 50%; --y: 85%; }
[data-pos="1"] { --x: 10%; --y: 70%; }
[data-pos="2"] { --x: 16%; --y: 18%; }
[data-pos="3"] { --x: 50%; --y: 12%; }
[data-pos="4"] { --x: 84%; --y: 18%; }
[data-pos="5"] { --x: 90%; --y: 70%; }

@container stage (max-aspect-ratio: 23/20) {
  [data-pos="0"] { --x: 50%; --y: 87%; }
  [data-pos="1"] { --x: 15%; --y: 70%; }
  [data-pos="2"] { --x: 15%; --y: 24%; }
  [data-pos="3"] { --x: 50%; --y: 10%; }
  [data-pos="4"] { --x: 85%; --y: 24%; }
  [data-pos="5"] { --x: 85%; --y: 70%; }
}

/* which side of the seat its bet appears on (six seat arrangement) */
[data-pos="1"], [data-pos="2"], [data-pos="3"] { --bl: calc(100% + 0.6em); --br: auto; --bt: 50%; --bb: auto; --btx: 0; --bty: -50%; }
[data-pos="4"], [data-pos="5"] { --bl: auto; --br: calc(100% + 0.6em); --bt: 50%; --bb: auto; --btx: 0; --bty: -50%; }
[data-pos="0"] { --bl: 50%; --br: auto; --bt: auto; --bb: calc(100% + var(--hw) * 0.98 + 0.5em); --btx: -50%; --bty: 0; }
/* tall stage: the side seats put their bet just under the name panel (their action tag moves above it) */
@container stage (max-aspect-ratio: 23/20) {
  [data-pos="1"], [data-pos="2"], [data-pos="4"], [data-pos="5"] {
    --bl: 50%; --br: auto; --bt: calc(100% + 0.5em); --bb: auto; --btx: -50%; --bty: 0;
  }
  .seat[data-pos="1"] .tag, .seat[data-pos="2"] .tag, .seat[data-pos="4"] .tag, .seat[data-pos="5"] .tag { top: -0.95em; bottom: auto; }
  /* the top seat has side seats close by on a tall stage, so its bet goes below its cards */
  [data-pos="3"] { --bl: 50%; --br: auto; --bt: calc(100% + var(--bw) * 0.9 + 0.5em); --bb: auto; --btx: -50%; --bty: 0; }
}
/* very short wide stage: your bet goes beside your panel because there is no room above your cards */
@container stage (max-height: 330px) and (min-aspect-ratio: 23/20) {
  [data-pos="0"] { --bl: auto; --br: calc(100% + 0.6em); --bt: 50%; --bb: auto; --btx: 0; --bty: -50%; }
}

/* ----- the felt ----- */
.felt {
  position: absolute;
  left: 3.5%; right: 3.5%; top: 6%; bottom: 9%;
  border-radius: 999px;
  padding: calc(var(--u) * 1.15);
  background: linear-gradient(160deg, var(--rail-hi), var(--rail-lo) 70%);
  box-shadow:
    0 calc(var(--u) * 1.4) calc(var(--u) * 3) rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(243, 201, 105, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.12);
}
.felt-cloth {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 50% 42%, var(--felt-hi) 0%, var(--felt-mid) 55%, var(--felt-lo) 100%);
  box-shadow:
    inset 0 0 0 calc(var(--u) * 0.18) rgba(243, 201, 105, 0.55),
    inset 0 0 calc(var(--u) * 4) rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.felt-cloth::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 5px);
  mix-blend-mode: overlay;
}
.felt-cloth::after {
  /* a thin inner racetrack line */
  content: "";
  position: absolute; inset: calc(var(--u) * 1.6);
  border-radius: 999px;
  border: 1px solid rgba(243, 201, 105, 0.16);
}
.felt-mark {
  position: absolute; left: 50%; top: 50%;
  translate: -50% -50%;
  display: flex; flex-direction: column; align-items: center;
  color: rgba(243, 201, 105, 0.12);
  text-transform: uppercase; letter-spacing: 0.4em; font-weight: 800;
  pointer-events: none; user-select: none;
}
.felt-mark span { font-size: calc(var(--u) * 3.2); }
.felt-mark small { font-size: calc(var(--u) * 1.15); letter-spacing: 0.7em; margin-top: calc(var(--u) * 0.2); }

/* ----- centre: pot, board, banner ----- */
.center {
  position: absolute;
  left: 50%; top: 46%;
  translate: -50% -50%;
  display: flex; flex-direction: column; align-items: center;
  gap: calc(var(--u) * 0.9);
  z-index: 2;
  width: max-content;
  max-width: 96%;
}

.pot {
  display: flex; align-items: center; gap: calc(var(--u) * 0.7);
  min-height: calc(var(--u) * 3);
  padding: calc(var(--u) * 0.35) calc(var(--u) * 1.2);
  border-radius: 99px;
  background: rgba(3, 10, 22, 0.55);
  border: 1px solid rgba(243, 201, 105, 0.3);
  font-size: calc(var(--u) * 1.25);
  transition: opacity 0.2s;
}
.pot.empty { opacity: 0.55; }
.pot-text { display: flex; align-items: baseline; gap: 0.4em; font-variant-numeric: tabular-nums; }
.pot-text small { color: var(--muted); font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.pot-text b { color: var(--gold); font-size: 1.15em; }

.board { display: flex; gap: calc(var(--cw) * 0.1); }
.board .slot {
  position: relative;
  width: var(--cw); height: calc(var(--cw) * 1.4);
  border-radius: calc(var(--cw) * 0.1);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.14);
}
.board .card { --w: var(--cw); position: absolute; inset: 0; }

.banner {
  min-height: calc(var(--u) * 2.6);
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.3);
  text-align: center;
  font-size: calc(var(--u) * 1.3);
  font-weight: 700;
}
.banner .line {
  padding: calc(var(--u) * 0.45) calc(var(--u) * 1.3);
  border-radius: 99px;
  background: linear-gradient(180deg, rgba(243, 201, 105, 0.95), rgba(200, 145, 44, 0.95));
  color: #1b1405;
  box-shadow: 0 calc(var(--u) * 0.4) calc(var(--u) * 1.4) rgba(0, 0, 0, 0.45);
  animation: pop 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  max-width: 92cqw;
}
.banner .line.you { background: linear-gradient(180deg, #6df0d2, #1fb596); }
.banner .line.plain { background: rgba(3, 10, 22, 0.7); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.banner .line small { font-weight: 600; opacity: 0.75; }

@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }

/* ----- seats ----- */
.seat {
  position: absolute;
  left: var(--x); top: var(--y);
  translate: -50% -50%;
  display: flex; flex-direction: column; align-items: center;
  z-index: 4;
  transition: opacity 0.3s, filter 0.3s;
}
/* seats along the top show their cards on the table side (below) */
.seat[data-pos="2"], .seat[data-pos="3"], .seat[data-pos="4"] { flex-direction: column-reverse; }

.hole {
  display: flex; justify-content: center;
  height: calc(var(--bw) * 1.4);
  margin-bottom: calc(var(--bw) * -0.5);
  pointer-events: none;
}
.seat[data-pos="2"] .hole, .seat[data-pos="3"] .hole, .seat[data-pos="4"] .hole {
  margin-bottom: 0; margin-top: calc(var(--bw) * -0.5);
}
.hole .card { --w: var(--bw); margin: 0 calc(var(--bw) * -0.08); }
.hole .card:nth-child(1) { rotate: -7deg; transform-origin: 80% 100%; }
.hole .card:nth-child(2) { rotate: 7deg; transform-origin: 20% 100%; }

.seat.me .hole { height: calc(var(--hw) * 1.4); margin-bottom: calc(var(--hw) * -0.42); }
.seat.me .hole .card { --w: var(--hw); margin: 0 calc(var(--hw) * 0.03); }
.seat.me .hole .card:nth-child(1) { rotate: -4deg; }
.seat.me .hole .card:nth-child(2) { rotate: 4deg; }

.panel {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 0.7em;
  padding: 0.5em 1.3em 0.5em 0.5em;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 0.5em 1.4em rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  min-width: 10.4em;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.seat.me .panel { min-width: 12em; }

.avatar {
  position: relative; flex: none;
  width: 3.4em; height: 3.4em; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1.35em; color: #fff;
  background: linear-gradient(145deg, hsl(var(--h) 70% 58%), hsl(calc(var(--h) + 30) 65% 34%));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
}
.avatar span { font-size: 1em; line-height: 1; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.ring { position: absolute; inset: -0.22em; border-radius: 50%; pointer-events: none; opacity: 0; }

.who { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.nm { font-size: 1.1em; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 7em; }
.stk { font-size: 1.45em; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }

.role {
  position: absolute; top: -0.55em; left: 2.9em;
  font-size: 0.85em; font-weight: 800; letter-spacing: 0.06em;
  padding: 0.15em 0.55em; border-radius: 99px;
  background: #1c2656; border: 1px solid rgba(255, 255, 255, 0.2); color: var(--text);
}
.role:empty { display: none; }

.tag {
  position: absolute; left: 50%; bottom: -0.85em; translate: -50% 0;
  z-index: 2;
  font-size: 0.95em; font-weight: 800; letter-spacing: 0.03em; white-space: nowrap;
  padding: 0.18em 0.9em; border-radius: 99px;
  background: #1c2656; border: 1px solid rgba(255, 255, 255, 0.22); color: var(--text);
  box-shadow: 0 0.2em 0.6em rgba(0, 0, 0, 0.4);
}
.tag:empty { display: none; }
.tag.raise { background: #6b2430; border-color: #ff8a98; }
.tag.call { background: #14456b; border-color: #78bbff; }
.tag.check { background: #14504a; border-color: #66e0c8; }
.tag.fold { background: #2a2f45; color: var(--muted); }
.tag.allin { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #1b1405; border-color: #ffe7a8; }
.tag.win { background: linear-gradient(180deg, #6df0d2, #1fb596); color: #04201a; border-color: #b5ffee; }
.tag.show { background: #22305f; }
.tag.turn { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #1b1405; border-color: #ffe7a8; animation: breathe 1.4s ease-in-out infinite; }
/* seats along the top keep their cards below, so the tag moves above the panel */
.seat[data-pos="2"] .tag, .seat[data-pos="3"] .tag, .seat[data-pos="4"] .tag { bottom: auto; top: -0.95em; }

/* On tall screens the upper side seats have free space above them, so their cards go there
   instead of down onto the board. */
@container stage (max-aspect-ratio: 23/20) {
  .seat[data-pos="2"], .seat[data-pos="4"] { flex-direction: column; }
  .seat[data-pos="2"] .hole, .seat[data-pos="4"] .hole { margin-top: 0; margin-bottom: calc(var(--bw) * -0.5); }
}

/* Your seat and the top seat are pinned to the stage edge, so tall seats can never spill
   out of the stage on short windows (phones on their side). */
.seat[data-pos="0"] { top: auto; bottom: 1.25em; translate: -50% 0; }
.seat[data-pos="3"] { top: 1.35em; translate: -50% 0; }

/* Side seats are anchored by their name panel, so --y is where the panel sits. Their cards
   stick out about 0.9 card widths above the panel (seat shifts up by half of that), or below it
   for seats whose cards face the table (seat shifts down). */
.seat[data-pos="1"], .seat[data-pos="5"] { translate: -50% calc(-50% - var(--bw) * 0.45); }
.seat[data-pos="2"], .seat[data-pos="4"] { translate: -50% calc(-50% + var(--bw) * 0.45); }
@container stage (max-aspect-ratio: 23/20) {
  .seat[data-pos="2"], .seat[data-pos="4"] { translate: -50% calc(-50% - var(--bw) * 0.45); }
}

/* very short stages (phones on their side): drop the pot and board a little so the top seat clears
   the pot, and scale seats and cards down a notch so everything still fits */
@container stage (max-height: 330px) {
  .center { top: 49.5%; }
}
/* tables of seven or more players on a tall screen: smaller card backs, there are many seats to fit */
@container stage (max-aspect-ratio: 23/20) {
  .stage-inner[data-dense="1"] { --bw: calc(var(--u) * 2.9); }
}

/*
 * Crowded tables (seven or more players) on a tall screen or a very short wide one have no room for chip
 * stacks next to every seat. There, the other players' bets are written in their action tag instead
 * ("Raise 120", "Blind 10"). Your own bet keeps its chips. Everywhere else the tag stays a plain word.
 */
.tag .amt { display: none; }
.tag.blind { display: none; }
@container stage (max-aspect-ratio: 23/20) {
  .stage-inner[data-dense="1"] .seat:not(.me) .bet { display: none; }
  .stage-inner[data-dense="1"] .seat:not(.me) .tag .amt { display: inline; }
  .stage-inner[data-dense="1"] .seat:not(.me) .tag.blind { display: block; }
}
/* very short wide screens (a phone on its side): from six players up, everyone including you uses tags */
@container stage (max-height: 330px) and (min-aspect-ratio: 23/20) {
  .stage-inner[data-crowd="1"] .bet { display: none; }
  .stage-inner[data-crowd="1"] .tag .amt { display: inline; }
  .stage-inner[data-crowd="1"] .tag.blind { display: block; }
}
/* tiny tall screens (about 320 wide, any number of players): there is no room for card backs or chip
   stacks around the seats, so other players' cards are left out and amounts go in the tags. Names,
   stacks and action tags are all still shown. */
@container stage (max-aspect-ratio: 23/20) and (max-height: 380px) {
  .stage-inner { --bw: 0px; }
  .stage-inner .seat:not(.me) .hole { display: none; }
  .stage-inner .bet { display: none; }
  .stage-inner .tag .amt { display: inline; }
  .stage-inner .tag.blind { display: block; }
}
@container stage (max-height: 260px) and (min-aspect-ratio: 23/20) {
  .stage-inner {
    --u: 7px;
    --bw: calc(var(--u) * 3.3);
    --cw: clamp(26px, min(6cqw, 11.5cqh), 60px);
    --hw: var(--cw);
  }
}

/* ==========================================================================
   Ten seat arrangement (seven to ten players)
   Your seat is still data-pos="0". The others are x1 to x9, clockwise from the bottom:
     x1 bottom left     x2 left lower     x3 left upper     x4 top left     x5 top centre
     x6 top right       x7 right upper    x8 right lower    x9 bottom right
   Wide stages: three seats along the top, two down each side, three along the bottom (you in the middle).
   Tall stages: the same three rows at the top and bottom, plus two side seats above and two below the board.
   Each seat sets its own layout through variables (see the generic rules right below):
     --flow       column = cards above the panel, column-reverse = cards below it
     --top/--bot  pin the seat to the stage edge (otherwise --y is the centre of the name panel)
     --ty         vertical shift that keeps --y on the panel when the cards stick out
     --hmt/--hmb  overlap of the cards with the panel;  --tgt/--tgb  where the action tag sits
   ========================================================================== */
.seat[data-pos^="x"] {
  flex-direction: var(--flow, column);
  top: var(--top, var(--y));
  bottom: var(--bot, auto);
  translate: -50% var(--ty, -50%);
}
.seat[data-pos^="x"] .hole { margin-top: var(--hmt, 0); margin-bottom: var(--hmb, calc(var(--bw) * -0.5)); }
.seat[data-pos^="x"] .tag { top: var(--tgt, auto); bottom: var(--tgb, -0.85em); }

/* bottom flanks: pinned to the bottom edge like your own seat, cards above */
[data-pos="x1"], [data-pos="x9"] { --top: auto; --bot: 1.25em; --ty: 0; }
/* lower sides: cards above the panel */
[data-pos="x2"], [data-pos="x8"] { --ty: calc(-50% - var(--bw) * 0.45); }
/* upper sides: cards face the table (below), the tag moves above */
[data-pos="x3"], [data-pos="x7"] {
  --flow: column-reverse; --hmb: 0; --hmt: calc(var(--bw) * -0.5); --tgt: -0.95em; --tgb: auto;
  --ty: calc(-50% + var(--bw) * 0.45);
}
/* top row: pinned to the top edge, cards below */
[data-pos="x4"], [data-pos="x5"], [data-pos="x6"] {
  --top: 1.35em; --flow: column-reverse; --hmb: 0; --hmt: calc(var(--bw) * -0.5); --tgt: -0.95em; --tgb: auto; --ty: 0;
}

/* wide stage */
[data-pos="x1"] { --x: 27%; }
[data-pos="x2"] { --x: 8%;  --y: 70%; }
[data-pos="x3"] { --x: 10%; --y: 23%; }
[data-pos="x4"] { --x: 29%; }
[data-pos="x5"] { --x: 50%; }
[data-pos="x6"] { --x: 71%; }
[data-pos="x7"] { --x: 90%; --y: 23%; }
[data-pos="x8"] { --x: 92%; --y: 70%; }
[data-pos="x9"] { --x: 73%; }

/* bet sides, wide stage: right of the panel, or left of it */
[data-pos="x2"], [data-pos="x3"], [data-pos="x5"], [data-pos="x6"], [data-pos="x9"] {
  --bl: calc(100% + 0.6em); --br: auto; --bt: 50%; --bb: auto; --btx: 0; --bty: -50%;
}
[data-pos="x1"], [data-pos="x4"], [data-pos="x7"], [data-pos="x8"] {
  --bl: auto; --br: calc(100% + 0.6em); --bt: 50%; --bb: auto; --btx: 0; --bty: -50%;
}

/* tall or narrow stage */
@container stage (max-aspect-ratio: 23/20) {
  /* all four side seats keep their cards above the panel */
  [data-pos="x2"], [data-pos="x8"], [data-pos="x3"], [data-pos="x7"] {
    --flow: column; --hmb: calc(var(--bw) * -0.5); --hmt: 0; --tgt: -0.95em; --tgb: auto;
    --ty: calc(-50% - var(--bw) * 0.45);
  }
  [data-pos="x1"] { --x: 17%; }
  [data-pos="x2"] { --x: 15%; --y: 66%; }
  [data-pos="x3"] { --x: 15%; --y: 33%; }
  [data-pos="x4"] { --x: 17%; }
  [data-pos="x5"] { --x: 50%; }
  [data-pos="x6"] { --x: 83%; }
  [data-pos="x7"] { --x: 85%; --y: 33%; }
  [data-pos="x8"] { --x: 85%; --y: 66%; }
  [data-pos="x9"] { --x: 83%; }

  /* bet sides, tall stage: the four side seats put theirs just under their panel, the top row goes
     inwards (the middle one below its cards), the bottom flanks put theirs above their cards */
  [data-pos="x2"], [data-pos="x3"], [data-pos="x7"], [data-pos="x8"] {
    --bl: 50%; --br: auto; --bt: calc(100% + 0.5em); --bb: auto; --btx: -50%; --bty: 0;
  }
  [data-pos="x4"] {
    --bl: calc(100% + 0.6em); --br: auto; --bt: 50%; --bb: auto; --btx: 0; --bty: -50%;
  }
  [data-pos="x6"] {
    --bl: auto; --br: calc(100% + 0.6em); --bt: 50%; --bb: auto; --btx: 0; --bty: -50%;
  }
  [data-pos="x5"] {
    --bl: 50%; --br: auto; --bt: calc(100% + var(--bw) * 0.9 + 0.5em); --bb: auto; --btx: -50%; --bty: 0;
  }
  [data-pos="x1"], [data-pos="x9"] {
    --bl: 50%; --br: auto; --bt: auto; --bb: calc(100% + var(--bw) * 0.9 + 0.5em); --btx: -50%; --bty: 0;
  }
}

.seg-wide button { font-size: 13px; padding: 0; }

.seat.active .panel {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 1.6em rgba(243, 201, 105, 0.45), 0 0.5em 1.4em rgba(0, 0, 0, 0.45);
}
.seat.active .ring {
  opacity: 1;
  background: conic-gradient(var(--gold) 0 30%, transparent 30% 100%);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 64%);
          mask: radial-gradient(circle, transparent 62%, #000 64%);
  animation: spin 1.1s linear infinite;
}
.seat.me.active .ring { animation: none; background: var(--gold); }

.seat.folded { opacity: 0.5; filter: saturate(0.5); }
.seat.folded .hole { opacity: 0; transition: opacity 0.3s 0.1s; }
.seat.out { opacity: 0.38; }
.seat.out .hole { display: none; }

/* ----- bots, open seats and kicking ----- */
.panel[role="button"] { cursor: pointer; }
.panel[role="button"]:hover { border-color: rgba(255, 255, 255, 0.32); }
.panel[role="button"]:focus-visible { outline-offset: 3px; }

/* a bot has a square avatar and a small BOT badge, so it is easy to tell from a person */
.seat.bot .avatar { border-radius: 28%; }
.seat.bot .ring { border-radius: 36%; }
.seat.bot.active .ring {
  background: none; border: 0.2em solid var(--gold);
  -webkit-mask: none; mask: none;
  animation: breathe 1.1s ease-in-out infinite;
}
.kind {
  position: absolute; left: 0.15em; top: 4.4em; z-index: 2;
  font-size: max(0.72em, 6.5px); font-weight: 900; letter-spacing: 0.08em; line-height: 1;
  padding: 0.22em 0.5em; border-radius: 99px;
  background: #0a0f24; border: 1px solid rgba(243, 201, 105, 0.6); color: var(--gold);
}

/* an open seat is a dashed outline you can click to put a bot in */
.seat.open.out { opacity: 0.85; }
.seat.open .panel { border-style: dashed; background: rgba(11, 18, 42, 0.35); box-shadow: none; backdrop-filter: none; }
.seat.open .avatar { background: transparent; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3); color: var(--muted); }
.seat.open .nm { color: var(--text); }
.seat.open .stk { font-size: 1.05em; font-weight: 600; color: var(--gold); }
.seat.open .role, .seat.open .dealer { display: none; }

/* kicked in the middle of a hand: still finishing it */
.seat.leaving { opacity: 0.7; }

.seat.winner .panel {
  border-color: #6df0d2;
  box-shadow: 0 0 0 1px #6df0d2, 0 0 2em rgba(109, 240, 210, 0.55), 0 0.5em 1.4em rgba(0, 0, 0, 0.45);
  animation: breathe 1.6s ease-in-out infinite;
}
.seat.loser .panel { opacity: 0.85; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { filter: brightness(1.18); } }

/* ----- bets: a child of the seat's name panel, on the side chosen by the --b* variables ----- */
.bet {
  position: absolute;
  left: var(--bl, auto); right: var(--br, auto); top: var(--bt, 50%); bottom: var(--bb, auto);
  translate: var(--btx, 0) var(--bty, -50%);
  display: flex; align-items: center; gap: 0.5em;
  z-index: 3; white-space: nowrap;
  font-size: 1.2em; font-weight: 800; font-variant-numeric: tabular-nums;
}
.bet b {
  padding: 0.12em 0.6em; border-radius: 99px;
  background: rgba(3, 10, 22, 0.72); border: 1px solid var(--line);
}
.bet[hidden] { display: none; }

.chips { display: flex; flex-direction: column-reverse; gap: 0.1em; align-items: center; }
.chips i {
  display: block; width: 1.9em; height: 0.52em; border-radius: 0.3em;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.85) 0 0.2em, transparent 0.2em 0.55em),
    var(--c);
  box-shadow: 0 0.12em 0 rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.pot .chips i { width: 1.7em; height: 0.46em; }
.pot .chips:empty { display: none; }

/* the dealer button: a small badge on the dealer's avatar */
.dealer {
  position: absolute; z-index: 3;
  left: 3.7em; top: 3.35em; /* the lower right corner of the avatar, inside the panel */
  width: 1.9em; height: 1.9em; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff, #d8dcf0);
  color: #121832; font-weight: 900; font-size: 1em; line-height: 1;
  box-shadow: 0 0.25em 0.6em rgba(0, 0, 0, 0.5), inset 0 0 0 0.16em var(--gold);
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.dealer[hidden] { display: none; }

.flychip { position: absolute; z-index: 9; pointer-events: none; translate: -50% -50%; }
.flychip i { display: block; width: 1.9em; height: 0.52em; border-radius: 0.3em; background: repeating-linear-gradient(90deg, rgba(255,255,255,.85) 0 .2em, transparent .2em .55em), var(--c, #f3c969); box-shadow: 0 0.12em 0 rgba(0,0,0,.4); }

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

.card {
  --w: 60px;
  position: relative;
  width: var(--w); height: calc(var(--w) * 1.4);
  perspective: calc(var(--w) * 8);
  flex: none;
  filter: drop-shadow(0 calc(var(--w) * 0.05) calc(var(--w) * 0.08) rgba(0, 0, 0, 0.45));
  --ink: var(--ink-s);
}
.card[data-s="h"] { --ink: var(--ink-h); }
.card[data-s="d"] { --ink: var(--ink-d); }
.card[data-s="c"] { --ink: var(--ink-c); }

.flip {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transform: rotateY(180deg);
  transition: transform 0.5s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.card.up .flip { transform: rotateY(0); }

.face, .back {
  position: absolute; inset: 0;
  border-radius: calc(var(--w) * 0.11);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.face {
  background: linear-gradient(160deg, #ffffff, #e9edf8);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.cr {
  position: absolute; left: 9%; top: 5%;
  display: flex; flex-direction: column; align-items: center; line-height: 1;
}
.cr b { font-size: calc(var(--w) * 0.42); font-weight: 800; letter-spacing: -0.04em; }
.cr svg { width: calc(var(--w) * 0.27); height: calc(var(--w) * 0.27); fill: currentColor; margin-top: calc(var(--w) * 0.02); }
.face .big {
  position: absolute; right: 8%; bottom: 6%;
  width: calc(var(--w) * 0.55); height: calc(var(--w) * 0.55);
  fill: currentColor; opacity: 0.95;
}
.back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 50%, rgba(243, 201, 105, 0.9) 0 7%, transparent 8%),
    repeating-linear-gradient(45deg, rgba(243, 201, 105, 0.22) 0 1.5px, transparent 1.5px 7px),
    repeating-linear-gradient(-45deg, rgba(243, 201, 105, 0.22) 0 1.5px, transparent 1.5px 7px),
    linear-gradient(150deg, #243a86, #101a44);
  box-shadow: inset 0 0 0 calc(var(--w) * 0.06) #0d1536, inset 0 0 0 calc(var(--w) * 0.085) rgba(243, 201, 105, 0.55);
}
.back::after {
  content: ""; position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  width: 30%; aspect-ratio: 1; background: rgba(243, 201, 105, 0.9);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.card.win { filter: drop-shadow(0 0 calc(var(--w) * 0.18) rgba(243, 201, 105, 0.95)); z-index: 1; }
.card.win .face { box-shadow: inset 0 0 0 2px var(--gold); }
.card.dim { filter: brightness(0.5) saturate(0.6); }

/* ---------- action dock ---------- */

.dock {
  flex: none;
  display: grid;
  grid-template-areas: "hint" "sizing" "actions";
  gap: 8px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 14px calc(12px + env(safe-area-inset-bottom));
  position: relative; z-index: 10;
}

.dock-hint {
  grid-area: hint;
  min-height: 24px;
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  font-size: 14px; font-variant-numeric: tabular-nums;
}
.dock-hint .hand { font-weight: 700; color: var(--text); }
.dock-hint .odds { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.dock-hint .odds b { color: var(--teal); }
.meter { width: 64px; height: 6px; border-radius: 9px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.meter i { display: block; height: 100%; width: var(--p, 0%); background: linear-gradient(90deg, var(--coral), var(--gold), var(--teal)); transition: width 0.4s; }

.sizing { grid-area: sizing; display: grid; gap: 8px; transition: opacity 0.2s; }
.presets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.presets button {
  height: 32px; border-radius: 99px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); color: var(--text);
  white-space: nowrap; padding: 0 4px;
}
.presets button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
.slider-row { display: flex; align-items: center; gap: 10px; }
.step {
  width: 34px; height: 34px; flex: none; border-radius: 50%; font-size: 20px; line-height: 1; font-weight: 700;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
}
.step:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; min-width: 0; height: 34px; background: transparent; margin: 0; --pct: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 9px;
  background: linear-gradient(90deg, var(--gold) var(--pct), rgba(255, 255, 255, 0.14) var(--pct));
}
input[type="range"]::-moz-range-track { height: 8px; border-radius: 9px; background: rgba(255, 255, 255, 0.14); }
input[type="range"]::-moz-range-progress { height: 8px; border-radius: 9px; background: var(--gold); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; margin-top: -9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #d9dff5);
  border: 3px solid var(--gold); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid var(--gold);
}

.actions { grid-area: actions; display: grid; grid-template-columns: 1fr 1.15fr 1.35fr; gap: 8px; }
.btn {
  position: relative;
  min-height: 48px; padding: 0 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius);
  font-weight: 800; font-size: 15px; letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: transform 0.08s, filter 0.15s, opacity 0.2s;
  user-select: none; white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.35; }
.btn kbd { display: none; }
.btn.fold { background: linear-gradient(180deg, #3a2030, #2a1522); border-color: #7a3548; color: #ffb3bf; }
.btn.call { background: linear-gradient(180deg, #153b63, #0f2a49); border-color: #3c78b8; color: #cfe6ff; }
.btn.raise { background: linear-gradient(180deg, #f6d27c, #d09a33); border-color: #ffe3a2; color: #251a05; }
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn.next { grid-column: 1 / -1; background: linear-gradient(180deg, #f6d27c, #d09a33); color: #251a05; border-color: #ffe3a2; min-height: 52px; font-size: 16px; }
.btn.primary { background: linear-gradient(180deg, #f6d27c, #d09a33); color: #251a05; border-color: #ffe3a2; min-height: 52px; font-size: 16px; padding: 0 28px; }
.btn.ghost { background: rgba(255, 255, 255, 0.06); border-color: var(--line); color: var(--text); min-height: 52px; padding: 0 22px; }
.btn.danger { background: linear-gradient(180deg, #3a2030, #2a1522); border-color: #7a3548; color: #ffb3bf; }
.btn.wide { width: 100%; }

/* dock states */
.dock[data-mode="wait"] .sizing { opacity: 0.4; pointer-events: none; }
.dock[data-mode="wait"] .btn:not(.next) { opacity: 0.35; pointer-events: none; }
.dock[data-mode="next"] .sizing, .dock[data-mode="busted"] .sizing { visibility: hidden; }
.dock:not([data-mode="next"]):not([data-mode="busted"]) .btn.next { display: none; }
.dock[data-mode="next"] .btn:not(.next), .dock[data-mode="busted"] .btn:not(.next) { display: none; }
.dock[data-mode="next"] .actions, .dock[data-mode="busted"] .actions { justify-items: center; }
.btn.next { width: min(100%, 440px); }
.dock[data-mode="turn"] .btn.raise:disabled, .dock[data-mode="turn"] .btn.fold:disabled { opacity: 0.3; }

/* ---------- history drawer ---------- */

.log {
  position: fixed; z-index: 40;
  top: var(--topbar-h); right: 0; bottom: 0;
  width: min(360px, 88vw);
  display: flex; flex-direction: column;
  background: var(--panel-solid);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  transform: translateX(104%);
  transition: transform 0.28s cubic-bezier(0.3, 0.8, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
.log.open { transform: none; }
.log-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.log-body { flex: 1; overflow-y: auto; padding: 8px 16px 16px; font-size: 13.5px; line-height: 1.5; }
.log-body .hh { margin-top: 14px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--gold); font-weight: 800; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.log-body .hh:first-child { margin-top: 0; border-top: 0; }
.log-body .ln { color: #c3cbea; }
.log-body .ln b { color: var(--text); }
.log-body .ln.win { color: var(--teal); }
.log-body .ln.street { color: var(--gold); }
.log-body .sv { display: inline-block; width: 0.95em; height: 0.95em; vertical-align: -0.12em; fill: currentColor; }
.log-body .cd { display: inline-flex; align-items: center; gap: 1px; font-weight: 800; padding: 0 5px; margin: 0 1px; border-radius: 4px; background: #eef1fa; color: var(--ink); }
.log-body .cd[data-s="h"] { --ink: var(--ink-h); } .log-body .cd[data-s="d"] { --ink: var(--ink-d); }
.log-body .cd[data-s="s"] { --ink: var(--ink-s); } .log-body .cd[data-s="c"] { --ink: var(--ink-c); }

/* ---------- toasts ---------- */

.toasts { position: fixed; top: calc(var(--topbar-h) + 8px); left: 50%; translate: -50% 0; z-index: 60; display: grid; gap: 6px; pointer-events: none; width: max-content; max-width: 92vw; }
.toast {
  padding: 8px 14px; border-radius: 99px; font-size: 13px; font-weight: 600;
  background: rgba(14, 22, 54, 0.96); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.3s both, toast-out 0.4s 2.6s forwards;
}
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

/* ---------- start screen ---------- */

.splash {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(900px 600px at 50% 20%, rgba(23, 113, 127, 0.45), transparent 65%),
    rgba(5, 8, 19, 0.92);
  backdrop-filter: blur(6px);
  transition: opacity 0.35s, visibility 0.35s;
  overflow-y: auto;
}
.splash.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-card { text-align: center; max-width: 460px; margin: auto; }
.splash-card h1 { margin: 18px 0 8px; font-size: clamp(30px, 8vw, 46px); line-height: 1.05; letter-spacing: -0.01em; }
.splash-card h1 em { font-style: normal; color: var(--gold); }
.splash-card p { margin: 0 auto 22px; color: var(--muted); line-height: 1.55; max-width: 38ch; }
.splash-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.link { margin-top: 16px; background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }
.link:hover { color: var(--text); }
.splash-cards { display: flex; justify-content: center; height: 118px; }
.splash-cards .card { --w: 76px; rotate: var(--r); margin: 0 -10px; transform-origin: 50% 120%; animation: fan 0.8s cubic-bezier(0.2, 1.2, 0.3, 1) both; }
.splash-cards .card:nth-child(2) { translate: 0 -8px; animation-delay: 0.08s; }
.splash-cards .card:nth-child(3) { animation-delay: 0.16s; }
@keyframes fan { from { rotate: 0deg; opacity: 0; translate: 0 30px; } }

/* ---------- dialogs ---------- */

dialog.dlg {
  border: 1px solid var(--line); border-radius: 18px; padding: 0;
  background: var(--panel-solid); color: var(--text);
  width: min(520px, calc(100vw - 24px)); max-height: min(86vh, 760px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
}
dialog.dlg.small { width: min(400px, calc(100vw - 24px)); }
dialog.dlg::backdrop { background: rgba(2, 4, 12, 0.7); backdrop-filter: blur(3px); }
.dlg-card { display: flex; flex-direction: column; max-height: inherit; margin: 0; }
.dlg-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 20px; }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-body { padding: 6px 20px 20px; overflow-y: auto; }
.dlg-body h3 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); }
.dlg-body h3 small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 500; margin-left: 6px; }
.center-text { text-align: center; padding-top: 22px; }
.center-text h2 { margin: 0 0 8px; }
.center-text p { color: var(--muted); line-height: 1.5; margin: 0 0 18px; }
.stack-actions { display: grid; gap: 10px; }

.field { display: grid; gap: 6px; margin: 10px 0; }
.field > label { font-size: 14px; font-weight: 600; }
.field label small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; margin-top: 2px; }
.field.row { grid-template-columns: 1fr auto; align-items: center; gap: 14px; }
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.seg button { flex: 1; height: 36px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: 13.5px; }
.seg button[aria-pressed="true"] { background: linear-gradient(180deg, #f6d27c, #d09a33); color: #251a05; }

.switch {
  -webkit-appearance: none; appearance: none; width: 48px; height: 28px; margin: 0; flex: none;
  border-radius: 99px; background: rgba(255, 255, 255, 0.14); position: relative; cursor: pointer; transition: background 0.2s;
}
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch:checked { background: var(--teal); }
.switch:checked::after { transform: translateX(20px); }

.help p { color: #c3cbea; line-height: 1.55; margin: 10px 0; }
.help b { color: var(--text); }
.help kbd, .kbd-line kbd { font: 700 12px/1 ui-monospace, Consolas, monospace; padding: 3px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line); margin: 0 2px; }
.ranks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: r; }
.ranks li { counter-increment: r; display: grid; grid-template-columns: 22px 1fr; gap: 4px 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.ranks li::before { content: counter(r); color: var(--gold); font-weight: 800; text-align: center; grid-row: span 2; }
.ranks .rn { font-weight: 700; font-size: 14px; }
.ranks .rn small { color: var(--muted); font-weight: 500; margin-left: 8px; }
.ranks .rc { display: flex; gap: 4px; }
.ranks .card { --w: 40px; }
.ranks .card .cr b { font-size: calc(var(--w) * 0.5); }
.ranks .card .cr svg { width: calc(var(--w) * 0.3); height: calc(var(--w) * 0.3); }
.dlg-card:focus { outline: none; }

/* ==========================================================================
   Responsive tuning for the action dock and chrome
   ========================================================================== */

/* wide screens: hint, sizing and buttons share a single row */
@media (min-width: 980px) and (min-height: 560px) {
  .dock {
    max-width: 1240px;
    grid-template-areas: "hint hint hint" "sizing actions actions";
    grid-template-columns: minmax(300px, 1.1fr) minmax(0, 1fr) minmax(0, 0.5fr);
    align-items: center; gap: 6px 22px;
  }
  .actions { grid-template-columns: 1fr 1.15fr 1.35fr; }
  /* between hands the single button takes the whole row (the hidden sizing controls keep their space) */
  .dock[data-mode="next"] .actions, .dock[data-mode="busted"] .actions { grid-area: 2 / 1 / 3 / 4; }
  .btn { min-height: 54px; font-size: 16px; }
  .btn kbd {
    display: inline-block; font: 700 11px/1 ui-monospace, Consolas, monospace;
    padding: 3px 5px; border-radius: 5px; background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(255, 255, 255, 0.18); opacity: 0.75;
  }
}

/* short landscape screens (phones on their side): buttons beside the sizing controls */
@media (max-height: 520px) and (min-width: 560px) {
  :root { --topbar-h: 42px; }
  .topbar { padding: 0 10px; }
  .brand-name { display: none; }
  .icon-btn { width: 34px; height: 34px; }
  .dock {
    max-width: none;
    grid-template-areas: "sizing actions";
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center; gap: 8px 14px;
    padding: 6px 12px calc(8px + env(safe-area-inset-bottom));
  }
  .dock-hint { display: none; }
  .sizing { gap: 4px; }
  .presets button { height: 26px; font-size: 11.5px; }
  .slider-row { gap: 6px; }
  .step { width: 28px; height: 28px; font-size: 17px; }
  input[type="range"] { height: 26px; }
  .btn { min-height: 44px; font-size: 14px; padding: 0 8px; }
  .btn.next { min-height: 44px; }
}

/* small phones */
@media (max-width: 480px) {
  .topbar { padding: 0 10px; gap: 6px; }
  .brand-name { display: none; }
  .meta { gap: 5px; }
  .chip-pill { font-size: 11px; padding: 4px 8px; }
  .hide-sm { display: none; }
  .dock { padding-left: 10px; padding-right: 10px; }
  .btn { font-size: 14px; padding: 0 8px; }
  .presets button { font-size: 11.5px; }
}
@media (max-width: 360px) {
  #metaStreet { display: none; }
}
/* the narrowest phones (about 320 wide): a tighter dock leaves the table more height */
@media (max-width: 340px) {
  .dock { gap: 5px; padding-top: 5px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .dock-hint { min-height: 18px; gap: 8px; font-size: 12.5px; flex-wrap: nowrap; }
  .dock-hint .meter { display: none; }
  .presets button { height: 28px; }
  .step { width: 30px; height: 30px; }
  input[type="range"] { height: 30px; }
  .btn { min-height: 42px; }
}

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

/* ?still=1 freezes motion so screenshots and automated checks are deterministic */
html.still *, html.still *::before, html.still *::after {
  animation-duration: 0.001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important; transition-delay: 0s !important;
}
