@font-face { font-family: "Manrope"; src: url("fonts/manrope-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("fonts/manrope-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("fonts/manrope-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("fonts/manrope-latin-800-normal.woff2") format("woff2"); font-weight: 800; font-display: swap; }

/* Geography Gym, "Clean": one centered column, the flag is the only loud thing on screen. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #15171c;
  --muted: #5b6270;
  --line: #dfe3e8;
  --track: #e3e6eb;
  --accent: #2f6bff;
  --good: #15803d;
  --good-bg: #e7f6ec;
  --bad: #c62828;
  --bad-bg: #fdecec;
  --flag-shadow: 0 1px 2px rgba(20, 23, 28, .08), 0 16px 40px -12px rgba(20, 23, 28, .25);
  --pop-shadow: 0 12px 40px -8px rgba(20, 23, 28, .22);
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #181b21;
  --ink: #eef0f3;
  --muted: #9aa1ad;
  --line: #2a2f38;
  --track: #262a31;
  --accent: #7aa2ff;
  --good: #4ade80;
  --good-bg: #13291c;
  --bad: #f87171;
  --bad-bg: #2d1717;
  --flag-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 24px 60px -16px rgba(0, 0, 0, .8);
  --pop-shadow: 0 12px 40px -8px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font: 500 16px/1.5 var(--font); display: flex; flex-direction: column; min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { flex: none; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 48px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.logo svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.top-right { display: flex; align-items: center; gap: 12px; }
.progress-mini { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); font-weight: 600; margin-right: 8px; }
.progress-mini b { color: var(--ink); font-weight: 700; }
.bar { width: 120px; height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .4s; }
.icon-btn, .menu-btn { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn { width: 44px; }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .i-moon, :root:not([data-theme="dark"]) .i-sun { display: none; }
.menu-btn { gap: 8px; padding: 0 14px 0 16px; font-size: 15px; font-weight: 700; }
.menu-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.menu-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.icon-btn:hover, .menu-btn:hover { border-color: var(--muted); }

/* Popovers: topic menu and settings panel */
.pop-wrap { position: relative; }
.pop { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--pop-shadow); z-index: 20; overflow: auto; max-height: calc(100vh - 100px); }
.menu { width: 220px; padding: 6px; }
.menu-list { display: grid; gap: 2px; }
.menu-list a { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 40px; padding: 0 12px; border-radius: 9px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 15px; }
.menu-list a:hover { background: var(--bg); }
.menu-list .chk { width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.menu-list a[aria-current] { font-weight: 800; }
.menu-list a[aria-current] .chk { visibility: visible; }

.panel { width: 300px; padding: 20px; display: grid; gap: 18px; }
.panel-title { font-size: 15px; font-weight: 800; }
.panel-title span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.field { display: grid; gap: 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.field select { height: 40px; width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 0 10px; font-weight: 600; font-size: 15px; color: var(--ink); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; font-size: 15px; cursor: pointer; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 36px; height: 20px; margin: 0; border-radius: 99px; background: var(--track); position: relative; cursor: pointer; transition: background .15s; }
.switch::before { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::before { transform: translateX(16px); }
.link-btn { justify-self: start; border: 0; background: none; padding: 0; color: var(--muted); font-weight: 600; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.link-btn:hover { color: var(--bad); text-decoration-color: currentColor; }
.icon-btn[aria-expanded="true"] { border-color: var(--muted); background: var(--bg); }

/* Mode row */
.modes { display: flex; justify-content: center; gap: 6px; padding: 0 20px; margin: -6px 0 6px; overflow-x: auto; scrollbar-width: none; }
.modes a { flex: none; padding: 8px 12px; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 15px; border-bottom: 2px solid transparent; }
.modes a:hover { color: var(--ink); }
.modes a[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }

/* Segmented control */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 8px 12px; font-weight: 700; font-size: 14px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg.soft { border: 0; background: var(--bg); padding: 3px; gap: 3px; border-radius: 10px; }
.seg.soft button { border-radius: 7px; padding: 6px 8px; }
.seg.soft button + button { border-left: 0; }
.seg.soft button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 1px var(--line); }

/* Main column */
main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 20px 48px; }
.view { width: 100%; max-width: 600px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.view.wide { max-width: 1100px; justify-content: flex-start; }
.view[hidden] { display: none; }
.loading { margin: auto; color: var(--muted); font-weight: 600; }

.flag { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; box-shadow: var(--flag-shadow); }
.qflag { width: min(440px, 100%); }
.qflag .flag { border-radius: 10px; }
.qflag.small { width: min(220px, 60%); margin-bottom: 14px; }
.qflag.small .flag { border-radius: 8px; }
.prompt { margin: 28px 0 0; color: var(--muted); font-weight: 600; font-size: 15px; text-align: center; }
.qname { font-size: clamp(28px, 6vw, 40px); font-weight: 800; letter-spacing: -0.02em; text-align: center; margin: 4px 0 4px; }
.answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; margin-top: 16px; }
.answer { min-height: 58px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 17px; font-weight: 700; padding: 10px 14px; transition: border-color .12s, background .12s, transform .08s; }
.answer:hover:not(:disabled) { border-color: var(--muted); }
.answer:active:not(:disabled) { transform: scale(.985); }
.answer:disabled { cursor: default; }
.answer.right { border-color: var(--good); background: var(--good-bg); color: var(--good); }
.answer.wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.answer.dim { opacity: .45; }
.flag-answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; width: 100%; margin-top: 20px; }
.flag-answer { border: 2px solid transparent; background: none; padding: 6px; border-radius: 14px; display: grid; gap: 6px; }
.flag-answer:hover:not(:disabled) { border-color: var(--line); }
.flag-answer:disabled { cursor: default; }
.flag-answer.right { border-color: var(--good); background: var(--good-bg); }
.flag-answer.wrong { border-color: var(--bad); background: var(--bad-bg); }
.flag-answer .cap { font-size: 14px; font-weight: 700; min-height: 1.5em; }
.type-row { display: flex; gap: 10px; width: 100%; margin-top: 16px; }
.type-row input { flex: 1; min-width: 0; height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 16px; font-size: 18px; font-weight: 600; }
.type-row input:focus { outline: none; border-color: var(--accent); }
.type-row input.right { border-color: var(--good); background: var(--good-bg); }
.type-row input.wrong { border-color: var(--bad); background: var(--bad-bg); }
.btn { height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 15px; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover:not(:disabled) { opacity: .9; }
.btn:disabled { opacity: .5; cursor: default; }
.type-row .btn { height: 56px; }

.below { margin-top: 18px; min-height: 24px; color: var(--muted); font-size: 14px; font-weight: 600; text-align: center; }
.result { margin-top: 22px; width: 100%; display: grid; gap: 14px; justify-items: center; text-align: center; }
.result-line { font-size: 17px; font-weight: 700; }
.result-line.good { color: var(--good); }
.result-line.bad { color: var(--bad); }
.result-sub { color: var(--muted); font-size: 14px; font-weight: 600; margin-top: -8px; }
.tip { width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--surface); font-size: 14px; color: var(--muted); }
.tip b { color: var(--ink); }
.minis { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.minis figure { margin: 0; width: 70px; font-size: 12px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.minis figcaption { margin-top: 4px; }
.minis .flag { border-radius: 4px; }
.kbd-hint { font-size: 13px; color: var(--muted); }
.kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 12px; font-weight: 700; }

/* Quiz */
.qtop { width: 100%; display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 18px; gap: 12px; }
.qtrack { flex: 1; height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; }
.qtrack span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.setup { display: grid; gap: 22px; justify-items: center; text-align: center; width: 100%; max-width: 420px; }
.setup h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; }
.setup p { margin: 6px 0 0; color: var(--muted); }
.setup .field { display: grid; gap: 8px; width: 100%; }
.setup .field > span { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.setup .btn.primary { width: 100%; height: 52px; font-size: 16px; }
.score { font-size: 64px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.score small { font-size: 28px; color: var(--muted); }
.misses { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px; width: 100%; margin-top: 8px; text-align: left; }
.misses figure { margin: 0; font-size: 13px; font-weight: 700; }
.misses figcaption { margin-top: 6px; }
.misses .of { color: var(--muted); font-weight: 600; }
.misses small { display: block; color: var(--bad); font-weight: 600; }

/* Name them (the #name-all mode) */
.na-bar { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; width: 100%; padding: 8px 0 16px; }
.na-bar input { flex: 1 1 260px; min-width: 0; height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 16px; font-size: 18px; font-weight: 600; }
.na-bar input:focus { outline: none; border-color: var(--accent); }
.na-bar input.flash { border-color: var(--good); background: var(--good-bg); }
.na-stat { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; min-width: 64px; text-align: center; }
#naBanner { width: 100%; }
.banner { width: 100%; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; margin-bottom: 8px; }
.banner.good { border-color: var(--good); background: var(--good-bg); color: var(--good); }
.na-hint { color: var(--muted); font-size: 14px; margin: 0 0 8px; width: 100%; }
#naBoard { width: 100%; }
.region-h { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.region-h h2 { font-size: 18px; font-weight: 800; }
.region-h span { color: var(--muted); font-size: 14px; font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 18px 14px; }
.tile .flag { border-radius: 6px; }
.tile-of { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.2; }
.tile-of + .lab { margin-top: 2px; }
.tile .lab { margin-top: 6px; font-size: 13px; font-weight: 700; line-height: 1.25; min-height: 2.5em; color: var(--muted); }
.tile.found .lab { color: var(--good); }
.tile.missed .lab { color: var(--bad); }
.tile.found .flag { animation: settle .3s ease-out; }
@keyframes settle { from { transform: scale(1.06); } }

/* Browse */
.browse-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; width: 100%; margin-bottom: 20px; }
.browse-bar input[type="search"] { flex: 1 1 200px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; font-weight: 600; }
#browseBody { width: 100%; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 22px 16px; }
.card { border: 0; background: none; padding: 0; text-align: left; display: grid; gap: 8px; }
.card .nm { font-weight: 700; display: flex; align-items: center; gap: 7px; line-height: 1.25; }
.card .sub { font-size: 13px; color: var(--muted); margin-top: -6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--track); flex: none; }
.dot.mastered { background: var(--good); }
.dot.learning { background: var(--accent); }
.card.hidden .nm span:not(.dot), .card.hidden .sub { filter: blur(6px); user-select: none; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.group { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 16px; display: grid; gap: 6px; align-content: start; }
.group h3 { font-size: 16px; font-weight: 800; }
.group p { margin: 0; font-size: 14px; color: var(--muted); }
.empty { padding: 40px 0; text-align: center; color: var(--muted); font-weight: 600; }

@media (max-width: 640px) {
  .top { padding: 16px 18px; }
  .top { gap: 10px; }
  .top-right { display: contents; }
  .logo { margin-right: auto; }
  .topic-wrap { order: 3; width: 100%; }
  .menu-btn { width: 100%; justify-content: space-between; }
  .menu { left: 0; right: 0; width: auto; }
  .panel { position: fixed; left: 12px; right: 12px; top: 70px; width: auto; }
  .modes { justify-content: flex-start; margin-top: 0; }
  .modes a { padding: 8px 10px; font-size: 14px; }
  .progress-mini { order: 4; width: 100%; margin: 0; }
  .bar { flex: 1; }
  .answers { gap: 10px; }
  .answer { font-size: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
  .cards { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
