/*
 * styles.css — all styling for Wall Go II.
 * Set dressing follows DevilsHeavy13 and DevilsRoulette (themselves after The
 * Devil's Plan): a lit concrete cell wall, dark slabs with a gold hairline,
 * purple furniture, gold for anything you act on, engraved Cinzel caps and
 * Zilla Slab for prose.
 *
 * used_by: index.html
 * related: offline.html (carries its own minimal copy of the palette);
 *          ui.js (builds the SVG board, rail and drawers this styles)
 * rules:
 *   - Mobile-first at ~380px. Every tappable control is at least 44px.
 *   - Colour has one meaning each: gold = you / act now, purple = the furniture
 *     that is not a control (the title ribbon, the band that marks a seat), and
 *     red / yellow / blue are the three players, as on the show. Controls are
 *     dark slabs with a gold hairline, as in DevilsRoulette; the board is a
 *     concrete slab, because it is a physical board.
 *   - The page is exactly one screen tall (.shell is 100dvh) and never scrolls:
 *     the board takes whatever height is left, the log scrolls inside itself.
 *   - .drawer is fixed to the bottom edge and slides up over the board.
 *   - Anything not needed right now is display:none, not greyed out.
 *   - Fonts are local files in fonts/. No url() to another origin, ever.
 * message: --p0, --p1, --p2 and the .cellr / .wall / .counter class names are
 *   read by ui.js and tests/game.spec.js; keep the names.
 * wiki: PRD.md §7
 */
@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 {
  --wall-lit: #a5a39e;
  --wall-mid: #7e7c78;
  --wall-dark: #5a5855;
  --wall-deep: #3e3d3b;

  --ink: #221e1b;
  --ink-soft: #3d3732;
  --ink-faint: #524c46;

  --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-900: #2d1245;
  --purple-700: #4a1d73;
  --purple-600: #5f2a94;
  --purple-500: #7634b4;
  --purple-400: #8a46c9;
  --purple-300: #ad7ae0;
  --purple-100: #e4d4f5;

  --gold-600: #9c7628;
  --gold-500: #c6992f;
  --gold-400: #d9b254;
  --gold-200: #f0dca4;

  /* The three players, in the show's own order, cut deeper than the broadcast's
     studio lighting. One flat colour each: the piece is the colour, and the
     board is the only thing on screen with a material. --deep is for the rail,
     the clock and anything that needs the same colour held back. */
  --p0: #a8332c;
  --p0-deep: #5e1613;
  --p1: #b08528;
  --p1-deep: #5f430d;
  --p2: #2f6396;
  --p2-deep: #15314f;

  /* Territory at game over: a wash, not a piece. Desaturated, so the board
     stays dark and the counters stay the brightest things on it. */
  --t0: #8f3a33;
  --t1: #93762c;
  --t2: #2f5c88;

  /* The board: a poured concrete slab with a steel frame and a brass inlay —
     the floor of the room the game is played in, lighter than the chrome
     around it so the counters and walls sit on top of it, not in it. */
  --board-rim: #4b4845;
  --board-rim-lit: #625e5a;
  --board-rim-dark: #2a2826;
  --board-cell: #8e8b86;
  --board-cell-alt: #86837e;
  --board-line: rgba(28, 24, 21, 0.26);
  --brass: rgba(217, 178, 84, 0.5);

  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --body: "Zilla Slab", Rockwell, Georgia, serif;
  --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);
  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: hidden;
  /* House rule: the sites are played, not read. Dragging across the board or
     the log must never paint a text selection. The exception below matches
     PWATemplate: form fields, and anything marked .selectable, stay selectable. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* The exception: anything the user types into, or any value they would
   reasonably want to copy out, stays selectable. */
input,
textarea,
select,
[contenteditable],
.selectable {
  -webkit-user-select: text;
  user-select: text;
}

.grain {
  /* Only wide enough for the ±4% drift below: a bigger inset overflows the
     page and widens the document. */
  position: fixed;
  inset: -8%;
  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); }
  20% { transform: translate(-4%, 3%); }
  40% { transform: translate(3%, -2%); }
  60% { transform: translate(-2%, -3%); }
  80% { transform: translate(2%, 2%); }
}

/* ---------------- shell ---------------- */

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  gap: 8px;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  margin: 0 auto;
  padding: 10px 12px 0;
}

.masthead { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.brand { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }

/* The purple ribbon with notched ends that every title hangs from. */
.eyebrow {
  display: inline-block;
  margin: 0;
  padding: 3px 12px;
  font-family: var(--display);
  font-size: 0.44rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  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 {
  margin: 0;
  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);
}

/* Hamburger menu. Built from the same parts as the status bar: a dark slab, a
   gold hairline, engraved caps. */
.menu { position: relative; flex: none; }
.menu-btn { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 0; background: var(--slab-bg); box-shadow: var(--shadow-slab); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 0.2s ease; }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: linear-gradient(180deg, #332e2a, #191715); border-color: rgba(240, 220, 164, 0.5); }
.menu-btn:focus-visible, .menu-item:focus-visible { outline: 2px solid var(--gold-200); outline-offset: -3px; }
.menu-bars { position: relative; width: 16px; height: 12px; }
.menu-bars i { position: absolute; left: 0; width: 16px; height: 2px; background: var(--gold-200); border-radius: 1px; transition: transform 0.22s var(--ease), opacity 0.15s ease, top 0.22s var(--ease); }
.menu-bars i:nth-child(1) { top: 0; }
.menu-bars i:nth-child(2) { top: 5px; }
.menu-bars i:nth-child(3) { top: 10px; }
.menu-btn[aria-expanded="true"] .menu-bars i:nth-child(1) { top: 5px; transform: rotate(45deg); }
.menu-btn[aria-expanded="true"] .menu-bars i:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] .menu-bars i:nth-child(3) { top: 5px; transform: rotate(-45deg); }
.menu-panel { position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; width: 212px; display: flex; flex-direction: column; border: 1px solid var(--line); border-top: 2px solid var(--gold-400); background: var(--slab); box-shadow: 0 18px 34px -10px rgba(0, 0, 0, 0.9); animation: sheet-in 0.2s var(--ease) both; }
.menu-panel[hidden] { display: none; }
@keyframes sheet-in { from { transform: translateY(14px); opacity: 0; } }
.menu-item { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 40px; padding: 0 12px 0 26px; border: 0; background: none; font-family: var(--display); font-size: 0.58rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; text-decoration: none; color: var(--gold-200); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 0.18s ease, color 0.18s ease; }
.menu-item::before { content: ''; position: absolute; left: 11px; top: 50%; width: 5px; height: 5px; margin-top: -3px; background: var(--gold-400); transform: rotate(45deg); opacity: 0.55; transition: opacity 0.18s ease; }
.menu-item + .menu-item { border-top: 1px solid var(--line-soft); }
.menu-item:hover, .menu-item:active { background: rgba(240, 220, 164, 0.07); color: var(--stock); }
.menu-item:hover::before, .menu-item:active::before { opacity: 1; }
.tool-label { flex: none; }
.tool-speeds, .tool-levels { display: flex; gap: 4px; font-family: var(--body); letter-spacing: 0; line-height: 1; text-transform: none; }
.tool-speeds i, .tool-levels i { padding: 1px 5px; border: 1px solid var(--line); font-style: normal; font-size: 0.7rem; font-weight: 600; color: var(--mute); }
.tool-levels i { font-size: 0.6rem; padding: 2px 4px; }
.tool-speeds i.on, .tool-levels i.on { color: var(--slab-deep); background: var(--gold-200); border-color: var(--gold-200); }
.menu-more { border-top: 1px solid var(--line); background: rgba(240, 220, 164, 0.04); }
.menu-more::after { content: '↗'; font-size: 0.8rem; letter-spacing: 0; }

/* ---------------- buttons ---------------- */

/* The house button, taken from DevilsRoulette part for part: a dark slab the
   colour of the chrome around it, a gold hairline, and gold light rising off
   its bottom edge — the one thing on it that is lit. Purple is for the
   furniture that is not a control (the ribbon, the bands that mark a seat);
   gold fill is reserved for the one button that moves the game on. */
.btn {
  appearance: none;
  flex: 1 1 auto;
  min-height: 46px;
  min-width: 46px;
  padding: 8px 12px;
  border: 1px solid rgba(240, 220, 164, 0.26);
  border-radius: 2px;
  background: linear-gradient(180deg, #332e2a, #191715);
  box-shadow: inset 0 1px 0 rgba(240, 220, 164, 0.1), inset 0 -14px 20px -16px var(--gold-400), 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); border-color: rgba(240, 220, 164, 0.5); }
.btn:active:not(:disabled) { transform: translateY(0); filter: brightness(0.95); }
.btn: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; color: var(--cream); }
.btn-ghost:hover:not(:disabled) { background: rgba(58, 50, 40, 0.75); border-color: rgba(240, 220, 164, 0.45); filter: none; }
.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; }
/* The armed wall breaker: the one red control on the screen. Scoped to that
   button, so other pressed toggles keep the house gold. */
#breaker-toggle[aria-pressed="true"] { border-color: var(--p0); color: var(--p0); background: linear-gradient(180deg, rgba(156, 42, 33, 0.55), var(--slab-deep)); }
.btn-kind { display: flex; align-items: center; justify-content: center; gap: 7px; }

/* ---------------- status strip ---------------- */

.status { display: grid; grid-template-columns: auto minmax(0, 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); }
.stat-value 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; }

/* ---------------- seat rail ---------------- */

.shell > .rail-wrap { flex: none; min-height: 0; }
/* Before a game is chosen there are no seats; an empty slab is just a line. */
.rail:empty { display: none; }
.rail { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); background: var(--slab-deep); }
.seat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px 8px;
  min-width: 0;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.seat + .seat { border-left: 1px solid var(--line-soft); }
/* The seat's colour is the one piece of player identity the rail carries. */
.seat::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--seat-colour, var(--purple-600)); }
.seat-name { font-family: var(--display); font-size: 0.5rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-pieces { display: flex; align-items: center; gap: 4px; }
.seat[data-you="true"] { background: linear-gradient(168deg, rgba(240, 220, 164, 0.11), rgba(240, 220, 164, 0.015)); }
.seat[data-you="true"] .seat-name { color: var(--gold-200); }
.seat[data-active="true"] { background: rgba(217, 178, 84, 0.16); box-shadow: inset 0 -3px 0 var(--gold-400); }
.seat[data-active="true"] .seat-name { color: var(--gold-200); }
/* The wall breaker is a mason's hammer. Spent, it greys out and stays where it
   was, so the rail always says how many were in the game. */
.seat-breaker { margin-left: auto; display: inline-flex; width: 19px; height: 19px; }
.seat-breaker svg { display: block; width: 100%; height: 100%; }
.hammer-head { fill: var(--gold-200); stroke: rgba(0, 0, 0, 0.55); stroke-width: 0.8; }
.hammer-haft { fill: var(--gold-600); stroke: rgba(0, 0, 0, 0.55); stroke-width: 0.8; }
.seat-breaker[data-spent="true"] { opacity: 0.45; }
.seat-breaker[data-spent="true"] .hammer-head { fill: var(--mute); }
.seat-breaker[data-spent="true"] .hammer-haft { fill: var(--ink-faint); }

.piece {
  display: inline-block;
  width: 13px;
  height: 13px;
  background: var(--seat-colour, var(--cream));
  border: 1px solid rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.piece-round { border-radius: 50%; }
.piece-square { border-radius: 1px; }

/* ---------------- the board ---------------- */

/* With no log under it, the board takes every spare pixel. */
.shell > .board-wrap { flex: 1 1 auto; }
.board-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
}

.board {
  width: 100%;
  max-width: min(100%, 72dvh);
  aspect-ratio: 1;
}
.board svg { display: block; width: 100%; height: 100%; }

.board-rim { fill: url(#rim-grad); stroke: #0b0807; stroke-width: 2; }
/* A brass inlay around the playing field: the one bright line on the board. */
.board-inlay { fill: none; stroke: var(--brass); stroke-width: 1.5; }
.board-vignette { fill: url(#board-vignette); pointer-events: none; }
.cellr { fill: var(--board-cell); }
.cellr.alt { fill: var(--board-cell-alt); }
.grid-line { stroke: var(--board-line); stroke-width: 1.5; stroke-linecap: square; }

/* A wall is a bar in the builder's colour on a dark edge. No bevel, no gloss,
   no shadow: the board carries the material, the pieces carry the colour. */
.wall { pointer-events: none; transform-box: fill-box; transform-origin: center; }
.wall-base { stroke: rgba(14, 11, 9, 0.72); stroke-width: 14; stroke-linecap: butt; }
.wall-cap { stroke: var(--gold-600); stroke-width: 10; stroke-linecap: butt; }
.wall[data-seat="0"] .wall-cap { stroke: var(--p0); }
.wall[data-seat="1"] .wall-cap { stroke: var(--p1); }
.wall[data-seat="2"] .wall-cap { stroke: var(--p2); }
.wall-new { animation: wall-in 0.28s var(--ease) both; }
@keyframes wall-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* A counter is a flat token with a dark edge. */
.counter { transition: transform 0.3s var(--ease); }
.counter-body { stroke: rgba(14, 11, 9, 0.75); stroke-width: 2; }
.counter[data-seat="0"] .counter-body { fill: var(--p0); }
.counter[data-seat="1"] .counter-body { fill: var(--p1); }
.counter[data-seat="2"] .counter-body { fill: var(--p2); }
.counter[data-mine="true"] { cursor: pointer; }
.counter[data-selected="true"] .counter-body { stroke: var(--gold-200); stroke-width: 3; }
.counter-drop { animation: drop-in 0.3s var(--ease) both; }
@keyframes drop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.spot {
  fill: rgba(240, 220, 164, 0.42);
  stroke: var(--gold-200);
  stroke-width: 3;
  cursor: pointer;
}
.spot:hover { fill: rgba(240, 220, 164, 0.66); }
.spot-break { fill: rgba(229, 89, 74, 0.35); stroke: var(--p0); stroke-dasharray: 10 8; }

.wall-spot {
  fill: rgba(240, 220, 164, 0.5);
  stroke: var(--gold-200);
  stroke-width: 2;
  cursor: pointer;
  animation: pulse 1.4s ease-in-out infinite;
}
.wall-spot:hover { fill: var(--gold-200); }
@keyframes pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

/* No fill by default, or a square nobody owns paints itself SVG-default black.
   The wash uses --t*, a lighter tint than the counters, so finished ground is
   plainly ground and not a giant piece. */
.terr { fill: none; opacity: 0; transition: opacity 0.5s var(--ease); }
.terr[data-seat="0"] { fill: var(--t0); }
.terr[data-seat="1"] { fill: var(--t1); }
.terr[data-seat="2"] { fill: var(--t2); }
.board[data-over="true"] .terr { opacity: 0.44; }

/* ---------------- footer ---------------- */

.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); }

/* ---------------- drawers ---------------- */

.drawer {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 460px);
  max-height: 94dvh;
  margin: 0 auto;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(240, 220, 164, 0.4);
  border-width: 0 1px;
  border-top: 2px solid var(--gold-400);
  background: linear-gradient(180deg, #302c29, #1a1816);
  box-shadow: 0 -20px 44px -14px rgba(0, 0, 0, 0.9);
  animation: drawer-in 0.36s var(--ease) backwards;
}
@keyframes drawer-in { from { transform: translateY(100%); } }

/* The prompt is the drawer's own title, set like a drawer handle's. */
.panel-prompt { margin: 0; font-family: var(--display); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-200); }
.panel-note { margin: 0; font-size: 0.86rem; color: var(--cream); }
.panel-row { display: flex; flex-wrap: wrap; gap: 8px; }
/* The pass-and-play gate wears the next player's colour, so the phone reaches
   the right hand before anybody has read the words. */
.panel-handoff { color: var(--seat-colour, var(--gold-200)); font-size: 0.78rem; }

.clock {
  position: relative;
  flex: none;
  height: 5px;
  background: rgba(240, 220, 164, 0.14);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}
.clock-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-500), var(--gold-200));
  transform-origin: left center;
}
.clock[data-low="true"] .clock-fill { background: linear-gradient(90deg, var(--p0-deep), var(--p0)); }

/* mode chooser */
.modes-title { margin: 0; font-family: var(--display); font-size: 0.86rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold-200); }
.modes-note { margin: 0; font-size: 0.82rem; color: var(--mute); }
/* Who fills the other seats — bots or the people around you — chosen before
   the board is. */
.modes-who { display: flex; gap: 8px; }
.btn-who { letter-spacing: 0.12em; font-size: 0.6rem; }

.mode-card {
  display: block;
  width: 100%;
  padding: 11px 13px;
  text-align: left;
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold-400);
  background: var(--slab-deep);
  box-shadow: var(--shadow-slab);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.16s var(--ease-snap);
}
.mode-card:hover { background: linear-gradient(168deg, #332e2a, #191715); border-color: rgba(240, 220, 164, 0.42); transform: translateY(-2px); }
.mode-card:focus-visible { outline: 2px solid var(--gold-200); outline-offset: 2px; }
.mode-card b { display: block; font-family: var(--display); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-200); }
.mode-card span { display: block; margin-top: 4px; font-size: 0.82rem; color: var(--cream); }

/* game over */
.over-title { margin: 0; font-family: var(--display); font-size: clamp(1rem, 6.4vw, 1.5rem); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-200); text-shadow: 0 0 24px rgba(217, 178, 84, 0.3); animation: slam 0.45s var(--ease) both; }
.over-title[data-out="true"] { color: var(--p0); text-shadow: 0 0 24px rgba(229, 89, 74, 0.35); }
@keyframes slam { from { transform: scale(1.25); opacity: 0; } }
.over-rows { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); background: var(--slab-deep); }
.over-row {
  position: relative;
  display: grid;
  grid-template-columns: 2.1rem 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
}
.over-row + .over-row { border-top: 1px solid var(--line-soft); }
.over-row::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--seat-colour, var(--purple-600)); }
.over-row[data-you="true"] { background: linear-gradient(168deg, rgba(240, 220, 164, 0.11), rgba(240, 220, 164, 0.015)); }
.over-place { font-family: var(--display); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; color: var(--gold-400); }
.over-name { font-family: var(--display); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--stock); }
.over-row[data-you="true"] .over-name { color: var(--gold-200); }
.over-score { font-size: 1.1rem; font-weight: 700; color: var(--stock); font-variant-numeric: tabular-nums; }
.over-score small { font-size: 0.5em; font-weight: 600; color: var(--mute); letter-spacing: 0.14em; text-transform: uppercase; }
.over-row[data-out="true"] .over-name::after {
  content: "Eliminated";
  display: block;
  margin-top: 2px;
  font-size: 0.48rem;
  letter-spacing: 0.2em;
  color: var(--p0);
}

/* ---------------- modals ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 9, 8, 0.78);
  animation: fade 0.18s var(--ease) both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 430px);
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 17px;
  background: linear-gradient(180deg, #302c29, #1a1816);
  border: 1px solid rgba(240, 220, 164, 0.4);
  border-top: 2px solid var(--gold-400);
  box-shadow: 0 36px 70px -20px #000;
  outline: none;
  scrollbar-width: thin;
  animation: sheet-in 0.28s var(--ease) both;
}
.modal-title { margin: 0; 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; font-size: 0.92rem; line-height: 1.5; color: var(--cream); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.rules-body { display: flex; flex-direction: column; gap: 10px; font-size: 0.88rem; line-height: 1.45; color: var(--cream); }
.rules-body p { margin: 0; }
.rules-body b, .rules-body strong { color: var(--gold-200); }
.rules-body em { color: var(--stock); font-style: italic; }

.rules-head { margin: 4px 0 -2px; font-family: var(--display); font-size: 0.54rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold-200); }
.rules-note { font-size: 0.78rem; color: var(--mute); }
.rules-out { color: var(--p0) !important; }

.rules-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.rules-steps li { position: relative; padding: 4px 0 4px 26px; counter-increment: step; }
.rules-steps li::before { content: counter(step); position: absolute; left: 0; top: 4px; display: grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--gold-600); background: #191715; font-family: var(--display); font-size: 0.56rem; font-weight: 700; color: var(--gold-200); }

.rules-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; border: 1px solid var(--line); background: var(--slab-deep); }
.rules-table th, .rules-table td { padding: 6px 9px; text-align: left; vertical-align: top; }
.rules-table tr + tr th, .rules-table tr + tr td { border-top: 1px solid var(--line-soft); }
.rules-table th { width: 78px; font-family: var(--display); font-size: 0.5rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-200); white-space: nowrap; }
.rules-table .piece { vertical-align: -1px; margin-right: 4px; --seat-colour: var(--gold-400); }

/* ---------------- stats sheet ---------------- */

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 12px; }
.stats-cell { padding: 6px 8px; background: rgba(0, 0, 0, 0.26); border: 1px solid var(--line-soft); }
.stats-cell span { display: block; font-size: 0.54rem; letter-spacing: 0.13em; text-transform: uppercase; color: var(--mute); }
.stats-cell b { font-family: var(--display); font-size: 1rem; font-weight: 400; color: var(--gold-200); }

.stats-tabs { display: flex; gap: 6px; margin-bottom: 11px; }
.stats-tab {
  flex: 1;
  min-height: 38px;
  font-family: var(--display);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid var(--line-soft);
  cursor: pointer;
}
.stats-tab[aria-selected="true"] { color: var(--gold-200); border-color: var(--gold-400); }

.stats-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.stats-table th, .stats-table td { padding: 4px 6px; text-align: right; border-bottom: 1px solid var(--line-soft); }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.stats-table thead th { font-size: 0.54rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--mute); font-weight: 400; }
.stats-table tr[data-you="true"] td { color: var(--gold-200); }

@media (max-height: 640px) {
  .wordmark { font-size: 1.25rem; }
  .stat-value { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .grain { animation: none; }
}
