/*
 * SameSame's own styles: the page frame, the board and cards, and the
 * settings. Colours come from tokens.css (the Vintage palette's
 * two looks plus the game content: --board, --card-back, --paper, --hint);
 * buttons, inputs, toasts, dialogs and chat chips are ui-kit.css's, with
 * SameSame's few overrides in the "Vintage" section at the end.
 */

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p { margin: 0; }

.app {
  max-width: 1040px;
  margin: 0 auto;
  /* The sides clear a notch in landscape too: the brand mark sits in the top left corner. */
  padding: max(14px, env(safe-area-inset-top)) max(clamp(14px, 4vw, 28px), env(safe-area-inset-right)) 32px
    max(clamp(14px, 4vw, 28px), env(safe-area-inset-left));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
/* As tall as its wordmark on every screen, so the brand mark never moves between them. */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; margin-bottom: 18px; }
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo {
  display: inline-flex; align-items: center; padding: 4px 2px; border: none; background: none; cursor: pointer;
  color: var(--fg); font: 800 26px/1 var(--font-display);
}
.topbar-right { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
/*
 * The nerdynoobs brand mark (§17): the mark and, where it fits, the wordmark, as
 * a link to the portal. Its colours live in the two images; this is only the box.
 */
.brand {
  position: relative; display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 2px;
  border-radius: var(--radius-chip);
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.brand img { display: block; flex-shrink: 0; }
/* "nerdynoobs" shows where the bar has no buttons (Home, the name gate, joining), and beside them from 640px. */
.brand .brand-word { display: none; width: auto; height: 17px; margin-right: 4px; }
.topbar:has(.topbar-right:empty) .brand .brand-word { display: block; }
.brand:active { transform: scale(0.97); }
@media (hover: hover) {
  .brand:hover { background-color: color-mix(in oklab, var(--surface-3) 55%, transparent); }
}
.brand-sep { flex-shrink: 0; width: 1px; height: 18px; background: var(--line-strong); }
/* "How to Play" in the bar: a "?" of icon size below 480px, where the label has no room beside the two marks. */
.how-q { display: none; font-size: 16px; font-weight: 800; }
/* Home's bar is the brand mark alone: the hero's name is the heading, as in Prism and Pentaline. */
body.at-home .logo, body.at-home .brand-sep { display: none; }
main { flex: 1; }

/* ---------- Panels ---------- */
.panel {
  padding: clamp(16px, 4vw, 28px); border: 0; border-radius: var(--radius-card);
  background: var(--surface); box-shadow: var(--shadow-1);
}
.stack { display: flex; flex-direction: column; gap: 18px; }
.stack.tight { gap: 8px; }
.narrow { max-width: 440px; margin: 0 auto; width: 100%; }
main > .panel + .panel, main > .panel + .lobby-actions { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.section-title { font: 700 24px/1.1 var(--font-display); }
/* A panel's own heading (the lobby's Players and Game settings), as in the other games. */
.panel-title { margin: 0; font: 700 18px/1.2 var(--font-display); }
.panel-title:focus { outline: none; }
.panel-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-chip); }
.muted { color: var(--fg-muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Home ---------- */
.hero { text-align: center; margin: 6px 0 22px; }
.hero h1 { font: 800 clamp(36px, 8vw, 60px)/1 var(--font-display); margin-bottom: 14px; }
.hero p { color: var(--fg-muted); font-size: clamp(15px, 3vw, 18px); max-width: 520px; margin: 0 auto; }
.hero p.tagline { font: 700 clamp(19px, 4vw, 24px)/1.2 var(--font-display); color: var(--fg); margin: -4px auto 10px; }
.category-label { font: 700 15px/1.3 var(--font-display); color: var(--fg); margin: 0 0 10px; }
.category-label.sub { font: 600 13px/1.3 var(--font-body); color: var(--fg-muted); margin: 16px 0 8px; }
.home-panel { max-width: 640px; margin: 0 auto 10px; }
.home-how { display: flex; justify-content: center; margin-bottom: 24px; }
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 20px; border-radius: var(--radius-control); background: var(--bg-deep); }
.tab {
  flex: 1; min-height: 2.5rem; padding: 8px 12px; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius-chip); background: transparent;
  color: var(--fg-muted); font: 700 15px/1.2 var(--font-body);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.tab[aria-selected="true"] { border-color: var(--fg); background: var(--fg); color: var(--surface); }
@media (hover: hover) { .tab[aria-selected="false"]:hover { color: var(--fg); } }
.tab-panel { display: flex; flex-direction: column; gap: 16px; }
.join-row { display: flex; gap: 8px; }
.join-row .input { flex: 1; min-width: 0; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--fg-muted); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.name-error { margin-top: -8px; }
.count-chip { min-width: 3rem; text-align: center; }

/* ---------- Mini cards ---------- */
.mini-card { border-radius: 9px; overflow: hidden; box-shadow: var(--shadow-1); aspect-ratio: 1; background: var(--paper); }
.mini-card svg { display: block; width: 100%; height: 100%; }

/* ---------- Settings ---------- */
.field .field-label { font-size: 14px; }
.field-note { margin: -2px 0 8px; }

.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
/* Picture and label on a barely-there surface; Night adds the quiet control outline. Selected: a navy (Night: cream) fill and a corner tick. */
.deck-tile {
  position: relative; display: flex; flex-direction: column; gap: 7px; align-items: stretch; padding: 7px 7px 9px; cursor: pointer;
  border: 1.5px solid var(--choice-edge); border-radius: var(--radius-control); background: var(--tint);
  color: var(--fg); font: 600 13px/1.2 var(--font-body);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.deck-tile.active { border-color: var(--fg); background: var(--fg); color: var(--surface); font-weight: 800; }
.deck-tile.active::after {
  content: ''; position: absolute; top: 2px; right: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--success) var(--tick-art) center / 64% no-repeat; box-shadow: 0 0 0 2px var(--surface);
}
.deck-art { border-radius: 9px; overflow: hidden; aspect-ratio: 1; box-shadow: 0 0 0 var(--card-edge-w) var(--card-edge); }
.deck-art svg { display: block; width: 100%; height: 100%; }
.deck-name { text-align: left; }

/* The settings' option chips (card difficulty, table size, flip-back time). */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.deck-chip {
  padding: 9.5px 14.5px; cursor: pointer; text-align: left;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface-2);
  color: var(--fg); font: 700 15px/1.25 var(--font-body);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.deck-chip .sub { display: block; font-size: 12px; font-weight: 600; color: var(--fg-muted); }
.deck-chip.active { border-color: var(--fg); background: var(--fg); color: var(--surface); }
.deck-chip.active .sub { color: var(--surface); }
@media (hover: hover) {
  .deck-tile:not(.active):hover, .deck-chip:not(.active):hover { background: var(--hover); }
}
.preview-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 10px; max-width: 420px; }

.toggle {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; cursor: pointer;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface-2);
  color: var(--fg); font: 700 13px/1.2 var(--font-body); white-space: nowrap;
}
/* Off: a hollow track in the control outline with the knob at the left. On: the selection's filled track, knob at the right. */
.toggle .knob {
  position: relative; width: 30px; height: 18px; border-radius: 10px; box-shadow: inset 0 0 0 1.5px var(--line-strong);
  background: var(--surface-3); transition: background-color var(--dur-fast) var(--ease-out);
}
.toggle .knob::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--fg-subtle); transition: transform var(--dur-fast) var(--ease-out);
}
.toggle.on .knob { background: var(--fg); box-shadow: none; }
.toggle.on .knob::after { background: var(--surface); transform: translateX(12px); }

/* ---------- Game layout ---------- */
body.in-game .app { height: 100vh; height: 100dvh; min-height: 0; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
body.in-game .topbar { margin-bottom: 8px; }
body.in-game main { display: flex; flex-direction: column; min-height: 0; }
.game { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 8px; }
.game-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.bar-left, .bar-right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-width: 0; }
.pill { padding: 5px 10px; border: 1px solid transparent; border-radius: var(--radius-pill); background: var(--surface); font-size: 13px; white-space: nowrap; }
.pill b { font: 700 15px/1 var(--font-display); }
.pill.ghost { background: none; border-color: var(--line); color: var(--fg-muted); }
.board-area { flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: center; }
.board-area.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
.board { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; perspective: 1000px; }
.board .card { flex: 0 0 auto; }
/*
 * The scoreboard, the turn line and the board move as one block: the board hangs 8px under the turn
 * line, and the block sits a little above the middle of the height the board leaves over (--spare,
 * from layoutBoard in board.js), so no dead band opens between the turn line and the cards, and the
 * cards sit lower, nearer the thumb. A translate moves them without changing the area layoutBoard
 * measures. A table that scrolls leaves nothing over (0px) and starts at the top.
 */
.game { --lift: calc(var(--spare, 0px) * 0.4); }
.game > .game-bar, .game > .turn-banner, .game > .room-notices, .board-area > .board { translate: 0 var(--lift); }

/* Every player and score stays in view: the chips wrap instead of scrolling off. */
.players { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
.pchip {
  display: flex; align-items: center; gap: 7px; padding: 5px 10px 5px 8px; white-space: nowrap;
  border: 2px solid transparent; border-radius: var(--radius-pill); background: var(--surface);
  font-weight: 700; font-size: 14px;
}
.pchip .sc { padding: 1px 8px; border-radius: var(--radius-pill); background: var(--bg-deep); font-family: var(--font-display); }
/* Whose turn: a filled chip (navy by day, cream by night); the others stay quiet. */
.pchip.turn { border-color: var(--fg); background: var(--fg); color: var(--surface); box-shadow: var(--shadow-1); }
.pchip.turn .sc { background: var(--surface); color: var(--fg); }
.pchip.turn.me .name::after { color: var(--surface); }
.pchip.turn .presence-dot { box-shadow: 0 0 0 1.5px var(--surface); }
.pchip.me .name::after { content: ' (you)'; color: var(--fg-muted); font-weight: 600; font-size: 12px; }
.turn-banner { min-height: 22px; text-align: center; font: 700 17px/1.3 var(--font-display); }
/* Where the focus lands when a game starts: a status line, read out, not a control. */
.turn-banner:focus { outline: none; }
.turn-banner .hl { color: var(--fg); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* ---------- Cards ---------- */
.card {
  position: relative; width: var(--size, 80px); height: var(--size, 80px); container-type: size;
  padding: 0; border: none; background: none; cursor: pointer;
  --r: calc(var(--size, 80px) * 0.12);
}
.card[aria-disabled="true"] { cursor: default; }
.board.locked .card { cursor: default; }
.card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r); }
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.42s cubic-bezier(0.4, 0.6, 0.3, 1.15); }
.card.flipped .card-inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; border-radius: var(--r); backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
/* The printed back (pictures in the Vintage section): a navy ground, a calm two-tone lattice, a cream frame and the red seal with the drawn "SS". Small cards get the simpler print. */
.card-back { background: var(--card-back) var(--card-back-art) center / 100% 100% no-repeat; box-shadow: var(--shadow-1); }
/* Dense tables (8x8 and 10x10: more than 36 cards) and small cards: the calmer print, so a full wall of seals does not speckle. */
.board:has(> .card:nth-child(37)) .card-back { background-image: var(--card-back-art-small); }
@container (max-width: 62px) { .card-back { background-image: var(--card-back-art-small); } }
.card-front { background: var(--paper); transform: rotateY(180deg); box-shadow: var(--shadow-1); }
/* A fine printed edge round the face, so the paper card reads on the cream table (transparent by night). */
.card-front::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 var(--card-edge-w) var(--card-edge);
}
.card-front svg { display: block; width: 100%; height: 100%; }
.card:not([aria-disabled="true"]):not(.flipped):hover .card-inner { transform: translateY(-2px); }
.board.locked .card:not(.flipped):hover .card-inner { transform: none; }
/*
 * Matched: a solid sage frame inside the card (about 3px on a 4x4 phone board, never past its cell)
 * and a sage tick badge on the top-right corner, inside the card so the board edge never clips it.
 * The picture stays at full strength: matched cards no longer fade.
 */
.card.matched .card-front::after { box-shadow: inset 0 0 0 clamp(2px, calc(var(--size, 80px) * 0.036), 4px) var(--success); }
.card.matched::after {
  --t: clamp(15px, calc(var(--size, 80px) * 0.28), 30px);
  content: ''; position: absolute; z-index: 2; top: calc(var(--size, 80px) * 0.035); right: calc(var(--size, 80px) * 0.035);
  width: var(--t); height: var(--t); border-radius: 50%; pointer-events: none;
  background: var(--success) var(--tick-art) center / 66% no-repeat;
  box-shadow: 0 0 0 max(1.5px, calc(var(--t) * 0.08)) var(--paper), 0 1px 3px rgb(11 23 44 / .35);
}
.card.matched .card-inner { animation: pop 0.4s ease; }
@keyframes pop { 45% { transform: rotateY(180deg) scale(1.08); } 100% { transform: rotateY(180deg) scale(1); } }

/* Hint: circle the one region that differs after a near miss */
.hint { position: absolute; inset: 0; pointer-events: none; display: flex; align-items: flex-end; justify-content: center; }
.hint svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
/*
 * The ring has no hue, so it shows on any picture (gold, red, pale paper, dark ink): a cream ring
 * (about 3px on a 4x4 phone board) between two navy keylines of about 1.5px. Two strokes of one
 * ellipse (board.js), widths kept in step with board.js's margin so the card never clips the ring.
 */
.hint svg { animation: hint-pulse 0.9s ease-in-out infinite alternate; }
.hint ellipse { fill: none; vector-effect: non-scaling-stroke; --w: clamp(2px, calc(var(--size, 80px) * 0.035), 3.5px); }
.hint .hint-key { stroke: var(--hint-key); stroke-width: calc(var(--w) + 3px); }
.hint .hint-ring { stroke: var(--hint); stroke-width: var(--w); }
.hint-label {
  margin-bottom: 6%; padding: 1px 6px; border-radius: var(--radius-chip); background: var(--hint);
  color: var(--hint-ink); box-shadow: 0 0 0 1.5px var(--hint-key); font-size: max(9px, calc(var(--size, 80px) * 0.16)); font-weight: 800;
}
@keyframes hint-pulse { from { opacity: 0.75; } to { opacity: 1; } }

/* ---------- Lobby / share ---------- */
.room-code { text-align: center; }
.share-box { display: flex; gap: 10px; align-items: center; }
.share-box .input { flex: 1; min-width: 0; }
.code-big { margin: 2px 0 12px; font: 700 34px/1.1 var(--font-body); letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.seat-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.seat-row {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 8px 6px 12px;
  border: 0; border-radius: var(--radius-control); background: var(--tint);
}
.seat-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.seat-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.seat-remove { margin-left: auto; }
.waiting { margin: 0; text-align: center; color: var(--fg-muted); }
.joining { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.joining-line { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; font-weight: 700; }

/* In game: who is reconnecting or left, and the host's choices. */
.room-notices { display: flex; flex-direction: column; gap: 6px; }
.room-notices:empty { display: none; }
.room-notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 6px 10px;
  border: 0; border-radius: var(--radius-control); background: var(--tint); font-size: 14px;
}
.room-notice-text { flex: 1 1 12rem; }

/* Chat: the rail under the board, the composer, the picker, seat bubbles. */
.chat-bar { display: flex; flex-direction: column; gap: 6px; }
.chat-compose { display: flex; gap: 8px; align-items: center; }
.chat-compose[hidden] { display: none; }
.chat-input { position: relative; flex: 1; min-width: 0; }
.chat-input .input { padding-right: 3rem; }
.chat-count {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none;
  color: var(--fg-subtle); font-size: 12px; font-variant-numeric: tabular-nums;
}
.bubble-layer { position: absolute; inset: 0; pointer-events: none; }
.bubble-layer .seat-bubble { position: absolute; translate: -50% 0; }
.chat-picker { display: flex; flex-direction: column; gap: 14px; }
.picker-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.picker-groups { display: flex; flex-direction: column; gap: 14px; }
.picker-group-name { margin: 0 0 6px; color: var(--fg-muted); font-size: 13px; font-weight: 600; }
.picker-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.howto-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.howto-title { margin: 0; }
.howto-list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding-left: 1.25rem; line-height: 1.45; }
.howto-list b { display: block; }
.howto-list span { color: var(--fg-muted); }

/* ---------- Results ---------- */
.dialog.result { text-align: center; }
.result-list { margin: 8px 0 14px; display: flex; flex-direction: column; gap: 8px; }
/* Plain rows on the dialog with a divider; the winner is a quiet well, bolder, with the sage tick. Not a button. */
.result-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--fg-muted); font-weight: 700; }
.result-row:last-child { border-bottom-color: transparent; }
.result-row.win { border-bottom-color: transparent; border-radius: var(--radius-chip); background: var(--tint); color: var(--fg); font-weight: 800; }
.result-row.win > :first-child { display: inline-flex; align-items: center; gap: 8px; }
.result-row.win > :first-child::before {
  content: ''; flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--success) var(--tick-art) center / 66% no-repeat;
}
.dialog.result .dialog-actions { flex-direction: column; align-items: stretch; }
/* View board and Leave, side by side under Play again and Change settings. */
.result-more { display: flex; gap: 8px; margin-top: 8px; }
.result-more > .btn { flex: 1 1 0; min-width: 0; }
/* The dock's reason for a blocked Play again, on its own line under the buttons. */
.dock-reason { flex-basis: 100%; margin: 0; text-align: start; }

/* "Connection lost. Reconnecting…" across the top; the page makes room for it. */
.conn-banner { position: fixed; inset: 0 0 auto; z-index: var(--z-sticky); }
body:has(.conn-banner) .app { padding-top: calc(max(14px, env(safe-area-inset-top)) + 2.5rem); }

@media (min-width: 640px) {
  .brand .brand-word { display: block; }
}

@media (max-width: 560px) {
  .app { padding-left: 8px; padding-right: 8px; }
  .deck-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  .chips.tiers { display: grid; grid-template-columns: 1fr 1fr; }
  .wide-only { display: none; }
  .game-bar { flex-wrap: nowrap; align-items: flex-start; }
  .bar-left { flex: 1 1 auto; }
  .bar-right { flex-wrap: nowrap; flex-shrink: 0; }
  .pchip { gap: 5px; padding: 3px 8px 3px 6px; font-size: 13px; }
  .logo { font-size: 22px; }
  .pill { padding: 4px 8px; font-size: 12px; }
  .panel { padding: 16px 14px; }
}

@media (max-width: 479px) {
  .how-btn { width: 2rem; padding: 0; }
  .how-btn .how-label { display: none; }
  .how-btn .how-q { display: inline; }
}

/* The narrowest phones: beside the buttons, no hairline, tighter gaps and a smaller wordmark, so the bar's two sides stay clear. */
@media (max-width: 359px) {
  .topbar:not(:has(.topbar-right:empty)) .brand-sep { display: none; }
  .topbar-right { gap: 4px; }
  .logo { font-size: 18px; }
}

/* A finger needs 44px: the kit grows its own controls, these are SameSame's. */
@media (pointer: coarse) {
  .logo, .tab, .toggle, .deck-chip, .topbar { min-height: 2.75rem; }
}

@media (pointer: coarse) and (max-width: 479px) {
  .how-btn { width: 2.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .card-inner, .toggle .knob, .toggle .knob::after, .brand { transition-duration: 1ms; }
  .brand:active { transform: none; }
  .card.matched .card-inner, .hint svg { animation: none; }
}

/* ==========================================================================
 * Vintage Day + Night (2026-11-17). The two looks' own values and the few
 * places where ui-kit.css (shared, untouched) needs SameSame's treatment.
 * tokens.css explains how a look is picked; the switch is public/theme.js.
 * The pictures below need literal hexes, all from the tokens.css ramps:
 * navy-900 #142139, navy-800 #273653, cream-50 #faf5e8, cream-300 #e0d2b2,
 * red-600 #a3302a, navy-950 #0c1a33.
 * ========================================================================== */
:root {
  color-scheme: light;
  --tint: color-mix(in oklab, var(--fg) 5%, var(--surface));     /* barely-there: rows, deck tiles */
  --hover: color-mix(in oklab, var(--fg) 10%, var(--surface));   /* hover on a tint or on paper */
  --choice-edge: transparent;                                    /* deck tiles: no box by day */
  --disabled-fill: var(--surface-3);                             /* a muted well, no outline */
  /* Day back: navy ground, navy-800 lattice, cream frame, the red seal with two drawn S. */
  --card-back-art: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3CclipPath id='f'%3E%3Crect x='12' y='12' width='76' height='76' rx='8'/%3E%3C/clipPath%3E%3C/defs%3E%3Cg clip-path='url(%23f)' stroke='%23273653' stroke-width='4'%3E%3Cpath d='M-50 0L50 100M-25 0L75 100M0 0L100 100M25 0L125 100M50 0L150 100M150 0L50 100M125 0L25 100M100 0L0 100M75 0L-25 100M50 0L-50 100'/%3E%3C/g%3E%3Crect x='8' y='8' width='84' height='84' rx='11' fill='none' stroke='%23faf5e8' stroke-width='3'/%3E%3Ccircle cx='50' cy='50' r='20' fill='%23142139'/%3E%3Ccircle cx='50' cy='50' r='17' fill='%23a3302a' stroke='%23faf5e8' stroke-width='2.4'/%3E%3Cpath d='M48 40a5 5 0 1 0 0 10a5 5 0 1 1 0 10' fill='none' stroke='%23faf5e8' stroke-width='3.4' stroke-linecap='round' transform='translate(-6 0)'/%3E%3Cpath d='M48 40a5 5 0 1 0 0 10a5 5 0 1 1 0 10' fill='none' stroke='%23faf5e8' stroke-width='3.4' stroke-linecap='round' transform='translate(10 0)'/%3E%3C/svg%3E");
  /* Small cards (10x10 and dense tables): no lattice, a thicker frame, a smaller seal. */
  --card-back-art-small: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='9' y='9' width='82' height='82' rx='11' fill='none' stroke='%23faf5e8' stroke-width='4'/%3E%3Cg transform='translate(50 50) scale(0.64) translate(-50 -50)'%3E%3Ccircle cx='50' cy='50' r='20' fill='%23142139'/%3E%3Ccircle cx='50' cy='50' r='17' fill='%23a3302a' stroke='%23faf5e8' stroke-width='2.4'/%3E%3Cpath d='M48 40a5 5 0 1 0 0 10a5 5 0 1 1 0 10' fill='none' stroke='%23faf5e8' stroke-width='3.4' stroke-linecap='round' transform='translate(-6 0)'/%3E%3Cpath d='M48 40a5 5 0 1 0 0 10a5 5 0 1 1 0 10' fill='none' stroke='%23faf5e8' stroke-width='3.4' stroke-linecap='round' transform='translate(10 0)'/%3E%3C/g%3E%3C/svg%3E");
  --tick-art: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5.5 12.5l4.2 4.2L18.5 7.8' fill='none' stroke='%23faf5e8' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:root[data-theme="night"] {
  color-scheme: dark;
  --choice-edge: var(--line-strong);                             /* unselected choices get the quiet outline */
  --disabled-fill: var(--surface-2);
  /* Night back: the same print on a wide cream margin, so a face-down card reads as a card on the navy table. */
  --card-back-art: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' fill='%23e0d2b2'/%3E%3Cdefs%3E%3CclipPath id='f'%3E%3Crect x='8' y='8' width='84' height='84' rx='6'/%3E%3C/clipPath%3E%3C/defs%3E%3Crect x='8' y='8' width='84' height='84' rx='6' fill='%23142139'/%3E%3Cg clip-path='url(%23f)' stroke='%23273653' stroke-width='4'%3E%3Cpath d='M-50 0L50 100M-25 0L75 100M0 0L100 100M25 0L125 100M50 0L150 100M150 0L50 100M125 0L25 100M100 0L0 100M75 0L-25 100M50 0L-50 100'/%3E%3C/g%3E%3Crect x='13.5' y='13.5' width='73' height='73' rx='4' fill='none' stroke='%23e0d2b2' stroke-width='1.6'/%3E%3Ccircle cx='50' cy='50' r='20' fill='%23142139'/%3E%3Ccircle cx='50' cy='50' r='17' fill='%23a3302a' stroke='%23faf5e8' stroke-width='2.4'/%3E%3Cpath d='M48 40a5 5 0 1 0 0 10a5 5 0 1 1 0 10' fill='none' stroke='%23faf5e8' stroke-width='3.4' stroke-linecap='round' transform='translate(-6 0)'/%3E%3Cpath d='M48 40a5 5 0 1 0 0 10a5 5 0 1 1 0 10' fill='none' stroke='%23faf5e8' stroke-width='3.4' stroke-linecap='round' transform='translate(10 0)'/%3E%3C/svg%3E");
  --card-back-art-small: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' fill='%23e0d2b2'/%3E%3Crect x='6' y='6' width='88' height='88' rx='7' fill='%23142139'/%3E%3Cg transform='translate(50 50) scale(0.64) translate(-50 -50)'%3E%3Ccircle cx='50' cy='50' r='20' fill='%23142139'/%3E%3Ccircle cx='50' cy='50' r='17' fill='%23a3302a' stroke='%23faf5e8' stroke-width='2.4'/%3E%3Cpath d='M48 40a5 5 0 1 0 0 10a5 5 0 1 1 0 10' fill='none' stroke='%23faf5e8' stroke-width='3.4' stroke-linecap='round' transform='translate(-6 0)'/%3E%3Cpath d='M48 40a5 5 0 1 0 0 10a5 5 0 1 1 0 10' fill='none' stroke='%23faf5e8' stroke-width='3.4' stroke-linecap='round' transform='translate(10 0)'/%3E%3C/g%3E%3C/svg%3E");
  --tick-art: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5.5 12.5l4.2 4.2L18.5 7.8' fill='none' stroke='%230c1a33' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
html { scrollbar-color: var(--line-strong) var(--bg); }
/* The kit's accent glow and gradient: the table is a flat colour in both looks. */
:where(body) { background-image: none; }

/* The nerdynoobs wordmark follows the look: the ink version on cream, the original on navy. */
/* Specific enough to beat every rule that shows the wordmark (the strongest is .topbar:has(...) .brand .brand-word). */
:root[data-theme="night"] .topbar:has(.topbar-right) .brand img.brand-word-day,
:root:not([data-theme="night"]) .topbar:has(.topbar-right) .brand img.brand-word-night { display: none; }

/* The look switch: one quiet icon button at the far right of the bar. */
.topbar-right { margin-left: auto; }
.theme-btn {
  display: inline-grid; place-items: center; flex-shrink: 0; width: 40px; height: 40px; margin-right: -6px; padding: 0;
  border: 0; border-radius: var(--radius-chip); background: transparent; color: var(--fg-muted); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.theme-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn .theme-moon { fill: currentColor; stroke: none; }
:root[data-theme="night"] .theme-btn .theme-moon, :root:not([data-theme="night"]) .theme-btn .theme-sun { display: none; }
@media (hover: hover) { .theme-btn:hover { background: var(--hover); color: var(--fg); } }
@media (pointer: coarse) { .theme-btn { width: 44px; height: 44px; } }

/* Mini cards and deck pictures on panels: the same edge as a face on the table (a hairline by day, a paper frame by night). */
.mini-card { box-shadow: 0 0 0 var(--card-edge-w) var(--card-edge), var(--shadow-1); }

/* Primary: the red with a soft lift (the kit's highlight is --fg, navy by day); pressing settles it. */
.btn-primary { box-shadow: inset 0 1px 0 rgb(255 255 255 / .16), var(--shadow-1); }
.btn-primary:active:not(:disabled, [aria-disabled="true"]) { box-shadow: none; }
/* Inputs, chips and outlined buttons: one 1.5px control outline. */
.input, .chip, .btn-secondary, .btn-tertiary { border-width: 1.5px; }
/* By day a field is the lightest paper with the outline, so it looks fillable (the kit's --bg well read as disabled). */
:root:not([data-theme="night"]) .input:not(:disabled, [readonly]) { background-color: var(--surface); }
/* Secondary by day: paper with the outline, clearly live (the kit's well read as disabled on cream). */
:root:not([data-theme="night"]) .btn-secondary { background-color: var(--surface); }
@media (hover: hover) {
  :root:not([data-theme="night"]) .btn-secondary:hover:not(:disabled, [aria-disabled="true"]) { background-color: var(--hover); }
  .btn-tertiary:hover:not(:disabled, [aria-disabled="true"]) { background-color: var(--hover); }
}
/* Disabled (Join with no code, Start before everyone is ready): a muted well with a muted label, no outline. */
.btn:not(.btn-ghost):disabled, .btn:not(.btn-ghost)[aria-disabled="true"] {
  border-color: transparent; background-color: var(--disabled-fill); color: var(--fg-subtle); box-shadow: none;
}
/* Placeholders in the muted tone, never mistaken for typed text. */
.input::placeholder { color: var(--fg-subtle); font-weight: 400; }
/* An error: the field's border turns the error colour, 2px. Focused, the ring is the same colour and touches
   the border, so the two read as one thicker ring, not two. */
.input[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.input[aria-invalid="true"]:focus-visible { border-color: var(--danger); outline: 2px solid var(--danger); outline-offset: 0; }

/* Choices (player count, chat picker): unselected has the control outline, selected is the navy (Night: cream) fill. */
.count-chip { border-color: var(--line-strong); }
.chip.is-active, .chip[aria-pressed="true"], .chip[aria-checked="true"] { border-color: var(--fg); background-color: var(--fg); color: var(--surface); }
.segmented { background-color: var(--bg-deep); }
.segmented-option[aria-pressed="true"] { background-color: var(--fg); color: var(--surface); }

/* Dialog and toasts float on their shadow, not an outline; a toast by day is paper. */
.dialog { border-color: transparent; }
/* A toast floats over anything: a quiet visible edge as well as its shadow; by day it is paper. */
.toast { border-color: var(--line-strong); }
:root:not([data-theme="night"]) .toast { background-color: var(--surface); }
.toast-error { border-color: var(--danger); border-width: 2px; }
.dialog-icon { background-color: var(--surface-3); color: var(--fg); }
/* How to Play's Close and the end screen's Leave: real (outlined) buttons, so the end screen has two lower styles. */
.howto-head .btn-ghost, .result-more .btn-ghost { border: 1.5px solid var(--line-strong); color: var(--fg); }
/* Below 380px the lobby's and the game's bars have no room for the switch beside How to Play and Leave
   (the "SameSame" name would run under them): there it shows on Home only. */
@media (max-width: 379px) { body:not(.at-home) .theme-btn { display: none; } }

/*
 * One visible height in the game and lobby bars (36px): Leave, the look switch, the speaker, "?",
 * the Hints pill and the player chips. Touch targets stay 44px through an invisible hit area.
 */
.topbar-right .btn, .theme-btn, .game-bar .toggle, .pchip { position: relative; min-height: 36px; height: 36px; }
.topbar-right .btn-icon, .how-btn, .theme-btn { width: 36px; }
.topbar-right .btn:not(.btn-icon):not(.how-btn) { width: auto; }
.game-bar .toggle { padding-block: 0; }
@media (pointer: coarse) {
  .topbar-right .btn, .theme-btn, .game-bar .toggle { min-height: 36px; height: 36px; }
  .topbar-right .btn-icon, .how-btn, .theme-btn { width: 36px; }
  .topbar-right .btn::after, .theme-btn::after, .game-bar .toggle::after {
    content: ''; position: absolute; top: 50%; left: 50%; min-width: 44px; min-height: 44px; width: 100%; height: 100%; translate: -50% -50%;
  }
}
@media (min-width: 480px) { .how-btn { width: auto; } }

/* Windows high contrast: shadows and fills vanish, so matched cards, the hint ring, selections and the turn chip get real outlines. */
@media (forced-colors: active) {
  .card.matched .card-front { outline: 4px solid Highlight; outline-offset: -4px; }
  .card.matched::after { forced-color-adjust: none; background-color: Highlight; }
  .hint ellipse { stroke: CanvasText; }
  .hint .hint-ring { stroke: Highlight; }
  .deck-tile.active, .deck-chip.active, .tab[aria-selected="true"], .segmented-option[aria-pressed="true"],
  .chip[aria-pressed="true"], .chip[aria-checked="true"], .chip.is-active, .pchip.turn, .toggle.on {
    outline: 3px solid Highlight; outline-offset: 1px;
  }
  /*
   * The card back is printed artwork drawn as a navy ground plus a data-URL picture: forced colours would
   * repaint the ground as Canvas and leave the lattice floating on white. Keep the print as it is (the
   * one place forced-color-adjust is off) and give every card a system-colour edge.
   */
  .card-back { forced-color-adjust: none; outline: 2px solid CanvasText; outline-offset: -2px; }
  /* A face-up card: a thin edge; a matched one keeps the thicker Highlight frame above. */
  .card-front { outline: 2px solid CanvasText; outline-offset: -2px; }
  /* The winner's row loses its tinted well: a Highlight frame instead. */
  .result-row.win { outline: 2px solid Highlight; }
  .result-row.win > :first-child::before { forced-color-adjust: none; background-color: Highlight; }
  /* The Hints switch: its track and knob are fills, which forced colours erase. Draw them in system colours. */
  .toggle .knob { forced-color-adjust: none; background: Canvas; box-shadow: none; border: 1.5px solid ButtonText; }
  .toggle .knob::after { background: ButtonText; top: 1.5px; left: 1.5px; }
  .toggle.on .knob { background: Highlight; border-color: Highlight; }
  .toggle.on .knob::after { background: HighlightText; }
}
