:root {
  --bg: #f3efe6;
  --bg-elev: #fffcf6;
  --ink: #1b1814;
  --ink-muted: #5c574e;
  --line: #d9d0c1;
  --accent: #b5471d;
  --seen-bg: #1f6b4a;
  --seen-ink: #f6f3ea;
  --bar: #1f6b4a;
  --bar-track: #e4ddd0;
  --map-empty: #e6dfd2;
  --map-seen: #1f6b4a;
  --map-stroke: #fffcf6;
  --map-sep: #c4bbaa;
  --danger: #9b2c2c;
  --shadow: 0 1px 2px rgba(27, 24, 20, 0.06), 0 8px 24px rgba(27, 24, 20, 0.06);
  --font-ui: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-plate: "Oswald", "Arial Narrow", "Franklin Gothic Medium", sans-serif;
  --btn-fg: #fff;
  --status-bg: #efe3c4;
  --status-fg: #4a3a14;
  --odds-likely-bg: #1f6b4a;
  --odds-likely-fg: #f6f3ea;
  --odds-maybe-bg: #c9842a;
  --odds-maybe-fg: #1a140a;
  --odds-long-bg: #6e6256;
  --odds-long-fg: #f6f3ea;
  --radius: 12px;
  --pad: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #13110e;
  --bg-elev: #1c1915;
  --ink: #f3eee4;
  --ink-muted: #b3ab9e;
  --line: #3a342c;
  --accent: #e08a4f;
  --seen-bg: #d4922d;
  --seen-ink: #1a140a;
  --bar: #e08a4f;
  --bar-track: #2a261f;
  --map-empty: #2a261f;
  --map-seen: #d4922d;
  --map-stroke: #13110e;
  --map-sep: #4a433a;
  --danger: #e07070;
  --btn-fg: #1a140a;
  --status-bg: #3a3118;
  --status-fg: #f0e0b8;
  --odds-likely-bg: #3d9a6a;
  --odds-likely-fg: #0e1a14;
  --odds-maybe-bg: #e0a33d;
  --odds-maybe-fg: #1a140a;
  --odds-long-bg: #8a7d70;
  --odds-long-fg: #1a140a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #13110e;
    --bg-elev: #1c1915;
    --ink: #f3eee4;
    --ink-muted: #b3ab9e;
    --line: #3a342c;
    --accent: #e08a4f;
    --seen-bg: #d4922d;
    --seen-ink: #1a140a;
    --bar: #e08a4f;
    --bar-track: #2a261f;
    --map-empty: #2a261f;
    --map-seen: #d4922d;
    --map-stroke: #13110e;
    --map-sep: #4a433a;
    --danger: #e07070;
    --btn-fg: #1a140a;
    --status-bg: #3a3118;
    --status-fg: #f0e0b8;
      --odds-likely-bg: #3d9a6a;
    --odds-likely-fg: #0e1a14;
    --odds-maybe-bg: #e0a33d;
    --odds-maybe-fg: #1a140a;
    --odds-long-bg: #8a7d70;
    --odds-long-fg: #1a140a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

body {
  padding: calc(12px + var(--safe-t)) calc(var(--pad) + var(--safe-r)) calc(40px + var(--safe-b)) calc(var(--pad) + var(--safe-l));
  max-width: 920px;
  margin: 0 auto;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--bg-elev);
  color: var(--ink);
  padding: 8px 12px;
  z-index: 20;
}
.skip:focus { left: 8px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand h1 {
  font-family: var(--font-plate);
  font-weight: 600;
  font-size: 1.85rem;
  letter-spacing: 0.04em;
  margin: 0;
  line-height: 1.1;
  text-transform: uppercase;
}

.tagline {
  margin: 2px 0 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn, .icon-btn, .chip, .tile, select, summary {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn {
  background: var(--accent);
  color: var(--btn-fg, #fff);
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.9rem;
  min-height: 40px;
}


.btn-ghost {
  background: transparent;
  color: var(--ink) !important;
  border: 1.5px solid var(--line);
}

.btn-danger {
  background: var(--danger);
  color: #fff !important;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--bg-elev);
  display: grid;
  place-items: center;
  padding: 0;
}

.theme-icon::before {
  content: "◐";
  font-size: 1.1rem;
  line-height: 1;
}

.progress-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.progress-label, .game-code, .bonus-line {
  margin: 0;
}

.progress-label { font-size: 1.05rem; }
.progress-label strong { font-size: 1.35rem; }
.denom { color: var(--ink-muted); font-weight: 700; }
.game-code { color: var(--ink-muted); font-size: 0.88rem; letter-spacing: 0.02em; }
.game-code strong { color: var(--ink); letter-spacing: 0.08em; font-family: var(--font-plate); font-size: 1rem; }

.bar {
  margin-top: 8px;
  height: 10px;
  border-radius: 999px;
  background: var(--bar-track);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  background: var(--bar);
  border-radius: inherit;
  transition: width 0.25s ease;
}

.bonus-line {
  margin-top: 8px;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.complete-banner {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--seen-bg);
  color: var(--seen-ink);
  font-weight: 700;
  text-align: center;
}

.status-banner {
  margin: -4px 0 14px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--status-bg, #efe3c4);
  color: var(--status-fg, #4a3a14);
  font-size: 0.9rem;
}

.toolbar { margin-bottom: 14px; }

.search-wrap input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  margin-bottom: 10px;
}

.search-wrap input:focus,
.btn:focus-visible,
.chip:focus-visible,
.icon-btn:focus-visible,
.tile:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip-row, .toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar-row { margin-top: 8px; justify-content: space-between; }

.chip {
  border: 1.5px solid var(--line);
  background: var(--bg-elev);
  border-radius: 999px;
  padding: 6px 12px;
  min-height: 36px;
  font-size: 0.9rem;
}

.chip.is-on {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.sort-wrap select {
  border: 1.5px solid var(--line);
  background: var(--bg-elev);
  border-radius: 999px;
  padding: 6px 32px 6px 12px;
  min-height: 36px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 54%, calc(100% - 11px) 54%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.view-toggle { display: flex; gap: 6px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.region-heading {
  grid-column: 1 / -1;
  margin: 12px 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
}

.region-heading:first-child { margin-top: 0; }

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 5.8rem;
  padding: 16px 6px 9px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--bg-elev);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), var(--shadow);
  text-align: center;
}

.tile .abbr {
  font-family: var(--font-plate);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1;
}

.tile .name {
  font-size: 0.72rem;
  line-height: 1.15;
  color: var(--ink-muted);
}

.tile .when {
  font-size: 0.68rem;
  color: var(--ink-muted);
  margin-top: 1px;
}

.tile.seen {
  background: var(--seen-bg);
  border-color: var(--seen-bg);
  color: var(--seen-ink);
  box-shadow: none;
}

.tile.seen .name,
.tile.seen .when { color: var(--seen-ink); opacity: 0.88; }

.tile:active { transform: scale(0.97); }

@media (prefers-reduced-motion: reduce) {
  .tile:active, .bar-fill { transition: none; transform: none; }
}

.bonus-wrap {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  padding: 4px 12px 12px;
}

.bonus-wrap summary {
  padding: 12px 4px;
  font-weight: 700;
  list-style: none;
}

.bonus-wrap summary::-webkit-details-marker { display: none; }
.bonus-wrap summary::before {
  content: "▸ ";
  color: var(--ink-muted);
}
.bonus-wrap[open] summary::before { content: "▾ "; }

.bonus-count { color: var(--ink-muted); font-weight: 400; }
.bonus-note { margin: 0 0 10px; color: var(--ink-muted); font-size: 0.88rem; }

.map-view { margin-bottom: 18px; }
.map-hint { margin: 0 0 8px; color: var(--ink-muted); font-size: 0.88rem; }
.map-mount {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 4px 4px;
  overflow: auto;
  box-shadow: var(--shadow);
}

#us-map {
  display: block;
  width: 100%;
  height: auto;
  min-height: 200px;
}

#us-map [data-code] {
  fill: var(--map-empty);
  stroke: var(--map-stroke);
  stroke-width: 0.8;
  cursor: pointer;
  transition: fill 0.15s ease;
}

#us-map [data-code].seen { fill: var(--map-seen); }

#us-map [data-code]:hover,
#us-map [data-code]:focus {
  filter: brightness(1.08);
  outline: none;
}

#us-map circle[data-code] {
  stroke-width: 1.2;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  box-shadow: var(--shadow);
  z-index: 30;
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: calc(100% - 32px);
}

.toast button {
  font: inherit;
  font-weight: 700;
  border: 0;
  background: transparent;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-elev);
  color: var(--ink);
  padding: 0;
  width: min(400px, calc(100% - 32px));
  box-shadow: var(--shadow);
}

.dialog::backdrop { background: rgba(20, 16, 12, 0.45); }

.dialog form { padding: 18px 18px 16px; }
.dialog h2 { margin: 0 0 8px; font-size: 1.2rem; }
.dialog p { margin: 0 0 16px; color: var(--ink-muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.empty {
  color: var(--ink-muted);
  text-align: center;
  padding: 28px 10px;
}

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .tile { min-height: 6rem; }
  .tile .abbr { font-size: 1.9rem; }
}

.expected-line {
  margin: 8px 0 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.odds-note {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.odds-note summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
  list-style: none;
  padding: 2px 0;
}
.odds-note summary::-webkit-details-marker { display: none; }
.odds-note summary::before { content: "▸ "; color: var(--ink-muted); }
.odds-note[open] summary::before { content: "▾ "; }
.odds-note p { margin: 8px 0 0; line-height: 1.45; }
.odds-note p:last-child { margin-bottom: 2px; }

.odds-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.odds-badge.likely { background: var(--odds-likely-bg); color: var(--odds-likely-fg); }
.odds-badge.maybe { background: var(--odds-maybe-bg); color: var(--odds-maybe-fg); }
.odds-badge.longshot { background: var(--odds-long-bg); color: var(--odds-long-fg); }
.tile.seen .odds-badge {
  background: color-mix(in srgb, var(--seen-ink) 18%, transparent);
  color: var(--seen-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--seen-ink) 35%, transparent);
}

.map-frame { position: relative; }
.map-tooltip {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, calc(-100% - 8px));
  background: var(--ink);
  color: var(--bg);
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.map-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink);
}
