/*
 * styles.css — all styling for Heavy 13.
 * Set dressing follows C:\Repo\Dev\DevilsRoulette (itself after MemoryPoker and
 * The Devil's Plan): a lit concrete cell wall, dark slabs with a gold hairline,
 * purple game furniture, gold for anything you act on, engraved Cinzel caps and
 * Zilla Slab.
 *
 * used_by: index.html
 * related: offline.html (carries its own minimal copy of the palette);
 *          ui.js (builds the stands, cubes, rail and hand this styles)
 * rules:
 *   - Mobile-first at ~380px. Every tappable control is at least 44px.
 *   - Colour has one meaning each: gold = you / act now, purple = game
 *     furniture, red/green/blue = the three porter stands. The stand colours are
 *     a departure from the purple-and-gold-only rule because they ARE the game.
 *   - Text straight on the wall is dark ink; text on a slab is cream or gold.
 *   - Every number on a game piece — hand card, rail card, cube — is set in the
 *     display face, the same engraved caps as the wordmark. Body face is for
 *     prose only.
 *   - Fonts are local files in fonts/. No url() to another origin, ever.
 *   - Anything not needed right now is display:none, not greyed out.
 *   - The page is exactly one screen tall (.shell is 100dvh) and never scrolls:
 *     the stands take whatever height is left, the log scrolls inside itself.
 *   - .drawer (hand, results) is fixed to the bottom edge. Slid away
 *     ([data-open="false"]) it shows only its 46px handle, which sits exactly
 *     over the 46px footer, so it never covers the stands or the log.
 *   - #toast is pointer-events:none so it can never block a tap.
 * message: --red, --green and the .cube/.stand class names are read by
 *   tests/game.spec.js; keep the names.
 * wiki: PRD.md
 */
@font-face { font-family: "Cinzel"; font-weight: 400 700; font-style: normal; font-display: swap; src: url("fonts/cinzel-latin.woff2") format("woff2"); }
@font-face { font-family: "Zilla Slab"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/zilla-slab-400.woff2") format("woff2"); }
@font-face { font-family: "Zilla Slab"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/zilla-slab-600.woff2") format("woff2"); }
@font-face { font-family: "Zilla Slab"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/zilla-slab-700.woff2") format("woff2"); }

:root {
  /* Concrete */
  --wall-lit: #a5a39e;
  --wall-mid: #7e7c78;
  --wall-dark: #5a5855;
  --wall-deep: #3e3d3b;

  /* Ink on the wall */
  --ink: #221e1b;
  --ink-soft: #3d3732;
  --ink-faint: #524c46;

  /* Slabs laid on the wall */
  --slab: #25211e;
  --slab-deep: #1a1816;
  --slab-bg: linear-gradient(180deg, rgba(48, 44, 41, 0.94), rgba(26, 24, 22, 0.96));
  --line: rgba(240, 220, 164, 0.2);
  --line-soft: rgba(240, 220, 164, 0.1);
  --cream: #d6cec2;
  --mute: #9c948a;
  --stock: #fbf9f4;

  /* Purple: the game furniture */
  --purple-900: #2d1245;
  --purple-700: #4a1d73;
  --purple-600: #5f2a94;
  --purple-500: #7634b4;
  --purple-400: #8a46c9;
  --purple-300: #ad7ae0;
  --purple-100: #e4d4f5;

  /* Gold: you, and anything you act on */
  --gold-600: #9c7628;
  --gold-500: #c6992f;
  --gold-400: #d9b254;
  --gold-200: #f0dca4;

  /* The game's one fact */
  --red: #e5594a;
  --red-deep: #9c2a21;
  --red-dim: #4a1a16;
  --green: #5cc487;
  --green-deep: #1f6a43;
  --green-dim: #173a28;

  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --body: "Zilla Slab", Rockwell, Georgia, serif;
  --turn: 0.75s;
  --ease: cubic-bezier(0.22, 0.61, 0.24, 1);
  --ease-snap: cubic-bezier(0.34, 1.46, 0.5, 1);
  --shadow-slab: 0 10px 24px -14px rgba(0, 0, 0, 0.9);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { color-scheme: dark; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.4;
  color: var(--cream);
  background-color: var(--wall-dark);
  /* One overhead light on a concrete wall. */
  background-image: radial-gradient(120% 88% at 50% 12%, var(--wall-lit) 0%, var(--wall-mid) 42%, var(--wall-dark) 74%, var(--wall-deep) 100%);
  background-attachment: fixed;
  touch-action: manipulation;
  overflow-x: hidden;
}

/* Concrete grain */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 8s steps(6) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(2%, 1%); }
}

button, input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

/* One screen, no scrolling. Below 540px tall (a phone on its side) it gives up
   and scrolls rather than crush the stands. */
.shell {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  height: 100vh;
  height: 100dvh;
  min-height: 540px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 16px env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shell > * { flex: none; }

/* ---------------- masthead ---------------- */

.masthead { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }

/* The purple ribbon with notched ends that every title hangs from. */
.eyebrow, .log-round span {
  display: inline-block;
  padding: 3px 16px;
  font-family: var(--display);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--gold-200);
  background: linear-gradient(180deg, var(--purple-700), var(--purple-900));
  box-shadow: inset 0 0 0 1px var(--gold-600), inset 0 1px 0 rgba(240, 220, 164, 0.3);
  clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 50%, 100% 100%, 0 100%, 9px 50%);
}

/* Engraved into the wall */
.wordmark {
  font-family: var(--display);
  font-size: 1.36rem;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.05em;
  white-space: nowrap;
  text-transform: uppercase;
  color: #171412;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.16), 0 -1px 1px rgba(0, 0, 0, 0.5);
}

/* Game speed, Stats, Rules: one quiet bar pressed into the wall. Small type,
   no fill, but each part is still a full 44px target. */
.tools { flex: none; display: flex; align-items: stretch; border: 1px solid rgba(34, 30, 27, 0.26); border-radius: 2px; background: rgba(24, 20, 18, 0.1); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18), 0 1px 0 rgba(255, 255, 255, 0.1); }
.tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 46px; min-height: 44px; padding: 0 7px; border: 0; background: none; font-family: var(--display); font-size: 0.48rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-soft); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 0.2s ease, color 0.2s ease; }
.tool + .tool { border-left: 1px solid rgba(34, 30, 27, 0.2); }
.tool:hover, .tool:active { color: var(--ink); background: rgba(24, 20, 18, 0.14); }
.tool:focus-visible { outline: 2px solid var(--purple-900); outline-offset: -3px; }
.tool-speeds { display: flex; gap: 6px; font-family: var(--body); font-size: 0.8rem; letter-spacing: 0; line-height: 1; text-transform: none; }
.tool-speeds i { font-style: normal; font-weight: 600; color: var(--ink-faint); opacity: 0.5; }
.tool-speeds i.on { color: var(--purple-900); opacity: 1; font-weight: 700; box-shadow: 0 2px 0 var(--purple-700); }

/* ---------------- buttons ---------------- */

.btn {
  appearance: none;
  min-height: 46px;
  min-width: 46px;
  padding: 8px 12px;
  border: 1px solid var(--purple-700);
  border-radius: 2px;
  background: linear-gradient(180deg, var(--purple-500), var(--purple-900));
  box-shadow: inset 0 1px 0 rgba(240, 220, 164, 0.22), 0 8px 18px -10px rgba(0, 0, 0, 0.95);
  font-family: var(--display);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-200);
  cursor: pointer;
  transition: transform 0.16s var(--ease-snap), filter 0.2s ease, box-shadow 0.25s ease, border-color 0.2s;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0); filter: brightness(0.95); }
.btn:focus-visible, summary:focus-visible { outline: 2px solid var(--gold-200); outline-offset: 2px; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; box-shadow: none; }

.btn-ghost { background: rgba(24, 20, 18, 0.62); border-color: rgba(240, 220, 164, 0.28); box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: rgba(45, 18, 69, 0.7); border-color: rgba(240, 220, 164, 0.45); filter: none; }
.btn-danger { border-color: var(--red) !important; color: var(--red) !important; }
/* Gold: the one button that moves the game on. */
.btn-primary { background: linear-gradient(180deg, var(--gold-200), var(--gold-500)); border-color: var(--gold-600); color: #1d1608; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 8px 18px -10px rgba(0, 0, 0, 0.95); }
.btn-wide { width: 100%; min-height: 54px; font-size: 0.8rem; letter-spacing: 0.22em; }

/* ---------------- status strip ---------------- */

.status { display: grid; grid-template-columns: auto auto 1fr; border: 1px solid var(--line); background: var(--slab-bg); box-shadow: var(--shadow-slab); }
.stat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 5px 12px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line-soft); }
.stat-wide { align-items: flex-start; }
.stat-label { display: block; font-family: var(--display); font-size: 0.46rem; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold-200); white-space: nowrap; }
.stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.05; color: var(--stock); font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); }
#penalty { color: var(--gold-400); }
#round small { font-size: 0.6rem; font-weight: 600; color: var(--mute); }
.stat-turn { max-width: 100%; font-size: 0.92rem; font-weight: 600; line-height: 1.55; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-turn.is-you { color: var(--gold-400); }


/* ---------------- pop-up announcement ---------------- */

.toast {
  position: fixed;
  z-index: 50;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  width: min(calc(100% - 20px), 440px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast-bottom { top: auto; bottom: max(10px, env(safe-area-inset-bottom)); }
.toast-bottom .toast-card { animation-name: toast-up; }
.toast-card {
  position: relative;
  overflow: hidden;
  padding: 10px 14px 13px;
  border: 1px solid rgba(240, 220, 164, 0.45);
  border-left: 5px solid var(--gold-400);
  background: linear-gradient(180deg, rgba(48, 44, 41, 0.98), rgba(22, 20, 18, 0.98));
  box-shadow: 0 18px 40px -8px rgba(0, 0, 0, 0.9);
  animation: toast-in 0.42s var(--ease) both;
}
.toast-head { font-family: var(--display); font-size: 0.54rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold-200); }
.toast-line { margin-top: 3px; font-size: 1.04rem; font-weight: 600; line-height: 1.25; color: var(--stock); }
.toast-private { border-color: var(--purple-300); border-left-color: var(--purple-300); background: linear-gradient(180deg, #40206a, #24123a); }
.toast-line-private { color: var(--gold-200); }
.toast-end { border-color: var(--red); border-left-color: var(--red); }
.toast-end .toast-head { color: var(--red); }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--gold-400); transform-origin: left; animation: toast-drain linear both; }
@keyframes toast-in { from { transform: translateY(-130%) scale(0.94); opacity: 0; } 60% { transform: translateY(4px) scale(1.01); opacity: 1; } }
@keyframes toast-up { from { transform: translateY(130%) scale(0.94); opacity: 0; } 60% { transform: translateY(-4px) scale(1.01); opacity: 1; } }
@keyframes toast-drain { to { transform: scaleX(0); } }

/* ---------------- drawers (action panel, results) ---------------- */

.drawer {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 460px);
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(240, 220, 164, 0.4);
  border-width: 0 1px;
  background: linear-gradient(180deg, #302c29, #1a1816);
  box-shadow: 0 -20px 44px -14px rgba(0, 0, 0, 0.9);
  transition: transform 0.34s var(--ease), box-shadow 0.34s ease;
  animation: drawer-in 0.36s var(--ease) backwards;
}
/* Slid away: only the handle is left, over the footer. */
.drawer[data-open="false"] { transform: translateY(calc(100% - 46px - env(safe-area-inset-bottom))); box-shadow: 0 -6px 16px -8px rgba(0, 0, 0, 0.8); }
@keyframes drawer-in { from { transform: translateY(100%); } }

.drawer-handle {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: 46px;
  padding: 7px 14px 0;
  border: 0;
  border-top: 2px solid var(--gold-400);
  background: linear-gradient(180deg, var(--purple-700), var(--purple-900));
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* Grab bar */
.drawer-handle::before { content: ""; position: absolute; top: 5px; left: 50%; width: 38px; height: 3px; margin-left: -19px; border-radius: 2px; background: rgba(240, 220, 164, 0.5); }
.drawer-handle:focus-visible { outline: 2px solid var(--gold-200); outline-offset: -3px; }
.drawer-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--display); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-200); }
.drawer-title.is-safe { color: var(--green); }
.drawer-title.is-dead { color: var(--red); }
.drawer-chev { flex: none; display: inline-flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 0.52rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--cream); }
.drawer-chev::after { content: ""; width: 7px; height: 7px; border: solid var(--gold-400); border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); transition: transform 0.3s var(--ease); }
.drawer[data-open="false"] .drawer-chev::after { transform: translateY(2px) rotate(-135deg); }
/* A drawer never grows past the screen: its body scrolls instead, so the final
   board is always reachable. */
.drawer { max-height: 94dvh; }
.drawer-body { flex: 1; display: flex; flex-direction: column; gap: 9px; padding: 11px 12px 12px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

.panel-help { font-size: 0.86rem; color: var(--cream); }




/* Investigation findings, wherever they are printed. */

/* ---------------- log ---------------- */

/* Section titles sit straight on the wall, engraved like the wordmark. */
.section-title { margin-bottom: 5px; font-family: var(--display); font-size: 0.6rem; font-weight: 700; letter-spacing: 0.26em; text-transform: uppercase; color: var(--ink); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.14); }

/* Whatever height the stands do not need goes to the log. */
.shell > .log-wrap { flex: 1 1 60px; min-height: 0; display: flex; flex-direction: column; }
.log-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.log { flex: 1; list-style: none; margin: 0; padding: 0; min-height: 0; scroll-behavior: smooth; overflow-y: auto; border: 1px solid var(--line); background: var(--slab-bg); box-shadow: var(--shadow-slab); font-size: 0.88rem; overscroll-behavior: contain; }
.log li { padding: 6px 10px; border-bottom: 1px solid var(--line-soft); }
.log .log-round { position: sticky; top: 0; z-index: 1; padding: 5px 10px; text-align: center; background: var(--slab-deep); border-bottom: 1px solid var(--line); }
.log-mine { color: var(--gold-200); }
.log-end { color: var(--red); font-weight: 700; }
/* The newest line: a gold marker that slides in, then keeps a slow pulse. */
.log .log-latest { position: relative; padding-left: 24px; background-color: rgba(217, 178, 84, 0.14); box-shadow: inset 3px 0 0 var(--gold-400); animation: log-flash 0.9s ease-out both; }
.log .log-latest::before { content: ""; position: absolute; left: 9px; top: 0.82em; width: 6px; height: 6px; background: var(--gold-400); transform: rotate(45deg); animation: log-nudge 1.1s ease-in-out infinite; }
@keyframes log-flash { from { background-color: rgba(240, 220, 164, 0.6); transform: translateX(-10px); } }
@keyframes log-nudge { 50% { transform: rotate(45deg) scale(0.55); opacity: 0.5; } }
.log-private { display: flex; gap: 8px; align-items: baseline; color: var(--gold-200); background-image: repeating-linear-gradient(45deg, rgba(228, 212, 245, 0.07) 0 1px, transparent 1px 6px), repeating-linear-gradient(-45deg, rgba(228, 212, 245, 0.07) 0 1px, transparent 1px 6px), linear-gradient(168deg, #40206a, #24123a); }
.tag { flex: none; padding: 1px 6px; background: linear-gradient(170deg, var(--gold-200), var(--gold-500)); color: #1d1608; font-family: var(--display); font-size: 0.48rem; font-weight: 700; letter-spacing: 0.16em; }

/* ---------------- game over ---------------- */

/* Results drawer: three tabs over one pane, Play again pinned underneath. */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); background: var(--slab-deep); }
.tab { min-height: 46px; padding: 0 4px; border: 0; background: none; font-family: var(--display); font-size: 0.58rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--mute); cursor: pointer; transition: color 0.2s ease, background 0.2s ease; }
.tab + .tab { border-left: 1px solid var(--line-soft); }
.tab:hover { color: var(--gold-200); }
.tab[aria-selected="true"] { color: var(--gold-200); background: linear-gradient(180deg, var(--purple-500), var(--purple-900)); box-shadow: inset 0 -3px 0 var(--gold-400); }
.tab:focus-visible { outline: 2px solid var(--gold-200); outline-offset: -3px; }
.pane { display: flex; flex-direction: column; gap: 8px; min-height: 156px; }

.verdict { padding: 9px 10px 8px; text-align: center; border: 1px solid; background: var(--slab-deep); animation: slam 0.45s var(--ease) both; }
.verdict-word { font-family: var(--display); font-size: clamp(1.05rem, 7.2vw, 1.9rem); font-weight: 700; letter-spacing: 0.1em; line-height: 1.05; }
.verdict-sub { margin-top: 5px; font-size: 0.86rem; color: var(--cream); }
.verdict-safe { border-color: var(--green); }
.verdict-safe .verdict-word { color: var(--green); text-shadow: 0 0 24px rgba(92, 196, 135, 0.35); }
.verdict-dead { border-color: var(--red); }
.verdict-dead .verdict-word { color: var(--red); text-shadow: 0 0 24px rgba(229, 89, 74, 0.35); }
@keyframes slam { from { transform: scale(1.25); opacity: 0; } }



/* ---------------- stats ---------------- */

.record { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; font-family: var(--body); font-size: 0.9rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--stock); background: var(--slab-deep); border-color: var(--line); box-shadow: none; }
.record-more { flex: none; font-family: var(--display); font-size: 0.56rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-400); }

.sheet-overlay { place-items: center; padding: 10px; }
.sheet { display: flex; flex-direction: column; width: min(100%, 440px); max-height: min(92svh, 760px); padding: 0; animation: sheet-in 0.28s var(--ease) both; }
@keyframes sheet-in { from { transform: translateY(14px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); }
.sheet-head .modal-title { margin: 0; }
.sheet-foot { display: flex; justify-content: flex-end; padding: 8px; border-top: 1px solid var(--line); }
.stats-body { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; overflow-y: auto; overscroll-behavior: contain; }
.stats-body .section-title { margin: 8px 0 0; color: var(--gold-200); text-shadow: none; }
.stats-empty { padding: 28px 8px; text-align: center; color: var(--cream); }
.stats-note { font-size: 0.74rem; color: var(--mute); }

.stats-hero { padding: 12px; border: 1px solid var(--line); border-left: 5px solid var(--mute); background: var(--slab-deep); }
.stats-hero-rate { font-size: 2.5rem; font-weight: 700; line-height: 1; color: var(--stock); font-variant-numeric: tabular-nums; }
.stats-hero-sub { margin-top: 4px; font-size: 0.92rem; }
.stats-hero-gap { margin-top: 2px; font-size: 0.92rem; font-weight: 700; }
.stats-hero-call { margin-top: 8px; font-size: 0.8rem; color: var(--mute); }
.stats-above { border-left-color: var(--green); }
.stats-above .stats-hero-rate, .stats-above .stats-hero-gap { color: var(--green); }
.stats-below { border-left-color: var(--red); }
.stats-below .stats-hero-rate, .stats-below .stats-hero-gap { color: var(--red); }
.stats-unclear { border-left-color: var(--gold-400); }
.stats-unclear .stats-hero-gap { color: var(--gold-400); }

.board { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); background: var(--slab-deep); }
.board-row { display: grid; grid-template-columns: 1fr auto 58px; gap: 3px 10px; align-items: baseline; padding: 7px 10px 9px; font-size: 0.9rem; }
.board-row + .board-row { border-top: 1px solid var(--line-soft); }
.board-name { font-weight: 600; color: var(--stock); }
.board-count { color: var(--mute); font-variant-numeric: tabular-nums; }
.board-rate { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.board-you { background: linear-gradient(168deg, #40206a, #24123a); }
.board-you .board-name { color: var(--gold-200); }
.bar { position: relative; grid-column: 1 / -1; height: 6px; background: rgba(240, 220, 164, 0.12); }
.bar i { display: block; height: 100%; background: var(--red); }
.bar-up i { background: var(--green); }
.bar::after { content: ""; position: absolute; top: -3px; bottom: -3px; left: 71.4%; width: 2px; background: var(--gold-200); }

.facts { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border: 1px solid var(--line); background: var(--slab-deep); }
.fact { padding: 7px 10px; min-width: 0; border-bottom: 1px solid var(--line-soft); }
.fact:nth-child(odd) { border-right: 1px solid var(--line-soft); }
.fact dt { font-family: var(--display); font-size: 0.46rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-200); }
.fact dd { margin: 2px 0 0; font-size: 0.94rem; font-weight: 600; color: var(--stock); }


/* ---------------- rules, footer ---------------- */

.rules-body { font-size: 0.88rem; color: var(--cream); }
.rules-body strong { color: var(--gold-200); }
.rules-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.rules-table th, .rules-table td { padding: 5px 6px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.rules-table th { font-family: var(--display); font-size: 0.48rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-200); }
.rules-table td:nth-child(2) { color: var(--gold-400); font-weight: 700; white-space: nowrap; }

/* Exactly as tall as a drawer handle, which sits over it when a drawer is slid away. */
.site-footer { display: flex; align-items: center; justify-content: space-between; height: 46px; font-size: 0.78rem; color: var(--ink-soft); }
.site-footer a { color: inherit; text-underline-offset: 3px; }
.site-footer a:hover { color: var(--purple-900); }

/* ---------------- modals (install prompt, stats) ---------------- */

.modal-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: end center; padding: 16px; background: rgba(12, 10, 9, 0.72); }
.modal { width: min(100%, 420px); padding: 18px; border: 1px solid rgba(240, 220, 164, 0.4); background: linear-gradient(180deg, #302c29, #1a1816); box-shadow: 0 36px 70px -20px #000; outline: none; }
.modal-title { margin: 0 0 8px; font-family: var(--display); font-size: 0.86rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold-200); }
.modal-body { margin: 0 0 16px; font-size: 0.92rem; color: var(--cream); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }


/* ---------------- the three porter stands ---------------- */

/* The middle of the screen, and the point of it. Takes whatever height the rest
   leaves over. Each stand is a pillar: a header with the running total, a well
   the cubes stack up inside, and a coloured base plate. */
/* The pillars are sized so the porter and his plate always clear the open
   drawer: the log below takes whatever is left, and the drawer covers that. */
.shell > .stands-wrap { position: relative; flex: 0 1 auto; height: min(430px, 37dvh); min-height: 206px; display: flex; }
.stands { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; min-height: 0; }

.stand { position: relative; display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--line); background: var(--slab-bg); box-shadow: var(--shadow-slab); transition: border-color 0.25s ease, box-shadow 0.25s ease; }
.stand-head { flex: none; padding: 5px 6px 4px; text-align: center; border-bottom: 1px solid var(--line-soft); }
.stand-name { font-family: var(--display); font-size: 0.46rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; }
/* No running total, no headroom meter, no warning colour. The cubes on the
   plate are the only record of what a stand holds, and adding them up is the
   player's job — the same job everyone at the table has. */

/* Cubes stack from the bottom up. The well scrolls if a stand gets very tall,
   but at 13 with cards 0-6 it rarely needs to. */
/* Cubes sit on the plate two to a row, stacking upward. Rows shrink to fit
   rather than scroll, so a loaded plate is always visible in one piece. */
.stand-well { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-height: 0; padding: 6px 4px 0; overflow: hidden; }
.stand-row { flex: 0 1 auto; display: flex; justify-content: center; gap: 3px; height: 26px; min-height: 12px; }
/* A row always holds two slots so the pair sits centred on the plate. A row
   with one cube keeps an invisible slot beside it, so the cube sits in the
   left-hand place rather than drifting to the middle. */
.cube-gap { flex: 0 0 auto; height: 100%; aspect-ratio: 1; visibility: hidden; }
/* Round banner: a purple band that sweeps across the stands when a round opens.
   It MUST stay absolutely positioned — in flow it becomes a flex sibling of the
   columns and squeezes them to half width. */
.round-banner { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; overflow: hidden; pointer-events: none; }
.rb-card { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 100%; padding: 12px 10px 13px; border: solid var(--gold-400); border-width: 2px 0; background: linear-gradient(180deg, rgba(95, 42, 148, 0.96), rgba(45, 18, 69, 0.97)); box-shadow: 0 18px 40px -10px #000, inset 0 1px 0 rgba(240, 220, 164, 0.25); animation: rb-sweep 2s both; }
.rb-round { font-family: var(--display); font-size: 1.35rem; font-weight: 700; letter-spacing: 0.22em; line-height: 1.1; text-transform: uppercase; color: var(--gold-200); text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); animation: rb-track 2s both; }
.rb-who { font-size: 0.95rem; font-weight: 600; text-align: center; color: var(--cream); }
.rb-you .rb-who { color: var(--gold-400); font-weight: 700; }
@keyframes rb-sweep {
  0% { transform: translateX(-112%) skewX(-14deg); opacity: 0; animation-timing-function: cubic-bezier(0.16, 0.84, 0.3, 1); }
  16% { transform: translateX(0) skewX(0); opacity: 1; }
  80% { transform: translateX(0) skewX(0); opacity: 1; animation-timing-function: cubic-bezier(0.7, 0, 0.84, 0.3); }
  100% { transform: translateX(112%) skewX(-14deg); opacity: 0; }
}
/* The round number eases its letters apart while the band holds. */
@keyframes rb-track { 0%, 16% { letter-spacing: 0.08em; } 80%, 100% { letter-spacing: 0.3em; } }
@keyframes rb-fade { 0%, 100% { opacity: 0; } 15%, 80% { opacity: 1; } }

/* The porter: a kneeling titan holding the plate the cubes stack on, after the
   Farnese Atlas. Marble, lit from above left, with a rim in the stand's colour. */
.atlas { flex: none; display: block; width: 100%; max-height: 104px; margin-top: -2px; filter: drop-shadow(0 -2px 6px rgba(0, 0, 0, 0.6)); }
.atlas-plate path { fill: var(--tone-deep); }
.atlas-plate .atlas-plate-under { fill: rgba(0, 0, 0, 0.55); }
.atlas-plate .atlas-plate-lip { fill: var(--tone); }
.atlas-lit { fill: #cfcabf; }
.atlas-dark { fill: #948d81; }
.atlas-ground { fill: #6b655c; }
.atlas-body { filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.12)); }
/* The plate keeps its own colour always; only the stand being placed on is lit. */
.stand-target .atlas { filter: drop-shadow(0 -2px 10px rgba(240, 220, 164, 0.55)); }
.stand-bust .atlas-body { animation: atlas-buckle 0.5s var(--ease) both; }
@keyframes atlas-buckle { 0%, 100% { transform: translateY(0); } 35% { transform: translateY(5px) scaleY(0.94); } }

/* A cube. Its number is the weight; its tint is its owner. */
.cube {
  flex: none;
  position: relative;
  display: grid;
  place-items: center;
  /* A real cube: square, so it shrinks in both directions as rows compress. */
  flex: 0 0 auto;
  height: 100%;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid rgba(0, 0, 0, 0.55);
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  color: #1d1608;
  background: linear-gradient(165deg, #cac4b9 0%, #b0a99e 46%, #8e887e 100%);
  /* A lit top edge and a dark foot: the bevel is what makes it read as solid. */
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    inset 0 -2px 0 rgba(0, 0, 0, 0.3),
    inset 2px 0 0 rgba(255, 255, 255, 0.14),
    0 2px 4px -1px rgba(0, 0, 0, 0.75);
}
/* Only the cube just placed moves: it falls from above the plate, picking up
   speed, and settles with a short squash. Everything already down stays put. */
.cube-new { animation-name: cube-land; animation-timing-function: linear; animation-fill-mode: both; }
@keyframes cube-land {
  0% { transform: translateY(-190px); opacity: 0; animation-timing-function: ease-in; }
  12% { opacity: 1; }
  68% { transform: translateY(0); animation-timing-function: ease-out; }
  80% { transform: translateY(0) scale(1.1, 0.82); }
  90% { transform: translateY(0) scale(0.97, 1.05); }
  100% { transform: translateY(0) scale(1, 1); }
}

/* The base cube left behind by a bust. */
.cube-base { outline: 1px dashed var(--red); outline-offset: 2px; }

/* The stand being placed on right now. */
.stand-target { border-color: var(--gold-400); box-shadow: 0 0 0 1px var(--gold-600), 0 10px 24px -14px #000; }
.stand-choice { cursor: pointer; }
.stand-choice:hover, .stand-choice:focus-visible { border-color: var(--gold-200); outline: none; box-shadow: 0 0 0 2px var(--gold-400); }

/* Bust: the stack flashes and the cleared cubes fall away. */
.stand-bust { animation: stand-shake 0.5s var(--ease) both; border-color: var(--red) !important; box-shadow: 0 0 0 2px var(--red-deep), 0 0 26px -4px rgba(229, 89, 74, 0.7) !important; }
@keyframes stand-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.cube-clearing { animation: cube-fall 0.45s cubic-bezier(0.5, 0, 0.9, 0.4) both; }
@keyframes cube-fall { to { transform: translateY(70px) rotate(14deg); opacity: 0; } }

/* The penalty number that flies off a busted stand. */
.burn { position: absolute; left: 50%; top: 34%; z-index: 6; transform: translateX(-50%); font-family: var(--display); font-size: 1.7rem; font-weight: 700; color: var(--red); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9); pointer-events: none; animation: burn-up 1.1s var(--ease) both; }
@keyframes burn-up { 0% { transform: translate(-50%, 14px) scale(0.6); opacity: 0; } 25% { transform: translate(-50%, 0) scale(1.15); opacity: 1; } 75% { opacity: 1; } 100% { transform: translate(-50%, -34px) scale(1); opacity: 0; } }

/* Stand colours. These three are the game's furniture, so they override the
   usual purple-only rule for game pieces. */
.stand-red { --tone: var(--red); --tone-deep: var(--red-deep); --tone-dim: var(--red-dim); }
.stand-green { --tone: var(--green); --tone-deep: var(--green-deep); --tone-dim: var(--green-dim); }
.stand-blue { --tone: #5a8fd6; --tone-deep: #23508f; --tone-dim: #16263f; }
.stand .stand-name { color: var(--tone); }
.stand { border-top: 2px solid var(--tone-deep); }

/* A colour named in prose is printed in that colour, so a sentence about the
   blue stand cannot be misread as being about the blue chip. */
.tone { font-weight: 700; }
.tone-red { color: var(--red); }
.tone-green { color: var(--green); }
.tone-blue { color: #6f9fe0; }
/* The rainbow chip is named in every colour it stands for. Gold is the fallback
   wherever background-clip: text is unavailable, so the word never goes blank. */
.tone-rainbow { color: var(--gold-200); }
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  .tone-rainbow {
    background-image: linear-gradient(92deg, var(--red) 4%, var(--gold-400) 32%, var(--green) 62%, #6f9fe0 92%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
}

/* ---------------- seat rail ---------------- */

.shell > .rail-wrap { flex: none; }
.rail { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); background: var(--slab-deep); }
.seat { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 1px 4px; min-width: 0; transition: background 0.25s ease; }
.seat + .seat { border-left: 1px solid var(--line-soft); }
.seat-id { font-family: var(--display); font-size: 0.5rem; font-weight: 700; letter-spacing: 0.08em; color: var(--mute); white-space: nowrap; }
.seat-pen { font-size: 1rem; font-weight: 700; line-height: 1.1; color: var(--stock); font-variant-numeric: tabular-nums; }
.seat-marks { display: flex; gap: 2px; height: 5px; }
.seat-mark { width: 5px; height: 5px; background: transparent; }
.seat-mark-first { background: var(--gold-400); transform: rotate(45deg); }
.seat-mark-pass { background: var(--purple-300); border-radius: 50%; }
.seat-mark-sub { background: var(--green); }

.seat-you { background: linear-gradient(168deg, #40206a, #24123a); }
.seat-you .seat-id { color: var(--gold-200); }
.seat-you .seat-pen { color: var(--gold-400); }
/* The seat on the clock. */
.seat-active { background: rgba(217, 178, 84, 0.16); box-shadow: inset 0 -3px 0 var(--gold-400); }
.seat-active .seat-id { color: var(--gold-200); }
.seat-waiting .seat-pen { opacity: 0.45; }
.seat-burned .seat-pen { animation: pen-hit 0.7s var(--ease) both; color: var(--red); }
@keyframes pen-hit { 0% { transform: scale(1); } 35% { transform: scale(1.5); color: var(--red); } 100% { transform: scale(1); } }

/* What a seat submitted, shown after the reveal. */
/* The revealed submission, laid out as it is on the table: a round colour token
   beside a rectangular rock card. */
.seat-sub { display: flex; align-items: center; justify-content: center; gap: 3px; height: 19px; }
.seat-sub-chip { width: 10px; height: 10px; border: 1px solid rgba(0, 0, 0, 0.5); border-radius: 50%; }
.chip-red { background: var(--red); }
.chip-green { background: var(--green); }
.chip-blue { background: #5a8fd6; }
/* The rainbow must be unmistakable at 10px, where a smooth gradient reads as a
   muddy blue square. So: a circle, not a square, with hard quarter stops and a
   gold ring. Shape alone tells it apart from the three colours. */
.chip-rainbow {
  border-radius: 50%;
  background: conic-gradient(var(--red) 0deg 90deg, var(--green) 90deg 180deg, #5a8fd6 180deg 270deg, var(--gold-200) 270deg 360deg);
  box-shadow: 0 0 0 1px var(--gold-200);
}
.seat-sub-chip.chip-rainbow { border-color: var(--gold-200); }
/* A miniature of the rock card in your hand, same stock and same proportions. */
.seat-sub-card {
  display: grid;
  place-items: center;
  width: 14px;
  height: 19px;
  border: 1px solid var(--purple-700);
  border-radius: 2px;
  background: linear-gradient(170deg, #efe9dd, #cfc5b4);
  font-family: var(--display);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  color: #2d1245;
}
.seat-sub-hidden { width: 14px; height: 19px; border: 1px dashed var(--mute); border-radius: 2px; }

/* Where this seat places in the round. */
.seat-order { height: 11px; font-family: var(--display); font-size: 0.44rem; font-weight: 700; letter-spacing: 0.08em; color: var(--mute); }
.seat-order-done { color: var(--ink-faint); text-decoration: line-through; }
.seat-order-now { color: var(--gold-200); }

/* ---------------- your hand ---------------- */

.hand-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-family: var(--display); font-size: 0.46rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-200); }
.hand-label span { font-family: var(--body); font-size: 0.74rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--mute); }

.cards { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.card {
  display: grid;
  place-items: center;
  min-width: 0;
  /* A real card: portrait, rounded, with an inner hairline for the border print. */
  aspect-ratio: 5 / 7;
  min-height: 54px;
  padding: 0;
  border: 1px solid var(--purple-700);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(45, 18, 69, 0.18), 0 2px 5px -2px rgba(0, 0, 0, 0.8);
  background: linear-gradient(170deg, #efe9dd, #cfc5b4);
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0;
  color: #2d1245;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 0.16s var(--ease-snap), box-shadow 0.2s ease, filter 0.2s ease;
}
.card:hover:not(:disabled) { transform: translateY(-3px); }
.card[aria-pressed="true"] { border-color: var(--gold-200); background: linear-gradient(170deg, var(--gold-200), var(--gold-500)); box-shadow: inset 0 0 0 1px rgba(45, 18, 69, 0.25), 0 0 0 2px var(--gold-400), 0 8px 16px -8px #000; transform: translateY(-5px); }
.card:disabled { opacity: 0.22; cursor: not-allowed; transform: none; }
.card:focus-visible { outline: 2px solid var(--gold-200); outline-offset: 2px; }

.chips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.chip {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 1px solid rgba(240, 220, 164, 0.3);
  background: var(--slab-deep);
  cursor: pointer;
  transition: transform 0.16s var(--ease-snap), box-shadow 0.2s ease;
}
.chip i { display: block; width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.6); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.chip-rainbow-tile i { border-radius: 50%; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 0 0 1px var(--gold-200); }
.chip:hover:not(:disabled) { transform: translateY(-3px); }
.chip[aria-pressed="true"] { border-color: var(--gold-200); box-shadow: 0 0 0 2px var(--gold-400), 0 8px 16px -8px #000; transform: translateY(-3px); }
.chip:disabled { opacity: 0.22; cursor: not-allowed; transform: none; }
.chip:focus-visible { outline: 2px solid var(--gold-200); outline-offset: 2px; }
.chip b { position: absolute; right: 2px; bottom: 0; font-family: var(--display); font-size: 0.44rem; font-weight: 700; color: var(--gold-400); }

/* Submission countdown. Drains left to right; turns red at the end. */
.clock { display: flex; align-items: center; gap: 8px; }
.clock-bar { flex: 1; height: 5px; background: rgba(240, 220, 164, 0.14); }
.clock-bar i { display: block; height: 100%; background: var(--gold-400); transform-origin: left; transition: background 0.3s ease; }
.clock-low i { background: var(--red); }
.clock-time { font-family: var(--body); font-size: 0.9rem; font-weight: 700; color: var(--cream); font-variant-numeric: tabular-nums; }
.clock-low .clock-time { color: var(--red); }

/* Place / pass row. */
.move-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.stand-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stand-pick .btn { min-height: 50px; }
.stand-pick .btn[data-stand="red"] { border-color: var(--red); color: var(--red); }
.stand-pick .btn[data-stand="green"] { border-color: var(--green); color: var(--green); }
.stand-pick .btn[data-stand="blue"] { border-color: #5a8fd6; color: #5a8fd6; }

/* ---------------- game over board ---------------- */

.board-final { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); background: var(--slab-deep); }
.final-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 7px 10px; font-size: 0.92rem; animation: final-in 0.35s var(--ease) both; }
.final-row + .final-row { border-top: 1px solid var(--line-soft); }
@keyframes final-in { from { transform: translateX(-12px); opacity: 0; } }
.final-place { font-family: var(--display); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; color: var(--gold-400); text-align: right; }
.final-name { min-width: 0; font-weight: 600; color: var(--stock); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.final-name small { display: block; font-size: 0.68rem; font-weight: 400; color: var(--mute); }
.final-name .final-stamp { display: inline-block; margin-top: 2px; }
.final-pen { font-weight: 700; color: var(--cream); font-variant-numeric: tabular-nums; }
.final-pen small { font-size: 0.62rem; font-weight: 400; color: var(--mute); }
.final-you { background: linear-gradient(168deg, #40206a, #24123a); }
.final-you .final-name { color: var(--gold-200); }
.final-first .final-place { color: var(--gold-200); font-size: 0.9rem; }
.final-out { background: rgba(74, 26, 22, 0.5); }
.final-out .final-place, .final-out .final-name, .final-out .final-pen { color: var(--red); }
.final-stamp { font-family: var(--display); font-size: 0.44rem; font-weight: 700; letter-spacing: 0.16em; color: var(--red); white-space: nowrap; }

@media (max-width: 359px) {
  /* Narrowest phones: the title stacks on two lines so the header still fits. */
  .eyebrow { display: none; }
  .wordmark { font-size: 1.1rem; white-space: normal; }
  .shell { padding-left: 12px; padding-right: 12px; }
  .cards, .chips { gap: 3px; }
  .card { font-size: 1.05rem; }
  .chip i { width: 18px; height: 18px; }
}

@media (min-width: 900px) {
  .shell { padding-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .grain, .verdict, .toast-card, .drawer, .sheet, .log .log-latest, .log .log-latest::before,
  .cube-new, .burn, .stand-bust, .cube-clearing, .final-row, .seat-burned .seat-pen, .stand-bust .atlas-body { animation: none; }
  .drawer, .drawer-chev::after, .card, .chip { transition: none; }
  .rb-card { animation-name: rb-fade; }
  .rb-round { animation: none; }
  .toast-bar { display: none; }
  .cube-clearing { opacity: 0; }
}
