/* Smart Pacts — the ONE shared component stylesheet (A7 design system).
 * Replaces the three parallel systems (index inline / event inline /
 * gallery.css). Every component is defined here exactly once and consumes
 * only tokens.css semantic tokens. Page-level <style> is reserved for true
 * one-offs (see docs/DESIGN.md).
 *
 * CONTROLLER CONTRACT: class names used by the TS controllers (.locked,
 * .entry.ok/.err, .mono, .muted, .num) and
 * every element id / data-act are load-bearing — renaming them silently
 * kills features. scripts/dom-contract.mjs enforces this at build time. */

/* ── base ── */
body {
  margin: 0;
  background: var(--bg-page);
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: var(--leading-body);
  -webkit-text-size-adjust: 100%;
}
::selection { background: var(--color-accent-soft); }
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
a { color: var(--color-accent); }
a:hover { color: var(--color-accent-hover); }

/* 🔴 THE hidden ATTRIBUTE MUST WIN. The browser hides [hidden] with a plain `display: none`, and
   every component below that sets `display` (.btn, .row, .kv, …) outranks it, so the controllers'
   `el.hidden = true` silently did nothing on those elements. MEASURED 2026-09-16 on the production
   build: 5 elements rendered while hidden — the /portal/ and /sandbox/portal/ "Resume paused move"
   button (live on smartpacts.io with no paused move), the /gallery/create/ preview row, the
   /gallery/studio/ move-in-flight row, the /gallery/token/ Buy button — and #wallet-choices (.row)
   stayed on screen after a wallet connected on /sell/ and /portal/. */
[hidden] { display: none !important; }

h1, h2, h3, h4 { line-height: var(--leading-heading); }
h1 { font-size: var(--text-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-wide); margin: var(--space-4) 0 var(--space-2); }
h2 { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin: var(--space-5) 0 var(--space-3); }
h3 { font-size: var(--text-base); font-weight: var(--weight-semibold); margin: var(--space-4) 0 var(--space-2); }
h4 { font-size: var(--text-base); font-weight: var(--weight-medium); margin: var(--space-4) 0 var(--space-1); }

/* ── utilities ── */
.muted { color: var(--color-text-secondary); }
.small { font-size: var(--text-sm); }
.mono { font-family: var(--font-mono); }
.breakable, .tx-id { overflow-wrap: anywhere; }   /* a 43-character request key sets a floor no phone meets */
.lede { color: var(--color-text-secondary); margin: 0 0 var(--space-5); font-size: var(--text-lg); }
.section-lede { color: var(--color-text-secondary); margin: 0 0 var(--space-5); }
.eyebrow {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 var(--space-2);
}

/* ── layout containers ── */
.wrap { max-width: var(--container-md); margin: 0 auto; padding: 0 var(--gutter); }
.wrap.sm { max-width: var(--container-sm); }
.wrap.lg { max-width: var(--container-lg); }

/* ── top chrome: banner + header as ONE sticky unit ──
   Two separate sticky elements at top:0 overlap while scrolling (the nav
   slides under the banner and becomes unreachable) — the wrapper keeps the
   compliance banner permanent AND the nav always visible. */
html { scroll-padding-top: 7.5rem; }           /* anchors land below the chrome */
.top-chrome {
  position: sticky;
  top: 0;
  z-index: var(--z-banner);
}

/* ── banner (valueless / testnet) ── */
.banner {
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-2) var(--space-4);
}
.banner strong { font-weight: var(--weight-semibold); }

/* ── global header / nav ── */
.site-header {
  position: relative;                          /* anchors the mobile menu */
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: var(--border-w) solid var(--color-border);
}
.site-header .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;   /* auto margins below decide who sits right */
  gap: var(--space-4);
  max-width: var(--container-lg);
  margin: 0 auto;
  padding: var(--space-3) var(--gutter);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark svg { width: 1.25rem; height: 1.25rem; display: block; }
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  font-size: var(--text-sm);
  margin-left: auto;                /* nav + theme toggle sit right; wordmark left */
}
.site-nav a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: var(--weight-medium);
  padding: var(--space-1) 0;
  border-bottom: 2px solid transparent;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.site-nav a:hover { color: var(--color-accent); }
.site-nav a[aria-current="page"], .site-nav a.active {
  color: var(--color-text);
  border-bottom-color: var(--color-accent);
}
.menu-toggle {
  display: none;
  font: inherit;
  background: none;
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  padding: var(--space-1) var(--space-3);
  cursor: pointer;
}
/* ── wallet button + dialog (SiteShell, SPT chrome) ──
   One control for every page: the header button opens the dialog; src/wallet-ui.ts drives it and
   src/lib/ui.ts's connect flow fills #wallet-info. The connected state shows the account. */
.wallet-btn { white-space: nowrap; flex-shrink: 0; padding-block: 0; }
/* 🔴 The tally component further down is also called `.bar` and gives it a fixed height with
   clipped overflow. That rule reached the header bar too: it was held to a sliver, anything taller
   was cut, and on a phone the theme toggle was pushed past the edge and clipped out of reach.
   The bar sizes to the wallet button on both sites; on a game table it keeps the smallest padding
   that holds the button, because that page is one screen and the header is taken out of the table. */
.site-header .bar { height: auto; overflow: visible; padding-block: var(--space-2); }
body[data-layout="game"] .site-header .bar { padding-block: var(--space-1); }
.wallet-btn.connected { background: var(--color-surface-raised); color: var(--color-text); border-color: var(--color-border-strong); font-family: var(--font-mono); }
.wallet-dialog {
  width: min(28rem, calc(100vw - var(--space-8)));
  padding: var(--space-5);
  border: var(--border-w) solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}
.wallet-dialog::backdrop { background: color-mix(in srgb, var(--sp-black) 65%, transparent); }
.wallet-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.wallet-dialog-head h2 { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.wallet-choices { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-3) 0; }
.wallet-choices .btn { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); text-align: left; }
.wallet-choices .btn .muted { font-weight: var(--weight-regular); }

/* ── light/dark toggle (SiteShell) ──
   Hidden until /theme.js has stamped data-theme on <html>: no JS, no button, and the page is
   dark. Two icons, one shown per scheme: the sun offers light while dark, the moon offers dark
   while light. aria-pressed (synced by theme.js) carries the state for assistive tech. */
.theme-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  flex-shrink: 0;
  font: inherit;
  background: none;
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
:root[data-theme] .theme-toggle { display: inline-flex; }
.theme-toggle:hover { color: var(--color-accent); border-color: var(--color-accent); }
.theme-toggle svg { width: 1rem; height: 1rem; display: block; }
.theme-toggle .to-dark { display: none; }
:root[data-theme="light"] .theme-toggle .to-light { display: none; }
:root[data-theme="light"] .theme-toggle .to-dark { display: block; }
/* On a phone the mark stands for the name (the link keeps its accessible name), so the
   wallet button, the menu and the theme toggle all fit, down to a 320px screen. */
@media (max-width: 26rem) { .wordmark-name { display: none; } }
@media (max-width: 48rem) {
  .site-header .bar { gap: var(--space-2); }
  .menu-toggle { display: inline-block; margin-left: auto; flex-shrink: 0; }   /* the nav leaves the flow below */
  .wallet-btn { font-size: var(--text-sm); padding-inline: var(--space-2); }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: var(--z-menu);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--color-surface);
    border-bottom: var(--border-w) solid var(--color-border);
    box-shadow: var(--shadow-md);
    padding: var(--space-2) var(--gutter) var(--space-3);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: var(--space-3) 0; border-bottom: var(--border-w) solid var(--color-border); }
  .site-nav a:last-child { border-bottom: none; }
  .site-nav a[aria-current="page"], .site-nav a.active { border-bottom-color: var(--color-border); color: var(--color-accent); }
}

/* ── buttons ── */
.btn {
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: var(--border-w) solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.btn:hover { border-color: var(--color-accent); color: var(--color-text); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.primary {
  background: linear-gradient(120deg, var(--color-accent), var(--color-accent-hover));
  color: var(--color-on-accent);
  border-color: transparent;
  box-shadow: 0 0 22px var(--color-accent-soft);
}
.btn.primary:hover { box-shadow: 0 0 30px var(--color-accent-soft), var(--shadow-sm); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--color-text-secondary); }
.btn.ghost:hover { color: var(--color-accent); transform: none; box-shadow: none; }
.btn.small { padding: var(--space-1) var(--space-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
/* Reach: a control that acts is tall enough to hit without aiming; the small utility ones
   (Refresh, Copy id) keep a lower floor. :where() keeps these at the weight of a plain `.btn`, so
   a component's own layout still wins.
   NOT inside a game table: that page is one screen, measured control by control
   (scripts/test-roulette-page.mjs, test-baccarat-page.mjs), so the table sizes only the controls
   that connect or sign — below. */
:where(body:not([data-layout="game"])) .btn { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--tap-min); }
:where(body:not([data-layout="game"])) .btn.small { min-height: var(--tap-min-small); }
.wallet-btn, #wc-pair .btn.primary, body[data-layout="game"] #place, body[data-layout="game"] #acct-empty .btn, body[data-layout="game"] .actions .rail-toggle { box-sizing: border-box; min-height: var(--tap-min); }
body[data-layout="game"] .wallet-btn, body[data-layout="game"] #wc-pair .btn.primary, body[data-layout="game"] #place, body[data-layout="game"] #acct-empty .btn { display: inline-flex; align-items: center; justify-content: center; }
.cta-row { display: flex; gap: var(--space-3); flex-wrap: wrap; margin: var(--space-4) 0 0; }

/* ── forms ── */
input, select, textarea {
  font: inherit;
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-md);
  border: var(--border-w) solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  max-width: 100%;
}
/* 🔴 THE FOCUS RING MUST SURVIVE. `input:focus` (0-1-1) outranks the global `:focus-visible`
   rule near the top of this file (0-1-0), so the blanket `outline: none` that used to live on
   this line deleted the 2px focus indicator from EVERY input, select and textarea on the site —
   including #g-pick, the first control on the games page. On a native checkbox (#browse-free)
   the accent `border-color` that replaced it renders nothing at all, so a keyboard user got no
   indicator whatsoever. The accent border is kept for every focus; the outline is now suppressed
   ONLY when the browser says this focus is not keyboard-ish, which is exactly what the design
   wanted. `:focus:not(:focus-visible)` is 0-2-1, so it beats the plain `:focus` rule whatever the
   source order — and when `:focus-visible` DOES match, nothing here overrides the global rule and
   the ring is drawn. (Text fields match `:focus-visible` on a mouse click too, by spec: typing
   follows a click, so the browser keeps the indicator. Selects and checkboxes do not.) */
/* The opened list of a <select> is drawn by the browser, not by the page: without these it takes
   the system's own colours — white on white in the dark scheme (founder, 2026-10-02). Both the
   options and the select itself state their colours from the tokens, in either scheme.
   Deliberately NOT done with the `color-scheme` property: that also repaints every native
   checkbox on the live pages (the 18+ ticks), which is a visible change nobody asked for. */
select { background-color: var(--color-surface); color: var(--color-text); }
select option, select optgroup { background-color: var(--color-surface); color: var(--color-text); }
input:focus, select:focus, textarea:focus { border-color: var(--color-accent); }
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) { outline: none; }
input.wide { width: min(34rem, 100%); font-family: var(--font-mono); font-size: var(--text-sm); }
.row, .buyrow, .voterow { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin: var(--space-3) 0; }
/* WRAP, or a form row cannot fit a phone. These labels are flex rows holding
   their own text AND their control (`<label>Network <select>…</select></label>`),
   so without wrapping the label is as wide as both together — a long option such
   as "testnet06 — test tokens, full functionality" made /portal 542px and
   /gallery/create 486px wide, overflowing at EVERY phone width including 414px.
   Verify with: MOBILE_CHECK_ROUTES=… node ../pco-website/scripts/mobile-check.mjs */
.row label, .buyrow label { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; min-width: 0; }

/* `min-width: 0` above is load-bearing, not decoration. A flex item defaults to
   `min-width: auto`, which REFUSES to shrink below its content's intrinsic
   width — so wrapping alone did not help: the select's own min-content width
   (set by its longest option) still forced the row open. Both are needed.
   Form controls need the same treatment for the same reason. */
input, select, textarea, button { max-width: 100%; min-width: 0; }
details summary { cursor: pointer; color: var(--color-text-secondary); font-size: var(--text-sm); }

/* ── form kit ── THE ONE DEFINITION of a form control on this site (docs/DESIGN.md "Forms").
   Every field is: a label above, ONE box of the same height (--tap-min) for whatever it holds —
   a text input, a select, a read-only value — with its unit inside the box at the right, and,
   for a number, a compact − / + pair inside the same box. A page never styles its own inputs.
   Sizes follow the public standards: 44 px control height (WCAG 2.5.5 / Apple HIG), stepper
   buttons 32 px wide (above the 24 px minimum of WCAG 2.5.8), label above the field (GOV.UK). */
.field[hidden], .control[hidden], .chips[hidden], .segmented[hidden] { display: none; }
.field { display: flex; flex-direction: column; gap: var(--space-1); margin: 0 0 var(--space-3); min-width: 0; }
.field > label, .field > .field-label { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text); }
.field > .field-hint { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; font-size: var(--text-sm); color: var(--color-text-secondary); min-height: var(--tap-min-small); }
.control {
  display: flex; align-items: stretch; box-sizing: border-box; width: 100%; min-width: 0; min-height: var(--tap-min);
  border: var(--border-w) solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); overflow: hidden;
}
.control:focus-within { border-color: var(--color-accent); outline: var(--border-w-accent) solid var(--color-focus); outline-offset: var(--border-w); }
.control > input, .control > select {
  flex: 1 1 auto; box-sizing: border-box; width: 100%; min-width: 0; border: 0; border-radius: 0; background-color: transparent;
  padding: 0 var(--space-3); font-family: var(--font-mono); outline: none;
}
.control > select { background-color: var(--color-surface); }   /* a select keeps a solid colour: its open list inherits it */
.control > .unit { display: flex; align-items: center; flex: 0 0 auto; padding: 0 var(--space-2); color: var(--color-text-secondary); font-size: var(--text-sm); white-space: nowrap; }
.control > .unit:empty { display: none; }
.control.readonly { background: var(--color-surface-raised); }
.control > .spin { display: flex; flex: 0 0 auto; border-left: var(--border-w) solid var(--color-border); }
.control > .spin > button {
  box-sizing: border-box; width: var(--tap-min-small); min-height: 100%; padding: 0; border: 0; border-radius: 0; cursor: pointer;
  background: transparent; color: var(--color-text); font: inherit; font-size: var(--text-base); line-height: 1;
}
.control > .spin > button + button { border-left: var(--border-w) solid var(--color-border); }
.control > .spin > button:hover { background: var(--color-surface-raised); color: var(--color-accent); }
.control > .spin > button:focus-visible { outline: var(--border-w-accent) solid var(--color-focus); outline-offset: calc(-1 * var(--border-w-accent)); }
/* one choice out of two or three, as a single box of the same height */
.segmented { display: flex; box-sizing: border-box; min-height: var(--tap-min); border: var(--border-w) solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; margin: 0 0 var(--space-3); }
.segmented > input { position: absolute; opacity: 0; pointer-events: none; }
.segmented > label { flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: var(--space-2); padding: 0 var(--space-3); cursor: pointer; font-weight: var(--weight-semibold); color: var(--color-text-secondary); }
.segmented > label + input + label { border-left: var(--border-w) solid var(--color-border); }
.segmented > input:checked + label { background: var(--color-surface-raised); color: var(--color-text); box-shadow: inset 0 calc(-1 * var(--border-w-accent)) 0 currentColor; }
.segmented > input:focus-visible + label { outline: var(--border-w-accent) solid var(--color-focus); outline-offset: calc(-1 * var(--border-w-accent)); }
/* quick choices under a field: equal small buttons in one row */
.chips { display: flex; gap: var(--space-2); margin: 0 0 var(--space-3); }
.chips > .btn { flex: 1 1 0; padding-left: 0; padding-right: 0; }

/* ── cards ── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: var(--space-4);
}
.card {
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-4);
  background: var(--color-surface);
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md), var(--shadow-glow); border-color: var(--color-border-strong); }
.card h3 { font-size: var(--text-base); font-weight: var(--weight-semibold); margin: 0 0 var(--space-2); }
.card p { margin: 0; font-size: var(--text-sm); color: var(--color-text-secondary); }
.cards.accent .card h3 { color: var(--color-accent); }

/* ── panels & steps (interactive sections; .locked is toggled by controllers) ──
   Blueprint detail: violet corner ticks (top-left / bottom-right pseudo-elements). */
.panel, .step {
  position: relative;
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5) var(--space-5);
  margin: var(--space-5) 0;
  background: var(--color-surface);
  transition: opacity var(--dur-base) var(--ease-out);
}
.panel::before, .step::before,
.panel::after, .step::after {
  content: '';
  position: absolute;
  width: 0.7rem;
  height: 0.7rem;
  pointer-events: none;
}
.panel::before, .step::before {
  top: -1px; left: -1px;
  border-top: 1px solid var(--tick-ink);
  border-left: 1px solid var(--tick-ink);
  border-top-left-radius: var(--radius-lg);
}
.panel::after, .step::after {
  bottom: -1px; right: -1px;
  border-bottom: 1px solid var(--tick-ink);
  border-right: 1px solid var(--tick-ink);
  border-bottom-right-radius: var(--radius-lg);
}
.panel.locked, .step.locked { opacity: 0.55; }
.step.locked .lock-note { color: var(--color-text); }
.panel.locked [data-act], .panel.locked input, .panel.locked select { pointer-events: none; }
.step.locked [data-act]:not([data-act="refresh-proposal"]),
.step.locked input { pointer-events: none; }
/* WalletConnect pairing panel (portal): the QR needs a light quiet zone on the dark brand,
   and must never be wider than the phone it is viewed on (rule 15b). */
#wc-pair canvas { display: block; max-width: 100%; height: auto; background: #fff; padding: var(--space-2); border-radius: var(--radius-sm); margin: var(--space-3) 0; }
#wc-pair .row { flex-wrap: wrap; }
#wc-pair ol { margin: var(--space-3) 0; padding-left: var(--space-5); }
#wc-pair li { margin: var(--space-2) 0; }
#wc-pair li .btn { margin-top: var(--space-2); }
#wc-uri { width: 100%; margin-top: var(--space-2); }

.step h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin: 0 0 var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.step h2 .n {
  display: inline-grid;
  place-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  flex-shrink: 0;
}

/* ── kv rows ── */
.kv {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin: var(--space-3) 0;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-raised);
  border-radius: var(--radius-md);
}
.kv > span:first-child, .kv > .k {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  min-width: 11rem;
}

/* ── operational notices (maintenance/status — NOT legal blocks; never use
      .disclaimer for these: the disclaimer gate requires those to be verbatim
      legal text) ── */
.notice {
  border: var(--border-w) solid color-mix(in srgb, var(--color-accent) 45%, var(--color-border));
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-5) 0;
  font-size: var(--text-sm);
}
.notice p { margin: var(--space-1) 0; }
.notice .lead { font-weight: var(--weight-semibold); color: var(--color-text); }
.notice .lead.err { color: var(--color-error); }
/* A bare `.err` had NO rule: the strongest sentence the site can print — a recomputation
   disagreeing with what a round stored — rendered as ordinary body text. The only rules were
   scoped to .notice and #log, so anything else claiming to be an error simply was not one. */
.err { color: var(--color-error); font-weight: 600; }

/* ── disclaimers (legal blocks — text is verbatim from the disclaimer set) ── */
.disclaimer {
  border: var(--border-w) solid var(--color-border);
  border-left: var(--border-w-accent) solid var(--color-accent);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-5) 0;
  font-size: var(--text-sm);
}
.disclaimer.inline { margin: var(--space-4) 0; }
.disclaimer p { margin: var(--space-1) 0; }
.disclaimer .tag {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  letter-spacing: var(--tracking-caps);
}

/* ── badges ── */
.badge {
  display: inline-block;
  font-size: var(--text-sm);
  padding: 0.1rem var(--space-2);
  border-radius: var(--radius-pill);
  border: var(--border-w) solid var(--color-border);
  color: var(--color-text-secondary);
}
.badge.on { border-color: var(--color-accent); color: var(--color-accent); }
/* status variants, copied from GitHub Primer's Label (variant="danger" / "attention"): an outlined pill whose
   border and text take the status colour. Text is never the only signal: the label says the status in words. */
.badge.danger { border-color: var(--color-error); color: var(--color-error); font-weight: var(--weight-semibold); }
.badge.attention { border-color: var(--color-attention); color: var(--color-attention); }
.live-badge {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-on-accent);
  background: var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 0.1rem var(--space-2);
  margin-right: var(--space-2);
  vertical-align: 0.1rem;
}
.dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-accent);
  margin-right: 0.35rem;
  vertical-align: 0.05rem;
}
@media (prefers-reduced-motion: no-preference) {
  .dot.pulse { animation: sp-pulse 2.4s var(--ease-in-out) infinite; }
  @keyframes sp-pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--color-accent-soft); }
    50% { box-shadow: 0 0 0 5px var(--color-accent-soft); }
  }
}

/* ── tables ── */
.tablewrap { overflow-x: auto; margin: var(--space-2) 0; }
table.plain, .bychain table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); }
table.plain th, table.plain td,
.bychain th, .bychain td {
  padding: var(--space-1) var(--space-2);
  border-bottom: var(--border-w) solid var(--color-border);
  text-align: left;
}
table.plain td.num, table.plain th.num,
.bychain th.num, .bychain td.num { text-align: right; font-family: var(--font-mono); }
.bychain tfoot td {
  border-bottom: none;
  border-top: 2px solid var(--color-border);
  font-weight: var(--weight-semibold);
}

/* ── tally bar (event vote) ── */
.tally { margin: var(--space-4) 0; }
.bar { display: flex; height: 0.75rem; border-radius: var(--radius-sm); overflow: hidden; background: var(--color-border); }
.bar .yes { background: var(--color-accent); transition: width var(--dur-slow) var(--ease-out); }
.bar .no { background: var(--sp-slate); transition: width var(--dur-slow) var(--ease-out); }
.tally-nums { display: flex; gap: var(--space-5); margin: var(--space-2) 0; font-size: var(--text-sm); flex-wrap: wrap; }

/* ── DOCKED activity log ──
   🔴 WHY THIS IS PINNED TO THE VIEWPORT. The log used to sit at the very bottom of a
   long page, so a refusal — "your balance covers at most 0" — was written where nobody
   was looking, and the action read as the button doing nothing. Feedback you have to
   go and find is not feedback. It now follows the reader.
   Controllers PREPEND entries, so the newest is at the top and no autoscroll is needed. */
.log-dock {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: var(--z-dock);
  width: min(24rem, calc(100vw - var(--space-8)));
  /* Load-bearing on phones: a flex item defaults to min-width:auto and refuses to
     shrink below its content, so a long <select> option sets the page's floor and the
     layout overflows every phone width. flex-wrap alone does not fix it. */
  min-width: 0;
}
.log-dock .log-panel {
  background: var(--color-surface-raised);
  border: var(--border-w) solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.log-dock summary {
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  user-select: none;
}
.log-dock summary:focus-visible { outline: var(--border-w-accent) solid var(--color-focus); }
.log-dock #log { margin: 0; max-height: 40vh; overflow-y: auto; padding: 0 var(--space-3) var(--space-3); }
.log-dock .log-hint { margin: 0 var(--space-3) var(--space-3); }
/* hide the placeholder as soon as there is anything real to read */
.log-dock .log-panel:has(#log .entry) .log-hint { display: none; }
/* keep the dock from sitting permanently on top of the footer */
body:has(.log-dock) { padding-bottom: var(--space-10); }

@media (max-width: 40rem) {
  .log-dock { left: var(--space-3); right: var(--space-3); bottom: var(--space-3); width: auto; }
  .log-dock #log { max-height: 30vh; }
}
@media (prefers-reduced-motion: no-preference) {
  .log-dock .log-panel { transition: box-shadow var(--dur-fast) ease; }
}

/* ── activity log (controllers prepend .entry nodes) ── */
#log { margin: var(--space-5) 0 0; font-family: var(--font-mono); font-size: var(--text-sm); }
#log .entry {
  padding: var(--space-2) var(--space-3);
  margin: var(--space-2) 0;
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  overflow-wrap: anywhere;
}
#log .entry.ok { border-left: var(--border-w-accent) solid var(--color-accent); }
#log .entry.err { border-left: var(--border-w-accent) solid var(--color-error); }
#log .entry a { color: var(--color-accent); }

/* ── code / teasers ── */
pre.teaser, .teaser {
  margin: var(--space-5) 0;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-raised);
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.teaser code { font-family: var(--font-mono); font-size: var(--text-sm); }

/* ── toc (guide pages) ── */
.toc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2) var(--space-3);
  margin: var(--space-5) 0;
}
/* each link a full target: at phone width the list wraps and bare 17 px text links crowd each other
   (WCAG 2.5.8 asks 24 × 24 px or the spacing of it — measured by test-ux on /trade/guide/) */
.toc a { display: inline-block; min-height: var(--tap-min-small); line-height: var(--tap-min-small); padding: 0 var(--space-1); }

/* ── markdown bodies (guide pages) ── */
.mdbody h1 { font-size: var(--text-2xl); }
.mdbody h2 { font-size: var(--text-lg); margin: var(--space-5) 0 var(--space-2); }
.mdbody h3 { font-size: var(--text-base); }
.mdbody code { font-family: var(--font-mono); font-size: 0.92em; background: var(--color-surface-raised); padding: 0.08em 0.35em; border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.mdbody pre { background: var(--color-surface-raised); border: var(--border-w) solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); overflow-x: auto; }
.mdbody pre code { background: none; padding: 0; }
.mdbody table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); margin: var(--space-3) 0; display: block; overflow-x: auto; }
.mdbody th, .mdbody td { padding: var(--space-1) var(--space-2); border: var(--border-w) solid var(--color-border); text-align: left; }
.mdbody blockquote { border-left: var(--border-w-accent) solid var(--color-accent); margin: var(--space-4) 0; padding: var(--space-1) var(--space-4); background: var(--color-surface-raised); border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.mdbody blockquote p { margin: var(--space-1) 0; }
.mdbody li { margin: var(--space-1) 0; }
.mdbody img { width: 100%; height: auto; display: block; margin: var(--space-3) auto; border: var(--border-w) solid var(--color-border); border-radius: var(--radius-lg); }
.mdbody img.tall { width: min(100%, 340px); }
.mdbody img.photo { width: min(100%, 460px); }

/* ── token detail art ── */
.detail-art {
  max-width: 26rem;
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface-raised);
}
.detail-art img { width: 100%; display: block; }

/* ── experiments (event page) ── */
.exp { border-top: var(--border-w) solid var(--color-border); padding-top: var(--space-3); margin-top: var(--space-4); }
.exp h3 { margin: 0 0 var(--space-1); }
.exp ol { margin: var(--space-1) 0 var(--space-2) 1.2rem; padding: 0; }
.exp li { margin: var(--space-1) 0; }

/* ── strand divider (the braid at rest) ── */
.strand-rule {
  height: 14px;
  background: var(--strand-rule) repeat-x center / 220px 14px;
  margin: var(--space-8) 0 var(--space-5);
}

/* ── stat strip (count-up numbers; site-ui.ts animates [data-count]) ── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: var(--space-4);
  margin: var(--space-6) 0;
  border-top: var(--border-w) solid var(--color-border);
  border-bottom: var(--border-w) solid var(--color-border);
  padding: var(--space-5) 0;
}
.stat { text-align: center; padding: var(--space-4) var(--space-2); }
.stat .num {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-medium);
  color: var(--color-accent);
  display: block;
  font-variant-numeric: tabular-nums;
}
.stat .label { font-size: var(--text-sm); color: var(--color-text-secondary); }

/* ── scroll reveal (site-ui.ts adds .pre off-screen, .in on entry) ── */
@media (prefers-reduced-motion: no-preference) {
  [data-reveal].pre { opacity: 0; transform: translateY(14px); }
  [data-reveal].in {
    opacity: 1;
    transform: none;
    transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  }
}

/* ── global footer ── */
.site-footer {
  border-top: var(--border-w) solid var(--color-border);
  margin-top: var(--space-9);
  padding: var(--space-7) 0 var(--space-7);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  background: var(--color-footer);
}
.site-footer .cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: var(--space-5);
  max-width: var(--container-lg);
  margin: 0 auto var(--space-5);
  padding: 0 var(--gutter);
}
.site-footer .col .col-h {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text);
  margin: 0 0 var(--space-2);
}
.site-footer .col ul { list-style: none; margin: 0; padding: 0; }
.site-footer .col li { margin: var(--space-2) 0; }
.site-footer .col a { color: var(--color-text-secondary); text-decoration: none; }
.site-footer .col a:hover { color: var(--color-accent); text-decoration: underline; }
.site-footer .legal {
  max-width: var(--container-lg);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.site-footer .legal .disclaimer { background: var(--color-surface-raised); }
.site-footer .fine { margin: var(--space-4) 0 0; }

/* ── legal / prose pages ── */
.prose h2 { margin-top: var(--space-6); }
.prose ul { padding-left: 1.2rem; }
.prose li { margin: var(--space-1) 0; }

/* ── misc ── */
.guide-link { color: var(--color-accent); font-weight: var(--weight-medium); text-decoration: none; }
.guide-link:hover { text-decoration: underline; }
.foot {
  margin-top: var(--space-7);
  border-top: var(--border-w) solid var(--color-border);
  padding-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}
.foot .mono { color: var(--color-text); }
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--color-surface);
  color: var(--color-accent);
  padding: var(--space-2) var(--space-3);
  z-index: 40;
}
.skip-link:focus { left: 0; }

/* ══════════════════════════════════════════════════════════════════════════════════════
   PLAY SITE — the roulette table as one screen (play/pages/index.astro, ADR-R7 §9).
   Tokens only. Regions: rail-l (two round cards) · stage (banner, wheel, felt, actions) ·
   rail-r (your board, wallet) · results strip. Desktop: nothing scrolls but the rails.
   Phone: the felt frame is the ONE scrolling region; the actions stay pinned; rail-r is a sheet.
   ══════════════════════════════════════════════════════════════════════════════════════ */
/* a fixed viewport height, not a minimum: with min-height the middle row grows with its content
   and the document scrolls (measured 821px at 760); with height it is capped and the parts inside
   shrink and scroll instead */
/* minmax(0, 1fr) on the COLUMN too: an auto column is sized by its items' min-content, and the
   header's flex row made the whole page 867px wide on a 375px phone (measured) */
body[data-layout="game"] { height: 100vh; height: 100dvh; min-height: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
/* the height chain: body rows → main (a stretched grid item) → .game at 100% of it, so the
   1fr rows inside resolve against a DEFINITE height and the rails/felt shrink and scroll instead
   of growing the document (measured: without height:100% the page scrolled 21px at 1200×760) */
body[data-layout="game"] .game-main { min-height: 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
/* two lines at most: the note, then one scrolling row of links — the table needs the height
   (measured: four wrapped lines cost the felt 60px at 1366×768) */
.site-footer.compact { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-1) var(--space-4); padding: var(--space-2) var(--gutter); margin: 0; min-width: 0; }
.site-footer.compact .fine:first-child { grid-column: 1 / -1; text-align: center; }
.site-footer.compact .fine { margin: 0; }
.site-footer.compact nav { display: flex; flex-wrap: nowrap; gap: var(--space-3); min-width: 0; overflow-x: auto; }
.site-footer.compact nav a { color: var(--color-text-secondary); font-size: var(--text-sm); white-space: nowrap; }
.site-footer.compact nav a:hover { color: var(--color-accent); }

/* the felt is the point: the rails take the least width that still reads (founder 2026-09-23:
   the table was too small on a PC), and the wheel shares a row with the banner so the felt gets the height */
.game { display: grid; grid-template-columns: minmax(190px, 220px) minmax(0, 1fr) minmax(220px, 250px); grid-template-rows: minmax(0, 1fr) auto; gap: var(--space-3); padding: var(--space-2) var(--gutter); min-height: 0; height: 100%; box-sizing: border-box; }
.game .rail { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-3); scrollbar-gutter: stable; }
.game .stage { min-height: 0; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-areas: 'wheel banner' 'felt felt' 'hint hint' 'actions actions'; gap: var(--space-2); }
.game .stage .wheel-host { align-self: center; }
.game .stage .result-banner { align-self: stretch; font-size: var(--text-lg); }
.result-banner { grid-area: banner; } .wheel-host { grid-area: wheel; } .felt-frame { grid-area: felt; } .felt-hint { grid-area: hint; } .actions { grid-area: actions; }
.game .results-strip { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--space-2); min-height: var(--space-6); }

/* round cards */
.card { background: var(--color-surface); border: var(--border-w) solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-3); }
.card-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 var(--space-2); margin: 0 0 var(--space-1); font-weight: var(--weight-semibold); }
.card-title { white-space: nowrap; }
.card-state { font-size: var(--text-sm); color: var(--color-text-secondary); text-align: right; }
.round-card[data-phase="open"] .card-state { color: var(--color-accent); }
.round-card[data-phase="last-call"] .card-state, .round-card[data-phase="last-call"] .card-clock { color: var(--color-error); }
.round-card[data-phase="due"] .card-state, .round-card[data-phase="spun"] .card-state { color: var(--color-accent); }
.card-clock { margin: 0 0 var(--space-1); font-size: var(--text-xl); min-height: 1.3em; }
.card-clock:empty { display: none; }
.card-note { margin: var(--space-1) 0 0; color: var(--color-text-secondary); }
.card-note:empty, .mine:empty, #board-verdict:empty, #place-status:empty, #results-note:empty, #place-cost:empty, #clock-note:empty { display: none; }
.tbar { height: var(--space-1); border-radius: var(--radius-pill); background: var(--color-border); overflow: hidden; }
.tbar-fill { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--color-accent); }
.round-card[data-phase="last-call"] .tbar-fill { background: var(--color-error); }
.round-card[data-phase="closed"] .tbar-fill, .round-card[data-phase="due"] .tbar-fill { background: var(--color-text-secondary); }
.round-card[data-phase="none"] .tbar, .round-card[data-phase="resolved"] .tbar, .round-card[data-phase="void"] .tbar, .round-card[data-phase="spun"] .tbar { visibility: hidden; }
.round-card.active { border-color: var(--color-accent); box-shadow: var(--shadow-glow); }
.mine { margin-top: var(--space-2); padding-top: var(--space-2); border-top: var(--border-w) solid var(--color-border); }
.mine .brow { display: flex; gap: var(--space-2); flex-wrap: wrap; font-family: var(--font-mono); }
.mine .brow .k { flex: 1 1 8rem; min-width: 0; }
.mine-h { margin: 0 0 var(--space-1); font-weight: var(--weight-semibold); }
.mine-line { margin: var(--space-1) 0 0; }
.sign-row { margin: var(--space-3) 0 0; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.activity { margin-top: var(--space-3); padding-top: var(--space-2); border-top: var(--border-w) solid var(--color-border); }
.activity .card-h { margin-bottom: 0; }
#activity-last:empty { display: none; }
#activity-last .entry { overflow-wrap: anywhere; }
#activity-last .entry.err { color: var(--color-error); }
#activity-last .tx-id, .mine .tx-id, #place-status .tx-id, #verify-payouts .tx-id { font-family: var(--font-mono); overflow-wrap: anywhere; }
.mine .paid { color: var(--color-accent); }
#verify-payouts .prow { padding: var(--space-1) 0; border-top: var(--border-w) solid var(--color-border); overflow-wrap: anywhere; }
.facts { margin: var(--space-2) 0 0; display: grid; gap: var(--space-1); }
.facts div { display: flex; justify-content: space-between; gap: var(--space-2); min-width: 0; }
.facts dt { color: var(--color-text-secondary); flex-shrink: 0; }
.facts dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.rail-links { display: flex; flex-direction: column; align-items: flex-start; gap: 0; margin: 0; }
.wallets { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-2) 0; }
/* the gate dims what it locks, never the note saying why: an opacity on the gate itself dimmed the note
   with it (2.83:1 dark, 2.34:1 light, measured) and a colour on the note cannot undo a parent's opacity
   (--color-text under it measured 5.83:1 dark, 4.14:1 light) */
.gate.locked > :not(.lock-note) { opacity: 0.55; }
.gate.locked .lock-note { color: var(--color-text); }
.gate.locked [data-act], .gate.locked input { pointer-events: none; }
/* the text is ONE flex item (a span): bare text nodes and the link would each become an item and
   the label would render as columns (measured) */
.ack { display: flex; gap: var(--space-3); align-items: flex-start; margin: 0 0 var(--space-2); cursor: pointer; }
.ack span { min-width: 0; }
/* the native box is 13px; the founder could barely see it (2026-09-23) — 24px, the accent colour, and
   the whole label is the target */
.ack input { width: var(--space-5); height: var(--space-5); margin: 0; flex-shrink: 0; accent-color: var(--color-accent); cursor: pointer; }
.ack input { margin-top: 0.25em; }
.target { margin: 0; }

/* the stage */
/* the banner is the clock: the live round's line, the next round's line in the card's colours, and
   the player's own result once the number is known */
.result-banner { margin: 0; min-height: var(--space-7); display: grid; align-content: center; justify-items: center; text-align: center; background: var(--color-surface-raised); border-radius: var(--radius-md); padding: var(--space-1) var(--space-3); gap: var(--space-1); }
.result-banner p { margin: 0; }
.banner-live { font-weight: var(--weight-semibold); font-size: var(--text-lg); }
.result-banner.spun .banner-live { color: var(--color-accent); }
.banner-next { font-size: var(--text-base); color: var(--color-text-secondary); }
.banner-next:empty, .banner-mine:empty { display: none; }
.result-banner[data-next="open"] .banner-next { color: var(--color-accent); }
.result-banner[data-next="last-call"] .banner-next { color: var(--color-error); font-weight: var(--weight-semibold); }
.banner-mine { font-size: var(--text-sm); color: var(--color-text); }
.banner-mine .hit { color: var(--color-accent); font-weight: var(--weight-semibold); }
.banner-mine .miss { color: var(--color-text-secondary); }
.wheel-host { display: grid; place-items: center; --wheel-size: clamp(100px, 15dvh, 150px); }
.wheel { position: relative; width: var(--wheel-size); aspect-ratio: 1; }
.wheel-rotor, .wheel-arm { position: absolute; inset: 0; transform-origin: 50% 50%; }
.wheel-rotor svg { display: block; width: 100%; height: 100%; }
.wheel .pocket.red { fill: var(--sp-error); }
.wheel .pocket.black { fill: var(--sp-ink-deep); }
.wheel .pocket.green { fill: var(--color-accent); }
.wheel .pocket { stroke: var(--sp-paper-dim); stroke-width: 0.6; }
.wheel .pocket-lbl { fill: var(--sp-paper); font-family: var(--font-mono); font-size: 8px; font-weight: 700; pointer-events: none; }
.wheel .wheel-ring { fill: none; stroke: var(--color-border-strong); stroke-width: 1.5; }
.wheel .wheel-hub { fill: var(--color-surface-sunken); stroke: var(--color-border-strong); }
.wheel-arm .wheel-ball { position: absolute; left: 50%; top: 7%; width: 7%; height: 7%; margin-left: -3.5%; border-radius: 50%; background: var(--sp-paper); box-shadow: var(--shadow-sm); }
.wheel-result { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-mono); font-weight: 700; font-size: var(--text-3xl); color: var(--color-text); opacity: 0; pointer-events: none; }
.wheel-result.show { opacity: 1; }
.wheel[data-state="settled"] .wheel-result { opacity: 1; }
.wheel.will-move .wheel-rotor, .wheel.will-move .wheel-arm { will-change: transform; }

/* the SVG has a ratio and no size of its own: it needs a DEFINITE box on both axes to fit into,
   so the frame stretches .felt to itself (a centred grid item would shrink to 0×0 — measured) */
.felt-frame { position: relative; min-height: 0; min-width: 0; display: grid; align-items: stretch; justify-items: stretch; overflow: hidden; }
.felt { min-width: 0; min-height: 0; width: 100%; height: 100%; display: grid; place-items: center; }
.felt svg { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; touch-action: manipulation; }
.felt .cell { stroke: var(--color-border-strong); stroke-width: 1; }
.felt .cell.red { fill: var(--sp-error); }
.felt .cell.black { fill: var(--sp-ink-deep); }
.felt .cell.green { fill: var(--color-accent-soft); }
.felt .cell.outside { fill: var(--color-surface-sunken); }
.felt .cell.strip { fill: var(--color-surface-raised); }
.felt .lbl { fill: var(--color-text); font-family: var(--font-mono); font-size: 13px; pointer-events: none; }
.felt .lbl.on-dark { fill: var(--sp-paper); }
.felt .lbl.cap { fill: var(--color-text-secondary); }
.felt .zone { fill: transparent; stroke: transparent; cursor: pointer; }
.felt .zone:hover, .felt .zone:focus-visible { stroke: var(--color-accent); stroke-width: 2; outline: none; }
.felt .zone.has { stroke: var(--color-accent); stroke-width: 1.5; stroke-dasharray: 3 2; }
/* the winning number and the player's bets that hit, once the number is known */
.felt .cell.win { stroke: var(--color-accent); stroke-width: 4; }
.felt .zone.hit { stroke: var(--color-accent); stroke-width: 3; stroke-dasharray: none; }
.felt .win-badge-bg { fill: var(--color-accent); stroke: var(--sp-paper); stroke-width: 1; pointer-events: none; }
.felt .win-badge { fill: var(--color-on-accent); font-family: var(--font-mono); font-size: 11px; font-weight: 700; pointer-events: none; }
.felt .chip { fill: var(--color-accent); stroke: var(--sp-paper); stroke-width: 1.5; pointer-events: none; }
.felt .chip-lbl { fill: var(--color-on-accent); font-family: var(--font-mono); font-size: 9px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.felt-hint { margin: 0; text-align: center; min-height: 1.4em; }

/* the verdict (play/verdict.ts): the player's own result over the table frame ONLY — the chips, the
   board rail and the round cards stay usable. Win = the accent with its glow; a return or a refund =
   the neutral raised surface; no win = calm secondary text, never shaming. The frame stops scrolling
   while it shows (on a phone the frame is the scroller and the panel would scroll away with the felt). */
.felt-frame:has(> .verdict:not([hidden])) { overflow: hidden; }
.verdict { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--space-2); box-sizing: border-box; background: color-mix(in srgb, var(--color-page) 72%, transparent); backdrop-filter: blur(var(--space-1)); -webkit-backdrop-filter: blur(var(--space-1)); cursor: pointer; }
.verdict-card { width: min(100%, 30rem); max-height: 100%; overflow-y: auto; box-sizing: border-box; display: grid; justify-items: center; gap: var(--space-1); padding: var(--space-4) var(--space-5); text-align: center; border-radius: var(--radius-lg); border: var(--border-w-accent) solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-lg); cursor: auto; }
.verdict-card p { margin: 0; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.verdict-word { font-size: var(--text-xl); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: var(--tracking-wide); line-height: var(--leading-tight); }
.verdict-amount { font-size: var(--text-4xl); font-weight: var(--weight-semibold); line-height: var(--leading-tight); white-space: nowrap; }
.verdict-detail { font-size: var(--text-base); color: var(--color-text-secondary); }
.verdict-paid { font-size: var(--text-sm); color: var(--color-text); }
.verdict-paid:empty { display: none; }
.verdict-card .btn { margin-top: var(--space-2); }
.verdict[data-kind="win"] .verdict-card { border-color: var(--color-accent); box-shadow: var(--shadow-glow), var(--shadow-lg); }
.verdict[data-kind="win"] .verdict-word, .verdict[data-kind="win"] .verdict-amount { color: var(--color-accent); }
.verdict[data-kind="returned"] .verdict-card, .verdict[data-kind="refund"] .verdict-card { background: var(--color-surface-raised); }
.verdict[data-kind="none"] .verdict-card { border-color: var(--color-border); }
.verdict[data-kind="none"] .verdict-word, .verdict[data-kind="none"] .verdict-amount { color: var(--color-text-secondary); }
.verdict[data-paid="true"] .verdict-paid { color: var(--color-accent); font-weight: var(--weight-semibold); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); min-width: 0; }
.actions .tray { display: flex; gap: var(--space-1); flex-wrap: wrap; min-width: 0; }
.tray .chipv { min-width: var(--space-7); min-height: var(--space-7); font-family: var(--font-mono); font-size: var(--text-sm); border-radius: var(--radius-pill); padding: 0 var(--space-1); }
.tray .chipv[aria-pressed="true"] { border-color: var(--color-accent); color: var(--color-accent); }
.actions .acts { display: flex; gap: var(--space-1); }
.actions .totals { margin: 0; margin-left: auto; }
.actions .rail-toggle { display: none; }
.rail .sheet-close { display: none; }

.board-list { display: flex; flex-direction: column; gap: var(--space-1); }
/* two lines per bet: name + stake, then the return + remove — a 280px rail cannot hold four
   items in one line (measured: the name wrapped one letter per line) */
.board-list .brow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 var(--space-2); align-items: center; font-family: var(--font-mono); font-size: var(--text-sm); min-width: 0; padding: var(--space-1) 0; border-bottom: var(--border-w) solid var(--color-border); }
.board-list .brow .k { min-width: 0; overflow-wrap: anywhere; }
.board-list .brow .muted { grid-column: 1; }
.board-list .brow .btn { grid-column: 2; justify-self: end; }
.board-list .brow .hit { color: var(--color-accent); font-weight: 700; }
.board-list .brow .miss { color: var(--color-text-secondary); }
.results { display: flex; gap: var(--space-1); overflow-x: auto; min-width: 0; flex: 1; }
.results .res { flex-shrink: 0; min-width: var(--space-7); min-height: var(--space-7); display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-family: var(--font-mono); font-weight: 700; font-size: var(--text-sm); color: var(--sp-paper); }
.results .res.red { background: var(--sp-error); }
.results .res.black { background: var(--sp-ink-deep); }
.results .res.green { background: var(--color-accent); color: var(--color-on-accent); }
.results .res.void { background: var(--color-surface-sunken); color: var(--color-text-secondary); }

/* dialogs over the stage: rules, the fairness check, the activity log */
dialog.sheet { border: var(--border-w) solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); color: var(--color-text); max-width: min(640px, 92vw); max-height: 85dvh; overflow: auto; padding: var(--space-5); box-shadow: var(--shadow-lg); }
dialog.sheet::backdrop { background: color-mix(in srgb, var(--sp-black) 60%, transparent); }
dialog.sheet h2 { margin: 0 0 var(--space-3); font-size: var(--text-lg); }
dialog.sheet ul.plain, dialog.sheet ol.plain { margin: var(--space-3) 0; padding-left: var(--space-4); }
dialog.sheet li { margin: var(--space-2) 0; }
dialog.sheet #log { max-height: 50dvh; overflow-y: auto; }
#verify-sig { width: 100%; max-width: 100%; }

@media (prefers-reduced-motion: no-preference) {
  .felt .cell.win { animation: felt-win var(--dur-slow) var(--ease-out) 3; }
  @keyframes felt-win { from { stroke-width: 1; } to { stroke-width: 4; } }
  .tbar-fill { transition: width var(--dur-slow) linear; }
  .wheel-result { transition: opacity var(--dur-slow) var(--ease-out); }
  .rail-r { transition: transform var(--dur-base) var(--ease-out); }
  .verdict:not([hidden]) { animation: verdict-fade var(--dur-base) var(--ease-out); }
  .verdict:not([hidden]) .verdict-card { animation: verdict-pop var(--dur-slow) var(--ease-out); }
  @keyframes verdict-fade { from { opacity: 0; } }
  @keyframes verdict-pop { from { opacity: 0; transform: scale(0.85); } }
}

/* phone and narrow windows: one column; the felt frame is the only scrolling region */
@media (max-width: 899px) {
  .game { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); gap: var(--space-2); padding: var(--space-2) var(--gutter) 0; }
  .game .rail-l { overflow: visible; flex-direction: row; gap: var(--space-2); order: 1; }
  .game .rail-l .round-card { flex: 1; min-width: 0; padding: var(--space-2); }
  .game .rail-l .facts, .game .rail-l .card-note, .game .rail-l .mine, .game .rail-l .rail-links, .game .rail-l .clock-note { display: none; }
  .card-h { flex-direction: column; align-items: flex-start; gap: 0; font-size: var(--text-sm); }
  .card-clock { font-size: var(--text-lg); }
  .game .results-strip { order: 2; min-height: var(--space-6); }
  /* the wheel sits BESIDE the banner: one row instead of two, and the felt gets the height */
  .game .stage { order: 3; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-areas: 'wheel banner' 'felt felt' 'hint hint' 'actions actions'; }
  /* only the wheel centres in its row; the felt frame must STRETCH to its row or it takes its
     content's height and overflows both ends (measured: y −54 to 751 at 667px) */
  .wheel-host { align-self: center; }
  .result-banner { min-height: var(--space-7); align-self: stretch; }
  .banner-live { font-size: var(--text-sm); }
  .banner-next { font-size: var(--text-sm); }
  .wheel-host { --wheel-size: clamp(80px, 13dvh, 104px); }
  .felt-frame { overflow-y: auto; overflow-x: hidden; place-items: start center; margin: 0 calc(-1 * var(--gutter)); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  /* the frame scrolls over the whole felt: .felt grows to the SVG and starts at the top —
     centred, the top of a taller SVG sits ABOVE the frame where no scroll can reach it (measured y −28) */
  .felt { height: auto; place-items: start center; }
  .felt svg { width: 100%; max-height: none; height: auto; }
  .felt-hint { display: none; }
  /* the phone's frame is about 200 CSS pixels tall (measured 200 at 375×667, 167 at 320×740): the word
     shares its row with Continue, the rest reads left-aligned under it, the small lines set tight */
  .verdict { padding: var(--space-1); }
  .verdict-card { width: 100%; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'word btn' 'amount amount' 'detail detail' 'paid paid'; justify-items: start; align-items: center; gap: 0 var(--space-2); padding: var(--space-2) var(--space-3); text-align: left; }
  .verdict-word { grid-area: word; font-size: var(--text-base); }
  .verdict-amount { grid-area: amount; font-size: var(--text-3xl); }
  .verdict-amount.long { font-size: clamp(var(--text-2xl), 10.4vw, var(--text-3xl)); }
  .verdict-detail { grid-area: detail; font-size: var(--text-sm); line-height: var(--leading-tight); }
  .verdict-card .verdict-paid { grid-area: paid; line-height: var(--leading-tight); margin-top: var(--space-1); }
  .verdict-card .btn { grid-area: btn; margin-top: 0; min-height: var(--space-6); padding-top: 0; padding-bottom: 0; }
  .actions { padding: var(--space-1) 0 calc(var(--space-1) + env(safe-area-inset-bottom)); border-top: var(--border-w) solid var(--color-border); gap: var(--space-1) var(--space-2); }
  .actions .acts .btn, .tray .chipv { min-height: var(--space-6); padding-top: 0; padding-bottom: 0; }
  .actions .acts .btn { padding-left: var(--space-2); padding-right: var(--space-2); }
  .actions .rail-toggle { flex: 1 1 100%; }
  /* the chip tray is one scrolling row (7 chips are wider than a phone); its min-content width must
     not widen the page: min-width 0 + overflow on the flex item itself (measured 512px without) */
  .actions .tray { flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; min-width: 0; padding-bottom: var(--space-1); }
  .actions .acts { flex-wrap: wrap; }
  .actions .rail-toggle { display: inline-flex; }
  .rail .sheet-close { display: inline-flex; align-self: flex-end; }
  .site-footer.compact .fine, .results-strip #results-note, .results-h { display: none; }
  .game .rail-r { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-dock); max-height: 75dvh; background: var(--color-surface); border-top: var(--border-w) solid var(--color-border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-3) var(--gutter) calc(var(--space-3) + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); transform: translateY(100%); visibility: hidden; }
  .game .rail-r.open { transform: none; visibility: visible; }
  .site-footer.compact { padding: var(--space-1) var(--gutter); }
  /* one scrolling line of links; min-width 0 or its nowrap content widens the whole page
     (measured: 867px document at 375 without it) */
  .site-footer.compact { grid-template-columns: minmax(0, 1fr); }
  .site-footer.compact nav { min-width: 0; flex-wrap: nowrap; overflow-x: auto; }
  .site-footer.compact nav a { white-space: nowrap; }
}

/* a desktop window that is short or narrow (founder 2026-09-26: a laptop at 125–150 % Windows scaling,
   about 1280×620 or 1093×600 of viewport, clipped the table at 100 % and fitted at an 80 % zoom). TEXT
   KEEPS ITS SIZE (founder: "keep it readable, don't make the letters smaller"): only the room around
   it gives — gaps, paddings, the wheel, the banner's floor, the chips' and results' tiles, the rails at
   their narrowest. Baccarat's card faces and boxes step down on its page. */
@media (min-width: 900px) and (max-height: 820px), (min-width: 900px) and (max-width: 1280px) {
  body[data-layout="game"] .game { gap: var(--space-2); padding: var(--space-1) var(--gutter); }
  body[data-layout="game"] .game .rail { gap: var(--space-2); }
  body[data-layout="game"] .card { padding: var(--space-2); }
  body[data-layout="game"] .game .stage { gap: var(--space-1); }
  body[data-layout="game"] .result-banner { min-height: var(--space-6); padding: 0 var(--space-3); gap: 0; }
  body[data-layout="game"] .wheel-host { --wheel-size: clamp(5.5rem, 13dvh, 7.5rem); }
  body[data-layout="game"] .tray .chipv { min-height: var(--space-6); padding-top: 0; padding-bottom: 0; }
  body[data-layout="game"] .actions .acts .btn { min-height: var(--space-6); padding-top: 0; padding-bottom: 0; }
  body[data-layout="game"] .results .res { min-height: var(--space-6); }
  body[data-layout="game"] .game .results-strip { min-height: var(--space-6); }
  body[data-layout="game"] .site-footer.compact { padding: var(--space-1) var(--gutter); }
}
/* shorter than the 760 the one-screen table is built for: NOTHING may be clipped or hidden, so the page
   stops being one fixed screen and scrolls as a whole — the rails show all they hold, the table frame
   takes its content's height (the felt at the stage's full width, its digits never shrunk to fit a
   height), and every control is reachable by scrolling the page, never inside a frame */
@media (min-width: 900px) and (max-height: 759.98px) {
  body[data-layout="game"] { height: auto; min-height: 100vh; min-height: 100dvh; grid-template-rows: auto auto auto; }
  body[data-layout="game"] .game-main { grid-template-rows: auto; }
  /* the rails a little WIDER than the one-screen layout's: their text wraps less, so the page is shorter
     and baccarat's next-round card (measured 624 px tall in the narrowest rail) fits a 600px window whole */
  body[data-layout="game"] .game { height: auto; grid-template-columns: 15rem minmax(0, 1fr) 15rem; grid-template-rows: auto auto; align-items: start; }
  body[data-layout="game"] .game .rail { overflow: visible; }
  body[data-layout="game"] .game .stage { grid-template-rows: auto auto auto auto; }
  body[data-layout="game"] .felt { height: auto; }
  body[data-layout="game"] .felt svg { width: 100%; max-height: none; height: auto; }
  /* a narrow window's felt is shorter than the verdict card (measured 196 px at 1024 wide, the card 240):
     while the verdict shows, the frame grows to hold it whole rather than scroll it */
  body[data-layout="game"] .felt-frame:has(> .verdict:not([hidden])) { min-height: 17.5rem; }
}
