/* ============================================================================
   F2 — Shared style tokens (lightweight foundation; NOT a redesign)
   ----------------------------------------------------------------------------
   Semantic CSS custom properties are the single source of truth for the
   parchment / classic theme. Every token maps 1:1 to a value the app already
   used, so adopting them is a pure refactor with ZERO visual change.

   How to use this foundation for NEW UI (existing UI migrates incrementally):
     - Colors:      --color-bg, --color-surface, --color-felt, --color-ink,
                    --color-ink-muted, --color-border, --color-accent,
                    --color-success, --color-danger-ink, --color-gold,
                    plus player + card-suit colors.
     - Typography:  --font-sans / --font-mono / --font-display; --text-* scale;
                    --text-base / --leading-base for body copy.
     - Spacing:     --space-1 .. --space-6 (a small 4px-based scale).
     - Radii:       --radius-sm / --radius / --radius-lg / --radius-pill.
     - Elevation:   --shadow / --shadow-modal / --shadow-selected.
   Component primitives built from these tokens live at the bottom of this file:
     .btn / .btn-primary, .input, .panel, .modal-overlay + .modal.
   They reproduce the current looks and are ready for new UI; existing elements
   keep their own classes for now (no rewiring = no regressions).

   Legacy short aliases (--bg, --ink, --btn, ...) are kept below so existing
   rules — and cardFace.css, which references --ink/--shadow/--card-red — keep
   resolving to identical values. Migrate refs to the semantic names over time.
   ============================================================================ */
:root {
  /* Surfaces */
  --color-bg: #f5edda;            /* warm parchment — page background */
  --color-surface: #fffaf0;       /* warm white — cards / panels / buttons */
  --color-felt: #fbf4e4;          /* table felt */
  --color-surface-input: #fff;    /* input field background */
  --color-surface-tag: #efe6d2;   /* small tag / chip surface (crib tag) */

  /* Ink / text */
  --color-ink: #2c2418;           /* warm near-black — primary text */
  --color-ink-soft: #5f5238;      /* softened ink — score breakdown items */
  --color-ink-muted: #8a7d63;     /* muted / secondary text */
  --color-on-accent: #fff;        /* text / icon on a filled accent surface */

  /* Lines / borders */
  --color-border: #e2d6bd;        /* hairline borders */
  --color-border-dashed: #b3a07a; /* dashed outlines (crib slot / crib tag) */

  /* Brand / accents */
  --color-accent: #2f6f9e;        /* interactive blue — primary buttons, selection */
  --color-success: #1f7a4d;       /* green — wins, notices, link hover */
  --color-gold: #c79a2e;          /* focus ring / highlight */
  --color-player-you: #b8332b;    /* player identity — you (red, bottom track) */
  --color-player-bot: #2f6f9e;    /* player identity — opponent (blue, top track) */
  --color-card-red: #c0392b;      /* card suit red — independent of player */

  /* State tints (chips, call bubbles, scrim) */
  --color-danger-ink: #a3331f;
  --color-danger-bg: rgba(192, 57, 43, 0.10);
  --color-danger-border: rgba(192, 57, 43, 0.22);
  --color-success-bg: rgba(31, 122, 77, 0.10);
  --color-success-border: rgba(31, 122, 77, 0.24);
  --color-call-you-bg: rgba(47, 111, 158, 0.16);   /* accent-blue @16% behind the "you" count */
  --color-call-bot-bg: rgba(184, 51, 43, 0.16);    /* you-red @16% behind the "bot" count */
  --color-scrim: rgba(40, 30, 15, 0.5);            /* modal backdrop */

  /* Card-back (face-down) palette — also referenced by cardFace.css */
  --card-back-top: #3a5d86;
  --card-back-bottom: #294767;
  --card-back-hatch: rgba(255, 255, 255, 0.06);
  --card-back-border: #213a5c;

  /* Typography */
  --font-sans: ui-rounded, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, sans-serif;
  --font-mono: ui-monospace, Menlo, monospace;
  --font-display: var(--font-sans);  /* same family for now; a hook for future display type */
  --text-base: 15px;                 /* body copy size */
  --leading-base: 1.4;               /* body line-height */
  /* Small type scale for new UI (existing rules keep their literal sizes for now). */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 26px;

  /* Spacing scale (4px base) for new UI; existing rules keep their literal spacing. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Radii */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Elevation */
  --shadow: 0 1px 3px rgba(60, 45, 20, 0.14);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.32);
  --shadow-selected: 0 8px 16px rgba(47, 111, 158, 0.35);  /* lifted selected card */

  /* Motion */
  --transition-fast: 0.08s;

  /* Card geometry — standard 2.5 : 3.5 (= 1.4) proportion; sized to balance the board. */
  --card-w: 70px;
  --card-h: 98px;

  /* ---- Legacy aliases: keep existing rules + cardFace.css resolving unchanged ---- */
  --bg: var(--color-bg);
  --panel: var(--color-surface);
  --felt: var(--color-felt);
  --ink: var(--color-ink);
  --muted: var(--color-ink-muted);
  --line: var(--color-border);
  --you: var(--color-player-you);
  --bot: var(--color-player-bot);
  --card-red: var(--color-card-red);
  --btn: var(--color-accent);
  --accent: var(--color-success);
  --gold: var(--color-gold);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 ui-rounded, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, sans-serif;
}
/* Widened from 880 to fit the versus/results rail beside the play area. The felt
   (play area) keeps its own ~880px width; the extra room is for the left rail. */
#app { max-width: 1200px; margin: 0 auto; padding: 12px 16px 36px; }

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

/* ============================================================================
   Global site header (U1) — appears on every page above the page content.
   Token-built; it never sets the page width, so the game board layout is
   unaffected (the board sizes to #app, which the header sits above).
   ============================================================================ */
.site-header { background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.site-header-inner {
  padding: var(--space-2) var(--space-4);
  display: flex; align-items: center; justify-content: flex-start; gap: var(--space-3);
}
.site-wordmark {
  font-family: var(--font-display); font-weight: 800; font-size: var(--text-xl);
  letter-spacing: 0.2px; color: var(--color-ink); text-decoration: none;
}
.site-wordmark:hover { color: var(--color-accent); }
/* Main nav (Play, Learn) — sits just right of the wordmark (left-aligned, not
   centered); auth is pushed to the far right (see .site-header-right). */
.site-nav { display: flex; align-items: center; gap: var(--space-6); margin-left: var(--space-4); }
.site-nav-link {
  font-weight: 700; font-size: var(--text-sm); color: var(--color-ink-muted);
  text-decoration: none; padding: var(--space-1) 0;
}
.site-nav-link:hover { color: var(--color-accent); }
/* Dropdown menu: the top label navigates; hovering or focusing within reveals the
   dropdown (no JS state — CSS :hover / :focus-within). The dropdown sits flush
   under the label (no gap) so the pointer can travel into it without closing. */
.site-nav-menu { position: relative; }
.site-nav-top {
  display: inline-flex; align-items: center;
  font-weight: 700; font-size: var(--text-sm); color: var(--color-ink-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  text-decoration: none; padding: var(--space-1) 0; cursor: pointer;
}
.site-nav-top:hover { color: var(--color-accent); }
.site-nav-dropdown {
  position: absolute; left: 0; top: 100%; z-index: 60; min-width: 210px;
  display: none; padding: var(--space-1);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-modal);
}
.site-nav-menu:hover .site-nav-dropdown,
.site-nav-menu:focus-within .site-nav-dropdown { display: block; }
.site-nav-drop-item {
  display: block; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: 600; color: var(--color-ink);
  text-decoration: none; white-space: nowrap;
}
.site-nav-drop-item:hover { background: var(--color-felt); color: var(--color-accent); }

.site-header-right { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
/* Compact the header buttons a touch relative to the page .btn default. */
.site-header-right .btn { padding: var(--space-2) var(--space-4); font-size: var(--text-sm); }

/* signed-in account menu */
.site-menu-wrap { position: relative; }
.site-menu-trigger {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font: inherit; font-weight: 700; font-size: var(--text-sm);
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-ink);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-pill); cursor: pointer; box-shadow: var(--shadow);
}
.site-menu-caret { color: var(--color-ink-muted); font-size: var(--text-xs); }
.site-menu {
  position: absolute; right: 0; top: calc(100% + var(--space-2)); z-index: 20; min-width: 180px;
  display: flex; flex-direction: column; padding: var(--space-1);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-modal);
}
.site-menu[hidden] { display: none; }
.site-menu-item {
  display: block; width: 100%; text-align: left; font: inherit; font-size: var(--text-sm);
  background: none; border: 0; border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3);
  color: var(--color-ink); text-decoration: none; cursor: pointer;
}
.site-menu-item:hover:not(.is-disabled) { background: var(--color-felt); }
.site-menu-item.is-disabled { color: var(--color-ink-muted); cursor: default; }

/* auth modal (login / signup / reset) — built on the .modal primitive */
.auth-modal { position: relative; text-align: left; min-width: 300px; max-width: 360px; }
.auth-modal-title { margin: 0 0 var(--space-3); font-size: var(--text-xl); }
.auth-modal-close {
  position: absolute; top: var(--space-3); right: var(--space-3); width: 30px; height: 30px;
  display: grid; place-items: center; font-size: var(--text-lg); line-height: 1;
  background: none; border: 0; border-radius: var(--radius-sm); color: var(--color-ink-muted); cursor: pointer;
}
.auth-modal-close:hover { background: var(--color-felt); color: var(--color-ink); }
.auth-form { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-3); }
.auth-form .btn { margin-top: var(--space-1); }
.auth-modal .home-auth-toggle { display: inline-block; margin-right: var(--space-3); margin-top: var(--space-1); }

/* game footer — carries the Leave control below the board */
.game-footer { display: flex; justify-content: center; margin-top: var(--space-4); }
.quit-toggle { padding: 6px 14px; font-size: 13px; font-weight: 700; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); border-radius: var(--radius-pill); cursor: pointer; box-shadow: var(--shadow); }

/* Game layout: the felt (play area) on the LEFT, the versus/results rail to its
   RIGHT (felt first in the DOM, rail second). The felt keeps its own width, so the
   play area is unaffected by the rail. */
.game-layout { display: flex; gap: var(--space-4); align-items: flex-start; justify-content: center; }
.side-rail { width: 260px; flex: none; }
.side-rail:empty { display: none; } /* collapse before a game starts */

/* felt / table */
.felt {
  flex: 0 1 880px; /* keeps its ~880px width beside the rail; shrinks on small screens */
  background: var(--felt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.table-inner { width: 100%; max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 4px; }
/* Inset the player areas so their cards line up with the board body. */
.seat { display: flex; flex-direction: column; gap: 3px; padding: 0 14px; }
/* the spoken count/call, to the right of a player's played cards */
.call { font-size: 18px; font-weight: 800; padding: 6px 16px; border-radius: var(--radius-pill); white-space: nowrap; }
.call.you { background: var(--color-call-you-bg); color: var(--you); }
.call.bot { background: var(--color-call-bot-bg); color: var(--bot); }

/* central stage — only the cut-for-deal now */
.stage { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 8px 0; }
.stage:empty { display: none; }

/* pegged cards on each player's side (overlapping, in play order) */
/* fixed-height pegging row so the player areas don't change height between phases.
   Cards sit flush against the board, label on the outer side: opponent (above the
   board) bottom-aligned with labels on top; you (below) top-aligned with labels below. */
.pegged { display: flex; gap: 12px; min-height: 104px; }
.pegged > .card:not(:first-child) { margin-left: -28px; } /* overlap played cards (per ACC) */
.deck { margin-left: auto; display: flex; gap: 16px; }

/* The show: top row = counted hand + starter + big total; second row = breakdown. */
.show-row { display: flex; align-items: center; gap: 8px; min-height: 104px; }
.show-row .show-starter { margin-left: 16px; }
.show-score { margin-left: 16px; font-size: 38px; font-weight: 800; font-variant-numeric: tabular-nums; }
/* matches a card row's reserved height so the seat box never changes height */
.show-breakdown { display: flex; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; gap: 6px 16px; min-height: 104px; padding-top: 6px; }
/* .bd-item / .bd-empty are still used by the finished-game replay view (replay.js). */
.bd-item { font-size: 14px; font-weight: 600; color: var(--color-ink-soft); cursor: default; }
.bd-item:hover { color: var(--accent); }
.bd-empty { color: var(--muted); font-style: italic; }
/* AM1: the live show now reads "You scored N" + an "Explain the score" link; the
   per-combo detail opens in a modal (reusing the tutorial's .sq-combo rows). */
.show-total { font-size: 16px; font-weight: 700; align-self: center; }
.explain-modal { text-align: left; max-width: 460px; }
.explain-modal h2 { text-align: center; }
.explain-body { margin: 6px 0 18px; min-width: 280px; }
.crib-tag { background: var(--color-surface-tag); border: 1px dashed var(--color-border-dashed); border-radius: 7px; padding: 4px 9px;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); align-self: center; margin-right: 6px; }

.seat.opp .pegged { align-items: flex-end; }
.seat.opp .deck { align-items: flex-end; }
.seat.you .pegged { align-items: flex-start; }
.seat.you .deck { align-items: flex-start; }

/* Table layout: the versus/results side panel on the left, the play area on the
   right. The board keeps its own max-width; the flex row centers the pair. */
.side-panel { width: 100%; display: flex; flex-direction: column; gap: var(--space-3); }

/* Versus box: one row per player — a coloured dot (you red, opponent blue, matching
   the board pegs), the name, and the running score on the right. */
.vs-box { padding: var(--space-3); display: flex; flex-direction: column; gap: 10px; }
.vs-row { display: flex; align-items: center; gap: 8px; }
.vs-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.vs-dot.you { background: var(--you); }
.vs-dot.opp { background: var(--bot); }
.vs-name { flex: 1; min-width: 0; font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-score { flex: none; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 17px; }

/* Game-over results box — in-page, under the versus box (no modal). It looks the
   same win or lose; the "You win/You lose" text carries the outcome. */
.results-box { padding: var(--space-4); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.results-outcome { font-size: 18px; font-weight: 800; }
.results-score { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.results-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.results-actions button { width: 100%; }
/* "Evaluate game" — a navigation (to the unified replay+analysis page), styled
   as the secondary action so it reads like its sibling button. */
.results-eval {
  display: block; width: 100%; text-align: center; text-decoration: none;
  font: inherit; font-weight: 700; color: var(--color-ink);
  background: var(--color-surface); border: 1px solid var(--line);
  border-radius: var(--radius-md, 8px); padding: 8px 14px;
}
.results-eval:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* The show reveals every hand in its own hand area (face up) and the crib in the
   dealer's pegging area — cards + starter + that hand's own count sit inline. Both
   row kinds read identically: a vertical Hand/Crib label, the cards (NOT overlapped),
   the starter, and the centered score. position: relative anchors the hover-reveal
   explain affordance in the row's lower-left. */
.hand.show-hand, .pegged.show-crib { position: relative; flex-wrap: nowrap; align-items: center; gap: 8px; }
/* Crib cards must NOT overlap (they'd otherwise inherit .pegged's negative margin).
   The extra .pegged class raises specificity above the base + mobile overlap rules. */
.pegged.show-crib > .card:not(:first-child) { margin-left: 0; }
/* The starter sits a fixed gap after the cards in BOTH rows. The crib rule needs
   enough specificity (0,4,0) to beat the crib's own overlap-reset above (also
   0,4,0 but earlier) AND the base .pegged overlap rule (267, 0,3,0) — otherwise
   the crib starter loses the 16px and jams against the crib cards (unlike the
   hand, whose row has no competing negative-margin rule). */
.show-hand .show-starter, .pegged.show-crib > .card.show-starter { margin-left: 16px; }
.show-hand .show-score, .show-crib .show-score { margin-left: 12px; font-size: 24px; align-self: center; }
.show-uncounted { margin-left: 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); align-self: center; }

/* Vertical (rotated) row label beside the cards — "Hand" or "Crib". Bottom-to-top
   text saves horizontal space vs a wide horizontal tag. Consistent for both rows. */
.show-label {
  writing-mode: vertical-rl; transform: rotate(180deg); align-self: center; flex: none;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); padding: 2px 0; margin-right: 4px;
}

/* "click to explain": hidden until the row is hovered/focused, then shown in the
   row's lower-left. Keyboard-focusable so it stays accessible. */
.show-explain {
  position: absolute; left: 0; bottom: 2px; z-index: 2;
  opacity: 0; pointer-events: none; transition: opacity var(--transition-fast);
  font: inherit; font-weight: 700; font-size: 11px; cursor: pointer;
  color: var(--color-accent); background: var(--color-surface);
  border: 1px solid var(--color-accent); border-radius: var(--radius-pill); padding: 2px 10px; box-shadow: none;
}
.show-hand:hover .show-explain, .show-crib:hover .show-explain,
.show-hand:focus-within .show-explain, .show-crib:focus-within .show-explain,
.show-explain:focus-visible { opacity: 1; pointer-events: auto; }
.show-explain:hover { background: var(--color-accent); color: var(--color-on-accent); }

/* the crib: a dashed card outline with "crib" inside (no faded card, no label) */
.crib-slot {
  width: var(--card-w); height: var(--card-h); border-radius: 9px;
  border: 2px dashed var(--color-border-dashed); background: transparent;
  display: grid; place-items: center;
  color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700;
}

/* middle: board (fills the table width) + the dealer's deck/crib flush right */
.board-area { width: 100%; display: flex; flex-direction: column; gap: 4px; }
.board-row { display: block; width: 100%; } /* block so the SVG fills the width (not flex-collapsed) */
.board-mount { width: 100%; }
.board-mount svg { display: block; width: 100%; height: auto; }
.rail-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }

/* hand — fixed height so the player areas stay constant between phases */
.hand { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 104px; }

/* cards */
/* The base card appearance (.card / .corner / .pip / .red / .black / .facedown)
   lives in cardFace.css, shared with the card designer. One card size everywhere
   via --card-w/--card-h. Below are the game-only card states. */
.card.selectable { cursor: pointer; }
.card.selectable:hover { transform: translateY(-5px); }
.card.selected { transform: translateY(-12px); border-color: var(--btn); box-shadow: var(--shadow-selected); }
.card.legal { cursor: pointer; outline: 2px solid var(--btn); outline-offset: 1px; }
/* The hover/selected lift (translateY, above) shifts a clickable card's hit box
   upward, uncovering a strip at its rest-position bottom edge that falls through
   to the .hand container (cursor: auto) — so the pointer flickers away there (and
   the lost :hover makes the lift jitter). A transparent hit-area skirt below each
   interactive card keeps its rest footprint covered, so the pointer stays and
   :hover holds, without giving any non-interactive card a pointer. Sized to the
   largest lift (12px, the selected state). */
.card.selectable::after, .card.legal::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 12px;
}
.card.legal:hover { transform: translateY(-5px); }
.card.dim { opacity: 0.4; }

/* controls */
.controls { margin-top: 6px; min-height: 44px; display: flex; align-items: center; gap: 12px; }
/* Game-flow status — lives inside the control zone, taking the button's place
   when you have no move (the zone's min-height keeps it from resizing). Left-
   aligned at the cards' edge (where the button box starts), same font/weight as
   a button, in dark ink for contrast. */
.status { color: var(--ink); font-weight: 700; }
button {
  font: inherit; font-weight: 700; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink);
  padding: 10px 18px; border-radius: 10px; cursor: pointer; box-shadow: var(--shadow);
}
button.primary { background: var(--btn); border-color: var(--btn); color: var(--color-on-accent); }
button.primary:disabled { opacity: 0.4; cursor: default; }
button:active { transform: translateY(1px); }

/* breakdown */

/* opening cut-for-deal screen */
.cut-row { display: flex; gap: 40px; }
.cut-seat { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cut-result { font-size: 17px; font-weight: 700; }

/* end overlay */
.overlay { position: fixed; inset: 0; background: var(--color-scrim); display: grid; place-items: center; z-index: 10; }
.card-modal { background: var(--panel); border-radius: var(--radius-lg); padding: 28px 36px; text-align: center; box-shadow: var(--shadow-modal); }
.card-modal h2 { margin: 0 0 6px; }
.card-modal p { color: var(--muted); margin: 6px 0 18px; font-weight: 600; }

/* homepage (index.html) — a light page, no game engine. A single centered card
   with the two ways to start and any games in progress. No page heading — the
   "Cribbager" wordmark lives in the site header. */
.home-play { max-width: 440px; margin: 6vh auto 0; padding: var(--space-5); }
/* Single centered card — still used by the password reset page (reset.js). */
.home-card { max-width: 440px; margin: 8vh auto 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 26px 30px 30px; box-shadow: var(--shadow); }
.home-title { margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: 0.2px; }
.home-input { display: block; width: 100%; box-sizing: border-box; padding: 9px 12px; margin: 8px 0;
  border: 1px solid var(--line); border-radius: 10px; font: inherit; background: var(--color-surface-input); }
/* Start actions stack vertically (full-width buttons). */
.home-actions { display: flex; flex-direction: column; gap: 8px; margin: 0 0 18px; }
.home-actions button { width: 100%; }
.home-action { text-align: center; padding: 12px; font-weight: 700; }
.home-games { margin-top: 22px; }
.home-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.home-game-row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 0; border-top: 1px solid var(--line); }
.home-resume { color: var(--btn); font-weight: 700; text-decoration: none; }
.home-resume:hover { text-decoration: underline; }
.home-forget { padding: 4px 11px; font-size: 13px; }
.gameid { font-family: var(--font-mono); font-size: 12px; color: var(--ink); word-break: break-all; }

/* Completed-game history ("Your games"), shown when signed in. */
.home-history { margin-top: 22px; }
.home-history:empty { display: none; }
.home-stats { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.home-history-list { display: flex; flex-direction: column; }
.home-history-row { display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-top: 1px solid var(--line); font-size: 13.5px; }
.home-history-badge { flex: none; width: 22px; height: 22px; border-radius: var(--radius-pill); display: grid;
  place-items: center; font-size: 11px; font-weight: 800; color: var(--color-on-accent); }
.home-history-row.won .home-history-badge { background: var(--accent); }
.home-history-row.lost .home-history-badge { background: var(--muted); }
.home-history-opp { flex: 1 1 auto; font-weight: 700; color: var(--ink); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.home-history-score { flex: none; font-variant-numeric: tabular-nums; color: var(--ink); }
.home-history-date { flex: none; color: var(--muted); font-size: 12px; min-width: 56px; text-align: right; }
.home-history-analyze { flex: none; color: var(--btn); font-weight: 700; text-decoration: none; font-size: 12.5px; }
.home-history-analyze:hover { text-decoration: underline; }

/* Profile page (U6) — account, lifetime statistics, and game history. Uses the
   F2 .panel primitive for each section; the history list reuses the .home-history-*
   row styles above so the rows read identically to the old home-page list. */
.profile-title { max-width: 640px; margin: 6vh auto var(--space-4); font-size: 26px; font-weight: 800; letter-spacing: 0.2px; }
.profile-section { max-width: 640px; margin: 0 auto var(--space-4); }
.profile-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); font-weight: 700; margin-bottom: var(--space-3); }
.profile-name { font-size: 20px; font-weight: 800; color: var(--ink); }
.profile-handle { color: var(--muted); font-weight: 700; margin-top: 2px; }
.profile-field { color: var(--ink); margin-top: var(--space-2); }
.profile-empty { color: var(--muted); }
.profile-stat-summary { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: var(--space-3); }
.profile-stat-grid { display: flex; flex-direction: column; }
.profile-stat-row { display: grid; grid-template-columns: 1fr repeat(4, 56px); gap: 8px;
  align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.profile-stat-head { border-top: none; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 700; }
.profile-stat-name { font-weight: 700; color: var(--ink); }
.profile-stat-cell { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.profile-stat-head .profile-stat-cell { color: var(--muted); }

/* homepage account bar */
.home-auth { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px;
  padding-bottom: 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.home-auth b { color: var(--ink); }
.home-auth-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 1; }
.home-auth-form .home-input { margin: 0; width: auto; flex: 1 1 110px; min-width: 100px; }
.home-auth-form button { padding: 8px 14px; }
.home-auth-toggle { font-size: 13px; color: var(--btn); text-decoration: none; }
.home-auth-toggle:hover { text-decoration: underline; }

/* auth feedback messages — consistent across the homepage auth bar and reset page.
   Error is red, notice/success is the accent green; both are full-width chips. */
.home-auth-err, .home-auth-note { font-size: 13px; width: 100%; border-radius: var(--radius-sm); padding: 7px 11px; font-weight: 600; }
.home-auth-err:empty, .home-auth-note:empty { display: none; }
.home-auth-err { color: var(--color-danger-ink); background: var(--color-danger-bg); border: 1px solid var(--color-danger-border); }
.home-auth-note { color: var(--accent); background: var(--color-success-bg); border: 1px solid var(--color-success-border); }

/* ============================================================================
   Shared component primitives (F2)
   ----------------------------------------------------------------------------
   Token-built classes that reproduce the existing looks, ready for NEW UI to
   adopt for a consistent feel. They are intentionally NOT wired onto current
   elements (which keep their own classes) so this refactor stays zero-change.
   - .btn / .btn-primary   mirror the bare <button> and <button class="primary">.
   - .input                mirrors .home-input (without its layout margin).
   - .panel                mirrors the .home-card surface container.
   - .modal-overlay/.modal mirror the game-over .overlay / .card-modal.
   ============================================================================ */
.btn {
  font: inherit; font-weight: 700; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-ink);
  padding: 10px 18px; border-radius: 10px; cursor: pointer; box-shadow: var(--shadow);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

.input {
  display: block; width: 100%; box-sizing: border-box; padding: 9px 12px;
  border: 1px solid var(--color-border); border-radius: 10px; font: inherit;
  background: var(--color-surface-input); color: var(--color-ink);
}

.panel {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--space-6);
}

.modal-overlay { position: fixed; inset: 0; background: var(--color-scrim); display: grid; place-items: center; z-index: 10; }
.modal { background: var(--color-surface); border-radius: var(--radius-lg); padding: 28px 36px; text-align: center; box-shadow: var(--shadow-modal); }

@media (max-width: 560px) {
  :root { --card-w: 52px; --card-h: 73px; }
  .card .pip { font-size: 26px; }
  .card .corner { font-size: 14px; }
  /* homepage: tighten the card's top margin on a phone. */
  .home-play { margin-top: 4vh; }
  .home-card { margin-top: 4vh; padding: 22px 18px 24px; } /* reset page card on phones */
  .home-auth-form { width: 100%; }
  .home-auth-form .home-input { flex-basis: 100%; min-width: 0; }
  .home-auth-form button { width: 100%; }
  .site-header-inner { padding: var(--space-2) var(--space-3); }
  .site-header-right .btn { padding: var(--space-2) var(--space-3); }

  /* Stack the versus/results rail below the felt on a phone (no room beside it). */
  .game-layout { flex-direction: column; align-items: stretch; }
  .side-rail { width: 100%; }

  /* Mobile quick-win (NU2): stop the pegging/show rows clipping on a ~375px
     phone. The felt/table contain any spill, and the horizontal card rows
     scroll instead of pushing cards off-screen. Interim fix ahead of the full
     responsive redesign (U3). */
  .felt { padding: 12px 10px; overflow-x: hidden; }
  .table-inner { overflow-x: hidden; }
  .seat { padding: 0 4px; }
  /* Played-card and show rows: let their contents scroll rather than clip. */
  .pegged, .show-row { overflow-x: auto; overflow-y: hidden; }
  /* Tighten overlap and the deck gap so a full row fits more often before it
     needs to scroll. */
  .pegged { gap: 8px; }
  .pegged > .card:not(:first-child) { margin-left: -22px; }
  .deck { gap: 10px; }
  /* The show total is oversized for a narrow column; shrink it and its insets. */
  .show-score { font-size: 28px; margin-left: 10px; }
  .show-row .show-starter { margin-left: 10px; }
  .show-breakdown { gap: 6px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .peg { transition: none !important; }
}

/* ============================================================================
   Unified replay + analysis (A10) — analyze.html / analyze.js ("Evaluate game").
   The replay board on the left, a per-deal decision rail on the right.
   Token-built, consistent with the rest of the app.
   ============================================================================ */
#analyze { max-width: 1240px; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-6); }
.an-title { margin: 0 0 var(--space-1); font-size: var(--text-2xl); font-weight: 800; }
.an-subtitle { margin: 0 0 var(--space-4); color: var(--color-ink-muted); }
.an-crib { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700;
  color: var(--color-ink-muted); background: var(--color-surface-tag); border-radius: var(--radius-pill);
  padding: 2px 10px; }
.an-badge { margin-left: auto; font-size: var(--text-sm); font-weight: 800; border-radius: var(--radius-pill);
  padding: 3px 11px; white-space: nowrap; }
.an-badge.ok { color: var(--color-success); background: var(--color-success-bg); border: 1px solid var(--color-success-border); }
.an-badge.off { color: var(--color-danger-ink); background: var(--color-danger-bg); border: 1px solid var(--color-danger-border);
  font-variant-numeric: tabular-nums; }

.an-hand-cards { display: flex; gap: var(--space-2); margin: var(--space-2) 0; flex-wrap: wrap; }
/* Thrown cards in the dealt six are dimmed; kept cards stay full-strength. */
.an-hand-cards .card.an-thrown { opacity: 0.42; }

.an-line { font-size: var(--text-md); color: var(--color-ink); line-height: 1.7; }
.an-line-engine { color: var(--color-ink-soft); margin-top: var(--space-1); }
.an-line-label { font-weight: 700; }
.an-line-sep { color: var(--color-ink-muted); }
.an-ev { color: var(--color-ink-muted); font-variant-numeric: tabular-nums; }
/* Compact suit-coloured rank+suit chip used inline in the verdict sentences. */
.an-chip { display: inline-block; font-weight: 800; font-variant-numeric: tabular-nums;
  padding: 0 3px; margin: 0 1px; }
.an-chip.red { color: var(--color-card-red); }
.an-chip.black { color: var(--color-ink); }

.an-message { text-align: center; max-width: 480px; margin: var(--space-5) auto 0; }
.an-message-title { font-size: var(--text-lg); font-weight: 800; margin: 0 0 var(--space-2); color: var(--color-ink); }
.an-message-body { color: var(--color-ink-muted); margin: 0 0 var(--space-3); }

/* --- the replay board half (A2's spectator view, reused verbatim) --- */
/* The replay's felt mirrors the live table, minus any interactive affordances. */
.replay-felt .card.selectable, .replay-felt .card.legal { cursor: default; }
.replay-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-4); }
.replay-controls .btn { min-width: 84px; }
.replay-jump-wrap { display: inline-flex; align-items: center; gap: var(--space-2);
  font-weight: 700; font-size: var(--text-sm); color: var(--color-ink-muted); }
.replay-jump { font: inherit; padding: var(--space-1) var(--space-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); }
.replay-scrub { flex: 1 1 200px; min-width: 160px; }
.replay-label { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--color-ink); white-space: nowrap; }
.replay-dealer-tag { margin-left: var(--space-2); font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--color-ink-muted); }
.replay-count { text-align: center; padding: var(--space-2) 0; font-size: var(--text-md);
  color: var(--color-ink-muted); font-weight: 700; }
.replay-count strong { color: var(--color-ink); font-size: var(--text-xl); font-variant-numeric: tabular-nums; }

/* --- the decision rail: board left, rail right; the rail keeps its width and
   the felt takes the rest. Desktop-first; on a narrow viewport the rail drops
   below the board (same pattern as the live game's side rail). --- */
.ev-layout { display: flex; gap: var(--space-4); align-items: flex-start; }
.ev-main { flex: 1 1 auto; min-width: 0; }
.ev-rail { width: 340px; flex: none; display: flex; flex-direction: column; gap: var(--space-3); }
@media (max-width: 900px) {
  .ev-layout { flex-direction: column; align-items: stretch; }
  .ev-rail { width: 100%; }
}

.ev-engines { display: flex; align-items: center; gap: var(--space-3); }
.ev-rail-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 700; color: var(--color-ink-muted); }

.ev-summary { padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-1); }
.ev-summary-line { font-weight: 700; color: var(--color-ink); font-variant-numeric: tabular-nums; }

/* The deal list. Each deal is a full-width button row: number, starting scores,
   the two ✓/✗ marks, and the divergence dot. The viewed deal is highlighted and
   its decision details expand beneath it. */
.ev-deals { padding: var(--space-2); display: flex; flex-direction: column; gap: 2px; }
.ev-deal { display: flex; align-items: center; gap: var(--space-2); width: 100%; text-align: left;
  font: inherit; cursor: pointer; background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); box-shadow: none; }
.ev-deal:hover { background: var(--color-felt); }
.ev-deal.is-current { background: var(--color-felt); border-color: var(--line); }
.ev-deal-no { font-weight: 800; color: var(--color-ink); white-space: nowrap; }
.ev-deal-scores { color: var(--color-ink-muted); font-weight: 700; font-variant-numeric: tabular-nums;
  margin-right: auto; }
.ev-mark { font-size: var(--text-xs); font-weight: 800; white-space: nowrap; }
.ev-mark.ok { color: var(--color-success); }
.ev-mark.bad { color: var(--color-danger-ink); }
.ev-mark.none { color: var(--color-ink-muted); font-weight: 700; }
/* Engine divergence: the owner wants to SEE where the engines split. */
.ev-disagree-dot { font-weight: 800; color: var(--gold); }
.ev-disagree { align-self: flex-start; font-size: var(--text-xs); font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--gold); margin-top: 2px; }

/* The viewed deal's decisions, inline under its row. */
.ev-decisions { display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-3); }
.ev-decision { display: flex; flex-direction: column; border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); background: var(--panel); }
.ev-decision.is-optimal { border-color: var(--color-success-border); }
.ev-decision-head { display: flex; align-items: center; gap: var(--space-2); }
.ev-decision-label { font-weight: 800; color: var(--color-ink); }
.ev-count { color: var(--color-ink-muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.ev-no-plays { color: var(--color-ink-muted); font-size: var(--text-sm); font-weight: 600; }
.ev-rail-note { padding: var(--space-4); }
/* Rail decision cards are narrow: shrink the dealt-six faces (the same
   --card-scale pattern the discard evaluator's deck rows use). */
.ev-decisions .an-hand-cards {
  --card-scale: 0.62;
  --card-w: calc(70px * var(--card-scale));
  --card-h: calc(98px * var(--card-scale));
  --card-rank-size: calc(18px * var(--card-scale));
  --card-suit-size: calc(14px * var(--card-scale));
  --card-pip-size: calc(32px * var(--card-scale));
}

/* === Discard trainer (A5) — a standalone practice page ====================== */
#practice { max-width: 720px; margin: 0 auto; padding: var(--space-5) var(--space-4); }
.pr-title { margin: 0 0 var(--space-1); font-size: var(--text-2xl); font-weight: 800; }
.pr-subtitle { margin: 0 0 var(--space-4); color: var(--color-ink-muted); }

.pr-board { display: flex; flex-direction: column; gap: var(--space-4); margin-bottom: var(--space-4); }

.pr-controls { display: flex; align-items: center; gap: var(--space-3); }
.pr-controls-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 700; color: var(--color-ink-muted); }
.pr-seg-group { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--radius-pill); overflow: hidden; }
.pr-seg { font: inherit; font-weight: 700; font-size: var(--text-sm); border: 0; cursor: pointer;
  background: var(--color-surface); color: var(--color-ink-muted); padding: var(--space-2) var(--space-4); }
.pr-seg + .pr-seg { border-left: 1px solid var(--color-border); }
.pr-seg.is-on { background: var(--color-accent); color: var(--color-on-accent); }

.pr-hand { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; }
.pr-hand .card.pr-thrown { opacity: 0.42; }

.pr-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); }
.pr-hint { color: var(--color-ink-muted); font-weight: 600; margin-right: auto; }

.pr-verdict { display: flex; flex-direction: column; gap: var(--space-3); }
.pr-verdict.is-optimal { border-color: var(--color-success-border); }
.pr-verdict-head { display: flex; align-items: center; gap: var(--space-3); }
.pr-rank { font-size: var(--text-xl); font-weight: 800; color: var(--color-ink); }
.pr-badge { margin-left: auto; font-size: var(--text-sm); font-weight: 800; border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3); font-variant-numeric: tabular-nums; }
.pr-badge.ok { color: var(--color-success); background: var(--color-success-bg); border: 1px solid var(--color-success-border); }
.pr-badge.off { color: var(--color-danger-ink); background: var(--color-danger-bg); border: 1px solid var(--color-danger-border); }

.pr-line { font-size: var(--text-md); color: var(--color-ink); line-height: 1.7; }
.pr-line-engine { color: var(--color-ink-soft); }
.pr-line-label { font-weight: 700; }
.pr-line-sep { color: var(--color-ink-muted); }
.pr-ev { color: var(--color-ink-muted); font-variant-numeric: tabular-nums; }
.pr-verdict-note { color: var(--color-ink-muted); font-size: var(--text-sm); margin: 0; }

.pr-chip { display: inline-block; font-weight: 800; font-variant-numeric: tabular-nums; padding: 0 3px; margin: 0 1px; }
.pr-chip.red { color: var(--color-card-red); }
.pr-chip.black { color: var(--color-ink); }

.pr-details summary { cursor: pointer; font-weight: 700; color: var(--color-ink-muted); }
.pr-table { width: 100%; border-collapse: collapse; margin-top: var(--space-3); font-size: var(--text-sm); }
.pr-table th, .pr-table td { text-align: left; padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--color-border); }
.pr-td-rank { color: var(--color-ink-muted); font-variant-numeric: tabular-nums; }
.pr-td-ev { text-align: right; font-variant-numeric: tabular-nums; }
.pr-td-tag { color: var(--color-ink-muted); text-transform: uppercase; font-size: var(--text-xs); letter-spacing: 0.5px; }
.pr-row.is-you { background: var(--color-success-bg); font-weight: 700; }

.pr-message { text-align: center; max-width: 480px; margin: var(--space-4) auto 0; }
.pr-message-body { color: var(--color-ink-muted); margin: 0 0 var(--space-3); }

/* === Discard evaluator (T1) — a standalone tools page ======================== */
/* Reuses the discard trainer's pr- vocabulary (title/subtitle/board/segments/
   table/chips); new here are the full-deck card picker and the situation panel. */
#discard-evaluator { max-width: 860px; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-6); }

/* The picker: the whole deck, one row per suit, as small card faces (scaled via
   the card-size vars, same trick as .sq-combo-cards). Rows scroll sideways on a
   narrow screen rather than wrapping mid-suit. */
.de-deck { display: flex; flex-direction: column; gap: var(--space-1); overflow-x: auto; padding-bottom: 2px; }
.de-deck-row {
  display: flex; gap: var(--space-1); flex-wrap: nowrap;
  --card-scale: 0.62;
  --card-w: calc(70px * var(--card-scale));
  --card-h: calc(98px * var(--card-scale));
  --card-rank-size: calc(18px * var(--card-scale));
  --card-suit-size: calc(14px * var(--card-scale));
  --card-pip-size: calc(32px * var(--card-scale));
}
.de-deck .card.de-pick { cursor: pointer; flex: none; }
.de-deck .card.de-pick:hover { transform: translateY(-3px); }
.de-deck .card.de-pick.selected { transform: translateY(-3px); border-color: var(--btn); box-shadow: var(--shadow-selected); }
/* Six picked: the rest of the deck steps back until something is deselected. */
.de-deck .card.de-pick.de-full { opacity: 0.45; }

/* The chosen hand, full size, in the app-wide rank-then-suit order; empty picks
   show as dashed placeholder slots so the row never changes size. */
.de-chosen { min-height: var(--card-h); }
.de-slot { width: var(--card-w); height: var(--card-h); border-radius: 9px;
  border: 2px dashed var(--color-border-dashed); background: transparent; }

.de-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-4); }
.de-field { display: flex; flex-direction: column; gap: var(--space-1); }
.de-score { width: 110px; }

/* Game-situation panel: the plain-language facts, then the one-line read on how
   the position shifts the discard decision. */
.de-situation { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.de-situation-line { margin: 0; color: var(--color-ink); }
.de-situation-guidance { margin: var(--space-2) 0 0; font-weight: 700; color: var(--color-ink); }

.de-result { display: flex; flex-direction: column; gap: var(--space-3); }
.de-lenses { display: flex; align-items: center; gap: var(--space-3); }
/* Why the win lens shows no ranking of its own far from the end. */
.de-lens-note { margin: 0; color: var(--color-ink-muted); font-size: var(--text-sm); }
.de-table { margin-top: 0; }
/* The column the active lens ranks by. */
.de-table th.is-lens, .de-table td.is-lens { background: var(--color-success-bg); }
.de-table th { color: var(--color-ink-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.5px; }

/* --- Score-distribution charts (A9 upside) --- */
/* Rows are clickable to pick which hold's distribution the chart below expands. */
.de-row { cursor: pointer; }
.de-row:hover { background: var(--color-felt); }
.de-row:focus-visible { outline: 2px solid var(--color-gold); outline-offset: -2px; }
.de-row.is-selected { background: var(--color-call-you-bg); }
.de-row.is-selected.is-you { background: var(--color-call-you-bg); }
.de-td-shape { padding-top: 2px; padding-bottom: 2px; }

/* One accent hue carries magnitude; the tail is an annotation band, not a 2nd hue. */
.de-mini { display: block; }
.de-bar { fill: var(--color-accent); }
.de-tail { fill: var(--color-accent); opacity: 0.08; }
.de-rule { stroke: var(--color-ink-muted); stroke-width: 1; }
.de-rule-faint { stroke: var(--color-border-dashed); stroke-dasharray: 2 2; }
.de-mean { stroke: var(--color-player-you); stroke-width: 1.5; }
.de-axis { stroke: var(--color-border); stroke-width: 1; }
.de-tick, .de-anno { fill: var(--color-ink-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.de-anno { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; }
.de-anno-mean { fill: var(--color-player-you); }
.de-bar-label { fill: var(--color-ink); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

.de-dist { display: flex; flex-direction: column; gap: var(--space-3); }
.de-dist-head { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.de-dist-keep { font-weight: 700; color: var(--color-ink); }
.de-chart-wrap { overflow-x: auto; }
.de-chart { display: block; }
.de-stats { display: flex; flex-wrap: wrap; gap: var(--space-5); }
.de-stat { display: flex; flex-direction: column; }
.de-stat-value { font-size: var(--text-xl); font-weight: 800; color: var(--color-ink); }
.de-stat-label { font-size: var(--text-xs); color: var(--color-ink-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.de-dist-note { margin: 0; color: var(--color-ink-muted); font-size: var(--text-sm); }

/* === Hand Counting Tutorial (A6) — a standalone hand-counting practice page === */
/* Reuses the discard trainer's pr- vocabulary (title/subtitle/board/badge);
   the show layout, the single control row, and the inline combo list are new. */
#scoring-quiz { max-width: 720px; margin: 0 auto; padding: var(--space-5) var(--space-4); }

/* Practice / Show-me segmented toggle above the deck. It sits as a direct child of
   the column-flex .pr-board, whose default align-items: stretch would blow the
   inline-flex pill out to the full panel width; align-self: flex-start keeps a
   segmented toggle shrunk to its content and left-aligned. (The discard trainer's
   .pr-seg-group is nested inside a row-flex .pr-controls, so it is not stretched.) */
.sq-modes { display: inline-flex; align-self: flex-start; border: 1px solid var(--color-border); border-radius: var(--radius-pill); overflow: hidden; margin-bottom: var(--space-3); }
.sq-mode-tab { background: none; border: 0; cursor: pointer; font-weight: 700; font-size: var(--text-sm); color: var(--color-ink-muted); padding: var(--space-2) var(--space-4); }
.sq-mode-tab.is-active { background: var(--color-accent); color: #fff; }
.sq-answer-loading { color: var(--color-ink-muted); font-weight: 600; }

.sq-show { display: flex; gap: var(--space-3); flex-wrap: wrap; justify-content: flex-start; align-items: flex-start; }
.sq-card-slot { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
/* The starter (cut) card is set apart with extra space and a label beneath it —
   no highlight ring. */
.sq-card-slot.is-starter { margin-left: var(--space-5); }
.sq-starter-tag { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 700; color: var(--color-ink-muted); }

/* Single control row reading "[kind] for [total count]": the kind selector, the
   literal "for" word, the running-total input, and the Add button all sit on one
   line at the same height. */
.sq-builder { display: flex; flex-direction: column; gap: var(--space-2); }
.sq-controls { display: flex; gap: var(--space-2); align-items: stretch; flex-wrap: wrap; }
.sq-controls > .input, .sq-controls > .btn { height: 42px; box-sizing: border-box; margin: 0; }
.sq-controls .sq-kind { width: auto; flex: 0 0 auto; }
.sq-controls .sq-for { display: flex; align-items: center; flex: 0 0 auto; font-weight: 700; color: var(--color-ink-muted); }
.sq-controls .sq-count { width: 130px; flex: 0 0 auto; }
.sq-builder-error { color: var(--color-danger-ink); font-weight: 600; font-size: var(--text-sm); }

/* Inline declared/combo list — no panel, no heading. */
.sq-decl-list { display: flex; flex-direction: column; gap: var(--space-2); }
.sq-combo { display: flex; align-items: center; gap: var(--space-2); }
/* Combo cards are small reference thumbnails — scale them down via the card-size
   vars (cascades to the .card children; tweak --card-scale to resize). */
.sq-combo-cards {
  display: inline-flex; gap: var(--space-1); flex-wrap: wrap;
  --card-scale: 0.75;
  --card-w: calc(70px * var(--card-scale));
  --card-h: calc(98px * var(--card-scale));
  --card-rank-size: calc(18px * var(--card-scale));
  --card-suit-size: calc(14px * var(--card-scale));
  --card-pip-size: calc(32px * var(--card-scale));
}
.sq-combo-call { font-weight: 700; }
.sq-combo.is-wrong { color: var(--color-ink-muted); }
.sq-combo.is-wrong .sq-combo-call { text-decoration: line-through; }
.sq-combo.is-wrong .sq-combo-cards { opacity: 0.5; }
.sq-combo.is-missed .sq-combo-call { color: var(--color-ink); }
/* Teaching correction on a right-cards / wrong-count line: the count it should
   read, shown in full ink (not struck) beside the crossed-out entered count. */
.sq-combo-fix { font-weight: 700; color: var(--color-ink); }
/* Leading chip on each scoring line, flush left: the remove (✕) button before
   grading; a green ✓ / red ✕ circle after. */
.sq-status, .sq-decl-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  font-size: var(--text-sm); font-weight: 800; line-height: 1; padding: 0;
  margin-right: var(--space-1);
}
.sq-decl-remove { background: none; border: 1px solid var(--color-ink-muted); color: var(--color-ink-muted); cursor: pointer; }
.sq-decl-remove:hover { color: var(--color-danger-ink); border-color: var(--color-danger-border); }
.sq-status.ok { color: var(--color-success); background: var(--color-success-bg); border: 1px solid var(--color-success-border); }
.sq-status.bad { color: var(--color-danger-ink); background: var(--color-danger-bg); border: 1px solid var(--color-danger-border); }

/* Bottom row: Submit Score on the left before grading; after grading the overall
   Correct / Not-quite graphic replaces it on the left, with New Hand on the right. */
.sq-bottom { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-2); }
.sq-bottom .btn { height: 42px; box-sizing: border-box; margin: 0; }
.sq-bottom .pr-badge { margin-left: 0; font-size: var(--text-md); }
