/* Football Brain – mobile-first, accessible by default.
   Themes via [data-theme]; text size via --scale on <html>. */

:root {
  --scale: 100%;
  --bg: #f4f6f2;
  --fg: #14201a;
  --muted: #3f5247;
  --card: #ffffff;
  --line: #cdd6cf;
  --accent: #0b6b3a;
  --accent-fg: #ffffff;
  --gold: #f5c518;
  --gold-fg: #1a1400;
  /* The appearance bonus number: gold on dark themes; gold is too pale on light, so light mode uses the accent green. */
  --bonus-fg: var(--accent);
  --pitch: #17653a;
  --pitch-2: #1b7243;
  --disc: #ffffff;
  --disc-fg: #10201a;
  --danger: #a3221b;
  --ok: #0b6b3a;
  --focus: #0a4fd1;
  --shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
:root[data-theme="dark"] {
  --bg: #0e1612; --fg: #eef4ef; --muted: #b3c3b8; --card: #16211b; --line: #2d3d33;
  --accent: #5fd48f; --accent-fg: #052313; --pitch: #14532d; --pitch-2: #176036;
  --danger: #ff9188; --ok: #7fe3a6; --focus: #ffd54a; --shadow: none; --bonus-fg: var(--gold);
}
:root[data-theme="contrast"] {
  --bg: #000; --fg: #fff; --muted: #fff; --card: #000; --line: #fff;
  --accent: #ffe600; --accent-fg: #000; --gold: #ffe600; --gold-fg: #000;
  --pitch: #000; --pitch-2: #000; --disc: #fff; --disc-fg: #000;
  --danger: #ff7b72; --ok: #6dff9c; --focus: #00e5ff; --shadow: none; --bonus-fg: var(--gold);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #0e1612; --fg: #eef4ef; --muted: #b3c3b8; --card: #16211b; --line: #2d3d33;
    --accent: #5fd48f; --accent-fg: #052313; --pitch: #14532d; --pitch-2: #176036;
    --danger: #ff9188; --ok: #7fe3a6; --focus: #ffd54a; --shadow: none; --bonus-fg: var(--gold);
  }
}

* { box-sizing: border-box; }
html { font-size: var(--scale); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2 { line-height: 1.2; margin: 0; }
button, select { font: inherit; color: inherit; }
/* Fast repeated taps (two backspaces, two hint presses) must not trigger Safari's double-tap zoom.
   "manipulation" still allows scrolling and pinch zoom, so players can zoom in when they need to. */
html, button, summary, a, label, select { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
main:focus { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: .5rem; top: -4rem; z-index: 10; background: var(--accent); color: var(--accent-fg);
  padding: .6rem .9rem; border-radius: .5rem; text-decoration: none;
}
.skip:focus { top: .5rem; }

/* Layout */
.topbar, main { width: min(100%, 32rem); margin-inline: auto; padding-inline: 1rem; }
/* Thin top bar (issue #20): name, settings and the More menu. */
.topbar {
  display: flex; align-items: center; justify-content: space-between; min-height: 2.75rem;
  padding: env(safe-area-inset-top) .25rem 0 .75rem; background: var(--card); border-bottom: 1px solid var(--line);
  /* The bar's background spans the window (issue #27), but its name and buttons stay over the 32rem
     column: the side padding grows by half of whatever width is left over. */
  width: 100%;
  padding-left: calc(max(0px, (100% - 32rem) / 2) + .75rem);
  padding-right: calc(max(0px, (100% - 32rem) / 2) + .25rem);
}
.topbar h1 { font-size: 1.0625rem; letter-spacing: -.01em; }
.top-actions { display: flex; align-items: center; }
.icon-btn, .menu-btn {
  min-width: 2.75rem; height: 2.75rem; border: 0; border-radius: .5rem; background: none; color: var(--fg); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem;
}
.menu-btn { padding: 0 .6rem; font-weight: 700; font-size: .875rem; }
.menu-btn[aria-expanded="true"] { background: var(--bg); }
.icon-btn svg, .menu-btn svg, .btn.icon svg {
  width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round;
}
.menu-btn svg { width: .9rem; height: .9rem; stroke-width: 2.5; transition: transform .15s ease; }
.menu-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
/* Above the menu scrim, so the More button and its menu stay sharp. */
.menu-wrap { position: relative; z-index: 16; }
.menu {
  position: absolute; right: 0; top: calc(100% + .15rem); z-index: 20; min-width: 12.5rem; margin: 0; padding: .25rem; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: .75rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.menu[hidden] { display: none; }
.menu-scrim { position: fixed; inset: 0; z-index: 15; }
.menu-scrim[hidden] { display: none; }
.menu button {
  width: 100%; min-height: 2.75rem; padding: 0 .75rem; border: 0; border-radius: .5rem; background: none;
  text-align: left; font-weight: 600; color: var(--fg); cursor: pointer;
}
.menu button:hover { background: var(--bg); }
.menu button[hidden] { display: none; }
#play [inert] { visibility: hidden; }
#play[hidden], #archive[hidden], #screen-tabs[hidden] { display: none; }
.archive {
  display: block; width: min(100%, 32rem); margin-inline: auto; padding: 1rem;
  overflow-y: auto;
}
.archive h2, .archive h3 { margin-block: 0 .75rem; }
.archive-month { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem; }
.archive-month h3 { margin: 0; text-align: center; }
.archive-month button { min-width: 44px; }
.archive-list { padding: 0; list-style: none; }
.archive-list .btn { display: flex; justify-content: space-between; width: 100%; gap: .75rem; text-align: left; }
.archive-list li + li { margin-top: .4rem; }
.archive-state { color: var(--muted); font-weight: 400; }
.menu-sep { height: 1px; margin: .25rem .5rem; background: var(--line); }
/* Layout areas (issue #18). One block of markup per area, placed by CSS:
   - mobile (default): the status area stays on top, and the found, play and hints screens sit side by
     side in a scroll-snap strip. Swipe right for found names, left for hints, or use the tabs.
   - desktop (64rem and up): three columns, with found names left, status and play centre, and hints right. */
.area-status, .area { display: flex; flex-direction: column; gap: .9rem; }
.area-status { grid-area: status; }
.area-play { grid-area: play; }
.area-found { grid-area: found; }
.area-hints { grid-area: hints; }

/* Mobile shell: the page fills the screen, and each screen scrolls on its own. */
body { display: flex; flex-direction: column; height: 100dvh; }
.topbar { flex: none; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: .6rem; padding-inline: 0; }
.area-status { flex: none; padding-inline: 1rem; gap: .5rem; }
.screens {
  position: relative; flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none;
}
.screens::-webkit-scrollbar { display: none; }
.screens > .area {
  flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always;
  overflow-y: auto; overscroll-behavior-y: contain; padding: .1rem 1rem 1rem;
}
/* Keep each item at its natural height and let the screen scroll instead. Without this the pitch, whose shirts
   are absolutely positioned and give it no content height, shrinks to nothing on short screens. */
.screens > .area > * { flex-shrink: 0; }
/* Found names sits left of play and hints right, while play stays first for screen readers and Tab. */
.screens > .area-found { order: -1; }
.screens > .area-hints { order: 1; }
/* Like the top bar: the background spans the window, and the tabs stay under the 32rem column. */
.screen-tabs {
  flex: none; display: flex; border-top: 1px solid var(--line); background: var(--card); padding-bottom: env(safe-area-inset-bottom);
  padding-inline: max(0px, (100% - 32rem) / 2);
}
.screen-tabs button {
  flex: 1; min-height: 3.25rem; border: 0; border-top: 3px solid transparent; background: none;
  font-weight: 700; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.screen-tabs button[aria-current="true"] { color: var(--fg); border-top-color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.screen-tabs .pill { text-decoration: none; }
body { padding-bottom: 0; }

/* Desktop: three columns that fill the window's height (issue #27). The side columns stay in view and
   scroll on their own, and the pitch grows into the centre column's spare height. */
@media (min-width: 64rem) {
  /* At least the window's height, so main can stretch to fill it. Only a minimum, so a short window
     (or a big zoom) still lets the page scroll rather than squashing the play area. */
  body { height: auto; min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
  /* Three equal columns sized like the mobile screens: 19–32rem each (19rem is the pitch width).
     3 × 19rem + 2 × 2rem gaps + 2rem padding = 63rem, inside the 64rem breakpoint. */
  main { width: min(100%, 100rem); }
  /* The bar spans the window, but its name and buttons line up with the centre column:
     the same width as one grid column below (3 columns, 2 gaps and the side padding share the width). */
  .topbar {
    width: 100%;
    padding-inline: calc((100% - clamp(19rem, (min(100%, 100rem) - 6rem) / 3, 32rem)) / 2);
  }
  main {
    display: grid; gap: .9rem 2rem; padding: 1rem; align-items: stretch;
    grid-template-columns: repeat(3, minmax(19rem, 32rem)); justify-content: center;
    grid-template-rows: auto 1fr;
    grid-template-areas: "found status hints" "found play hints";
  }
  .area-status { padding-inline: 0; gap: .9rem; }
  .screens { display: contents; }
  .screens > .area { padding: 0; overflow: visible; }
  /* contain: size stops a long found list or hints list from making the grid taller: the column takes
     the height the centre column sets and scrolls inside instead. Drawers are only as tall as their
     content, so they grow as names are found or hints unlocked, and the column scrolls once they fill it. */
  .screens > .area-found, .screens > .area-hints {
    position: sticky; top: 1rem; max-height: calc(100dvh - 2rem); overflow-y: auto; contain: size;
  }
  .area-play { justify-content: center; }
  .screen-tabs { display: none; }
}

/* Share the themed scrollbar between the side panels and dialogs. The WebKit rules cover older Safari. */
:is(.screens > .area-found, .screens > .area-hints, dialog) {
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
:is(.screens > .area-found, .screens > .area-hints, dialog)::-webkit-scrollbar { width: .5rem; }
:is(.screens > .area-found, .screens > .area-hints, dialog)::-webkit-scrollbar-track { background: transparent; }
:is(.screens > .area-found, .screens > .area-hints, dialog)::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
:is(.screens > .area-found, .screens > .area-hints, dialog)::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* The pitch grows into the play area's spare height (decision 0027): on desktop, and in a narrow
   window on a computer with a mouse or trackpad, which gets the mobile layout. Phones and tablets
   (touch) keep the fixed phone pitch.
   The pitch box's height is set by the layout, not by its content (container-type: size), so the
   pitch can be sized from it: as wide as the play area allows, or as tall as the box allows, whichever
   is smaller. Never smaller than the phone pitch (19rem), and never wider than 32rem. The shirts and
   letters scale with the pitch. Once the pitch reaches the play area's width the box stops growing
   (max-height, measured against the play area), and the leftover space goes around the play block. */
@media (min-width: 64rem), (hover: hover) and (pointer: fine) {
  .area-play { container-type: inline-size; }
  .pitch-fit {
    flex: 1 1 0; container-type: size; display: flex; flex-direction: column; justify-content: center;
    min-height: calc(19rem * 264 / 310 + .625rem);
    max-height: calc(min(100cqw, 32rem) * 264 / 310 + .625rem);
  }
  /* ".pitch-fit >" outranks the base .pitch rule further down the file. */
  .pitch-fit > .pitch { width: clamp(19rem, min(100cqw, (100cqh - .625rem) * 310 / 264), 32rem); }
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); }
.small { font-size: .85rem; color: var(--muted); margin: .25rem 0; }
.strong { font-weight: 700; color: var(--fg); }

/* Progress card (issue #20), the same on mobile and desktop: one row of rank, breadcrumbs and score,
   then a centred row of daily badges. The top row opens the ranks list and the badge row opens the
   badges list (js/app.js). */
.progress {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .25rem .6rem;
  padding: .375rem .625rem; border-radius: .75rem;
}
.rank-row { display: contents; }
.rank-name, .bar, .score { cursor: pointer; }
/* The rank and, on a practice puzzle, the Practice tag share the first cell (issue #33). */
.rank-cell { grid-column: 1; grid-row: 1; min-width: 0; }
.mode-tag {
  padding: .0625rem .375rem; border: 1px solid var(--muted); border-radius: 99px;
  font-size: .6875rem; font-weight: 700; line-height: 1.3; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  /* Nudge down so the caps sit level with the middle of the rank name beside it. */
  position: relative; top: 1px;
}
.mode-tag[hidden] { display: none; }
.rank-name {
  position: relative; min-height: 1.75rem; display: flex; align-items: center; gap: .375rem;
  background: none; border: 0; padding: 0; font-size: 1.0625rem; line-height: 1.2; font-weight: 700; color: var(--fg);
}
/* Keep a 44px tap area without the extra height showing. */
.rank-name::after { content: ""; position: absolute; inset: -.5rem -.25rem; }
/* Rank breadcrumbs: one segment per rank, filled to --crumb. */
.bar { grid-column: 2; grid-row: 1; }
.crumbs { display: flex; gap: 3px; list-style: none; margin: 0; padding: 0; }
.crumbs li {
  flex: 1; height: .5rem; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent) var(--crumb, 0%), var(--line) var(--crumb, 0%));
}
.score { grid-column: 3; grid-row: 1; font-size: .875rem; color: var(--muted); }
.score strong { font-size: 1.0625rem; color: var(--fg); font-variant-numeric: tabular-nums; }
/* Daily badges share a single tap target across the progress card. */
.badges {
  grid-column: 1 / -1; grid-row: 2; display: flex; justify-content: space-between;
  width: 100%; max-width: 322px; min-height: 46px; margin: 0 auto; padding: 0 4px;
  background: none; border: 0; border-radius: .5rem; color: inherit; font: inherit; cursor: pointer;
}
.badges:empty { display: none; }
.badge-slot {
  --shield-fill: var(--bg); --shield-stroke: var(--accent); --shield-icon: var(--fg);
  display: flex; justify-content: center; align-items: flex-start;
  width: 44px; height: 46px; flex: 0 0 auto;
}
.badge-slot.earned { --shield-fill: var(--gold); --shield-stroke: var(--gold-fg); --shield-icon: var(--gold-fg); }
.badge-slot.lost { --shield-fill: var(--card); --shield-stroke: var(--muted); --shield-icon: var(--muted); }
.badge-shield { position: relative; width: 40px; height: 44px; }
.badge-shield > svg { display: block; }
.shield-outline { fill: var(--shield-fill); stroke: var(--shield-stroke); }
.shield-icon { stroke: var(--shield-icon); }
.badge-chip {
  position: absolute; left: 25px; top: 27px; min-width: 18px; height: 18px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--card); border-radius: 9px;
  background: var(--accent); color: var(--accent-fg); font-size: 10px; font-weight: 900; line-height: 14px;
  font-variant-numeric: tabular-nums;
}
.lost .badge-chip { background: var(--muted); color: var(--card); }

/* Word entry */
.entry { text-align: center; }
.word {
  /* One full line of letters tall even when empty, so the first letter never pushes the pitch down. */
  min-height: calc(1.45em + 3px); line-height: 1.45; font-size: clamp(1.7rem, 8vw, 2.3rem); font-weight: 800; letter-spacing: .06em;
  display: flex; justify-content: center; align-items: center; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; text-transform: uppercase;
  border-bottom: 3px solid var(--line); margin: 0 auto; padding: 0 .5rem; max-width: 100%;
}
.word:empty::before { content: "Type or tap letters"; font-size: 1rem; font-weight: 500; letter-spacing: 0; color: var(--muted); text-transform: none; }
/* Letters shrink by --fit (set by fitWord in js/app.js) so a long name stays on one line. */
.word > span { font-size: calc(var(--fit, 1) * 1em); letter-spacing: .06em; }
.word .c { color: var(--accent); }
:root[data-theme="light"] .word .c, :root[data-theme="system"] .word .c { text-shadow: none; }
.word .c::after { content: ""; }
.word .x { color: var(--danger); text-decoration: line-through; text-decoration-thickness: 3px; }
.word .separator { white-space: pre; }
.caret::after { content: ""; display: inline-block; width: 2px; height: 1.6rem; margin-left: 2px; background: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
/* Above the word; keeps its height when empty so nothing below moves. */
/* Room for two lines (a rejection can carry a second line), so the word and pitch never move. */
.message { min-height: 2.5rem; display: flex; flex-direction: column; justify-content: flex-end; margin: 0; font-size: .875rem; line-height: 1.25rem; font-weight: 600; }
.message.ok { color: var(--ok); }
.message.bad { color: var(--danger); }
.message-detail { display: block; }
.message .link { font: inherit; color: inherit; background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
/* Error messages fade out after a few seconds (js/app.js, say). */
.message { transition: opacity .6s ease; }
.message.fading { opacity: 0; }
/* Gold pill: "Pangram!", a new badge, or every name found. Inline, so its padding never changes the line height,
   and each wrapped line gets its own rounded ends. */
.message .pill { background: var(--gold); color: var(--gold-fg); padding: .1rem .6rem; border-radius: 99px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* Pitch */
/* Shirt letters use one bundled font so every device draws the same shapes (fonts/OFL.txt).
   The file holds only A–Z, "_" and "-". */
@font-face {
  font-family: "Barlow Condensed"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("../fonts/barlow-condensed-800-shirts.woff2") format("woff2");
  unicode-range: U+2D, U+41-5A, U+5F;
}
/* The pitch is the same size on every phone: a 320px phone's width less the screen padding (304px at
   default text size), narrower only where the screen is. On desktop it grows to fill the centre column
   (see the desktop block above, decision 0027). Shirts are as big as fit
   five across with 4px between tap areas and 4px to the edge, since 5-3-2's back five is the widest row.
   --shirt is resolved in each shirt against the pitch container (container query units). js/app.js
   places the shirts from it. */
.pitch {
  --gap: 4px;
  --shirt: calc((100cqw - 6 * var(--gap)) / 5);
  container-type: inline-size;
  position: relative; width: min(100%, 19rem); aspect-ratio: 310 / 264; margin: .25rem auto .375rem; border-radius: 1.25rem;
  background:
    repeating-linear-gradient(var(--pitch) 0 12.5%, var(--pitch-2) 12.5% 25%);
  border: 3px solid rgba(255, 255, 255, .75);
  overflow: hidden;
}
.pitch::before { /* centre circle */
  content: ""; position: absolute; left: 50%; top: 50%; width: 29%; aspect-ratio: 1; transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, .6); border-radius: 50%; pointer-events: none;
}
.pitch::after { /* halfway line */
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 3px; background: rgba(255, 255, 255, .45); pointer-events: none;
}
:root[data-theme="contrast"] .pitch { background: #000; border-color: #fff; }
.shirt {
  -webkit-user-select: none;
  user-select: none;
  position: absolute; z-index: 1; width: 16%; width: var(--shirt); min-width: 44px; min-height: 44px;
  aspect-ratio: 1; border-radius: .4rem; transform: translate(-50%, -50%);
  background: transparent; color: var(--disc-fg); border: 0; padding: 0;
  filter: drop-shadow(0 0 4px rgb(0 0 0 / .65));
  /* Letters are 56% of the shirt: the widest, W, still clears the shirt body. */
  font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 800;
  font-size: 1.5rem; font-size: calc(var(--shirt) * .56); cursor: pointer;
  display: grid; place-items: center;
  transition: transform .12s ease, left .3s ease, top .3s ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.shirt::before {
  content: ""; position: absolute; inset: 2px;
  background: var(--disc);
  clip-path: polygon(29% 8%, 40% 3%, 45% 11%, 55% 11%, 60% 3%, 71% 8%, 100% 27%, 87% 50%, 74% 43%, 74% 96%, 26% 96%, 26% 43%, 13% 50%, 0 27%);
}
/* Barlow's line box sits its capitals a little low; this centres them on the shirt. */
.shirt span { position: relative; margin-top: -.09em; line-height: 1; }
/* The keeper stands 4px above the bottom edge. */
.shirt.goalkeeper { left: 50%; top: calc(100% - var(--gap) - var(--shirt) / 2); color: #fff; }
.shirt.goalkeeper::before { background: #4c3480; }
.shirt.captain { color: var(--gold-fg); }
.shirt.captain::before { background: var(--gold); }
/* Captain's mark: a gold SVG star on a dark disc, sized with the shirt (js/app.js adds it). */
.captain-mark {
  position: absolute; top: 9%; right: 1%; display: grid; place-items: center;
  width: 15px; height: 15px; width: calc(var(--shirt) * .27); height: calc(var(--shirt) * .27);
  border-radius: 50%; background: var(--gold-fg); color: var(--gold);
}
.captain-mark svg { width: 66%; height: 66%; fill: currentColor; }
.shirt:active { transform: translate(-50%, -48%) scale(.94); }
.pitch :focus-visible { outline-color: #fff; outline-offset: 3px; box-shadow: 0 0 0 6px #000; }
@media (forced-colors: active) {
  .shirt { filter: none; }
  .shirt, .shirt.goalkeeper { color: ButtonText; }
  .shirt.captain { color: HighlightText; }
  .shirt::before, .shirt.goalkeeper::before { forced-color-adjust: none; background: ButtonFace; }
  .shirt.captain::before { background: Highlight; }
  .captain-mark { forced-color-adjust: none; background: HighlightText; color: Highlight; }
}

/* Controls */
.controls { display: flex; justify-content: center; gap: .6rem; flex-wrap: wrap; }
.btn {
  min-height: 3rem; min-width: 5.5rem; padding: .5rem 1.1rem; border-radius: 99px; border: 2px solid var(--line);
  background: var(--card); font-weight: 700; cursor: pointer;
}
.btn.icon { min-width: 4rem; padding: .5rem .75rem; display: inline-flex; align-items: center; justify-content: center; color: var(--fg); }
.btn.icon svg { width: 1.4rem; height: 1.4rem; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
/* Give up: low-key until the first tap arms it, then red for the confirming tap. */
.btn.quiet { color: var(--muted); border-color: var(--line); background: none; font-weight: 600; }
.btn.quiet.danger { color: var(--danger); border-color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn:active { transform: scale(.97); }

/* Drawers */
.drawer { padding: 0; }
.drawer summary {
  cursor: pointer; padding: .9rem 1rem; font-weight: 700; min-height: 3rem; list-style-position: inside;
  display: flex; align-items: center; gap: .5rem;
}
.drawer-body { padding: 0 1rem 1rem; }
.pill {
  display: inline-block; text-align: center; font-variant-numeric: tabular-nums;
  background: var(--accent); color: var(--accent-fg); border-radius: 99px;
  padding: .05rem .6rem; font-size: .85rem; font-weight: 700;
}
.pill.soft { background: transparent; color: var(--muted); border: 1px solid var(--line); }
/* Give the desktop heading counts a slight optical adjustment for the system font. */
@media (min-width: 64rem) {
  .drawer summary .pill { padding-inline: calc(.6rem - .5px) calc(.6rem + .5px); }
}
/* Centre digits and capitals on their real height. System fonts leave more room above capitals than
   below, so pill numbers and button labels otherwise sit 1-2px low. Pills get padding back to keep their
   height. Browsers without text-box keep the old spacing. */
@supports (text-box: trim-both cap alphabetic) {
  .pill { text-box: trim-both cap alphabetic; padding-block: .35rem; }
  .btn:not(.icon) { text-box: trim-both cap alphabetic; }
}
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .25rem; }
select { min-height: 2.75rem; border-radius: .6rem; border: 2px solid var(--line); background: var(--card); padding: 0 .6rem; }
.empty { color: var(--muted); margin: .5rem 0 0; }
/* Segmented buttons (found-names sort). */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: .6rem; overflow: hidden; background: var(--card); }
.seg button { min-height: 2.75rem; padding: 0 .8rem; border: 0; background: none; color: var(--muted); font-weight: 700; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.stack { display: flex; flex-direction: column; gap: .6rem; }

.found-list { list-style: none; margin: .25rem 0 0; padding: 0; display: grid; gap: .4rem; }
.found-list button {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  min-height: 2.9rem; padding: .4rem .8rem; border-radius: .7rem; border: 1px solid var(--line); background: var(--bg); cursor: pointer; text-align: left;
}
.found-list .w { font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.found-list .meta { color: var(--muted); font-size: .85rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
/* Keep the bulb and number aligned the same way in both hint counters. */
.hint-count, .dynamic-hint-button {
  display: inline-flex; align-items: center; gap: .12em; line-height: 1; font-variant-numeric: tabular-nums;
}
.hint-count svg, .dynamic-hint-button svg {
  display: block; flex: none; width: 1.15em; height: 1.15em;
  fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round;
}
.found-list .pts { font-weight: 700; color: var(--fg); font-variant-numeric: tabular-nums; }
.badge { background: var(--gold); color: var(--gold-fg); border-radius: 99px; font-size: .6875rem; font-weight: 800; padding: .1rem .5rem; }
@keyframes pop { from { transform: scale(.96); background: var(--gold); } to { transform: none; } }
.found-list li.new button { animation: pop .5s ease; }

/* Hint table */
.table-wrap { overflow-x: auto; }
/* Fixed layout shares the drawer width between columns, so the grid never needs to scroll. */
.hint-table { border-collapse: collapse; width: 100%; table-layout: fixed; font-variant-numeric: tabular-nums; text-align: center; font-size: .875rem; }
.hint-table th, .hint-table td { border: 1px solid var(--line); padding: .35rem .1rem; overflow-wrap: anywhere; }
.hint-table th:first-child, .hint-table th:last-child, .hint-table td:last-child { width: 3.4em; }
.hint-table thead th, .hint-table tbody th { background: var(--bg); }
.hint-table td.zero { color: var(--muted); }
.hint-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.hint-actions[hidden] { display: none; }

.dynamic-hints-list { list-style: none; margin: .25rem 0 0; padding: 0; display: grid; gap: .4rem; }
.dynamic-hints-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem;
  padding: .25rem .5rem .25rem .8rem; border: 1px solid var(--line); border-radius: .7rem; background: var(--bg);
  font-variant-numeric: tabular-nums;
}
.dynamic-hint-clue-column, .dynamic-hint-button-column {
  display: flex; flex-direction: column; justify-content: center;
}
.dynamic-hint-clue-column { gap: .25rem; }
.dynamic-hint-button-column { align-items: flex-end; gap: .25rem; }
.dynamic-hint-button-column:has(> .dynamic-hint-player-count) {
  justify-content: space-between;
}
.dynamic-hint-actions { display: flex; gap: .25rem; }
.dynamic-hint-button, .dynamic-hint-cycle {
  justify-content: center;
  box-sizing: border-box; width: 33px; height: 33px; padding: .2rem; border: 1px solid var(--line); border-radius: .55rem;
  background: var(--card); cursor: pointer;
}
.dynamic-hint-cycle { font-size: 1.25rem; line-height: 1; }
.dynamic-hint-cycle:disabled { opacity: .5; cursor: default; }
.dynamic-hint-button[aria-disabled="true"] { opacity: .65; cursor: default; }
.dynamic-hint-button { gap: 0; }
.dynamic-hint-button > span { margin-inline-start: -2px; }
.dynamic-hint-button[hidden] { display: none; }
/* Points unit in grey, like "pts" in the score; surnames weighted like the found names list. */
.dynamic-hint-unit { color: var(--muted); }
.dynamic-hint-player-count { display: block; color: var(--muted); font-size: .8em; }
.dynamic-hint-surname { font-weight: 800; letter-spacing: .04em; }
/* Revealed rows have no hint button, so keep the height the button gave them. */
.dynamic-hints-list li:has(.dynamic-hint-button[hidden]) { min-height: calc(33px + .5rem + 2px); }
.dynamic-hint-profile:not([hidden]) {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: .25em .35em;
  padding-bottom: .3em;
}
.dynamic-hint-clue-column > .dynamic-hint-profile:not([hidden]) { min-height: 1.5em; }
.dynamic-hint-flag {
  display: inline-block; width: auto; height: 1.24em; aspect-ratio: 4 / 3;
  align-self: center; border-radius: .12em;
}
.dynamic-hint-club {
  padding: .05em .35em; border-radius: .3em;
  font-size: .8em; line-height: 1.25; font-weight: 800;
  background: var(--club-bg, transparent);
  color: var(--club-fg, inherit);
  border-bottom: .2em solid var(--club-accent, var(--line));
}

.dynamic-hint-club:is([data-club="ARS"], [data-club="BAR"], [data-club="BRE"], [data-club="CHA"],
  [data-club="LIV"], [data-club="MID"], [data-club="NFO"], [data-club="SHU"], [data-club="SOU"],
  [data-club="STK"], [data-club="SUN"], [data-club="SWI"]) {
  --club-bg: #b31b2c; --club-fg: #fff; --club-accent: #fff;
}
.dynamic-hint-club:is([data-club="BHA"], [data-club="BIR"], [data-club="BLB"], [data-club="CAR"],
  [data-club="CHE"], [data-club="EVE"], [data-club="HUD"], [data-club="IPS"], [data-club="LEI"],
  [data-club="OLD"], [data-club="POR"], [data-club="QPR"], [data-club="RDG"], [data-club="SHW"],
  [data-club="WIG"]) {
  --club-bg: #174b9c; --club-fg: #fff; --club-accent: #fff;
}
.dynamic-hint-club:is([data-club="AVL"], [data-club="BUR"], [data-club="WHU"]) {
  --club-bg: #782440; --club-fg: #fff; --club-accent: #99cdef;
}
.dynamic-hint-club:is([data-club="BOL"], [data-club="LEE"], [data-club="TOT"], [data-club="WBA"]) {
  --club-bg: #fff; --club-fg: #18264c; --club-accent: #18264c;
}
.dynamic-hint-club[data-club="LEE"] { --club-accent: #f4cc28; }
.dynamic-hint-club:is([data-club="DER"], [data-club="FUL"], [data-club="NEW"], [data-club="SWA"]) {
  --club-bg: #fff; --club-fg: #222; --club-accent: #222;
}
.dynamic-hint-club:is([data-club="BLP"], [data-club="LUT"]) {
  --club-bg: #ff851e; --club-fg: #222; --club-accent: #fff;
}
.dynamic-hint-club:is([data-club="COV"], [data-club="MCI"]) {
  --club-bg: #95cef2; --club-fg: #162d48; --club-accent: #fff;
}
.dynamic-hint-club:is([data-club="HUL"], [data-club="WAT"], [data-club="WOL"]) {
  --club-bg: #f4b426; --club-fg: #222; --club-accent: #222;
}
.dynamic-hint-club:is([data-club="BOU"], [data-club="MUN"]) {
  --club-bg: #b31b2c; --club-fg: #fff; --club-accent: #222;
}
.dynamic-hint-club[data-club="BRA"] { --club-bg: #782440; --club-fg: #fff; --club-accent: #f4b426; }
.dynamic-hint-club[data-club="CRY"] { --club-bg: #174b9c; --club-fg: #fff; --club-accent: #e43d45; }
.dynamic-hint-club[data-club="NOR"] { --club-bg: #fae447; --club-fg: #164e32; --club-accent: #168341; }
.dynamic-hint-club[data-club="WIM"] { --club-bg: #18264c; --club-fg: #fff; --club-accent: #fae447; }

/* Dialogs */
dialog { border: 1px solid var(--line); border-radius: 1.2rem; background: var(--card); color: var(--fg); width: min(92vw, 26rem); padding: 0; }
/* The More menu uses the same backdrop as dialogs. */
dialog::backdrop, .menu-scrim {
  background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
/* In dialogs with only a button at the bottom (How to play, About) the heading takes focus, so they
   open at the top rather than scrolled to that button. The heading isn't a control, so no focus ring. */
.dlg h2[autofocus]:focus { outline: none; }
.dlg { padding: 1.2rem; display: flex; flex-direction: column; gap: .8rem; }
.dlg h2 { font-size: 1.0625rem; }
/* Stats: six number tiles, then a strip of badge shields with how often each was earned. */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin: 0; }
.stat-grid > div {
  display: flex; flex-direction: column-reverse; align-items: center; justify-content: center; gap: .1rem;
  padding: .55rem .25rem; border: 1px solid var(--line); border-radius: .75rem; text-align: center;
}
.stat-grid dt { color: var(--muted); font-size: .8rem; }
.stat-grid dd { margin: 0; font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stats-heading { margin: 1rem 0 .4rem; font-size: .95rem; }
.badge-strip { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .25rem; }
.badge-strip li { display: grid; justify-items: center; gap: .15rem; font-size: .85rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.badge-strip .never { color: var(--muted); font-weight: 400; }
.stats-help { margin-top: .9rem; }
.stats-help summary { cursor: pointer; font-weight: 700; font-size: .9rem; }
.stats-help .small { margin: .5rem 0 0; }
.how { margin: 0; padding-left: 1.2rem; display: grid; gap: .45rem; }
.how-note { display: block; color: var(--muted); font-size: .9em; }
.gold { background: var(--gold); color: var(--gold-fg); padding: 0 .3rem; border-radius: .3rem; }
/* Fonts reserve more room above letters than below, so an inline background sits high. Where supported,
   trim the box to the cap height and baseline, then pad evenly, with extra below for descenders. */
@supports (text-box: trim-both cap alphabetic) {
  .gold { display: inline-block; text-box: trim-both cap alphabetic; padding: .3em .3rem .45em; }
}
.field { display: grid; gap: .3rem; font-weight: 700; }
/* Settings: backup and restore, set apart from the display options above. */
.backup { display: flex; flex-direction: column; gap: .6rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.backup h3 { margin: 0; font-size: 1rem; }
.backup p { margin: 0; }
.backup .share-status:empty { margin-top: -.6rem; }
.backup-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.backup-buttons .btn { min-width: 0; padding-inline: .5rem; }
.phrase-box { display: flex; flex-direction: column; gap: .5rem; padding: .75rem; border: 1px solid var(--line); border-radius: 12px; }
.phrase-box[hidden] { display: none; }
.phrase { font-size: 1.25rem; font-weight: 700; overflow-wrap: anywhere; user-select: all; }
.restore-confirm { display: flex; flex-direction: column; gap: .5rem; padding: .75rem; border: 1px solid var(--line); border-radius: .75rem; }
.restore-confirm[hidden] { display: none; }
.rank-points { margin: 0 0 .75rem; font-size: .9rem; }
.rank-points p { margin: .15rem 0; }
.rank-points p:last-child { margin-top: .4rem; }
.rank-points strong { font-weight: 800; }
.rank-points .total { color: var(--bonus-fg); }
/* Laid out like a found name, so it reads as part of the list. */
.bonus-line {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 0 0 .5rem;
  min-height: 2.9rem; padding: .4rem .8rem; border-radius: .7rem; border: 1px solid var(--line); background: var(--bg);
  color: var(--fg); font: inherit; text-align: left; cursor: pointer;
}
.bonus-line .w { font-weight: 800; letter-spacing: .04em; text-transform: uppercase; font-size: .85rem; }
.bonus-line .pts { font-weight: 800; color: var(--bonus-fg); font-variant-numeric: tabular-nums; }
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.rank-list li { display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid var(--line); border-radius: .6rem; padding: .45rem .8rem; }
.rank-list li[aria-current="true"] { background: var(--accent); color: var(--accent-fg); font-weight: 800; }
.rank-next { flex-basis: 100%; display: flex; justify-content: space-between; font-size: .8rem; font-weight: 600; }
/* Close X, top right of a dialog, alongside the Close button at the bottom. */
dialog:has(.dlg-x) h2 { padding-right: 2.5rem; }
.dlg-x { position: absolute; top: .5rem; right: .5rem; color: var(--muted); }
/* Celebration (Star, Legend). The rank pops in; reduced motion turns that off with every other animation. */
.celebrate { text-align: center; }
.share-status { margin: 0; text-align: center; }
/* Kept in the page so it announces reliably; an empty one takes no space. */
.share-status:empty { margin-top: -.8rem; }
.celebrate-rank { display: inline-block; background: var(--gold); color: var(--gold-fg); padding: .3rem 1rem; border-radius: 99px; font-size: 1.5rem; animation: celebrate-pop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes celebrate-pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.celebrate-body { display: flex; flex-direction: column; gap: .6rem; }
.celebrate-body p { margin: 0; }
.celebrate-badges { list-style: none; margin: .3rem 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0; }
/* Six 40px slots fit one row down to a 320px screen. */
.celebrate-badges .badge-slot { width: 40px; }
.badge-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.badge-list li {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .6rem;
  border: 1px solid var(--line); border-radius: .6rem; padding: .45rem .7rem; line-height: 1.3;
}
.badge-list .small { margin: .1rem 0 0; font-size: .85rem; }
.badge-earned { font-size: .75rem; font-weight: 800; color: var(--gold-fg); background: var(--gold); border-radius: 99px; padding: .05rem .45rem; }
.badge-lost { font-size: .75rem; font-weight: 700; color: var(--muted); }
.badge-count { display: grid; justify-items: end; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge-pool { font-size: .75rem; font-weight: 400; color: var(--muted); }
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.players li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .6rem;
  border-bottom: 1px solid var(--line); padding: .35rem 0;
}


@media (prefers-reduced-motion: reduce) {
  :root[data-motion="system"] *, :root[data-motion="system"] *::before, :root[data-motion="system"] *::after { animation: none !important; transition: none !important; }
}
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after { animation: none !important; transition: none !important; }

/* Hints screen: giving up sits at the bottom, below both hint drawers. */
.reveal-block { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding-top: .75rem; }

/* Mobile only (below 64rem): the whole puzzle fits on one screen without scrolling, so the message,
   word, pitch and controls sit together at the bottom of the play screen, and giving up sits at the
   bottom of the hints screen. */
@media (max-width: 63.98rem) {
  main { gap: 0; }
  .area-status { padding: .375rem .5rem; }
  .screens > .area { padding: 0 .5rem .75rem; }
  .area-play { gap: 0; }
  .area-play > .entry { margin-top: auto; }
  .reveal-block { margin-top: auto; }
  /* In a narrow window with a mouse there's no thumb to keep the block near, so it's centred instead
     (decision 0027). Auto margins rather than justify-content: center, so a short window still scrolls
     to the top of the block rather than cutting it off. */
  @media (hover: hover) and (pointer: fine) {
    .area-play > .controls { margin-bottom: auto; }
  }
  /* The Hints tab already shows names left. */
  .names-left { display: none; }
}
@media (forced-colors: active) {
  .mode-tag { border-color: CanvasText; color: CanvasText; }
  .crumbs li { forced-color-adjust: none; background: linear-gradient(90deg, Highlight var(--crumb, 0%), GrayText var(--crumb, 0%)); }
}

/* Shown only below the browser support floor (index.html). Plain CSS that old browsers understand. */
.unsupported body > :not(.old-browser) { display: none !important; }
.old-browser { box-sizing: border-box; width: calc(100% - 2rem); max-width: 28rem; margin: 3rem auto; padding: 1.25rem 1.5rem; background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 1rem; }
.old-browser h2 { margin: 0 0 .75rem; font-size: 1.25rem; }
.old-browser p { margin: .5rem 0; line-height: 1.45; }
.old-browser[hidden] { display: none; }
