/* Shared design tokens and base styles. Matches mockups/screens.html: one dark look built for TV readability.
   These are the Night theme; [data-swatch] previews a theme's colours inside a theme picker.
   The one bold thing in the design is the letter tiles (and the mascot standing on them). Everything
   around them stays quiet: flat panels, few outlines, short sentence-case labels, drawn icons (no emoji). */
:root, [data-swatch="night"] {
  --ground: #0A0F1F; --screen: #10162B; --panel: #172042; --panel-hi: #222C55; --line: #34406C;
  --ink: #EEF1FA; --muted: #98A4C6; --tile: #F4F6FB; --tile-edge: #8C98BA;
  --gold: #F5B83D; --gold-edge: #B9821A; --good: #3DD6B0; --bad: #FF7A6B; --bad-edge: #B3473B;
  --info: #6FA8FF; /* a dead end in the Daily result */
  --chart-a: #B9821A; --chart-b: #5A8FE6; /* chart series on the stats page, checked for colour-blind readers */
  --player: #141B38; --chain: #C9D1E8; --overlay: rgb(10 15 31 / 0.86);
  --on-accent: #10162B; /* text on gold, red and white tiles */
  /* Roles that differ on a light theme: gold as text, highlight rings, the focus ring, a lost heart. */
  --accent-ink: var(--gold); --ring: var(--gold); --focus: var(--gold); --heart-lost: var(--line);
  --display: 'Bricolage Grotesque', Georgia, serif; --body: Figtree, system-ui, sans-serif;
  --radius: 16px; --radius-sm: 12px;
  color-scheme: dark;
}
/* Themes (server/themes.js). The host picks one for the room; TV and phones follow. All are dark, so
   gold text and white tiles keep their contrast. Paid themes (Party Pack, PLAN.md section 8) go here too. */
:root[data-theme="forest"], [data-swatch="forest"] {
  --ground: #08140F; --screen: #0E1D16; --panel: #15291F; --panel-hi: #1F3A2C; --line: #33573F;
  --ink: #ECF5EF; --muted: #9DBBA8; --tile-edge: #86A592; --player: #11231A; --chain: #CBE0D2; --overlay: rgb(8 20 15 / 0.86);
}
:root[data-theme="berry"], [data-swatch="berry"] {
  --ground: #140A1A; --screen: #1C0F25; --panel: #2A1736; --panel-hi: #3A2149; --line: #573469;
  --ink: #F6EEF9; --muted: #BFA3CC; --tile-edge: #A68BB3; --player: #22122C; --chain: #E2CFEA; --overlay: rgb(20 10 26 / 0.86);
}
/* Sketchbook: paper and ink, to match the mascot's hand-drawn style. The light theme, so gold is only
   used as a fill; gold text and rings use darker amber (all text checked for WCAG AA contrast). */
:root[data-theme="sketchbook"], [data-swatch="sketchbook"] {
  --ground: #FAF6EC; --screen: #FFFDF8; --panel: #FFFFFF; --panel-hi: #F3ECDD; --line: #2B2520;
  --ink: #1E1A16; --muted: #675D53; --tile: #FFFFFF; --tile-edge: #2B2520;
  --gold-edge: #2B2520; --good: #17805E; --bad: #C23B2A; --bad-edge: #2B2520; --info: #2F6FD0;
  --player: #FFFFFF; --chain: #3A332D; --overlay: rgb(250 246 236 / 0.94); --on-accent: #1E1A16;
  --accent-ink: #8A5100; --ring: #B87400; --focus: #1E1A16; --heart-lost: #D8CFC0;
  color-scheme: light;
}
/* On paper, panels and tiles get ink outlines instead of standing out by shade. New panel classes go here. */
:root[data-theme="sketchbook"] :is(.card, .tile, .player, .chip, .meaning, .award, .howto, .notice, .predict-box, .vote-card,
  .seg, .player-admin li, .stat-row div, .standing, .timer, .reaction, .tv .pill, .tv .qr, .way, .mini i, .today, .btn.ghost,
  .pu, .icon-btn, .share-btn, .handoff, .ballot, .mark, .group, .join-group, .group-form, .board-card) {
  outline: 2px solid var(--line); outline-offset: -2px;
}
:root[data-theme="sketchbook"] .dot { box-shadow: 0 0 0 1.5px var(--line); }
:root[data-theme="sketchbook"] .seg label:has(input:checked) { box-shadow: inset 0 0 0 2px var(--line); }
/* Dyslexia-friendly font (public/js/reading.js). Only downloaded when someone turns it on. */
@font-face { font-family: "OpenDyslexic"; src: url("/fonts/OpenDyslexic-Regular.woff2") format("woff2"); font-weight: 100 500; font-display: swap; }
@font-face { font-family: "OpenDyslexic"; src: url("/fonts/OpenDyslexic-Bold.woff2") format("woff2"); font-weight: 600 900; font-display: swap; }
:root.dyslexic { --display: "OpenDyslexic", system-ui, sans-serif; --body: "OpenDyslexic", system-ui, sans-serif; }
/* OpenDyslexic is already spaced out: drop the extra letter spacing used on labels and chains. */
html.dyslexic body { line-height: 1.65; }
html.dyslexic body * { letter-spacing: normal !important; }
/* Its letters are taller and sit lower: size them by their height so they stay inside the tiles. */
html.dyslexic .tile, html.dyslexic .mini i { font-size-adjust: 0.4; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--ground); color: var(--ink); }
body { font-family: var(--body); font-size: 17px; line-height: 1.5; min-height: 100dvh; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); }
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.08; text-wrap: balance; letter-spacing: -0.01em; }
p { text-wrap: pretty; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Icons: public/img/icons.svg, sized to the text around them. */
.icon { width: 1.25em; height: 1.25em; flex-shrink: 0; vertical-align: -0.25em; }

.page { max-width: 680px; margin: 0 auto; padding: 24px 16px 64px; display: flex; flex-direction: column; gap: 14px; }
/* Text pages (privacy, terms, support): the gap does the spacing; headings get a little more room above. */
.page > :is(p, h1, h2, ul, ol) { margin: 0; }
.page > h1 { margin: 16px 0 4px; font-size: 2.2em; }
.page > h2 { margin-top: 18px; font-size: 1.3em; }
.page > p { color: var(--chain); max-width: 38em; }
.page > .logo { font-size: 21px; }
.logo { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: 0.01em; text-decoration: none; color: var(--ink);
  display: inline-flex; align-items: center; gap: 0.4em; white-space: nowrap; }
/* The name as one word, LETTERHOP, with HOP in gold. */
.logo .wordmark { color: var(--ink); }
/* The full logo (home page, TV lobby): the mascot standing on the H of HOP. Small headers use the head. */
/* He's about three letters tall. His feet (y 132 of 140) sit on top of the H: the capital's height (0.66em)
   plus the font's descent (0.29em) above the bottom of the HOP box (measured for Bricolage Grotesque). */
.logo.brand { --mascot-h: 2.2em; padding-top: calc(var(--mascot-h) - 0.05em); }
.logo.brand .hop { position: relative; }
.brand-mascot { position: absolute; left: 0.37em; bottom: calc(0.946em - var(--mascot-h) * 8 / 140); width: calc(var(--mascot-h) * 100 / 140); height: var(--mascot-h);
  transform: translateX(-50%); }
.brand-mascot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.logo span { color: var(--accent-ink); }
/* The mascot's head beside the name (drawn by tools/build-icons.mjs from public/js/mascot.js). */
.logo-mark { width: auto; height: 1.3em; flex-shrink: 0; }

.tiles { display: flex; gap: 10px; flex-wrap: wrap; }
.tile { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 64px; border-radius: 12px;
  font-family: var(--display); font-weight: 800; font-size: 38px; line-height: 1; text-transform: uppercase;
  color: var(--on-accent); background: var(--tile); box-shadow: 0 5px 0 var(--tile-edge); }
/* The changed letter: colour plus underline, so it doesn't rely on colour alone. */
.tile.changed { background: var(--gold); box-shadow: 0 5px 0 var(--gold-edge); text-decoration: underline 4px; text-underline-offset: 6px; }

/* Buttons. Gold with a pressed-tile edge is the main action; there's one per screen. Ghost is everything else. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; padding: 8px 26px; text-align: center;
  border: 0; border-radius: var(--radius); font: 800 20px/1.1 var(--display); text-decoration: none; cursor: pointer;
  background: var(--gold); color: var(--on-accent); box-shadow: 0 5px 0 var(--gold-edge); transition: transform 0.08s, box-shadow 0.08s; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--gold-edge); }
.btn.ghost { background: var(--panel-hi); color: var(--ink); box-shadow: none; }
.btn.ghost:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn .icon { width: 1.1em; height: 1.1em; }
/* A plain text action ("Leave room", "Change players"). */
.link-btn { background: none; border: 0; padding: 10px 2px; color: var(--muted); font: 700 16px var(--body); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--ink); }
/* "Install the app" (public/js/install.js): only shown when the browser offers it. */
.install { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.card { background: var(--panel); border-radius: var(--radius); padding: 18px 20px; }
.status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
.status.on::before { background: var(--good); }
footer { color: var(--muted); font-size: 14px; display: flex; gap: 16px; flex-wrap: wrap; }

/* Small sentence-case headings above a group ("Players", "Level"). */
.label { font-size: 0.85em; font-weight: 700; color: var(--muted); }

/* "1,284 people have played today" on the home page and the Daily Word */
.crowd { margin: 0; color: var(--chain); }
.crowd b { color: var(--accent-ink); }

/* Today's board: how everyone did on today's word, as a small bar chart (home page and Daily intro). */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 44px; }
.spark i { flex: 1; min-width: 4px; height: calc(var(--h) * 100%); min-height: 3px; border-radius: 3px 3px 0 0; background: var(--line); }
.spark i.top { background: var(--gold); }

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