/* Shared styles for every page. Default palette "Alluka": light pink and coral. Dark default: "Orchid". */
:root {
  --bg: #fff8f8;
  --panel: #ffffff;
  --fg: #3b2327;
  --muted: #9c6f76;
  --line: #fbd5d6;
  --sea: #ffecee;
  --water: #ffecee;
  --land: #ffd9d0;
  --land-edge: #ff8f7e;
  --found: #e5533f;
  --missed: #b49ca1;
  --accent: #e8553f;
  --target: #6d2e5b;
  --target-edge: #ffffff;
  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f141a; --panel: #2a1b23; --fg: #f8e8ef; --muted: #c49aad; --line: #4a2e3b;
    --sea: #2f1d27; --water: #2f1d27; --land: #3d2632; --land-edge: #f08fb0; --found: #ff7aa8; --missed: #9d8590; --accent: #ff8fb5; --target: #ffd166; --target-edge: #1f141a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1f141a; --panel: #2a1b23; --fg: #f8e8ef; --muted: #c49aad; --line: #4a2e3b;
  --sea: #2f1d27; --water: #2f1d27; --land: #3d2632; --land-edge: #f08fb0; --found: #ff7aa8; --missed: #9d8590; --accent: #ff8fb5; --target: #ffd166; --target-edge: #1f141a;
  color-scheme: dark;
}
/* Theme picker overrides (set by assets/theme.js). Listed after the system-theme blocks so a picked theme wins. */
:root[data-palette="alluka"] {
  --bg: #fff8f8; --panel: #ffffff; --fg: #3b2327; --muted: #9c6f76; --line: #fbd5d6;
  --sea: #ffecee; --water: #ffecee; --land: #ffd9d0; --land-edge: #ff8f7e; --found: #e5533f; --missed: #b49ca1; --accent: #e8553f; --target: #6d2e5b; --target-edge: #ffffff;
  color-scheme: light;
}
:root[data-palette="classic"] {
  --bg: #ffffff; --panel: #ffffff; --fg: #111111; --muted: #5c5c5c; --line: #d4d4d4;
  --sea: #ffffff; --water: #ffffff; --land: #ffffff; --land-edge: #111111; --found: #111111; --missed: #9a9a9a; --accent: #111111; --target: #ffffff; --target-edge: #111111;
  color-scheme: light;
}
:root[data-palette="orchid"] {
  --bg: #1f141a; --panel: #2a1b23; --fg: #f8e8ef; --muted: #c49aad; --line: #4a2e3b;
  --sea: #2f1d27; --water: #2f1d27; --land: #3d2632; --land-edge: #f08fb0; --found: #ff7aa8; --missed: #9d8590; --accent: #ff8fb5; --target: #ffd166; --target-edge: #1f141a;
  color-scheme: dark;
}
:root[data-palette="classic-dark"] {
  --bg: #111111; --panel: #1a1a1a; --fg: #f2f2f2; --muted: #a3a3a3; --line: #333333;
  --sea: #111111; --water: #111111; --land: #111111; --land-edge: #f2f2f2; --found: #f2f2f2; --missed: #6b6b6b; --accent: #f2f2f2; --target: #111111; --target-edge: #f2f2f2;
  color-scheme: dark;
}
.theme-pick { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 14px; }
.theme-pick select { font: 600 13px var(--font-body); color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 48px;
}
a { color: var(--accent); }
main { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(24px, 5vw, 34px); line-height: 1.1; margin: 0; text-wrap: balance; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Site navigation */
.site-nav { max-width: 1040px; margin: 0 auto 20px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 14px; }
.site-nav .brand { font-family: var(--font-display); font-weight: 800; font-size: 17px; color: var(--fg); text-decoration: none; margin-right: auto; }
.site-nav .brand span { color: var(--accent); }
.site-nav a:not(.brand) { color: var(--muted); text-decoration: none; font-weight: 600; }
.site-nav a:not(.brand):hover, .site-nav a[aria-current="page"] { color: var(--accent); }
.crumbs { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }

/* Home and category pages */
.hero { display: flex; flex-direction: column; gap: 8px; padding-block: 12px 8px; max-width: 640px; }
.hero p { margin: 0; color: var(--muted); font-size: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--fg);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card h2, .card h3 { font-family: var(--font-display); font-size: 18px; margin: 0; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card .mode { font: inherit; color: inherit; }
.card .meta { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.sub-head { font-family: var(--font-display); font-size: 17px; font-weight: 700; color: var(--muted); margin: 22px 0 10px; }
.subsub-head { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 14px 0 8px; }
.sub-head:first-child { margin-top: 4px; }
.group-head { font-family: var(--font-display); font-size: 22px; font-weight: 800; margin: 4px 0 10px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.card.soon { opacity: .6; pointer-events: none; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.tabs button {
  font: 600 14px var(--font-body); border-radius: 999px; padding: 7px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg);
}
.tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.tabs .count { font-family: var(--font-mono); font-size: 12px; opacity: .75; margin-left: 4px; }
.empty-tab { color: var(--muted); background: var(--sea); border: 1px dashed var(--line); border-radius: 12px; padding: 20px; margin: 0; }

/* Quiz */
.top { max-width: 760px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.quiz-head { display: flex; flex-direction: column; gap: 2px; }
.best { margin: 6px 0 0; font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.best.perfect { display: inline-block; align-self: flex-start; color: var(--found); border: 1px solid var(--found); border-radius: 999px; padding: 2px 10px; }
.best[hidden] { display: none; }
.card .best { margin-top: 4px; font-size: 12px; }
.intro { margin: 6px 0 0; font-size: 14px; color: var(--fg); background: var(--sea); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; max-width: 65ch; }
.bar {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
}
.bar input[type="text"] {
  min-width: 0; width: 100%; font: 500 17px var(--font-body); color: var(--fg); background: var(--bg);
  border: 2px solid var(--line); border-radius: 8px; padding: 10px 12px; outline: none;
}
.bar input[type="text"]:focus { border-color: var(--accent); }
.bar input[type="text"].flash { border-color: var(--found); }
.bar input[type="text"]:disabled { opacity: .6; }
.bar input[type="text"].shake { animation: shake .3s; border-color: var(--missed); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.stat { font-family: var(--font-mono); font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; text-align: center; min-width: 76px; }
.stat small { display: block; font-family: var(--font-body); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat.low { color: var(--found); }
.feedback { flex: 1 1 160px; margin: 0; min-width: 0; font-size: 14px; color: var(--muted); text-align: center; }
.feedback.ok { color: var(--found); font-weight: 600; }
.feedback.bad { color: var(--fg); }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.buttons { display: flex; gap: 8px; }
.buttons button {
  font: 600 14px var(--font-body); border-radius: 8px; padding: 9px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg);
}
.buttons button.primary { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.buttons button:disabled { opacity: .5; cursor: default; }

.board { position: relative; background: var(--water); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.board svg { display: block; width: 100%; height: auto; max-height: 70vh; cursor: zoom-in; }
.board svg.zoomed { cursor: zoom-out; }
/* Wide maps (the World) stretch across most of the screen. */
.board.wide { width: calc(100vw - 48px); margin-left: calc(50% - 50vw + 24px); }
.board.wide svg { max-height: 82vh; }
.other-land { fill: var(--water); stroke: var(--line); stroke-width: 1px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.lake { fill: var(--water); stroke: var(--land-edge); stroke-width: 1.5px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
/* Lakes on land that isn't part of the quiz get the same thin outline as that land. */
.lake.lake-other { stroke: var(--line); stroke-width: 1px; }
.no-labels .label { display: none; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.country { fill: var(--land); stroke: var(--land-edge); stroke-width: 2px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.dot { fill: var(--found); fill-opacity: .85; stroke: var(--panel); stroke-width: var(--dot-stroke, 3px); }
.missed .dot { fill: var(--missed); }
.pending .dot { fill: var(--target); fill-opacity: 1; stroke: var(--target-edge); stroke-width: calc(var(--dot-stroke, 2px) * 1.5); }
.pending .label { display: none; }
.label { font: 700 var(--label-size, 22px) var(--font-body); fill: var(--fg); paint-order: stroke; stroke: var(--land); stroke-width: calc(var(--label-size, 22px) / 4.4); stroke-linejoin: round; }
.missed .label { fill: var(--missed); }
.pop { animation: pop .35s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

.result {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.result strong { font-family: var(--font-display); font-size: 20px; }
.result span { color: var(--muted); }

.columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.columns.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 820px) { .columns { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .columns, .columns.two { grid-template-columns: 1fr; } }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.col h2 { font-family: var(--font-display); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin: 0; }
.limit { font: 600 12px var(--font-body); color: var(--fg); background: var(--sea); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; cursor: pointer; }
.col ol { margin: 0; padding-left: 26px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.col ol li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
.col .empty { color: var(--muted); font-size: 14px; margin: 0; }
.more { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.place-name { color: var(--muted); }
.popn { color: var(--muted); font-variant-numeric: tabular-nums; }
.star { color: var(--found); }
.tally .row { display: flex; justify-content: space-between; gap: 8px; }
.tally b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--found); }
.tiers { display: flex; flex-direction: column; gap: 10px; }
.tier { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; font-size: 14px; }
.tier b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.meter { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--sea); border: 1px solid var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--found); width: 0; transition: width .3s; }
.answer-table-wrap { padding-bottom: 6px; }
.table-scroll { overflow-x: auto; }
.answer-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.answer-table th, .answer-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.answer-table thead th { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.answer-table tbody th { font-weight: 500; width: 55%; }
.answer-table .role { color: var(--muted); font-weight: 400; font-size: 13px; }
.answer-table td { font-weight: 600; }
.answer-table td.got { color: var(--found); }
.answer-table .aside { display: block; font-weight: 400; font-size: 12px; color: var(--muted); font-style: italic; }
.answer-table td.missed { color: var(--missed); }
.answer-table tbody tr:nth-child(even) { background: var(--sea); }
.source { font-size: 12px; color: var(--muted); margin: 0; }

@media (max-width: 520px) {
  .bar { grid-template-columns: 1fr 1fr; }
  .bar input[type="text"] { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .pop, .bar input[type="text"].shake { animation: none; }
  .meter i, .card { transition: none; }
}

.pop-summary { margin: 0; font-size: 15px; color: var(--fg); text-align: center; }

/* Compact boxes for per-state quiz lists */
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mini-box { background: var(--sea); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mini-box h3 { margin: 0 0 2px; font-family: var(--font-display); font-size: 14px; font-weight: 700; }
.mini-box a { font-size: 13px; color: var(--accent); text-decoration: none; display: flex; justify-content: space-between; gap: 6px; }
.mini-box a:hover { text-decoration: underline; }
.mini-box .best { position: static; font-size: 11px; padding: 0 5px; margin: 0; }

/* Missed cities, listed after a population quiz ends */
.missed { margin-top: 18px; background: var(--sea); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.missed h2 { margin: 0 0 8px; font-family: var(--font-display); font-size: 17px; }
.missed-list { margin: 0; padding-left: 2.2em; columns: 3 220px; column-gap: 28px; font-size: 14px; }
.missed-list li { break-inside: avoid; padding: 2px 0; }
.missed-list li > span { display: inline-flex; }
.missed-list .missed-name { margin-right: 8px; }
.missed-list .missed-pop { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Home page search */
.search { max-width: 720px; margin: 8px 0 20px; }
.search input { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--sea); color: inherit; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-count { margin: 8px 2px 4px; color: var(--muted); font-size: 13px; min-height: 1em; }
.search-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.search-results a { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--sea); color: inherit; text-decoration: none; }
.search-results a:hover, .search-results li:first-child a { border-color: var(--accent); }
.sr-title { font-weight: 600; flex: 1 1 260px; min-width: 0; }
.sr-meta { color: var(--muted); font-size: 13px; }
.search-results .best { margin: 0; font-size: 12px; }
.sr-more { color: var(--muted); font-size: 13px; padding: 4px 2px; }

/* Little place maps in the catalog */
.thumb { display: block; fill: var(--land); stroke: var(--land-edge); stroke-width: 0.8px; stroke-linejoin: round; vector-effect: non-scaling-stroke; overflow: visible; }
.card .thumb { width: 64px; height: 44px; margin-bottom: 2px; }
.mini-box h3 { display: flex; align-items: center; gap: 8px; }
.mini-box .thumb { width: 34px; height: 24px; flex: none; }
.thumb.letter text { font: 800 20px var(--font-display); fill: var(--accent); stroke: none; }
.mini-box h3.letter-head { font-size: 26px; line-height: 1; color: var(--accent); margin: 2px 0 4px; }
/* Two-column results (tablets, narrow windows): keep "Best countries" right under "By population". */
@media (min-width: 521px) and (max-width: 820px) { .columns .col-countries { grid-column: 2; } }

/* Citydle: bright pill in the top bar and a promo card on the home page. */
.site-nav a.nav-citydle { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px 5px 10px; border-radius: 999px; font-weight: 800; color: #24101b; text-decoration: none;
  background: linear-gradient(120deg, #ff6b9d, #ffb347 45%, #4fd1c5); background-size: 200% 100%; box-shadow: 0 2px 12px rgba(255, 107, 157, .35); animation: cdShine 6s ease-in-out infinite; }
.site-nav a.nav-citydle:hover, .site-nav a.nav-citydle[aria-current="page"] { color: #24101b; filter: brightness(1.08); }
.nav-citydle-dot { width: 7px; height: 7px; border-radius: 50%; background: #24101b; box-shadow: 0 0 0 0 rgba(36, 16, 27, .6); animation: cdBlip 1.6s ease-out infinite; }
.nav-citydle-tag { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; background: rgba(36, 16, 27, .85); color: #fff; padding: 2px 6px; border-radius: 999px; }
@keyframes cdShine { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes cdBlip { 0% { box-shadow: 0 0 0 0 rgba(36, 16, 27, .55); } 100% { box-shadow: 0 0 0 7px rgba(36, 16, 27, 0); } }
.citydle-promo { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px; align-items: center; margin: 8px 0 18px; padding: 22px 24px;
  border-radius: 18px; text-decoration: none; color: #24101b; background: linear-gradient(120deg, #ff6b9d 0%, #ffb347 50%, #4fd1c5 100%); background-size: 200% 100%;
  box-shadow: 0 10px 30px rgba(255, 107, 157, .3); animation: cdShine 10s ease-in-out infinite; transition: transform .15s ease, box-shadow .15s ease; }
.citydle-promo:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(255, 107, 157, .42); }
.citydle-promo .kicker { display: inline-flex; gap: 8px; align-items: center; font: 800 12px var(--font-body); letter-spacing: .08em; text-transform: uppercase; }
.citydle-promo .kicker b { background: #24101b; color: #fff; padding: 3px 8px; border-radius: 999px; }
.citydle-promo h2 { margin: 6px 0 6px; font: 800 clamp(30px, 6vw, 44px)/1 var(--font-display); letter-spacing: -.01em; }
.citydle-promo p { margin: 0 0 14px; font-size: 15px; max-width: 46ch; color: #3a1a2b; }
.citydle-promo .cta { display: inline-flex; align-items: center; gap: 8px; background: #24101b; color: #fff; font: 700 15px var(--font-body); padding: 10px 16px; border-radius: 999px; }
.citydle-promo .done { margin-left: 10px; font-weight: 700; font-size: 14px; }
.citydle-promo svg { width: 100%; height: auto; }
.citydle-promo .ring { animation: cdRing 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes cdRing { from { opacity: .9; transform: scale(1); } to { opacity: 0; transform: scale(3.2); } }
@media (max-width: 560px) { .citydle-promo { grid-template-columns: 1fr; } .citydle-promo svg { display: none; } }
@media (prefers-reduced-motion: reduce) { .site-nav a.nav-citydle, .citydle-promo, .nav-citydle-dot, .citydle-promo .ring { animation: none; } }
