/* Layout: one-screen app. Map fills the stage; the clue panel docks below it on
   phones and beside it on wide screens. The look is a game show: a stage-blue
   top band (the only blue background), gold buttons that press in, and the
   panel as a card over a sand-colored map.
   Prompts are styled as Texas road signs: green guide signs for towns, brown
   recreation signs for landmarks. */
:root {
  --ground: #18227a;      /* stage blue, for the top band only */
  --top-ink: #ffffff;
  --top-soft: #b6bdf5;
  --logo-tap: #ff4747;    /* "State" white, "Tap" red: the flag's colors */
  --surface: #ffffff;
  --ink: #161c52;
  --ink-soft: #5e6177;
  --line: #e7e3da;
  --link: #2f4fd6;
  --focus: #2f4fd6;

  --water: #e9e4d8;      /* sand behind the map, sea included */
  --land-tx: #fffdf7;
  --land-tx-hover: #fff3d1;
  --land-other: #f4f0e6;
  --county: #e6dcc6;
  --border-tx: #18227a;
  --map-plain: #e9e4d8;

  --sign-green: #0d6a46;
  --sign-brown: #6c4128;
  --sign-ink: #ffffff;
  --sign-white: #ffffff;
  --sign-blue: #1d4f99;
  --sign-white-ink: #151515;
  --sign-marker: #262624;
  --sign-marker-ink: #e8e4d8;
  --sign-marker-edge: #262624;
  --stripe-county: #ffffff;
  --stripe-history: #c9c4b0;
  --zone: rgb(24 34 122 / 0.16);
  --zone-edge: #18227a;
  --zone-solid: #d5d8ee;

  --accent: #ffc72c;
  --accent-ink: #161c52;
  --accent-edge: #d99a00;
  --disabled-edge: #d3cdbf;
  --pin: #ff3358;
  --pin-ring: #ffffff;
  --star: #18227a;
  --star-ring: #ffffff;

  --band-star: #3657e8;
  --band-good: #19a35a;
  --band-ok: #f2b705;
  --band-ok-ink: #161c52;
  --band-meh: #ef6c00;
  --band-bad: #ff3358;

  --font-display: "Lilita One", "Rubik", system-ui, sans-serif;
  --font-ui: "Rubik", system-ui, sans-serif;
  --font-sign: "Overpass", "Highway Gothic", "Arial Narrow", Arial, system-ui, sans-serif;

  --radius: 14px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0d1250;
    --top-soft: #9aa2e6;
    --surface: #1c1c21;
    --ink: #f2f2f5;
    --ink-soft: #a9abb8;
    --line: #34343c;
    --link: #9fb2ff;
    --focus: #ffc72c;
    --water: #121215;
    --land-tx: #2b2b31;
    --land-tx-hover: #36363d;
    --land-other: #1f1f24;
    --county: #3e3e46;
    --border-tx: #d4d7ee;
    --map-plain: #121215;
    --sign-green: #0f7650;
    --sign-brown: #7a4a2f;
    --sign-blue: #2a5fae;
    --sign-marker-edge: #57574f;
    --zone: rgb(255 199 44 / 0.2);
    --zone-edge: #ffc72c;
    --zone-solid: #4a4a6a;
    --disabled-edge: #111114;
    --pin-ring: #121215;
    --star: #ffc72c;
    --star-ring: #121215;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0d1250;
  --top-soft: #9aa2e6;
  --surface: #1c1c21;
  --ink: #f2f2f5;
  --ink-soft: #a9abb8;
  --line: #34343c;
  --link: #9fb2ff;
  --focus: #ffc72c;
  --water: #121215;
  --land-tx: #2b2b31;
  --land-tx-hover: #36363d;
  --land-other: #1f1f24;
  --county: #3e3e46;
  --border-tx: #d4d7ee;
  --map-plain: #121215;
  --sign-green: #0f7650;
  --sign-brown: #7a4a2f;
  --sign-blue: #2a5fae;
  --sign-marker-edge: #57574f;
  --zone: rgb(255 199 44 / 0.2);
  --zone-edge: #ffc72c;
  --zone-solid: #4a4a6a;
  --disabled-edge: #111114;
  --pin-ring: #121215;
  --star: #ffc72c;
  --star-ring: #121215;
  color-scheme: dark;
}

/* Satellite map: NASA imagery with no county or state lines. Texas keeps a
   faint outline, the area outside play is shaded a little, and answers are
   drawn in white and gold so they read on any terrain. */
:root[data-mapstyle="satellite"] {
  --water: #0a1a3f;
  --map-plain: #0a1a3f;
  --border-tx: rgb(255 255 255 / 0.6);
  --zone: rgb(255 255 255 / 0.22);
  --zone-edge: #ffffff;
  --zone-solid: #ffffff;
  --star: #ffc72c;
  --star-ring: #161c52;
}
:root[data-mapstyle="satellite"] :is(.land-other, .neighbor-lines, .county, .state, .state-lines, .us-outline) { display: none; }
:root:not([data-mapstyle="satellite"]) :is(.imagery, .outside, .inset-label) { display: none; }
.outside { fill: rgb(0 0 0 / 0.28); fill-rule: evenodd; pointer-events: none; }
.inset-label {
  fill: rgb(255 255 255 / 0.85); font: 600 10px/1 var(--font-ui); letter-spacing: 0.14em; text-transform: uppercase;
  text-anchor: middle; paint-order: stroke; stroke: rgb(0 0 0 / 0.45); stroke-width: 2.5px; pointer-events: none;
}
:root[data-mapstyle="satellite"] .tx-outline { stroke-width: 1.2; }
:root[data-mapstyle="satellite"] .zone-band { opacity: 0.55; }
:root[data-mapstyle="satellite"] .link { stroke: #ffffff; opacity: 0.9; }
:root[data-mapstyle="satellite"] .map-wrap:has(#map:focus-visible)::after {
  background:
    linear-gradient(#fff, #fff) center / 2px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 2px no-repeat;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.45 var(--font-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr); /* a too-wide top bar clips instead of widening the page */
}

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 12px 8px;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  color: var(--top-ink);
}
.topbar :focus-visible { outline-color: var(--accent); }
.topbar-start { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-word {
  font-family: var(--font-display); font-size: 1.55rem; letter-spacing: 0.01em; line-height: 1;
  color: var(--top-ink); text-decoration: none; white-space: nowrap;
}
.brand-tap { color: var(--logo-tap); }
.brand-word { display: inline-flex; align-items: center; gap: 0.28em; }
/* The logo: a gold map pin with the Lone Star in it */
.brand-mark { width: 0.95em; height: 1.14em; flex: none; overflow: visible; }
.brand-pin { fill: var(--accent); stroke: #fff; stroke-width: 2.4; stroke-linejoin: round; }
.brand-star { fill: var(--ground); }
.topbar-end { display: flex; align-items: center; gap: 12px; flex: none; }
.about-link {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 50%; background: rgb(255 255 255 / 0.12);
  font-family: var(--font-display); font-size: 1.1rem; text-decoration: none; color: var(--top-ink);
}
.about-link:hover { background: rgb(255 255 255 / 0.22); }

/* Game tabs: each is a real link to that game's page, switched in place by app.js */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.1);
  min-width: 0;
}
.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--top-soft);
  min-width: 0;
  transition: background 150ms, color 150ms;
}
.tab:hover { color: var(--top-ink); }
.tab.is-active { background: var(--top-ink); color: #18227a; }
.tab-mark { width: 26px; height: 26px; flex: none; }
.tab-mark path { fill: currentColor; }
.tab-name { font-weight: 700; font-size: 1rem; }
.tab-status {
  white-space: nowrap;
  font-size: 0.7rem; font-weight: 800; font-variant-numeric: tabular-nums;
  padding: 2px 6px; border-radius: 999px;
  background: var(--band-good); color: var(--sign-ink);
}
.tab:not(.is-active) .tab-status { background: rgb(255 255 255 / 0.18); color: var(--top-ink); }
.running { display: grid; justify-items: end; line-height: 1.05; }
.running-label { font-size: 0.75rem; font-weight: 500; color: var(--top-soft); }
.running-value { font-family: var(--font-display); font-size: 1.75rem; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ── Progress: five score tiles ──────────────────────────── */
.markers {
  list-style: none;
  margin: 0;
  padding-block: 4px 12px;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.marker {
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 8px 4px 6px;
  border-radius: 12px;
  color: var(--top-soft);
  font-variant-numeric: tabular-nums;
  /* Theme stripe across the top of each tile */
  box-shadow: inset 0 4px 0 var(--theme-stripe, transparent);
}
.marker:not(.is-done) { background: rgb(255 255 255 / 0.1); }
.marker-mult { font-size: 0.68rem; font-weight: 700; }
.marker-pts { font-family: var(--font-display); font-size: 1.15rem; line-height: 1.1; color: var(--top-ink); }
.marker.is-current:not(.is-done) {
  background: rgb(255 255 255 / 0.2);
  box-shadow: inset 0 4px 0 var(--theme-stripe, transparent), 0 0 0 3px var(--accent);
}
.marker[data-theme="texas-city"], .marker[data-theme="usa-city"] { --theme-stripe: var(--sign-green); }
.marker[data-theme="texas-county"] { --theme-stripe: var(--stripe-county); }
.marker[data-theme="texas-parks"] { --theme-stripe: var(--sign-brown); }
.marker[data-theme="texas-history"] { --theme-stripe: var(--stripe-history); }
.marker[data-theme="usa-fact"] { --theme-stripe: var(--sign-blue); }
.marker[data-theme="texas-legends"], .marker[data-theme="usa-greats"] { --theme-stripe: var(--accent); }
.marker.is-done { color: rgb(255 255 255 / 0.85); }
.band-star { background: var(--band-star); }
.band-good { background: var(--band-good); }
.band-ok { background: var(--band-ok); }
.band-meh { background: var(--band-meh); }
.band-bad { background: var(--band-bad); }
/* Yellow is too light for white numbers. */
.marker.band-ok, .marker.band-ok .marker-pts, .recap-dot.band-ok { color: var(--band-ok-ink); }

/* ── Stage: map + panel ──────────────────────────────────── */
.stage {
  min-height: 0;
  display: grid;
  /* Fixed panel height on phones so the map never resizes between steps. */
  grid-template-rows: minmax(0, 1fr) clamp(230px, 45%, 430px);
}
.map-wrap {
  position: relative;
  min-height: 0;
  background: var(--water);
  overflow: hidden;
}
.map-wrap[data-map="usa"] { background: var(--map-plain); }
.map-wrap { transition: opacity 160ms ease; }
.map-wrap.is-switching { opacity: 0.25; }
#map:focus { outline: none; }
#map:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
/* Keyboard crosshair: Enter drops the pin here */
.map-wrap:has(#map:focus-visible)::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  pointer-events: none;
  background:
    linear-gradient(var(--ink), var(--ink)) center / 2px 100% no-repeat,
    linear-gradient(var(--ink), var(--ink)) center / 100% 2px no-repeat;
  opacity: 0.8;
}
.state { fill: var(--land-tx); stroke: none; transition: fill 120ms; }
#map.is-guessing .state:hover { fill: var(--land-tx-hover); }
.state-lines { fill: none; stroke: var(--county); stroke-width: 0.9; vector-effect: non-scaling-stroke; }
.us-outline { fill: none; stroke: var(--border-tx); stroke-width: 1.3; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#map { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#map.is-guessing { cursor: crosshair; }

.land-other { fill: var(--land-other); stroke: var(--land-other); stroke-width: 2; vector-effect: non-scaling-stroke; }
.neighbor-lines { fill: none; stroke: var(--county); stroke-width: 0.8; vector-effect: non-scaling-stroke; }
.county { fill: var(--land-tx); stroke: var(--county); stroke-width: 0.6; vector-effect: non-scaling-stroke; transition: fill 120ms; }
#map.is-guessing .county:hover { fill: var(--land-tx-hover); }
.tx-outline { fill: none; stroke: var(--border-tx); stroke-width: 1.6; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

.zone { fill: var(--zone); stroke: var(--zone-edge); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
path.zone.is-path, path.zone.is-path-edge { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: none; }
path.zone.is-path-edge { stroke: var(--zone-edge); }
path.zone.is-path { stroke: var(--zone-solid); }
.zone-band { opacity: 0.7; }
.zone-band.is-new { animation: band-in 500ms ease-out; }
@keyframes band-in { from { opacity: 0; } to { opacity: 0.7; } }
.zone.is-new { animation: zone-in 500ms ease-out; }
@keyframes zone-in { from { opacity: 0; } to { opacity: 1; } }
.link { fill: none; stroke: var(--ink-soft); stroke-width: 1.6; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.pin-body { fill: var(--pin); stroke: var(--pin-ring); stroke-width: 1.5; }
.pin-label { fill: #fff; font: 800 10px/1 var(--font-sign); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.pin.is-pending .pin-body { animation: drop 260ms cubic-bezier(.3, 1.4, .6, 1); transform-origin: 0 0; }
.star-body { fill: var(--star); stroke: var(--star-ring); stroke-width: 1.5; stroke-linejoin: round; }
.star.is-new .star-body { animation: pop 420ms cubic-bezier(.3, 1.6, .5, 1); transform-origin: 0 0; }
@keyframes drop { from { transform: translateY(-14px) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

.zoom-controls {
  position: absolute;
  top: 10px;
  right: calc(10px + env(safe-area-inset-right, 0px));
  display: grid;
  gap: 8px;
}
.zoom-controls button {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: #18227a;
  box-shadow: 0 3px 0 rgb(24 34 122 / 0.25);
  font-family: var(--font-display); font-size: 1.4rem; line-height: 1;
  cursor: pointer;
}
.zoom-controls svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ── Panel: a card pulled up over the bottom of the map ─── */
.panel {
  position: relative;
  margin-top: -16px;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 24px rgb(0 0 0 / 0.18);
  background: var(--surface);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-block: 18px 0;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.panel-inner { display: grid; gap: 12px; max-width: 34rem; margin-inline: auto; padding-bottom: 16px; }
/* Primary action stays on screen while longer write-ups scroll beneath it. */
.actions {
  position: sticky;
  bottom: 0;
  padding-block: 8px 16px;
  margin-bottom: -16px;
  background: linear-gradient(to bottom, transparent, var(--surface) 8px);
}

/* "Counties   3 of 5   Double points" */
.eyebrow {
  margin: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px;
  font-size: 0.9rem; font-weight: 500; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.eyebrow .bonus {
  padding: 2px 9px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 0.8rem; font-weight: 700;
}

.sign {
  --sign-bg: var(--sign-green);
  justify-self: start;
  max-width: 100%;
  background: var(--sign-bg);
  color: var(--sign-ink);
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 2px 0 rgb(0 0 0 / 0.18);
  font-family: var(--font-sign);
}
.sign.is-brown { --sign-bg: var(--sign-brown); }
.sign.is-blue { --sign-bg: var(--sign-blue); }
/* Great Americans and Texas legends: a stage-blue plaque with a gold rule. */
.sign.is-legend { --sign-bg: #1b2470; color: #ffffff; box-shadow: 0 0 0 1px #ffc72c inset, 0 2px 0 rgb(0 0 0 / 0.25); }
.sign.is-legend .sign-inner { border-color: #ffc72c; }
.sign.is-legend .sign-kicker { color: #ffc72c; opacity: 1; }
.sign.is-white { --sign-bg: var(--sign-white); color: var(--sign-white-ink); box-shadow: 0 0 0 1px var(--line), 0 2px 0 rgb(0 0 0 / 0.18); }
.sign.is-marker { --sign-bg: var(--sign-marker); color: var(--sign-marker-ink); border-radius: 6px; box-shadow: 0 0 0 1px var(--sign-marker-edge), 0 2px 0 rgb(0 0 0 / 0.25); }
.sign.is-marker .sign-inner { border-radius: 3px; border-style: double; border-width: 4px; }
.sign.is-marker .sign-kicker { text-transform: none; letter-spacing: 0.08em; }
.sign.is-long .sign-name { font-size: clamp(1.15rem, 4.6vw, 1.45rem); line-height: 1.2; }
.sign.is-small.is-long .sign-name { font-size: 1.05rem; }
.sign.is-chip { padding: 2px; border-radius: 6px; justify-self: auto; }
.sign.is-chip .sign-inner { padding: 2px 7px 1px; border-width: 1.5px; border-radius: 4px; font-size: 0.72rem; font-weight: 800; white-space: nowrap; }
.sign.is-marker.is-chip .sign-inner { border-width: 3px; }
.sign-inner {
  border: 2px solid currentColor;
  border-radius: 9px;
  padding: 7px 18px 9px;
  display: grid;
  gap: 1px;
}
.sign-kicker { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.92; }
.sign-name { font-size: clamp(1.55rem, 6.5vw, 2.15rem); font-weight: 800; line-height: 1.08; text-wrap: balance; overflow-wrap: anywhere; }
.sign.is-small .sign-inner { padding: 5px 14px 7px; }
.sign.is-small .sign-name { font-size: 1.2rem; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.hint { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }
/* Touch screens and mice get their own instructions. */
.for-mouse { display: none; }
@media (hover: hover) and (pointer: fine) {
  .for-touch { display: none; }
  .for-mouse { display: inline; }
}

/* Gold game-show button that presses in */
.btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  padding: 13px 22px 11px;
  margin-bottom: 5px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 5px 0 var(--accent-edge);
  cursor: pointer;
  transition: transform 60ms, box-shadow 60ms;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-edge); }
.btn:disabled { background: var(--line); color: var(--ink-soft); box-shadow: 0 5px 0 var(--disabled-edge); transform: none; cursor: not-allowed; }
.btn.is-wide { width: 100%; }

.result { display: flex; flex-wrap: wrap; gap: 6px 28px; align-items: end; }
.stat { display: grid; gap: 1px; }
.stat-label { font-size: 0.85rem; font-weight: 500; color: var(--ink-soft); }
.stat-value { font-family: var(--font-display); font-size: 1.9rem; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stat-sub { font-family: var(--font-ui); font-size: 0.8rem; font-weight: 500; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.stat-value .stat-sub { margin-left: 6px; }

.answer { margin: 0; font-size: 1.15rem; font-weight: 700; line-height: 1.25; }
.answer span { display: block; font-size: 0.85rem; font-weight: 500; color: var(--ink-soft); }
.stat.is-inside .stat-value { color: var(--band-good); }
.blurb { margin: 0; font-size: 1rem; line-height: 1.55; max-width: 65ch; }
.blurb.is-missing { color: var(--ink-soft); font-style: italic; }
.place-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 0.82rem; color: var(--ink-soft); }
.place-meta a { text-underline-offset: 2px; }

/* Intro */
.intro-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.9rem, 7.5vw, 2.4rem); line-height: 1.02; letter-spacing: 0.005em; text-wrap: balance; }
.intro-copy { margin: 0; font-size: 1rem; line-height: 1.5; max-width: 60ch; }
.themes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.themes li { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; font-weight: 500; min-width: 0; }

/* Results */
.final { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.final-score { font-family: var(--font-display); font-size: clamp(3.2rem, 14vw, 4.2rem); line-height: 1; font-variant-numeric: tabular-nums; }
.final-max { font-size: 1.1rem; font-weight: 500; color: var(--ink-soft); }
.final-verdict { flex-basis: 100%; margin: 0; font-size: 1rem; font-weight: 500; }
.recap { list-style: none; margin: 0; padding: 0; display: grid; }
.recap li {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.recap li:last-child { border-bottom: 1px solid var(--line); }
.recap-dot { width: 1.6rem; height: 1.6rem; border-radius: 8px; display: grid; place-items: center; color: var(--sign-ink); font-family: var(--font-display); font-size: 0.95rem; }
.recap-name { font-weight: 500; min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.recap-name small { display: block; font-size: 0.75rem; font-weight: 500; color: var(--ink-soft); }
.recap-mi { color: var(--ink-soft); font-size: 0.88rem; }
.recap-pts { font-family: var(--font-display); font-size: 1.1rem; min-width: 3ch; text-align: right; }
.share-preview {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--line);
  font: 500 0.95rem/1.5 var(--font-ui);
  white-space: pre-wrap;
  user-select: all;
}
.cross-sell { margin: 0; font-weight: 700; }
.cross-sell a { color: var(--ink); text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.countdown { margin: 0; font-size: 0.9rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.toast { font-size: 0.88rem; font-weight: 500; color: var(--band-good); }

/* Phones: brand, both tabs, score and help share one row. Tab outlines go, and
   the active tab drops its progress (the score tiles already show it). */
@media (max-width: 500px) {
  .tab-mark { display: none; }
  .tab { padding: 5px 10px; }
  .tab.is-active .tab-status, .tab-score { display: none; }
  .topbar, .topbar-start, .topbar-end { gap: 8px; }
  .about-link { width: 28px; height: 28px; }
  .brand-word { font-size: 1.3rem; }
  .running-value { font-size: 1.45rem; }
}
@media (max-width: 400px) {
  .topbar, .topbar-start { gap: 6px; }
}
@media (max-width: 370px) {
  .tab { padding: 5px 8px; }
  .brand-word { font-size: 1.15rem; }
}
/* The smallest phones keep the name and drop the pin */
@media (max-width: 340px) {
  .brand-mark { display: none; }
}

/* Wide screens: panel becomes a sidebar */
@media (min-width: 860px) {
  .stage { grid-template-rows: none; grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); }
  .panel { margin-top: 0; border-radius: 22px 0 0 0; box-shadow: -8px 0 24px rgb(0 0 0 / 0.18); padding-block: 20px; }
  .markers { grid-template-columns: repeat(5, minmax(0, 104px)); }
}

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

/* ── About and 404 pages ─────────────────────────────────── */
body.page-doc { overflow: auto; height: auto; background: var(--surface); }
.doc-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding-block: 14px;
  padding-left: var(--gutter-l); padding-right: var(--gutter-r);
  background: var(--ground);
}
.doc-header .brand-word { margin-right: auto; }
.doc-back {
  font-weight: 700; color: var(--top-ink); text-decoration: none;
  padding: 6px 12px; border-radius: 999px; background: rgb(255 255 255 / 0.12);
}
.doc-back:hover { background: rgb(255 255 255 / 0.22); }
.doc {
  max-width: 44rem; margin-inline: auto;
  padding-block: 8px 64px;
  padding-left: var(--gutter-l); padding-right: var(--gutter-r);
  font-size: 1.05rem; line-height: 1.6;
}
.doc h1, .doc h2, .doc h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.1; letter-spacing: 0.005em; text-wrap: balance; }
.doc h1 { font-size: clamp(2.2rem, 8vw, 2.9rem); margin: 24px 0 8px; }
.doc h2 { font-size: 1.5rem; margin: 36px 0 8px; }
.doc h3 { font-size: 1.15rem; margin: 20px 0 4px; }
.doc p { margin: 0 0 12px; max-width: 65ch; }
.doc-lede { font-size: 1.15rem; }
.doc a { color: var(--link); text-underline-offset: 2px; }
.doc-games dt { font-family: var(--font-display); font-size: 1.1rem; margin-top: 12px; }
.doc-games dd { margin: 2px 0 0; }
.doc-bands { list-style: none; padding: 0; margin: 12px 0 16px; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 0.9rem; font-weight: 500; }
.doc-bands li { display: flex; align-items: center; gap: 8px; }
.doc-bands b { width: 22px; height: 10px; border-radius: 4px; display: inline-block; }
.doc-email { user-select: all; font-weight: 700; }

/* ── Level badge (top bar) ───────────────────────────────── */
.me-button {
  --progress: 0%;
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; flex: none;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent) var(--progress), rgb(255 255 255 / 0.2) 0);
}
.me-level {
  width: 25px; height: 25px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ground); color: var(--top-ink); font: 400 0.95rem/1 var(--font-display);
}

/* ── Sound toggle (map controls) ─────────────────────────── */
.sound-toggle svg { width: 17px; height: 17px; }
.sound-toggle .spk { fill: currentColor; stroke: none; }
.sound-toggle .waves, .sound-toggle .cross { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.sound-toggle .cross, .sound-toggle.is-muted .waves { display: none; }
.sound-toggle.is-muted .cross { display: inline; }
.sound-toggle.is-muted { color: var(--ink-soft); }

/* ── Panel steps fade in; switching days fades out first ── */
.panel-inner { animation: panel-in 220ms ease-out; }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } }
.panel.is-changing .panel-inner { opacity: 0; transform: translateY(6px); transition: opacity 150ms, transform 150ms; }

/* ── Day picker ──────────────────────────────────────────── */
.day-pick-wrap { display: inline-flex; }
.day-pick {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 11px; border-radius: 999px;
  background: var(--line); color: var(--ink); font: inherit; font-weight: 600;
}
.day-pick:hover { background: color-mix(in srgb, var(--line) 70%, var(--accent)); }
.day-pick .caret { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 180ms; }
.day-pick[aria-expanded="true"] .caret { transform: rotate(180deg); }
.day-menu {
  position: fixed; z-index: 40; width: min(300px, calc(100vw - 32px));
  max-height: min(420px, 60vh); overflow-y: auto; overscroll-behavior: contain;
  display: grid; gap: 2px; padding: 6px;
  background: var(--surface); color: var(--ink); border-radius: 16px;
  box-shadow: 0 0 0 1px var(--line), 0 16px 40px rgb(0 0 0 / 0.25);
  opacity: 0; transform: translateY(-6px) scale(0.98); transform-origin: top left;
  transition: opacity 160ms ease, transform 200ms cubic-bezier(.2, .8, .2, 1);
}
.day-menu.is-above { transform-origin: bottom left; transform: translateY(6px) scale(0.98); }
.day-menu.is-open { opacity: 1; transform: none; }
.day-option {
  appearance: none; border: 0; background: none; cursor: pointer; font: inherit; color: inherit; text-align: left;
  display: grid; grid-template-columns: minmax(0, 1fr) auto 3.4rem; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: 11px;
}
.day-option:hover, .day-option:focus-visible { background: var(--line); outline: none; }
.day-option.is-current { background: rgb(255 199 44 / 0.22); }
.day-name { font-weight: 600; }
.day-no { font-size: 0.8rem; color: var(--ink-soft); }
.day-score { justify-self: end; font: 400 1.05rem/1 var(--font-display); }
.day-progress { justify-self: end; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.day-play { justify-self: end; font-size: 0.85rem; font-weight: 700; color: var(--link); }

/* ── Level on the final screen ───────────────────────────── */
.level-badge {
  width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 400 1.05rem/1 var(--font-display);
  box-shadow: 0 3px 0 var(--accent-edge);
}
.level-line {
  appearance: none; border: 0; cursor: pointer; font: inherit; color: inherit; text-align: left;
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: var(--radius); background: var(--line);
}
.level-text { display: grid; gap: 4px; flex: 1; min-width: 0; }
.level-text b { font-weight: 700; }
.level-text small { font-size: 0.78rem; color: var(--ink-soft); }
.level-bar { display: block; height: 8px; border-radius: 999px; background: rgb(0 0 0 / 0.08); overflow: hidden; }
.level-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 600ms ease; }
.level-up {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius);
  background: rgb(255 199 44 / 0.25); animation: pop-in 420ms cubic-bezier(.3, 1.5, .5, 1);
}
@keyframes pop-in { from { transform: scale(0.9); opacity: 0; } }
.row .btn-quiet { margin-bottom: 5px; }

/* ── The Me sheet ────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sheet-layer { position: fixed; inset: 0; z-index: 50; }
.sheet-layer[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgb(8 12 40 / 0.55); opacity: 0; transition: opacity 240ms; }
.sheet-layer.is-open .sheet-backdrop { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 90%;
  display: grid; grid-template-rows: auto auto auto minmax(0, 1fr);
  background: var(--surface); color: var(--ink);
  border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgb(0 0 0 / 0.3);
  padding: 14px var(--gutter-r) 0 var(--gutter-l);
  transform: translateY(100%); transition: transform 280ms cubic-bezier(.2, .8, .2, 1);
}
.sheet-layer.is-open .sheet { transform: none; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 480px; max-height: 86%; border-radius: 22px;
    transform: translate(-50%, -46%) scale(0.97); opacity: 0; transition: transform 240ms cubic-bezier(.2, .8, .2, 1), opacity 200ms; padding: 16px 20px 0; }
  .sheet-layer.is-open .sheet { transform: translate(-50%, -50%); opacity: 1; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-close {
  width: 34px; height: 34px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--line); color: var(--ink);
}
.sheet-close svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--line); }
.seg button {
  appearance: none; border: 0; background: none; cursor: pointer; color: var(--ink-soft);
  padding: 7px 14px; border-radius: 999px; font: inherit; font-weight: 600;
  transition: background 150ms, color 150ms;
}
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.15); }
.seg-games { justify-self: start; margin-top: 12px; }
.seg-scope { margin-bottom: 6px; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 14px 0 calc(24px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 12px; align-content: start; }
.sheet-body h3 { margin: 8px 0 0; font: 400 1.15rem/1.1 var(--font-display); }
.sheet-body h3 small { font: 500 0.78rem var(--font-ui); color: var(--ink-soft); margin-left: 6px; }
.me-card { display: grid; gap: 8px; padding: 14px; border-radius: var(--radius); background: rgb(255 199 44 / 0.16); }
.me-card { grid-template-columns: auto 1fr; align-items: center; }
.me-xp { grid-column: 1 / -1; font-size: 0.78rem; color: var(--ink-soft); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tile { display: grid; justify-items: center; gap: 2px; padding: 10px 4px; border-radius: 12px; background: var(--line); text-align: center; }
.tile-value { font: 400 1.6rem/1 var(--font-display); }
.tile-label { font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); }
.tile small { font-size: 0.68rem; color: var(--ink-soft); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding-top: 6px; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.bar { width: 100%; max-width: 30px; border-radius: 6px 6px 2px 2px; animation: grow 500ms cubic-bezier(.2, .8, .2, 1) both; transform-origin: bottom; }
@keyframes grow { from { transform: scaleY(0); } }
.bar-num { font-size: 0.62rem; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.bar-day { font-size: 0.6rem; color: var(--ink-soft); white-space: nowrap; }
.spread { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.spread li { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); align-items: center; gap: 10px; font-size: 0.85rem; }
.themes-avg li { grid-template-columns: 8rem minmax(0, 1fr); }
.themes-avg .sign.is-chip { justify-self: start; }
.spread-label { color: var(--ink-soft); font-weight: 500; }
.spread-bar span {
  display: block; min-width: 1.6rem; padding: 3px 7px; border-radius: 6px; text-align: right;
  background: var(--ink-soft); color: #fff; font-weight: 700; font-size: 0.78rem; font-variant-numeric: tabular-nums;
  animation: grow-x 500ms cubic-bezier(.2, .8, .2, 1) both; transform-origin: left;
}
@keyframes grow-x { from { transform: scaleX(0); } }
.board { list-style: none; margin: 0; padding: 0; display: grid; }
.board li {
  display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 10px 6px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
.board li:first-child { border-top: 0; }
.board .rank { font: 400 1.05rem/1 var(--font-display); color: var(--ink-soft); text-align: center; }
.board li:nth-child(1) .rank { color: #d4a000; }
.board .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .games { font-size: 0.78rem; color: var(--ink-soft); }
.board .pts { font: 400 1.1rem/1 var(--font-display); }
.board li.is-me { background: rgb(255 199 44 / 0.2); border-radius: 10px; }
.board li.is-below { margin-top: 6px; border-top: 1px dashed var(--line); }
.nick-form { display: grid; gap: 6px; padding: 12px; border-radius: var(--radius); background: var(--line); }
.nick-form label { font-weight: 600; }
.nick-form input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1.5px solid transparent;
  background: var(--surface); color: var(--ink); font: inherit;
}
.nick-form input:focus { border-color: var(--accent); outline: none; }
.nick-form .row { flex-wrap: nowrap; }
.nick-form button { appearance: none; border: 0; border-radius: 10px; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); font: 400 1.05rem/1 var(--font-display); box-shadow: 0 3px 0 var(--accent-edge); cursor: pointer; }
.nick-msg { font-size: 0.8rem; color: var(--ink-soft); min-height: 1em; }
.sheet .empty { margin: 8px 0; color: var(--ink-soft); }
.sheet .fine { margin: 4px 0 0; font-size: 0.75rem; color: var(--ink-soft); }
.btn-quiet { color: var(--ink); }
.sheet-help { font-weight: 600; color: var(--link); }
.sheet-head .seg button { white-space: nowrap; padding: 7px 12px; }

/* Phones: the level badge takes the help button's spot (help moves into the sheet). */
@media (max-width: 500px) {
  .about-link { display: none; }
}
@media (max-width: 370px) {
  .running-label { display: none; }
  .running-value { font-size: 1.3rem; }
  .me-button { width: 30px; height: 30px; }
  .me-level { width: 23px; height: 23px; font-size: 0.85rem; }
}

/* ── First-game walkthrough ──────────────────────────────── */
.coach-layer {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px;
  background: rgb(8 12 40 / 0.6); opacity: 0; transition: opacity 200ms;
}
.coach-layer.is-open { opacity: 1; }
.coach {
  width: min(360px, 100%); display: grid; gap: 14px; padding: 22px 20px 16px; border-radius: 22px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 50px rgb(0 0 0 / 0.35);
  transform: translateY(10px) scale(0.97); transition: transform 240ms cubic-bezier(.2, .8, .2, 1);
}
.coach-layer.is-open .coach { transform: none; }
.coach-body { display: grid; justify-items: center; gap: 8px; text-align: center; min-height: 190px; align-content: start; animation: panel-in 220ms ease-out; }
.coach-icon { width: 64px; height: 64px; }
.coach h2 { margin: 4px 0 0; font: 400 1.7rem/1.05 var(--font-display); }
.coach p { margin: 0; font-size: 1rem; line-height: 1.5; color: var(--ink-soft); }
.coach-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.coach-dots { display: flex; gap: 6px; }
.coach-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: background 150ms, transform 150ms; }
.coach-dots i.is-on { background: var(--accent); transform: scale(1.25); }
.coach .btn { min-width: 120px; }

/* Bigger map buttons on touch screens */
@media (pointer: coarse) {
  .zoom-controls button { width: 42px; height: 42px; }
}
