/* ==========================================================================
   Groupier

   Two rooms, one set of rules. Light is a plain, quiet scheduling board; dark
   is the full casino (felt, brass, rose). The split is deliberate, and it lives
   entirely in the tokens below: every component rule is written once and reads
   its look from a token, so a theme is one block of values rather than a
   second copy of the stylesheet.

   Shape: cards 14px, squares 8px (10px on felt), buttons and inputs are pills.
   One accent per room: sky in light, brass in dark.
   ========================================================================== */

:root {
  color-scheme: light;

  --bg:          #FAFAF9;
  --surface:     #FFFFFF;
  --surface-2:   #F5F5F4;
  --line:        #E7E5E4;
  --line-soft:   #F0EFEE;
  --ink:         #1C1917;
  --ink-2:       #57534E;
  --ink-3:       #78716C;   /* 4.8:1 on white: labels have to be readable too */

  --accent:      #0284C7;
  --accent-ink:  #0369A1;
  --accent-wash: #E0F2FE;
  --oxblood:     #B91C1C;   /* errors, "can't", ruled out */
  --oxblood-bg:  #FEF2F2;
  --win-ink:     var(--accent-ink);

  --radius-card: 14px;
  --radius-cell: 8px;
  --shadow:      0 1px 2px rgb(28 25 23 / .04), 0 8px 18px -10px rgb(28 25 23 / .12);

  /* surfaces */
  --card-bg:     var(--surface);
  --card-border: 1px solid var(--line);
  --card-shadow: var(--shadow);
  --solid-bg:    var(--surface);          /* anything that floats over content */

  /* the board */
  --board-bg:     var(--surface);
  --board-border: 1px solid var(--line);
  --board-pad:    10px;
  --board-shadow: var(--shadow);
  --baize-bg:     transparent;
  --baize-pad:    0;
  --baize-radius: 0;
  --baize-shadow: none;
  --sticky-bg:    var(--surface);

  /* squares */
  --cell-bg:      var(--surface-2);
  --cell-border:  var(--line);
  --cell-shadow:  none;
  --hover-bg:     var(--accent-wash);
  --hover-border: var(--accent);
  --lead-bg:      var(--accent-wash);
  --lead-border:  var(--accent);
  --lead-shadow:  none;
  --block-bg:     #FEF2F2;
  --block-border: #FCA5A5;
  --block-ink:    #B91C1C;
  --dead-bg:      repeating-linear-gradient(-45deg, rgb(0 0 0 / .045) 0 5px, transparent 5px 10px), var(--surface-2);
  --head-border:  var(--line);
  --icon:         var(--accent);

  /* controls */
  --btn-bg:        var(--surface);
  --btn-border:    var(--line);
  --btn-hover-bg:  var(--surface-2);
  --primary-bg:    var(--accent-ink);   /* white on sky-700 is 5.9:1; sky-500 was 2.7 */
  --primary-ink:   #FFFFFF;
  --primary-edge:  var(--accent-ink);
  --primary-shadow: 0 6px 16px -8px rgb(3 105 161 / .6);
  --seg-bg:        var(--surface-2);
  --on-bg:         var(--ink);          /* the chosen mode: never the primary's colour */
  --on-ink:        #FFFFFF;
  --cant-on-bg:    var(--oxblood);
  --toast-bg:      var(--ink);
  --toast-ink:     #FFFFFF;

  /* results */
  --verdict-bg:      var(--surface-2);
  --verdict-border:  var(--line);
  --verdict-win-bg:  var(--accent-wash);
  --verdict-win-border: var(--accent);

  --dealer: none;                          /* the cat deals in the casino only */
  --room: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg:          #07231A;
    --surface:     #114431;
    --surface-2:   #17573F;
    --line:        #1E6A4C;
    --line-soft:   #17573F;
    --ink:         #F4F1E6;
    --ink-2:       #B9C9BC;
    --ink-3:       #8FA69A;

    --felt:        #114431;
    --felt-hi:     #17573F;
    --felt-deep:   #0B2E21;
    --brass:       #C9A227;
    --brass-hi:    #E9CE7A;
    --brass-dim:   #8A6B28;
    --rail:        #6E4A1E;
    --rail-hi:     #A87C39;
    --rose:        #D6455F;

    --accent:      var(--brass);
    --accent-ink:  var(--brass-hi);
    --accent-wash: rgb(201 162 39 / .18);
    --oxblood:     #F0A29B;
    --oxblood-bg:  rgb(148 50 46 / .3);
    --win-ink:     var(--brass-hi);

    --radius-cell: 10px;
    --shadow:      0 1px 2px rgb(0 0 0 / .35), 0 14px 34px -22px #000;

    --card-bg:     linear-gradient(180deg, rgb(255 255 255 / .05), rgb(0 0 0 / .10));
    --card-border: 1px solid rgb(255 255 255 / .07);
    --card-shadow: inset 0 1px 0 rgb(255 255 255 / .07), 0 6px 18px -12px #000;
    --solid-bg:    #0E3627;

    --board-bg:     linear-gradient(150deg, var(--rail-hi), var(--rail) 40%, #4A3114 70%, var(--rail-hi));
    --board-border: none;
    --board-pad:    5px;
    --board-shadow: 0 10px 30px -14px #000, inset 0 1px 0 rgb(255 255 255 / .22);
    --baize-bg:     radial-gradient(120% 140% at 50% 0%, var(--felt-hi), var(--felt) 55%, #0D3626);
    --baize-pad:    8px;
    --baize-radius: 14px;
    --baize-shadow: inset 0 2px 10px rgb(0 0 0 / .45);
    --sticky-bg:    #134B36;

    --cell-bg:      linear-gradient(180deg, rgb(255 255 255 / .045), rgb(0 0 0 / .10));
    --cell-border:  rgb(255 255 255 / .08);
    --cell-shadow:  inset 0 1px 0 rgb(255 255 255 / .05);
    --hover-bg:     rgb(255 255 255 / .07);
    --hover-border: rgb(233 206 122 / .5);
    --lead-bg:      linear-gradient(180deg, rgb(201 162 39 / .26), rgb(201 162 39 / .08));
    --lead-border:  var(--brass-hi);
    --lead-shadow:  inset 0 1px 0 rgb(255 255 255 / .18), 0 0 0 1px var(--brass-dim),
                    0 6px 22px -8px rgb(201 162 39 / .55);
    --block-bg:     rgb(148 50 46 / .3);
    --block-border: #B8615A;
    --block-ink:    #F3BDB8;
    --dead-bg:      repeating-linear-gradient(-45deg, rgb(0 0 0 / .22) 0 5px, transparent 5px 10px), rgb(0 0 0 / .16);
    --head-border:  rgb(255 255 255 / .08);
    --icon:         var(--brass);

    --btn-bg:        rgb(255 255 255 / .05);
    --btn-border:    rgb(255 255 255 / .14);
    --btn-hover-bg:  rgb(255 255 255 / .10);
    --primary-bg:    linear-gradient(180deg, var(--brass-hi), var(--brass));
    --primary-ink:   #241B04;
    --primary-edge:  var(--brass-hi);
    --primary-shadow: 0 4px 14px -6px rgb(201 162 39 / .75), inset 0 1px 0 rgb(255 255 255 / .45);
    --seg-bg:        rgb(0 0 0 / .2);
    --on-bg:         linear-gradient(180deg, #D94C66, #B8334D);
    --on-ink:        #FFFFFF;
    --cant-on-bg:    linear-gradient(180deg, #A8403B, #8C2F2B);
    --toast-bg:      #F4F1E6;
    --toast-ink:     #0B2E21;

    --verdict-bg:      rgb(255 255 255 / .04);
    --verdict-border:  rgb(255 255 255 / .10);
    --verdict-win-bg:  linear-gradient(180deg, rgb(201 162 39 / .22), rgb(201 162 39 / .07));
    --verdict-win-border: rgb(233 206 122 / .5);

    --dealer: flex;
    /* A faint weave on the felt room. On body, so it covers the whole page and
       not just the first screen of it. */
    --room: repeating-linear-gradient(0deg, rgb(255 255 255 / .014) 0 1px, transparent 1px 3px),
            repeating-linear-gradient(90deg, rgb(0 0 0 / .05) 0 1px, transparent 1px 3px);
  }
}

/* ================================================================== base */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--room), var(--bg);
  color: var(--ink);
  font: 500 16px/1.4 ui-rounded, "SF Pro Rounded", "Segoe UI Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Tapping the same square twice quickly is the normal way to play, and iOS
   reads a double tap as "zoom in". touch-action: manipulation tells it the
   second tap is a tap, without taking pinch zoom away from anyone who needs to
   magnify the board. */
button, input, label, .cell, .colh, .rowh {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* Rapid taps on a grid otherwise start selecting the numbers inside it. */
.board, .tray, .topbar { -webkit-user-select: none; user-select: none; }

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

/* ================================================================ layout */

.app {
  display: grid;
  height: 100dvh;
  gap: 10px;
  /* A phone sideways puts the notch on one side and the home bar at the
     bottom, and Safari happily lays content under both. */
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "top top" "side main" "side tray" "side foot";
}
@media (min-width: 721px) and (max-width: 900px) {
  .app { grid-template-columns: 200px minmax(0, 1fr); }
}
.app.loading { display: grid; place-items: center; }

.main {
  grid-area: main; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: 10px;
}

/* ---- a phone held sideways -----------------------------------------------
   One screen, no page scroll, and the board gets everything that is left. The
   question moves into the corner, and explanation is what goes. */
@media (orientation: landscape) and (max-height: 560px) {
  /* Fill what is left rather than claiming the viewport: the demo build puts
     a banner above this. #root is the flex child, not .app. */
  body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
  body > #root { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .app.compact {
    flex: 1 1 auto; min-height: 0; height: auto; overflow: hidden;
    padding: 8px; gap: 8px;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    grid-template-columns: 184px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top main" "side main" "side tray";
  }
  /* The cat is decoration, and on 375px of height it pushed the answer below
     the fold of the rail. The answer wins. */
  .app.compact .ask, .app.compact .foot, .app.compact .brand, .app.compact .dealer { display: none; }
  .app.compact .side { overflow-y: auto; gap: 8px; }
  .app.compact .panel { padding: 9px 11px; }
  .app.compact .verdict { padding: 7px 9px; }
  .app.compact .verdict .pick { font-size: 15px; }
  .app.compact .verdict .note { display: none; }
  .app.compact .board { padding: calc(var(--board-pad) * .8); }
}

/* ================================================================ top */

.topbar { grid-area: top; display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%; overflow: hidden; display: grid; place-items: center;
}
.brand .mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand h1 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.brand small { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); }

/* The question, in the corner, only on a phone held sideways. */
.qline {
  display: none; margin: 0;
  font-size: 14px; font-weight: 800; line-height: 1.2; letter-spacing: -.01em;
  overflow: hidden;
  -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical;
}
.app.compact .qline { display: -webkit-box; }

/* ================================================================ cards */

.card, .panel {
  background: var(--card-bg);
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 12px 14px;
}

/* Section headings in the rail. The only small-caps labels on the page. */
.label, .side h2 {
  margin: 0 0 8px;
  font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3);
}

/* The question, and nothing else: one line of context above the board. */
.ask { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; padding: 12px 16px; }
.ask h2 {
  margin: 0; font-size: clamp(17px, 1.7vw, 21px); font-weight: 800; line-height: 1.2;
  letter-spacing: -.02em; text-wrap: balance;
}
.ask .sub { font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* ================================================================ rail */

.side {
  grid-area: side; min-width: 0; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}

/* The cat, dealing, on a brass shelf. */
.dealer {
  display: var(--dealer); flex: none; position: relative; overflow: hidden;
  align-items: center; justify-content: center; padding: 8px;
  background: radial-gradient(90% 120% at 50% 100%, var(--felt-hi, transparent), var(--felt-deep, transparent));
}
.dealer svg { display: block; width: 100%; height: auto; max-width: 140px; }
.dealer::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--rail, transparent), var(--brass, transparent), var(--rail, transparent));
}

.plist { display: flex; flex-direction: column; }
.plist .p {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 5px 0; font-size: 14px; font-weight: 700;
}
.plist .p + .p { border-top: 1px solid var(--line-soft); }
.plist .p .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .p .bal { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.plist .p.now .nm, .plist .p.now .bal { color: var(--win-ink); }
.plist .p .nm.editable { cursor: text; text-decoration: underline dotted var(--ink-3); text-underline-offset: 3px; }
.plist .p input.rename {
  flex: 1; min-width: 0; padding: 3px 8px; font: inherit;
  border: 1px solid var(--accent); border-radius: 999px;
  background: var(--surface-2); color: inherit;
}
/* Your own seat you can always give up; someone else's only while empty. */
.plist .p .seatx {
  flex: none; width: 24px; height: 24px; padding: 0; line-height: 1;
  border: 1px solid transparent; border-radius: 50%; background: none;
  color: var(--ink-3); font-size: 16px; font-weight: 700; cursor: pointer;
  opacity: 0; transition: opacity .12s, color .12s, border-color .12s;
}
.plist .p:hover .seatx, .plist .p .seatx:focus-visible { opacity: 1; }
.plist .p .seatx:hover { color: var(--oxblood); border-color: var(--oxblood); }
@media (hover: none) { .plist .p .seatx { opacity: 1; } }
.empty { margin: 0; color: var(--ink-3); font-size: 13.5px; }

.totalrow {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft);
  display: flex; align-items: baseline; justify-content: space-between;
}
.totalrow span { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.totalrow b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Where it stands */
.verdicts { display: flex; flex-direction: column; gap: 8px; }
.verdict {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 9px 11px; border-radius: 12px;
  background: var(--verdict-bg); border: 1px solid var(--verdict-border);
}
.verdict.win { background: var(--verdict-win-bg); border-color: var(--verdict-win-border); }
.verdict .lbl { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.verdict .pick {
  font-size: 17px; font-weight: 800; line-height: 1.2; letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.verdict.win .pick { color: var(--win-ink); }
.verdict .note { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.verdict .note.bad { color: var(--oxblood); }

/* ================================================================ seat screen */

.app.gateonly {
  height: auto; min-height: 100dvh; max-width: 600px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: none;
  grid-template-areas: "top" "main";
  align-content: start;
}
.seatgate { display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.seatgate h2 { margin: 0; font-size: clamp(24px, 6vw, 30px); line-height: 1.15; letter-spacing: -.02em; text-wrap: balance; }
.seatgate .sub, .seatgate .deal { margin: 0; color: var(--ink-2); font-size: 15px; }
.denoms.gate { display: flex; gap: 7px; flex-wrap: wrap; }
.gaterow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.gaterow input { flex: 1 1 200px; min-width: 0; }
.gaterow .btn.go { margin-left: 0; padding: 12px 22px; font-size: 15px; }

/* ================================================================ board */

.board {
  display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden;
  background: var(--board-bg);
  border: var(--board-border);
  border-radius: var(--radius-card);
  box-shadow: var(--board-shadow);
  padding: var(--board-pad);
}
.baize {
  display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden;
  background: var(--baize-bg);
  border-radius: var(--baize-radius);
  box-shadow: var(--baize-shadow);
  padding: var(--baize-pad);
}
.fitter { flex: 1 1 auto; min-height: 0; overflow: hidden; }
.fitter.scroll { overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* Sizes are dealt by fitTable in pixels: columns through <col>, rows on each
   <tr>, and the table as the exact sum of both. Nothing here uses percentage
   row heights, which is how Morning once towered over Evening. */
table.grid {
  width: 100%; table-layout: fixed;
  border-collapse: separate; border-spacing: 4px;
}
.grid col.c-corner { width: 70px; }
@media (max-width: 720px) { .grid col.c-corner { width: 58px; } }
.app.compact .grid col.c-corner { width: 62px; }
.grid th, .grid td { padding: 0; }
.grid td { height: 100%; }

/* Row and column headings are buttons: tapping one backs the whole line. */
.colh, .rowh {
  display: flex; align-items: center; justify-content: center; gap: 3px;
  width: 100%; height: 100%; min-height: 26px; padding: 5px 4px;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  color: var(--ink-2); font: 700 12px/1.15 inherit; text-align: center;
  overflow: hidden; cursor: default;
  transition: background .12s, border-color .12s, color .12s;
}
.rowh { flex-direction: column; font-size: 11px; }
.colh .ico, .rowh .ico { flex: none; width: 16px; height: 16px; color: var(--icon); }
.stack-col { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.betting .colh, .betting .rowh { cursor: pointer; border-color: var(--head-border); }
@media (hover: hover) {
  .betting .colh:hover, .betting .rowh:hover {
    background: var(--hover-bg); border-color: var(--hover-border); color: var(--ink);
  }
}

/* Large boards (hourly and friends): fixed-size columns inside a scrollport,
   with the headings pinned so every square still says which day and hour it
   is. Pinned headings need a solid background or the squares show through. */
.grid.large .colh, .grid.large .rowh { font-size: 10.5px; padding: 4px 2px; }
.grid.large thead th { position: sticky; top: 0; z-index: 2; background: var(--sticky-bg); }
.grid.large tbody th { position: sticky; left: 0; z-index: 1; background: var(--sticky-bg); }
.grid.large thead th.corner { left: 0; z-index: 3; }

/* ---- squares ---- */
.cell {
  position: relative; container-type: inline-size;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 100%; height: 100%; padding: 4px; overflow: hidden;
  background: var(--cell-bg);
  border: 1px solid var(--cell-border);
  border-radius: var(--radius-cell);
  box-shadow: var(--cell-shadow);
  color: var(--ink); font: inherit; text-align: center; cursor: default;
  transition: background .12s, border-color .12s, transform .12s cubic-bezier(.16, 1, .3, 1);
}
.betting .cell { cursor: pointer; }
.betting .cell:active { transform: scale(.96); }
@media (hover: hover) {
  .betting .cell:hover { background: var(--hover-bg); border-color: var(--hover-border); }
}
.cell.lead { background: var(--lead-bg); border-color: var(--lead-border); box-shadow: var(--lead-shadow); }
.cell.lead .amt { color: var(--win-ink); }
.cell.blocked { background: var(--block-bg); border-color: var(--block-border); }
.cell.dead { background: var(--dead-bg); border-style: dashed; color: var(--ink-3); cursor: default; }
.cell.dead:active { transform: none; }
.cell.called { border-color: var(--lead-border); box-shadow: inset 0 0 0 2px var(--accent); }
.cell.called::after {
  content: "✓"; position: absolute; top: 4px; right: 6px;
  font-size: 12px; font-weight: 800; color: var(--win-ink);
}

/* The chips and their count, together, in the middle of the square. */
.cell .tag { display: flex; align-items: center; justify-content: center; gap: 5px; max-width: 100%; }
.cell .amt {
  font-size: clamp(12px, 20cqi, 18px); font-weight: 800; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.cell .flag { font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.cell .note {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: clamp(9px, 13cqi, 11px); font-weight: 700; line-height: 1.2; color: var(--block-ink);
}
/* A narrow square cannot say who, so it only says that someone can't (the
   tint) and keeps its full text for the tooltip and screen readers. It keeps
   one pile beside the count rather than a crowd over it. */
@container (max-width: 58px) {
  .cell .note { display: none; }
  .cell .stacks .stack + .stack { display: none; }
  .cell .tag { gap: 3px; }
}

/* One-axis boards: a set of equal squares, sized by fitTiles. */
.onegrid { display: grid; gap: 4px; justify-content: center; align-content: center; min-height: 100%; }
.cell.onecell { justify-content: space-between; padding: 10px 8px; }
.celllabel { font-size: clamp(12px, 15cqi, 18px); font-weight: 800; line-height: 1.15; }
.cell.onecell .tag { flex: 1; }

/* ================================================================ chips */

.stacks { display: flex; align-items: flex-end; gap: 3px; min-width: 0; }
/* A small leaning pile. --n chips, each --i up the pile; sizes scale with the
   square the pile sits in (cqi), and the tray sets its own. */
.stack {
  --chip: clamp(12px, 18cqi, 26px);
  --step: calc(var(--chip) * .22);
  position: relative; flex: none;
  width: calc(var(--chip) + (var(--n, 1) - 1) * var(--step) * .5);
  height: calc(var(--chip) + (var(--n, 1) - 1) * var(--step));
}
.stack .chip {
  position: absolute;
  left: calc(var(--i, 0) * var(--step) * .5);
  bottom: calc(var(--i, 0) * var(--step));
  width: var(--chip); height: var(--chip);
}

/* A poker chip: coloured body, centre pip, rim spots, slight lift. */
.chip, .d {
  display: block; flex: none; border-radius: 50%; aspect-ratio: 1;
  background:
    radial-gradient(circle closest-side at 50% 42%, rgb(255 255 255 / .28) 0 18%, transparent 19%),
    radial-gradient(circle closest-side at 50% 50%, var(--c) 0 58%, transparent 59%),
    repeating-conic-gradient(from 8deg, rgb(255 255 255 / .92) 0 12deg, var(--c) 12deg 45deg);
  box-shadow:
    inset 0 1px 1px rgb(255 255 255 / .45),
    inset 0 -1px 2px rgb(0 0 0 / .35),
    0 1px 2px rgb(0 0 0 / .4);
}
/* Relative, so the rim ring below measures against the chip itself. Left
   static, its percentage insets resolved against the page and it drew a faint
   oval across the whole screen. */
.d { position: relative; width: 26px; height: 26px; }
.d.sm { width: 15px; height: 15px; }
.chip::after, .d::after {
  content: ""; position: absolute; inset: 28%; border-radius: 50%;
  border: 1px solid rgb(255 255 255 / .28); pointer-events: none;
}

/* ================================================================ tray */

.tray {
  grid-area: tray; min-width: 0;
  display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap;
  padding: 10px 12px;
}
.purse {
  display: grid; grid-template-columns: auto auto; column-gap: 10px; align-items: center;
}
.purse .k { grid-column: 1; font-size: 11px; font-weight: 700; color: var(--ink-3); white-space: nowrap; }
.purse .v {
  grid-column: 1; font-size: 22px; font-weight: 800; line-height: 1.05;
  font-variant-numeric: tabular-nums; color: var(--win-ink);
}
.purse .v.called-pick { font-size: 17px; }
.purse .stack { --chip: 20px; grid-column: 2; grid-row: 1 / span 2; }

/* One choice among three, so it looks like one control. */
.modes {
  display: inline-flex; gap: 2px; padding: 3px;
  border-radius: 999px; background: var(--seg-bg); border: 1px solid var(--line-soft);
}
.modes button {
  padding: 8px 14px; border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-2); font: 700 13px/1 inherit; white-space: nowrap; cursor: pointer;
  transition: background .12s, color .12s;
}
@media (hover: hover) { .modes button:hover { color: var(--ink); } }
.modes button[aria-pressed="true"] { background: var(--on-bg); color: var(--on-ink); }
.modes button.mode-cant[aria-pressed="true"] { background: var(--cant-on-bg); color: #fff; }

.tray .btn.go { margin-left: auto; }

@media (max-width: 720px) {
  .tray { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .purse { grid-column: 1; grid-row: 1; justify-self: start; }
  .tray .btn.go { grid-column: 2; grid-row: 1; }
  .modes { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(3, 1fr); }
}
.app.compact .tray { flex-wrap: nowrap; overflow-x: auto; padding: 6px 10px; gap: 8px; }
.app.compact .purse .k { display: none; }
.app.compact .purse .v { font-size: 19px; }
.app.compact .modes button { padding: 6px 11px; font-size: 12.5px; }
.app.compact .tray .btn { padding: 7px 13px; font-size: 12.5px; }

/* ================================================================ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 15px; border-radius: 999px;
  border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--ink);
  font: 700 13px/1 inherit; white-space: nowrap; cursor: pointer;
  transition: background .12s, border-color .12s, transform .12s cubic-bezier(.16, 1, .3, 1);
}
@media (hover: hover) { .btn:hover:not(:disabled) { background: var(--btn-hover-bg); } }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn.go {
  background: var(--primary-bg); color: var(--primary-ink);
  border-color: var(--primary-edge); box-shadow: var(--primary-shadow);
}
@media (hover: hover) { .btn.go:hover:not(:disabled) { background: var(--primary-bg); filter: brightness(1.06); } }
/* A picked option in a row of options (the setup page's time limits). */
.btn.on { background: var(--on-bg); color: var(--on-ink); border-color: transparent; }

.hint { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.hint b { color: var(--ink); }
.foot { grid-area: foot; margin: 0; max-width: 70ch; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.foot b { color: var(--ink); }

/* Errors float over everything, because on a sideways phone there is no card
   left to put them in. */
.toast {
  position: fixed; z-index: 50; left: 50%; top: max(12px, env(safe-area-inset-top));
  transform: translateX(-50%); max-width: min(92vw, 440px);
  padding: 10px 16px; border-radius: 14px;
  background: var(--toast-bg); color: var(--toast-ink);
  font-size: 14px; font-weight: 700; line-height: 1.3; text-align: center;
  box-shadow: 0 12px 30px -12px rgb(0 0 0 / .5);
}

/* ================================================================ forms
   Shared with the setup page. */

input[type="text"] {
  width: 100%; padding: 11px 16px;
  font: 600 15px/1.3 inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
input[type="text"]::placeholder { color: var(--ink-3); opacity: 1; }
.sheet { grid-area: main; display: flex; flex-direction: column; gap: 18px; padding: 22px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 220px; }
.tokens { display: flex; flex-wrap: wrap; gap: 7px; }
.token {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 7px 6px 14px;
  font-size: 14px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
.token button {
  all: unset; cursor: pointer; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink-3); font-size: 16px; line-height: 1;
}
.token button:hover { color: var(--oxblood); background: var(--oxblood-bg); }
.rules { display: flex; flex-direction: column; }
.rule { display: flex; gap: 12px; padding: 10px 0; }
.rule input { margin: 2px 0 0; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.rule .t { display: flex; flex-direction: column; gap: 2px; }
.rule .t b { font-size: 14.5px; font-weight: 800; }
.rule .t small { font-size: 12.5px; font-weight: 600; line-height: 1.45; color: var(--ink-2); }

/* ================================================================ motion */

@media (prefers-reduced-motion: no-preference) {
  /* Only the chip you just placed drops in. Every square is rebuilt on each
     render, so animating every chip replayed the whole board on every tap. */
  .cell.fresh .stack .chip:last-child { animation: drop .3s cubic-bezier(.16, 1, .3, 1) backwards; }
  @keyframes drop { from { transform: translateY(-8px) scale(.8); opacity: 0; } }
  .toast { animation: toast-in .22s cubic-bezier(.16, 1, .3, 1) backwards; }
  @keyframes toast-in { from { transform: translate(-50%, -8px); opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- a phone held upright ------------------------------------------------
   The page scrolls, the board is as wide as the screen, and the controls
   stay under your thumb. */
@media (max-width: 720px) {
  .app {
    height: auto; min-height: 100dvh;
    padding: 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "top" "main" "tray" "side" "foot";
    align-content: start;
  }
  .board, .baize { flex: 0 0 auto; }
  /* A scrolling board needs a bounded box to scroll inside. */
  .fitter.scroll { flex: none; height: min(62dvh, 560px); }
  .app > .tray {
    position: sticky; z-index: 5;
    bottom: max(8px, env(safe-area-inset-bottom));
    background: var(--solid-bg);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
  .app > .side { overflow: visible; }
  .dealer { display: none !important; }
  .colh { padding: 4px 1px; font-size: 11.5px; }
  .grid .rowh { padding: 4px 2px; }
}
