/* crest — the shelf's shell (phage's, dice's, mahjong's, solitaire's and
 * minesweeper's before it: the bar, the menu sheet, the rows, the foot of
 * settings) around a battlefield drawn on a canvas by board.js (board.css is
 * its own; it reads the tokens declared here).
 *
 * THE ROOM IS THE NIGHT BEFORE A BATTLE (mahjong-v4's rule, "match the theme
 * of the game"): every screen sits on deep blue — the shield's field, black at
 * the edges — whatever the Appearance setting says. The setting chooses the
 * PANELS: light is pale parchment with dark ink, dark is navy glass with light
 * ink. Two token scopes do it: the ground takes the night's ink; the panels put
 * their own back. The board's panels (board.css) are paper too: #board scopes
 * the paper tokens under the shared names board.css reads (--panel, --ink…).
 *
 * THE SIDES' COLOURS are the handheld's: you are BLUE, the enemy RED, an ally
 * GREEN. board.css declares them (--bd-side0/1/2) and art.js reads them off
 * the board once mounted; the shell's own uses (a party row, the readout)
 * take the same three here.
 *
 * GOLD MEANS YOU (wizard's rule): your row on a leaderboard, your best on a
 * card, the one button that is the next thing to do — and the crest itself.
 */

:root {
  --bg:       #070b16;
  --panel:    #ffffff;
  --glass:    rgba(255, 255, 255, .78);
  --glass-2:  rgba(255, 255, 255, .55);
  --line:     rgba(60, 60, 67, .16);
  --line-2:   rgba(60, 60, 67, .08);
  --ink:      #000000;
  --ink-2:    #3c3c43;
  --dim:      #8a8a8e;
  --dim-2:    #b0b0b6;
  --pill:     #efeff0;
  --good:     #1a9e4b;
  --warn:     #b8730a;
  --bad:      #e5322b;
  --link:     #007aff;
  --heart:    #e0596e;
  --gold:     #d9a520;
  --gold-lit: #ffd45c;
  --gold-ink: #1a1200;
  /* THE ACCENT (crest-v16, the game-polish recipe, design/game-polish/README.md): every "this one" control — the
     primary button, a chip or tab that is on, your row — wears it; GOLD IS FOR PRIZES (stars, the supporter mark). */
  --accent: #4a7cf0; --accent-lit: #8eb0ff; --accent-ink: #ffffff;   /* window blue: the board's windows (the owner's pick) */
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --shadow:   0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);

  /* The night: the ground of every screen, and what is written straight on it. */
  --night-1:  #121c3d;
  --night-2:  #04070f;
  --night-ink: #eef1ff;
  --night-dim: rgba(238, 241, 255, .62);
  --night-line: rgba(255, 255, 255, .18);
  --night-glass:   rgba(255, 255, 255, .10);
  --night-glass-2: rgba(255, 255, 255, .06);
  --night-link:    #9ec5ff;

  /* The sides: you, the enemy, an ally (board.css --bd-side0/1/2 say the same). */
  --side0: #3b7dff;
  --side1: #ff4b3e;
  --side2: #3ddc5a;

  /* The panels: parchment by day. */
  --paper-1:  #f7f6f1;
  --paper-2:  #e9e6dc;
  --paper-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 0 0 .5px rgba(0,0,0,.35), 0 10px 24px rgba(0,0,0,.35);
  --paper-ink: #15130f; --paper-ink-2: #3f3a30; --paper-dim: #7d7668; --paper-dim-2: #aca69a;
  --paper-line: rgba(40, 30, 10, .18); --paper-line-2: rgba(40, 30, 10, .1);
  --paper-pill: rgba(40, 30, 10, .08); --paper-glass: rgba(255, 255, 255, .6); --paper-glass-2: rgba(40, 30, 10, .06);
  --paper-link: #2457c5;

  --r-card: 18px;
  --r-mid:  14px;
  --r-sm:   10px;

  --font: -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-num: ui-rounded, -apple-system, "SF Pro Rounded", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

/* THE PANELS BY NIGHT: navy glass, light ink. The ground does not change. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper-1: #1b2240; --paper-2: #11172c;
    --paper-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 .5px rgba(120, 140, 200, .25), 0 10px 24px rgba(0,0,0,.5);
    --paper-ink: #f2f4ff; --paper-ink-2: #d6dbf0; --paper-dim: #8f97b5; --paper-dim-2: #5d6482;
    --paper-line: rgba(180, 190, 230, .22); --paper-line-2: rgba(180, 190, 230, .12);
    --paper-pill: rgba(180, 190, 230, .12); --paper-glass: rgba(255, 255, 255, .08); --paper-glass-2: rgba(180, 190, 230, .08);
    --paper-link: #9ec5ff;
    --good: #30d158; --warn: #ffd60a; --bad: #ff453a; --gold: #e8c05a; --gold-lit: #ffd77a;
  }
}
:root[data-theme="dark"] {
  --paper-1: #1b2240; --paper-2: #11172c;
  --paper-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 .5px rgba(120, 140, 200, .25), 0 10px 24px rgba(0,0,0,.5);
  --paper-ink: #f2f4ff; --paper-ink-2: #d6dbf0; --paper-dim: #8f97b5; --paper-dim-2: #5d6482;
  --paper-line: rgba(180, 190, 230, .22); --paper-line-2: rgba(180, 190, 230, .12);
  --paper-pill: rgba(180, 190, 230, .12); --paper-glass: rgba(255, 255, 255, .08); --paper-glass-2: rgba(180, 190, 230, .08);
  --paper-link: #9ec5ff;
  --good: #30d158; --warn: #ffd60a; --bad: #ff453a; --gold: #e8c05a; --gold-lit: #ffd77a;
}

/* THE GAME'S FACE: Pixelify Sans for every title, name and number — board.css
   asks for it as "Crest Pixel" (SIL OFL 1.1, from Google Fonts' repository,
   served from here, registered in ~/claude/dependencies.json as crest-fonts). */
/* THE DIGITS ARE SILKSCREEN'S (crest-v21, review idea 3): in Pixelify Sans a 5 reads as an S at the unit card's size
 * ("HP 2S/2S"). The same family name over 0–9 only, so every number — on the page and on the canvases, which ask for
 * "Crest Pixel" too — takes Silkscreen's square digits and every letter stays Pixelify's. THE WEIGHTS MUST MATCH FACE
 * FOR FACE: a browser picks the faces for a weight first and only then splits them by unicode-range, so with Pixelify
 * as one 400–700 face beside a Silkscreen Bold at 700, every bold word went to the system font (seen in the v21 shots).
 * So Pixelify (one variable file) is declared twice, 400–600 and 700, the same two weights as Silkscreen's. */
@font-face { font-family: "Crest Pixel"; src: url("fonts/PixelifySans.ttf") format("truetype"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "Crest Pixel"; src: url("fonts/PixelifySans.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Crest Pixel"; src: url("fonts/Silkscreen-Regular.ttf") format("truetype"); font-weight: 400 600; font-display: swap; unicode-range: U+0030-0039; }
@font-face { font-family: "Crest Pixel"; src: url("fonts/Silkscreen-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; unicode-range: U+0030-0039; }
:root { --font-game: "Crest Pixel", var(--font-num); }

* { box-sizing: border-box; }
/* `[hidden]` MUST WIN (solitaire's lesson: any author `display` beats the UA's). */
[hidden] { display: none !important; }

/* NATIVE CONTROLS FOLLOW THE IN-APP CHOICE (IOS.md §11). */
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

html, body {
  margin: 0;
  min-height: 100%;              /* the page scrolls; the battle locks it (see "the shell") */
  font-family: var(--font);
  color: var(--night-ink);
  -webkit-font-smoothing: antialiased;
}
/* On the ROOT, not the body: a short screen's body ends mid-screen, and a
   gradient painted on it stopped there in a seam (mahjong-v4). */
html { background: radial-gradient(140% 90vh at 50% 0, var(--night-1), var(--night-2)) no-repeat, var(--night-2); }
body { background: transparent; }

/* No text selection, no long-press callout, no double-tap zoom — on EVERY
   element (IOS.md §27: touch-action is not inherited). */
*, *::before, *::after { touch-action: manipulation; }
body {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
input, textarea { -webkit-user-select: text; user-select: text; }

/* THE GLASS AT THE TOP (IOS.md §1): iOS 26 blurs a band under the status bar. */
:root { --glass-t: 20px; }

/* ── the shell ─────────────────────────────────────────────────────────────

   THE PAGE SCROLLS; THE BATTLE LOCKS IT (IOS.md §15, gems' shape). The home,
   the campaign, the prep and the menu are in-flow content and the document is
   their one scroller. While the game shows (and the menu is closed) app.js
   sets html.locked: the root is the viewport and nothing moves under a drag —
   the board owns every finger on it (board.css: touch-action none). */
html.locked, html.locked body { height: 100%; min-height: 0; overflow: hidden; overscroll-behavior: none; }
html.locked main { height: 100%; }

.view {
  padding: calc(8px + var(--glass-t) + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
  max-width: 560px; margin: 0 auto;
}
.view[hidden] { display: none !important; }
/* WHILE THE MENU IS OPEN the screen under it is hidden and pinned, not unmounted. */
body:has(#sheet-menu:not([hidden])) main { visibility: hidden; position: fixed; inset: 0; height: auto; }

/* THE GROUND: every screen takes the night's ink. */
.view, .sheet-body, .gate {
  --ink: var(--night-ink); --ink-2: var(--night-ink); --dim: var(--night-dim); --dim-2: var(--night-dim);
  --line: var(--night-line); --line-2: var(--night-line);
  --glass: var(--night-glass); --glass-2: var(--night-glass-2); --pill: var(--night-glass); --link: var(--night-link);
  color: var(--ink);
}

.view-head { padding: 12px 4px 18px; }
.view-head.bar { display: flex; align-items: center; gap: 10px; }
.bar-title { flex: 1; min-width: 0; }
.view-head h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -.2px; font-family: var(--font-game); }
.view-sub { margin: 4px 0 0; color: var(--dim); font-size: 15px; }

/* THE PANELS: the paper's (or the glass's) tokens, then the panel. */
.card, .mode-card, .board-list, .signin-card, .overlay-card {
  --ink: var(--paper-ink); --ink-2: var(--paper-ink-2); --dim: var(--paper-dim); --dim-2: var(--paper-dim-2);
  --line: var(--paper-line); --line-2: var(--paper-line-2);
  --pill: var(--paper-pill); --glass: var(--paper-glass); --glass-2: var(--paper-glass-2); --panel: var(--paper-1);
  --link: var(--paper-link); --heart: #d4475d; --games-gold: #c48a12;
  color: var(--ink);
  background: linear-gradient(170deg, var(--paper-1), var(--paper-2));
  box-shadow: var(--paper-shadow);
}

.card { border-radius: var(--r-card); padding: 16px; margin: 0 0 18px; }
.card h3 { margin: 0 0 12px; font-size: 16px; font-weight: 650; }
.card.rows { padding: 0 16px; }

.fine { margin: 12px 6px 0; color: var(--dim); font-size: 12.5px; line-height: 1.5; }
.fine strong { color: var(--ink-2); font-weight: 600; }
.fine a { color: var(--link); }
.fine.in-card { margin-left: 0; margin-right: 0; }
.fine.version { font-family: var(--font-num); }
.fine.center { text-align: center; }

/* ── buttons ───────────────────────────────────────────────────────────── */

.btn {
  font: inherit; font-size: 16px; font-weight: 600;
  padding: 12px 18px; border-radius: var(--r-mid);
  color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--glass); border: .5px solid var(--line); box-shadow: var(--shadow);
}
.btn:active { opacity: .7; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-quiet   { background: transparent; color: var(--link); box-shadow: none; border-color: transparent; }
.btn-wide    { display: flex; width: 100%; margin-top: 18px; }
.btn-small   { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: .4; cursor: default; }
.view .btn:not(.btn-primary):not(.btn-quiet) { box-shadow: none; }
.btn.armed { color: var(--accent-lit); }
.btn-primary.armed { color: var(--accent-ink); background: var(--accent-lit); }

.icon {
  font: inherit; font-size: 20px; line-height: 0;
  width: 40px; height: 40px; border-radius: 20px;
  display: grid; place-items: center; flex: none; padding: 0;
  color: var(--ink); cursor: pointer;
  background: var(--glass); border: .5px solid var(--line);
}
.icon:active { opacity: .7; }

.pill {
  display: block; width: 100%; margin: 0 0 14px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 10px 14px; border-radius: 999px; cursor: pointer;
  background: var(--night-glass); color: var(--night-ink); border: .5px solid var(--night-line);
}

/* ── the gate ──────────────────────────────────────────────────────────── */

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.signin-card { max-width: 340px; width: 100%; text-align: center; padding: 26px 22px 22px; border-radius: var(--r-card); }
.signin-card h1 { margin: 14px 0 6px; font-size: 30px; letter-spacing: -.02em; font-family: var(--font-game); }
.signin-card .lede { margin: 0 0 22px; color: var(--ink-2); font-size: 15px; line-height: 1.45; }
.signin-card .btn-wide { margin-top: 0; }
.brand { display: block; width: 88px; height: 88px; margin: 0 auto; border-radius: 22.5%; box-shadow: 0 0 0 1px var(--line), 0 6px 18px rgba(0,0,0,.14); }
.gate-msg { margin: 0 0 18px; padding: 11px 13px; border-radius: var(--r-mid); background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); font-size: 13px; line-height: 1.45; text-align: left; }

/* ── the home ──────────────────────────────────────────────────────────── */

.mode-cards { display: grid; gap: 18px; }
.mode-card {
  display: flex; gap: 14px; align-items: stretch; width: 100%; text-align: left;
  font: inherit; cursor: pointer; padding: 16px; border-radius: var(--r-card); border: 0;
}
.mode-card:active { translate: 0 2px; }
.mode-card:disabled { opacity: .6; cursor: default; }
.mode-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.mode-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.mode-card h3 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0; font-family: var(--font-game); }
.mode-card .shape { color: var(--dim); font-size: 12.5px; font-family: var(--font-num); white-space: nowrap; }
.mode-card .blurb { margin: 5px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.mode-art { flex: none; width: 64px; display: flex; align-items: center; justify-content: center; position: relative; }
.mode-art canvas, .mode-art img { width: 64px; height: 64px; display: block; image-rendering: pixelated; }
.mode-art img { border-radius: 14px; image-rendering: auto; }
.mode-card-stats { display: flex; gap: 18px; margin-top: 12px; padding-top: 11px; border-top: .5px solid var(--line-2); }
.mode-card-stats div { display: flex; flex-direction: column; gap: 1px; }
.mode-card-stats .v { font-family: var(--font-num); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mode-card-stats .k { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .4px; }
.mode-card-stats .v.none { color: var(--dim-2); }
.mode-card-stats .v.you { color: var(--accent-lit); }
/* A battle in play stays NIGHT (it is the field you left), raised on the dark. */
.mode-card.resume {
  --ink: var(--night-ink); --ink-2: var(--night-ink); --dim: var(--night-dim); --line-2: var(--night-line);
  background: var(--night-glass); color: var(--night-ink); box-shadow: inset 0 0 0 1px var(--night-line), 0 8px 18px rgba(0,0,0,.22);
}

/* ── the campaign ──────────────────────────────────────────────────────── */

.camp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.camp-head h3 { margin: 0; font-size: 21px; font-family: var(--font-game); }
.camp-stars { color: var(--gold); letter-spacing: 2px; font-size: 18px; white-space: nowrap; }
.camp-stars .off { color: var(--dim); opacity: .45; }
.camp-recipe { margin: 6px 0 0; font-size: 15px; color: var(--ink-2); line-height: 1.45; }
.camp-detail .btn-wide { margin-top: 14px; }
.camp-list .camp-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: .5px solid var(--line-2); width: 100%; text-align: left; font: inherit; color: inherit; background: none; border-left: 0; border-right: 0; border-top: 0; cursor: pointer; }
.camp-list .camp-row:last-child { border-bottom: 0; }
.camp-list .camp-row:active { background: var(--pill); }
.camp-list .camp-row.locked { opacity: .45; cursor: default; }
.camp-list .camp-row.is-on .camp-n { color: var(--accent-lit); }
.camp-n { flex: none; width: 30px; font-family: var(--font-game); font-size: 18px; font-weight: 700; color: var(--dim); text-align: right; }
.camp-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.camp-t { font-size: 15.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.camp-m { font-size: 12px; color: var(--dim); margin-top: 1px; }
.camp-s { flex: none; color: var(--gold); letter-spacing: 1px; font-size: 14px; min-width: 3.2em; text-align: right; }
.camp-s .off { color: var(--dim); opacity: .45; }
.chips-k { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px; margin: 0 0 8px; }
.chips-k + .segmented { margin-bottom: 14px; }

/* ── prep: who deploys, what they carry ────────────────────────────────── */

.prep-note { margin: 0 6px 14px; }
.party-list .party-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: .5px solid var(--line-2);
  width: 100%; text-align: left; font: inherit; color: inherit; background: none; border-left: 0; border-right: 0; border-top: 0; cursor: pointer;
}
.party-list .party-row:last-child { border-bottom: 0; }
.party-list .party-row:active { background: var(--pill); }
.party-row .party-face { flex: none; width: 44px; height: 44px; image-rendering: pixelated; border-radius: 8px; }
.party-row .party-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.party-row .party-name { font-size: 16px; font-weight: 700; font-family: var(--font-game); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.party-row .party-name .party-tag { font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--accent-lit); margin-left: 6px; letter-spacing: .3px; text-transform: uppercase; }
.party-row .party-meta { font-size: 12px; color: var(--dim); margin-top: 1px; font-variant-numeric: tabular-nums; }
.party-row .party-items { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.item-chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 2px 8px 2px 4px; border-radius: 8px;
  background: var(--pill); font: inherit; font-size: 12px; color: var(--ink-2); border: 2px solid transparent; cursor: pointer;
}
.item-chip canvas { image-rendering: pixelated; width: 20px; height: 20px; }
.item-chip .uses { color: var(--dim); font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.item-chip.picked { border-color: var(--link); }
.party-row .party-mark { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 14px; font-weight: 800; color: transparent; }
.party-row.on .party-mark { background: var(--side0); border-color: var(--side0); color: #fff; }
.party-row.fixed .party-mark { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.party-row.off { opacity: .62; }
.party-row.target { box-shadow: inset 0 0 0 2px var(--link); border-radius: 10px; }
.convoy { min-height: 64px; }
.convoy .convoy-items { display: flex; flex-wrap: wrap; gap: 6px; }
.convoy .convoy-empty { color: var(--dim); font-size: 13px; margin: 0; }
.convoy.target { box-shadow: var(--paper-shadow), inset 0 0 0 2px var(--link); }
.convoy .convoy-gold { font-size: 12px; color: var(--dim); margin: 10px 0 0; font-family: var(--font-num); }

/* ── skirmish ──────────────────────────────────────────────────────────── */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  font: inherit; font-size: 14px; font-weight: 600; padding: 9px 14px; border-radius: 999px; cursor: pointer;
  background: var(--glass-2); border: .5px solid var(--line-2); color: var(--ink);
}
.chips button.is-on { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: var(--shadow); }
.chip-note { min-height: 2.9em; }

/* ── a game in play ────────────────────────────────────────────────────── */

#view-game {
  height: 100%; max-width: none;
  display: flex; flex-direction: column; overflow: hidden; gap: 0;
  padding: calc(4px + var(--glass-t) + env(safe-area-inset-top, 0px)) 0 0;
}
.game-head { display: flex; align-items: center; gap: 8px; padding: 2px 10px 8px calc(10px + env(safe-area-inset-left, 0px)); padding-right: calc(10px + env(safe-area-inset-right, 0px)); flex: none; max-width: 760px; width: 100%; margin: 0 auto; }
/* THE READOUT: the turn and whose phase, the objective under it. */
.readout { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.readout-turn { font-family: var(--font-game); font-size: 17px; font-weight: 700; color: var(--night-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout-turn.enemy { color: var(--side1); }
.readout-turn.ally { color: var(--side2); }
.readout-goal { font-size: 12px; color: var(--night-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

/* THE SPEAKER (CLAUDE.md 5e, letters' .snd-g). */
.snd-g { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.snd-g .ol { fill: none; }
.sound-btn[aria-pressed="true"] .snd-off, .sound-btn[aria-pressed="false"] .snd-on { display: none; }
.sound-btn[aria-pressed="false"] { opacity: .62; }
#view-game .icon { background: var(--night-glass); color: var(--night-ink); border-color: var(--night-line); box-shadow: none; }

/* THE STAGE THE BOARD FILLS: the rest of the screen under the header. The
   board (C's) is laid in it edge to edge; the note and the end overlay are
   its siblings. Everything in here is absolute inside the stage, nothing is
   fixed (IOS.md §15). */
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#board { position: absolute; inset: 0; min-height: 0; }
/* THE BOARD'S PANELS ARE PAPER: board.css reads the house names, so the paper
   tokens are put under them here (the view above scoped the night's ink). */
#board {
  --bg: var(--night-2); --panel: var(--paper-1); --ink: var(--paper-ink); --ink-2: var(--paper-ink-2);
  --dim: var(--paper-dim); --line: var(--paper-line); --pill: var(--paper-pill); --link: var(--paper-link);
  --font-num: var(--font-game);
}
.game-note {
  position: absolute; left: 12px; right: 124px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 5;
  margin: 0; padding: 0 4px; pointer-events: none;
  color: var(--night-ink); font-size: 13px; line-height: 1.4; min-height: 2.8em; display: grid; align-content: end;
  text-shadow: 0 1px 2px rgba(0,0,0,.9), 0 0 6px rgba(0,0,0,.7);
  opacity: 0; transition: opacity .2s;
}
.game-note.show { opacity: 1; }
.game-note.warn { color: var(--gold-lit); }
/* crest-v15: the board's windows hold the bottom corners (the terrain window, End turn), so the note stands over them —
   and since crest-v21 stops short of the right edge, where Danger stands over End turn */
.game-note { right: 124px; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }

/* SIDEWAYS (crest-v15, prompt 806 — the owner's pick: "turn the phone: the screen is the old handheld's shape and
   shows the most map"). On a short landscape screen the board is the whole screen and the header floats over its top
   right corner as one of the board's windows, its buttons in the same order (CLAUDE.md 5e: ≡ last, the speaker
   second last). Upright, the header stays above the board. */
@media (orientation: landscape) and (max-height: 500px) {
  #view-game { padding-top: 0; position: relative; }
  #view-game .game-head {
    position: absolute; z-index: 6; top: calc(8px + env(safe-area-inset-top, 0px)); right: calc(8px + env(safe-area-inset-right, 0px));
    width: auto; max-width: 52%; margin: 0; gap: 4px; padding: 3px 4px;
    background: linear-gradient(#4870e8, #2440a8); border: 2px solid #f4f6ff; border-radius: 8px;
    box-shadow: 0 0 0 2px #101840, inset 0 0 0 1px #8aa4ff, 0 4px 0 rgba(0, 0, 0, .25);
  }
  #view-game .game-head .readout { padding: 0 4px; text-shadow: 1px 1px 0 #101840; }
  #view-game .game-head .readout-turn { font-size: 15px; color: #fff; }
  #view-game .game-head .readout-turn.enemy { color: #ffb4a4; }
  #view-game .game-head .readout-turn.ally { color: #b4f4c0; }
  #view-game .game-head .readout-goal { color: #c4d0ff; font-size: 11px; }
  #view-game .game-head .icon { background: none; border-color: transparent; color: #fff; width: 40px; height: 40px; }
  #board { --bd-flip-top: 66px; }
  .game-note { left: 130px; right: 130px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}

/* ── the end of a game ─────────────────────────────────────────────────── */

.overlay {
  position: absolute; inset: 0; z-index: 1000; display: grid; place-items: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(4, 7, 15, .62);
}
.overlay-card { width: min(340px, 92%); padding: 24px 20px; text-align: center; border-radius: var(--r-card); max-height: 92%; overflow: auto; }
.overlay-mark { line-height: 0; display: flex; justify-content: center; min-height: 40px; }
.overlay-mark canvas { width: 72px; height: 72px; image-rendering: pixelated; }
.overlay-card h2 { margin: 14px 0 4px; font-size: 28px; letter-spacing: 0; font-family: var(--font-game); font-weight: 700; }
.overlay-card h2.won { color: var(--good); }
.overlay-card h2.lost { color: var(--bad); }
.overlay-card h2 .camp-stars { font-family: var(--font); font-size: 18px; vertical-align: 2px; margin-left: 6px; }
.overlay-line { margin: 0; color: var(--dim); font-size: 14px; line-height: 1.5; }
.overlay-stats { display: flex; justify-content: center; gap: 20px; margin: 18px 0 0; padding: 14px 0 0; border-top: .5px solid var(--line-2); }
.overlay-stats div { display: flex; flex-direction: column; gap: 2px; }
.overlay-stats dt { font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .4px; order: 2; }
.overlay-stats dd { margin: 0; font-family: var(--font-game); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; order: 1; }
.overlay-submit { margin: 14px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--dim); min-height: 17px; }
.overlay-submit.bad { color: var(--warn); }
.overlay-submit.good { color: var(--good); }
.overlay-btns { display: flex; gap: 10px; margin-top: 18px; }
.overlay-btns .btn { flex: 1; padding-left: 10px; padding-right: 10px; white-space: nowrap; }

/* ── segmented control ─────────────────────────────────────────────────── */

.segmented { display: flex; gap: 3px; padding: 3px; background: var(--glass-2); border-radius: var(--r-sm); border: .5px solid var(--line-2); }
.segmented button {
  flex: 1; font: inherit; font-size: 14px; font-weight: 600; padding: 8px 6px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); cursor: pointer;
}
.segmented button[aria-selected="true"], .segmented button.is-on { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); }
.segmented.seg-sm { flex: none; }
.segmented.seg-sm button { flex: none; font-size: 13px; padding: 6px 10px; }

/* ── the leaderboards ──────────────────────────────────────────────────── */

.board-list { margin-top: 10px; padding: 0; overflow: hidden; border-radius: var(--r-card); }
.board-sub { margin: 18px 4px 0; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.board-sub + .board-list { margin-top: 8px; }
.board-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: .5px solid var(--line-2); }
.board-row:last-child { border-bottom: 0; }
.board-row.you { background: var(--accent-soft); }
.board-rank { width: 26px; flex: none; text-align: right; font-family: var(--font-num); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--dim); }
.board-row.you .board-rank { color: var(--accent-lit); }
.board-who { flex: 1; min-width: 0; }
.board-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-row.you .board-name { font-weight: 700; }
.board-meta { font-size: 11.5px; color: var(--dim); margin-top: 1px; }
.board-time { font-family: var(--font-game); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.board-time .star { color: var(--gold); font-family: var(--font); font-size: 14px; margin-left: 2px; }
.board-empty { padding: 26px 20px; text-align: center; color: var(--dim); font-size: 14px; line-height: 1.5; }

/* ── settings rows ─────────────────────────────────────────────────────── */

.rows > .row, .rows > div > .row { padding: 13px 0; border-bottom: .5px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.rows > .row:last-child, .rows > div > .row:last-child { border-bottom: 0; }
.rows > .row.row-stack { flex-direction: column; align-items: stretch; gap: 8px; }
.row-head { display: flex; align-items: center; justify-content: space-between; }
.row-k { font-size: 15px; font-weight: 500; }
.row-v { font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; }
.row-note { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--dim); }
.rows > button.row-tap {
  appearance: none; -webkit-appearance: none; width: 100%; background: none; border: 0;
  border-bottom: 1px solid var(--line-2); font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.rows > button.row-tap:active { background: var(--pill); }
.row-tap .chev { color: var(--dim); font-size: 22px; line-height: 1; margin-top: -2px; }

.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--pill); transition: background .2s ease; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s ease; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .4; }

.prose p { margin: 0 0 12px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.prose p:last-child { margin-bottom: 0; }
.prose-meta { font-size: 12px !important; color: var(--dim) !important; font-family: var(--font-mono); }
.update-note { color: var(--warn) !important; }

/* ── the menu sheet ────────────────────────────────────────────────────── */

/* IN FLOW, NOT FIXED (IOS.md §15): the page is the menu's scroller. */
.sheet { position: relative; z-index: 1100; }
.sheet-body {
  padding: calc(8px + var(--glass-t) + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) calc(32px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
  max-width: 560px; width: 100%; margin: 0 auto;
}
.sheet-body > .view-head { padding-bottom: 4px; }
h2.sec { margin: 26px 4px 10px; font-size: 24px; font-weight: 700; letter-spacing: 0; font-family: var(--font-game); }
.sheet-body section:first-of-type h2.sec { margin-top: 14px; }
#sec-game .card { margin-top: 14px; }

/* ── the foot of settings (CLAUDE.md 5) ───────────────────────────────── */

#tipjar-card { margin-top: 14px; }
#tipjar .tip-glyph { color: var(--heart); font-size: 18px; line-height: 1; margin-right: 2px; }
#tipjar .row-k { flex: 1; }
:root { --games-gold: #c48a12; }
#games-card { margin-top: 14px; }
#games-row { padding: 12px 0; }
.games-lockup { display: inline-flex; flex: none; flex-direction: column; align-items: flex-end; line-height: 1; font-family: "SF Pro Rounded", ui-rounded, var(--font); font-weight: 700; }
.games-lockup .gl-mark { font-size: 22px; letter-spacing: -0.01em; color: var(--ink); }
.games-lockup .gl-ca { color: var(--dim); }
.games-lockup .gl-sub { font-size: 10px; letter-spacing: .02em; color: var(--games-gold); margin-top: -1px; margin-right: 1px; }
#games-row .games-more { flex: 1; text-align: right; color: var(--dim); font-weight: 400; }
#account-card { padding: 16px 16px 0; }
#account-card #account-who { margin: 0 0 12px; }
#account-card .rows { margin: 0 -16px; }
#account-card .rows > button.row-tap { padding: 13px 16px; border-bottom: 0; border-top: .5px solid var(--line-2); }
.rows > button.row-tap.danger { color: var(--bad); }
details.technical { padding: 0; overflow: hidden; }
details.technical > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 16px; }
details.technical > summary::-webkit-details-marker { display: none; }
details.technical > summary .chev { color: var(--dim); font-size: 22px; line-height: 1; margin-top: -2px; transition: transform .15s; }
details.technical[open] > summary .chev { transform: rotate(90deg); }
details.technical > summary:active { background: var(--pill); }
details.technical .kv { margin: 0; padding: 4px 16px 12px; border-top: .5px solid var(--line-2); }
details.technical .kv > div { display: flex; gap: 12px; padding: 8px 0; border-bottom: .5px solid var(--line-2); }
details.technical .kv > div:last-child { border-bottom: 0; }
details.technical .kv dt { flex: 0 0 76px; font-size: 13px; color: var(--dim); }
details.technical .kv dd { margin: 0; flex: 1; min-width: 0; font-size: 12px; font-family: var(--font-mono); color: var(--ink-2); line-height: 1.5; overflow-wrap: anywhere; }
details.technical > .row-note { padding: 0 16px 14px; }
#credits .row-note { padding: 0 16px 12px; }
#credits .row-note:first-of-type { padding-top: 12px; border-top: .5px solid var(--line-2); }
#credits a { color: var(--link); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 1300;
  max-width: min(92vw, 420px); padding: 10px 14px; border-radius: 14px;
  background: rgba(246, 247, 251, .96); color: #10131f; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  font-size: 14px; line-height: 1.4; text-align: center;
}

.banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-mid);
  font-size: 13.5px; line-height: 1.45; z-index: 1200;
  background: rgba(246, 247, 251, .97); color: #10131f; box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.banner .banner-retry { margin-left: auto; padding: 6px 13px; font: inherit; font-size: 12.5px; font-weight: 600; line-height: 1.2; border: 0; border-radius: 999px; background: #d9a520; color: #1a1200; cursor: pointer; }
.banner .banner-retry:disabled { opacity: .45; }
.banner .banner-retry + button { margin-left: 4px; }
.banner button { margin-left: auto; flex: none; font: inherit; font-size: 20px; line-height: 1; border: 0; background: transparent; color: inherit; cursor: pointer; }

/* The supporter's mark, for the day the `crest` product is sold (none yet). */
.mark { display: inline-block; margin-left: 5px; vertical-align: -1px; cursor: pointer; line-height: 0; }
.mark svg { width: .8em; height: .8em; display: inline-block; }
