:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --accent: #2563eb;
  --good: #16a34a;
  --bad: #dc2626;
  --border: #d9dce3;
  /* Heatmap: one green hue, light (fast) -> dark (slow); grey = not seen */
  --heat-1: #b7ebb0;
  --heat-2: #7fd277;
  --heat-3: #43ad45;
  --heat-4: #1f7f2c;
  --heat-5: #0b4d17;
  --unseen: #e3e6ea;
}
/* Dark theme: follows the system unless the visitor picked one with the toggle (theme.js sets
   data-theme on <html>). color-scheme also switches form controls and the shape images' colours. */
:root { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12151c;
    --card: #1c2029;
    --text: #e8eaf0;
    --muted: #9aa1ae;
    --accent: #60a5fa;
    --good: #4ade80;
    --bad: #f87171;
    --border: #2e3442;
    --unseen: #313744;
    --water: #172033;
    --land: #475569;
    --land-hover: #64748b;
    --land-off: #2a3344;
    --map-border: #1c2029;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12151c;
  --card: #1c2029;
  --text: #e8eaf0;
  --muted: #9aa1ae;
  --accent: #60a5fa;
  --good: #4ade80;
  --bad: #f87171;
  --border: #2e3442;
  --unseen: #313744;
  --water: #172033;
  --land: #475569;
  --land-hover: #64748b;
  --land-off: #2a3344;
  --map-border: #1c2029;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 32px 16px; }
main:has(#game:not([hidden])) { max-width: 1440px; padding-top: 20px; }
h1 { font-size: 2.4rem; margin: 0 0 4px; text-align: center; }
h2 { text-align: center; margin: 0 0 4px; }
h3 { margin-top: 32px; }
.sub { text-align: center; color: var(--muted); margin: 0 0 24px; }

button {
  font: inherit;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }
kbd { font-size: .75em; color: var(--muted); margin-left: 4px; }

.regions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.regions button {
  padding: 18px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.regions button strong { font-size: 1.1rem; }
.regions button span { color: var(--muted); font-size: .9rem; }
.regions button.world { grid-column: 1 / -1; text-align: center; align-items: center; }

.options { max-width: 560px; margin: 24px auto 16px; display: flex; flex-direction: column; gap: 10px; }
.option { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); line-height: 1.4; }
.option input[type=checkbox] { margin-top: 3px; }
.option strong { color: var(--text); }
.option.disabled { opacity: .5; }
.temp-row { align-items: center; flex-wrap: wrap; padding-left: 24px; }
.temp-row input { flex: 1; min-width: 120px; accent-color: var(--accent); }
.temp-row output { color: var(--text); font-variant-numeric: tabular-nums; min-width: 3em; }
.temp-row .hint { flex-basis: 100%; font-size: .85rem; }
.practice { display: block; margin: 0 auto; border-color: var(--bad); }

.hud {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-bottom: 16px;
}
.flag-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: clamp(260px, calc(100vh - 270px), 680px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
#flag { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 1px 4px rgba(0,0,0,.3)); }

.reveal { min-height: 1.6em; text-align: center; margin: 12px 0; font-weight: 600; }
.reveal.good { color: var(--good); }
.reveal.bad { color: var(--bad); }

#guess {
  width: 100%;
  font-size: 1.3rem;
  padding: 14px 16px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  outline: none;
}
#guess:focus { border-color: var(--accent); }
#guess.shake { animation: shake .3s; border-color: var(--bad); }
@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.note { text-align: center; color: var(--muted); font-size: .9rem; }

.missed {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.missed li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  font-size: .9rem;
}
.missed img { width: 100%; height: 80px; object-fit: contain; display: block; margin-bottom: 6px; }

@media (max-width: 520px) {
  .flag-wrap { height: clamp(200px, 48vh, 420px); padding: 8px; }
  h1 { font-size: 1.9rem; }
}

/* Suggestions dropdown */
.guess-box { position: relative; }
.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.suggestions li { padding: 8px 12px; border-radius: 6px; cursor: pointer; }
.suggestions li.active { background: var(--accent); color: #fff; }

.missed .name { display: block; }
.missed .detail { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }

/* Stats */
.stats-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-bottom: 16px; }
.stats-controls select {
  font: inherit; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
}
.option-inline { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-weight: 600; font-size: .85rem; }
th[data-key] { cursor: pointer; user-select: none; }
th[data-key]:hover { color: var(--text); }
th[data-sort="asc"]::after { content: " ▲"; }
th[data-sort="desc"]::after { content: " ▼"; }
.num { text-align: right; }
td img { width: 36px; height: 24px; object-fit: contain; display: block; }
button.danger { color: var(--bad); }

/* Infinite-mode banner */
.banner {
  text-align: center;
  font-weight: 600;
  color: var(--accent);
  margin: -8px 0 8px;
}
.banner.fade { animation: banner-fade 3s forwards; }
@keyframes banner-fade { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }

/* Rounds chart: two single-series bar strips on a shared round axis */
.session-panel { margin-top: 16px; }
#game:has(#session-panel:not([hidden])) .flag-wrap { height: clamp(220px, calc(100vh - 450px), 680px); }
#game .rounds-chart { padding: 8px 12px 4px; }
#game .strip + .strip { margin-top: 6px; }
.rounds-chart {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px 8px;
}
.strip + .strip { margin-top: 12px; }
.strip-head { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.strip-latest { color: var(--text); font-variant-numeric: tabular-nums; }
.bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 34px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}
.bar-col {
  flex: 1 0 14px;
  max-width: 40px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  cursor: default;
}
.bar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar-col:hover .bar { filter: brightness(1.15); }
.bar-col.live .bar { opacity: .4; }
.bar-col.partial .bar {
  background: repeating-linear-gradient(135deg, var(--accent) 0 3px, transparent 3px 6px);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.bars.axis { height: auto; border: none; overflow: hidden; }
.bars.axis span { flex: 1 0 14px; max-width: 40px; text-align: center; font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.tooltip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  white-space: pre-line;
  background: var(--text);
  color: var(--bg);
  font-size: .8rem;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

/* Game layout: play area on the left, flag heatmap in the top right */
#game:not([hidden]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
}
.game-main { grid-column: 1; grid-row: 1; min-width: 0; }
.heatmap-panel {
  grid-column: 2;
  grid-row: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
@media (max-width: 900px) {
  #game:not([hidden]) { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .heatmap-panel { grid-column: 1; grid-row: 1; justify-self: stretch; }
  .game-main { grid-row: 2; }
  /* Full-width grid of smaller squares, and a shorter flag so the answer box stays on screen */
  #heatmap { grid-template-columns: repeat(auto-fill, 14px); }
  #heatmap .sq { width: 14px; height: 14px; }
  #game .flag-wrap { height: clamp(180px, calc(100vh - 520px), 520px); }
}
.heatmap-head { display: flex; justify-content: space-between; gap: 16px; font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
#heatmap-count { color: var(--text); font-variant-numeric: tabular-nums; }
.heatmap {
  display: grid;
  grid-template-columns: repeat(var(--cols, 14), 18px);
  gap: 3px;
}
.sq {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--flag, none) center / cover no-repeat, var(--unseen);
}
.sq.unseen { background: var(--unseen); }
/* Strong green tint over the flag: the level colour dominates, the flag just shows through */
.sq.seen::after { content: ""; position: absolute; inset: 0; opacity: .9; }
.sq.lv1, .sq.lv1::after { background-color: var(--heat-1); }
.sq.lv2, .sq.lv2::after { background-color: var(--heat-2); }
.sq.lv3, .sq.lv3::after { background-color: var(--heat-3); }
.sq.lv4, .sq.lv4::after { background-color: var(--heat-4); }
.sq.lv5, .sq.lv5::after { background-color: var(--heat-5); }
#heatmap .sq:hover { outline: 2px solid var(--text); outline-offset: 1px; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 8px;
  font-size: .7rem;
  color: var(--muted);
}
.heatmap-legend .sq { width: 11px; height: 11px; border-radius: 2px; }
.heatmap-legend span:not(.sq) { margin: 0 3px; }
.legend-gap { flex: 1; }

.tooltip .tip-flag { display: block; width: 96px; margin-bottom: 6px; border-radius: 2px; }
.tooltip strong { display: block; }
.tooltip .tip-detail { display: block; opacity: .8; }

/* Quiz tabs (hidden while playing) */
.tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: -12px auto 20px;
  padding: 4px;
  width: fit-content;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.tabs a {
  padding: 6px 18px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { background: var(--accent); color: #fff; }
main:has(#game:not([hidden])) .tabs { display: none; }

/* Correct-answer feedback */
.flag-wrap { position: relative; }
.flag-wrap.glow { animation: glow .55s ease-out; }
.flag-wrap.glow-soft { animation: glow-soft .45s ease-out; }
@keyframes glow {
  0% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 70%, transparent); border-color: var(--good); }
  25% { transform: scale(1.025); }
  100% { transform: scale(1); box-shadow: 0 0 0 18px transparent; }
}
@keyframes glow-soft {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 40%, transparent); border-color: var(--good); }
  100% { box-shadow: 0 0 0 10px transparent; }
}
.reveal.pop { animation: pop .35s cubic-bezier(.34, 1.8, .64, 1); }
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.streak { color: #f97316; font-weight: 700; display: inline-block; }
.streak.bump { animation: bump .3s cubic-bezier(.34, 1.8, .64, 1); }
@keyframes bump { 0% { transform: scale(1.6); } 100% { transform: scale(1); } }
.confetti {
  position: fixed;
  z-index: 30;
  width: 8px;
  height: 12px;
  margin: -6px 0 0 -4px;
  border-radius: 2px;
  pointer-events: none;
  animation: confetti .8s cubic-bezier(.15, .7, .35, 1) forwards;
}
@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0) scale(.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 60px)) rotate(var(--rot)) scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .flag-wrap.glow, .reveal.pop, .streak.bump { animation: none; }
}

/* Speed run */
.speed-clock {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  margin: -8px 0 8px;
  font-variant-numeric: tabular-nums;
}
#speed-time { font-size: 2rem; font-weight: 700; letter-spacing: .02em; }
.speed-best { color: var(--muted); font-size: .9rem; }

.records {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  max-width: 560px;
  margin: 0 auto 24px;
}
.records h3 { margin: 0 0 6px; font-size: .9rem; color: var(--muted); }
.records th, .records td { padding: 5px 6px; font-size: .85rem; }
.records tbody th { position: static; color: var(--text); font-weight: 500; }
.records td.muted { color: var(--muted); }
.records td:last-child { color: var(--muted); }
@media (min-width: 1340px) {
  .records { position: absolute; top: 20px; right: 20px; width: 300px; margin: 0; }
}
#home:not([hidden]) { display: flex; flex-direction: column; }
@media (max-width: 1339px) {
  .records { order: 1; width: 100%; margin: 24px auto 0; }
}
.records tbody tr:last-child th { border-bottom: none; }

/* Answer style / layout / rotation pickers */
.choice-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.choice-label { color: var(--muted); min-width: 64px; font-size: .9rem; }
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 5px 12px; border-radius: 6px; color: var(--muted); font-size: .9rem; }
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.records-variant { margin: -4px 0 6px; font-size: .8rem; color: var(--accent); }

/* Multiple choice */
.mc { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mc .choice { display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-size: 1.1rem; text-align: left; }
.mc .choice kbd { margin: 0; font-size: .8rem; border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.choice.right, .cell-mc button.right { background: var(--good); border-color: var(--good); color: #fff; }
.choice.wrong, .cell-mc button.wrong { border-color: var(--bad); color: var(--bad); opacity: .6; cursor: default; }
.choice.answer { border: 2px solid var(--good); }
@media (max-width: 520px) { .mc { grid-template-columns: 1fr; } }

/* Rotation: rotated images sit in a square sized to the box's shorter side */
.flag-wrap, .rot-box { container-type: size; }
#flag.rot, img.rot { width: 100cqmin; height: 100cqmin; transform: rotate(var(--angle, 0deg)) scale(var(--rot-scale, 1)); }
img.rot.spin { animation: spin var(--spin-dur, 4s) linear infinite; }
@keyframes spin {
  from { transform: rotate(0deg) scale(var(--rot-scale, 1)); }
  to { transform: rotate(360deg) scale(var(--rot-scale, 1)); }
}
@media (prefers-reduced-motion: reduce) { img.rot.spin { animation-duration: calc(var(--spin-dur, 4s) * 3); } }

/* Grid layout */
main:has(#grid:not([hidden])) { max-width: 1440px; padding-top: 20px; }
main:has(#grid:not([hidden])) .tabs { display: none; }
.grid-actions { margin: 0 0 16px; }
.grid-cells {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.cell {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cell-img { height: 120px; display: flex; align-items: center; justify-content: center; }
.cell-img img { max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 1px 3px rgba(0,0,0,.3)); }
.cell-img img.rot { max-width: none; max-height: none; }
.cell input {
  width: 100%;
  font: inherit;
  padding: 7px 9px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.cell input:focus { border-color: var(--accent); }
.cell input.shake { animation: shake .3s; border-color: var(--bad); }
.cell-mc { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.cell-mc button { padding: 5px 6px; font-size: .8rem; line-height: 1.2; }
.cell-name { text-align: center; font-weight: 600; padding: 7px 0; }
.cell.right { border-color: var(--good); }
.cell.right .cell-name { color: var(--good); }
.cell.late { border-color: #d97706; }
.cell.late .cell-name { color: #d97706; }
.cell.glow { animation: glow-soft .45s ease-out; }
.cell .suggestions { min-width: 200px; max-height: 220px; }
.cell .suggestions li { padding: 6px 10px; font-size: .9rem; }
.tabs { flex-wrap: wrap; max-width: 100%; }
@media (max-width: 520px) { .tabs a { padding: 6px 12px; font-size: .9rem; } }

/* Quiz tabs, grouped World / US states */
.tab-group {
  align-self: center;
  padding: 0 6px 0 12px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Each group stays on one line; the two groups wrap onto separate lines when there isn't room. */
.tab-set { display: flex; gap: 2px; align-items: center; }
.tabs { row-gap: 2px; border-radius: 22px; }
.tabs a { padding: 6px 14px; }

/* Map quiz */
:root {
  --water: #dbeafe;
  --land: #b4c0d0;
  --land-hover: #8796ab;
  --land-off: #e6eaf0;
  --map-border: #ffffff;
}
.map-prompt {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 10px;
  min-height: 1.3em;
}
.map-wrap {
  position: relative;
  height: clamp(260px, calc(100vh - 320px), 720px);
  background: var(--water);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.map-wrap:active { cursor: grabbing; }
/* --k = map units per screen pixel (set from JS), so borders stay hairlines at any zoom without the
   slow vector-effect: non-scaling-stroke. */
#map-svg { width: 100%; height: 100%; display: block; transform-origin: 0 0; will-change: transform; --k: 1; }
#map-svg .bg { fill: var(--land-off); stroke: var(--map-border); stroke-width: calc(var(--k) * .5px); }
#map-svg .place {
  fill: var(--land);
  stroke: var(--map-border);
  stroke-width: calc(var(--k) * .8px);
  stroke-linejoin: round;
  cursor: pointer;
}
#map-svg .place.hover { fill: var(--land-hover); }
#map-svg .place.off { fill: var(--land-off); pointer-events: none; }
#map-svg .dot { stroke: var(--text); stroke-width: calc(var(--k) * 1px); fill-opacity: .9; }
#map-svg .dot.off { display: none; }
/* Borderless: land in one colour, and no hover outline to give the borders away */
/* Borderless: every place and the non-quiz territories (Western Sahara, Greenland…) in one colour,
   with a 1.5px outline in that colour so no seam shows where neighbours meet. Places outside the
   round stay lighter, so you can still see which area is in play. */
#map-svg.borderless .place, #map-svg.borderless .bg { fill: var(--land); stroke: var(--land); stroke-width: calc(var(--k) * 1.5px); }
#map-svg.borderless .place.off { fill: var(--land-off); stroke: var(--land-off); }
#map-svg.borderless .dot { stroke: var(--text); }
#map-svg .place.found, #map-svg .place.right { fill: var(--good); }
#map-svg .place.wrong { fill: var(--bad); }
#map-svg .place.hint, #map-svg .place.answer { fill: #f59e0b; animation: map-pulse .7s ease-in-out infinite alternate; }
@keyframes map-pulse { to { fill-opacity: .45; } }
.map-zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1;
}
.map-zoom button { width: 36px; height: 36px; padding: 0; font-size: 1.2rem; line-height: 1; }
#game:has(#session-panel:not([hidden])) .map-wrap { height: clamp(220px, calc(100vh - 500px), 720px); }
@media (max-width: 900px) {
  #game .map-wrap { height: clamp(220px, calc(100vh - 470px), 560px); }
}
.map-wrap.glow-soft { animation: glow-soft .45s ease-out; }

/* Connect */
main:has(#connect:not([hidden])) { max-width: 1100px; padding-top: 20px; }
main:has(#connect:not([hidden])) .tabs { display: none; }
#connect .map-wrap { height: clamp(240px, calc(100vh - 400px), 620px); }
.connect-prompt { font-weight: 500; }
.cx-end { font-weight: 700; color: var(--accent); }
#map-svg .place.from, #map-svg .place.to { fill: var(--accent); }
#map-svg .place.cx-on { fill: var(--good); }
#map-svg .place.cx-near { fill: #f59e0b; }
#map-svg .place.cx-far { fill: var(--bad); }
#map-svg .place.route { fill: var(--good); animation: map-pulse .7s ease-in-out infinite alternate; }
#connect .guess-box { margin-top: 4px; }
#cx-guess {
  width: 100%;
  font-size: 1.2rem;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  outline: none;
}
#cx-guess:focus { border-color: var(--accent); }
#cx-guess.shake { animation: shake .3s; border-color: var(--bad); }
.cx-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.cx-list li { padding: 4px 10px; border-radius: 999px; font-size: .9rem; font-weight: 600; color: #fff; }
.cx-list li.cx-on, .cx-key.cx-on { background: var(--good); }
.cx-list li.cx-near, .cx-key.cx-near { background: #f59e0b; }
.cx-list li.cx-far, .cx-key.cx-far { background: var(--bad); }
.cx-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px 0 10px; vertical-align: -1px; }
.regions button:disabled { opacity: .5; cursor: default; border-color: var(--border); }

/* Page text under the quiz options (also what search engines read) and the footer */
.seo-text { max-width: 640px; margin: 40px auto 0; color: var(--muted); line-height: 1.6; }
.seo-text h2 { text-align: left; font-size: 1.1rem; color: var(--text); margin: 24px 0 6px; }
.seo-text p { margin: 0 0 10px; }
.more-quizzes { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.more-quizzes a {
  display: block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-size: .9rem;
}
.more-quizzes a:hover { border-color: var(--accent); }
.site-footer { text-align: center; margin: 40px 0 8px; font-size: .9rem; }
.site-footer a, .static-page main a { color: var(--accent); }
main:has(#game:not([hidden])) .site-footer,
main:has(#grid:not([hidden])) .site-footer,
main:has(#connect:not([hidden])) .site-footer { display: none; }
.static-page main { line-height: 1.6; }
.static-page h2 { text-align: left; margin-top: 28px; }
.static-page .more-quizzes a { color: var(--text); }

/* Light/dark toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  margin-left: 4px;
  border-radius: 999px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.theme-toggle:hover { color: var(--text); border-color: var(--border); }
.theme-toggle svg { width: 18px; height: 18px; }
.site-footer .theme-toggle { vertical-align: middle; margin-left: 8px; }
