/* Worldly: a field card floating over a live globe.
   One typeface (Lexend, built for reading fluency: kids reading unfamiliar
   place names). One bold device: pressable signal-yellow game buttons and very
   large question type. Each subject has its own colour, taken from map symbology,
   and the panel's top band shows which subject you're in. */

@font-face {
  font-family: "Lexend";
  src: url("fonts/lexend-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Lexend";
  src: url("fonts/lexend-latin-ext-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ink: #172a46;
  --ink-2: #4b5d78;
  --ink-3: #7d8ca3;
  --fog: #eef3f2;
  --card: #ffffff;
  --line: #d5dfe0;
  --signal: #ffc93c;
  --signal-glow: rgba(255, 201, 60, .35);
  /* The Solar System view (G6): space is dark in light and dark themes alike, so one value. */
  --void: #060a13;
  --void-ink: #eef3ff;
  --void-veil: rgba(6, 10, 19, .62);
  --void-dim: #93a1bb;
  --signal-deep: #d99a00;
  --capitals: #e4572e;
  --countries: #3a86d6;
  --regions: #7a5ad3;
  --flags: #1f9e74;
  --physical: #12858f;
  --space: #5b5fd6;
  --chemistry: #b7791f;
  --good: #23a066;
  --bad: #d9483b;
  --learning: #f79d65;
  --young: #4ea5d9;
  --mature: #23a066;
  --subject: var(--ink);
  /* Surfaces that stay dark in both themes (the top bar, toasts) and the colours that sit on
     top of a fill. In light they are the ink; dark mode (below) gives each its own value. */
  --chrome: #172a46;
  --press: #172a46;      /* the pressable buttons' edge and the shadow they sink into */
  --sel: #172a46;        /* a picked card's edge */
  --on-signal: #172a46;
  --on-subject: #fff;
  --on-ink: #fff;
  --track: #e2e9ea;
  --track-2: #dfe7e8;
  --chip-edge: #d6dbe2;
  --tint: 10%;           /* a picked subject card: this much subject colour over the card */
  --good-field: #e9f7ef; --bad-field: #fdeeec;
  --good-soft: #e6f6ed; --good-edge: #9fdbbd; --good-deep: #12583a; --good-flash: #c9efd9; --good-text: #1b7d4f;
  --bad-soft: #fdebe8; --bad-edge: #f2b2a9; --bad-deep: #8c241a;
  --info-soft: #fff6dc; --info-edge: #f3dc94;
  --review-soft: #dcebf8; --review-deep: #1f5a93;
  --link: #1f5a93;        /* links in notes and photo credits (the browser's blue was unreadable in dark) */
  --learning-soft: #fde4d3; --learning-deep: #9a4512;
  --flag-edge: rgba(23, 42, 70, .15);
  --flag-float: rgba(8, 18, 36, .55);  /* the edge and shadow of a flag drawn large over the map */
  --flag-xl-shadow: 0 0 0 1px rgba(23, 42, 70, .18), 0 6px 18px rgba(23, 42, 70, .12);
  --panel-shadow: 0 18px 50px rgba(8, 18, 36, .35), 0 2px 8px rgba(8, 18, 36, .18);
  --scrim: rgba(8, 18, 36, .45);  /* behind a modal sheet */
  --scrim-deep: rgba(8, 18, 36, .92);  /* behind an enlarged photo or flag */
  --on-chrome: #fff;      /* text and icons on --chrome */
  --font: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
  --layout: side;        /* which layout is in force: set by the layout media queries, read by js/layout.js */
  --panel-w: clamp(340px, 32vw, 420px);
  --safe-l: env(safe-area-inset-left, 0px);
  /* The top bar: its own height plus the status bar's when installed (black-translucent on iOS). */
  --top-base: 60px;
  --top-h: calc(var(--top-base) + env(safe-area-inset-top, 0px));
  /* type scale, ratio 1.25 */
  --t-xs: 12.5px; --t-s: 14px; --t-m: 16px; --t-l: 20px; --t-xl: 25px; --t-2xl: 32px; --t-3xl: 44px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font: 400 var(--t-m)/1.5 var(--font); color: var(--ink); background: #0e1c33; -webkit-font-smoothing: antialiased; }
#map { position: fixed; inset: 0; }
.maplibregl-ctrl-attrib { font: 11px/1.4 system-ui, sans-serif; }

/* --- stage: a set's own view in place of the map (js/stage.js; the list view, G5) ---------- */
#stage { position: fixed; z-index: 2; top: var(--top-h); right: 0; bottom: 0; left: calc(var(--panel-w) + 32px + var(--safe-l));
  overflow-y: auto; padding: 28px 24px; background: #0e1c33; }
#stage[hidden] { display: none; }
body.staged #map { visibility: hidden; }

/* --- the periodic table view (js/viz/periodic.js) and element cards (js/chem.js) ------------ */
/* Family colours: pastel tiles that stay distinct from the game's yellow / green / red states.
   The table sits on the stage's navy in both themes, so the tiles keep their colours in dark. */
:root {
  --fam-alkali: #f4a19a; --fam-alkaline: #ffc98a; --fam-transition: #e9d5ad; --fam-post: #a9dccb;
  --fam-metalloid: #c6e3a0; --fam-nonmetal: #9fc9f5; --fam-halogen: #c3b1f0; --fam-noble: #f2a9d4;
  --fam-lanthanoid: #8fdde6; --fam-actinoid: #dba6e6; --el-ink: #14233b;
}
[data-fam="alkali"] { --fam: var(--fam-alkali); } [data-fam="alkaline"] { --fam: var(--fam-alkaline); }
[data-fam="transition"] { --fam: var(--fam-transition); } [data-fam="post"] { --fam: var(--fam-post); }
[data-fam="metalloid"] { --fam: var(--fam-metalloid); } [data-fam="nonmetal"] { --fam: var(--fam-nonmetal); }
[data-fam="halogen"] { --fam: var(--fam-halogen); } [data-fam="noble"] { --fam: var(--fam-noble); }
[data-fam="lanthanoid"] { --fam: var(--fam-lanthanoid); } [data-fam="actinoid"] { --fam: var(--fam-actinoid); }
#panel[data-band="chemistry"] { --subject: var(--chemistry); }
.pick[data-subject^="chemistry/"] svg { color: var(--chemistry); }

#stage.pt-stage { padding: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 35%, #183056 0%, #0e1c33 70%); }
.pt { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.pt.dragging { cursor: grabbing; }
.pt-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.pt-axis { position: absolute; color: #7d8ca3; font-size: 20px; font-weight: 600; display: grid; place-items: center; }
.pt-axis.g { height: 30px; }
.pt-axis.p { width: 34px; }
.pt-tile { position: absolute; width: 94px; height: 94px; border-radius: 10px; background: var(--fam); color: var(--el-ink);
  overflow: hidden; cursor: pointer; transition: background-color .25s, filter .25s, opacity .25s, box-shadow .25s; }
.pt-tile:focus-visible { outline: 4px solid var(--signal); outline-offset: 3px; }
.pt-tile > span { position: absolute; left: 0; right: 0; text-align: center; line-height: 1; white-space: nowrap; }
.pt-num { top: 9px; left: 9px !important; text-align: left !important; font-size: 15px; font-weight: 600; opacity: .8; }
.pt-sym { top: 26px; font-size: 38px; font-weight: 700; letter-spacing: -.5px; }
.pt-name { bottom: 11px; font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.pt-img { position: absolute; inset: 0; background: center / cover no-repeat; opacity: 0; transition: opacity .3s; }
.pt-tile[data-predicted] { background-image: repeating-linear-gradient(135deg, transparent 0 9px, rgba(255, 255, 255, .28) 9px 13px); }
/* Far out: the symbol only, big enough to read. */
.pt[data-lod="1"] .pt-num, .pt[data-lod="1"] .pt-name { display: none; }
.pt[data-lod="1"] .pt-sym { top: 22px; font-size: 50px; }
/* Close in: the photo fills the tile, the words sit on a shade, the family is the rim. */
.pt[data-lod="3"] .pt-tile[data-photo] .pt-img { opacity: 1; }
.pt[data-lod="3"] .pt-tile[data-photo]::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(8, 16, 30, .55) 0%, rgba(8, 16, 30, 0) 42%, rgba(8, 16, 30, 0) 58%, rgba(8, 16, 30, .75) 100%);
  box-shadow: inset 0 0 0 4px var(--fam); }
.pt[data-lod="3"] .pt-tile[data-photo] > span { z-index: 1; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); }
.pt[data-lod="3"] .pt-tile[data-photo] .pt-sym { top: 8px; right: 9px; left: auto; text-align: right; font-size: 24px; }
/* A quiz hides what is asked: names always, symbols or numbers in their own sets, and photos. */
.pt.quiz .pt-tile:not(.shown) .pt-name, .pt.nolabels .pt-tile:not(.shown) .pt-name { visibility: hidden; }
.pt.quiz[data-fact="sym"] .pt-tile:not(.shown) .pt-sym { visibility: hidden; }
.pt.quiz[data-fact="sym"] .pt-tile:not(.shown) .pt-num { display: block; top: 30px; left: 0 !important; text-align: center !important; font-size: 30px; }
.pt.quiz[data-fact="num"] .pt-tile:not(.shown) .pt-num { visibility: hidden; }
.pt.quiz .pt-tile:not(.shown) .pt-img, .pt.quiz .pt-tile:not(.shown)::after { opacity: 0 !important; box-shadow: none; background: none; }
.pt.quiz .pt-tile:not(.shown) > span { color: var(--el-ink) !important; text-shadow: none !important; }
.pt.quiz[data-lod="3"] .pt-tile:not(.shown) .pt-sym { top: 26px; right: 0; left: 0; text-align: center; font-size: 38px; }
/* Game states, the same colours as the map. */
.pt-tile.out { opacity: .22; cursor: default; }
.pt-tile[data-state="dim"] { opacity: .3; }
.pt-tile[data-state="todo"] { filter: grayscale(.9) brightness(.82); }
.pt-tile[data-state="focus"] { background: var(--signal); z-index: 2; box-shadow: 0 0 0 5px #fff, 0 0 26px 8px rgba(255, 201, 60, .75); animation: pt-pulse 1.6s ease-in-out infinite; }
.pt-tile[data-state="good"] { background: var(--good); color: #fff; }
.pt-tile[data-state="bad"] { background: var(--bad); color: #fff; }
.pt[data-lod="3"] .pt-tile[data-photo][data-state="good"]::after { box-shadow: inset 0 0 0 7px var(--good); }
.pt[data-lod="3"] .pt-tile[data-photo][data-state="bad"]::after { box-shadow: inset 0 0 0 7px var(--bad); }
.pt-tile[data-state="good"] > span, .pt-tile[data-state="bad"] > span { color: #fff !important; }
@keyframes pt-pulse { 50% { box-shadow: 0 0 0 5px #fff, 0 0 40px 14px rgba(255, 201, 60, .45); } }
.pt-hold { position: absolute; width: 94px; height: 94px; border-radius: 10px; border: 3px dashed var(--fam); color: var(--fam);
  display: grid; place-items: center; font-size: 17px; font-weight: 600; }
.pt-legend { position: absolute; margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, auto); gap: 12px 26px;
  color: #cfdaea; font-size: 19px; justify-content: start; pointer-events: none; }
.pt-legend li { display: flex; align-items: center; gap: 9px; }
.pt-legend i { width: 22px; height: 22px; border-radius: 6px; background: var(--fam); flex: none; }
.pt-zoom { position: absolute; right: 14px; bottom: 14px; display: grid; gap: 6px; z-index: 3; }
.pt-zoom button { width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .92); color: #172a46;
  font: 600 22px/1 var(--font); cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.pt-zoom button:hover { background: #fff; }
.pt-zoom button:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

/* --- Explore: one explorer per subject (js/explorers/), a switcher heading each panel ------------ */
.explore-switch { display: flex; gap: 6px; margin: 0 0 14px; padding: 4px; border-radius: 14px; background: var(--track); overflow-x: auto; scrollbar-width: none; }
.explore-switch::-webkit-scrollbar { display: none; }
.explore-switch a { flex: 1 0 auto; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 10px; border-radius: 10px;
  font-weight: 600; font-size: var(--t-s); color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.explore-switch a svg { width: 20px; height: 20px; flex: none; }
.explore-switch a:hover { color: var(--ink); }
.explore-switch a.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.explore-switch a:focus-visible { outline: 3px solid var(--signal); outline-offset: 1px; }
.explore-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.explore-chips button { padding: 7px 14px; }
.explore-chips button[aria-pressed="true"] { border-color: var(--sel); box-shadow: inset 0 0 0 1px var(--sel); }
.explore-play { margin-top: 18px; }
.explore-play .row { flex-wrap: wrap; }
.solar-card sup.cite { font-size: .7em; margin-left: 2px; color: var(--ink-3); }
.solar-card ol.sources { margin: 12px 0 0; padding-left: 20px; }
.solar-card ol.sources a { color: inherit; }

/* --- the Solar System view (js/viz/solar.js, G6): space is dark in both themes ------------- */
#stage.solar-stage { padding: 0; overflow: hidden; background: var(--void); }
.solar { position: absolute; inset: 0; overflow: hidden; user-select: none; -webkit-user-select: none; }
.solar-gl, .solar-gl canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.solar-gl canvas { cursor: grab; }
.solar-gl canvas:active { cursor: grabbing; }
.solar-tags { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.solar-label { position: absolute; left: 0; top: 0; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  font: 600 13px/1.35 system-ui, sans-serif; color: var(--void-ink); background: var(--void-veil); }
.solar-label[data-state="good"] { background: var(--good); color: var(--on-ink); }
.solar-label[data-state="bad"] { background: var(--bad); color: var(--on-ink); }
.solar-ring { position: absolute; left: 0; top: 0; border-radius: 50%; border: 3px solid var(--signal); box-sizing: border-box; }
.solar-ring[data-state="focus"] { animation: solar-pulse 1.6s ease-in-out infinite; }
.solar-ring[data-state="good"] { border-color: var(--good); }
.solar-ring[data-state="bad"] { border-color: var(--bad); }
.solar-ring[data-state="todo"] { border-color: var(--void-dim); border-width: 2px; }
@keyframes solar-pulse { 50% { box-shadow: 0 0 0 6px var(--signal-glow); } }
@media (prefers-reduced-motion: reduce) { .solar-ring[data-state="focus"] { animation: none; } }
.solar-ui { position: absolute; right: 14px; bottom: 14px; z-index: 3; display: flex; align-items: flex-end; gap: 10px; }
.solar-layout { display: flex; border-radius: 12px; overflow: hidden; background: var(--void-veil); padding: 3px; gap: 3px; }
.solar-layout button { border: 0; border-radius: 9px; padding: 8px 12px; font: 600 14px system-ui, sans-serif; background: transparent; color: var(--void-ink); cursor: pointer; }
.solar-layout button[aria-pressed="true"] { background: var(--void-ink); color: var(--void); }
.solar-zoom { display: grid; gap: 6px; }
.solar-zoom button { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--void-ink); color: var(--void);
  font: 600 22px/1 system-ui, sans-serif; cursor: pointer; }
.solar-ui button:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
.solar-note { position: absolute; left: 14px; bottom: 10px; right: 230px; margin: 0; z-index: 2; pointer-events: none;
  font: 12px/1.4 system-ui, sans-serif; color: var(--void-dim); }
.solar-wait { position: absolute; inset: 0; display: grid; place-items: center; color: var(--void-dim); font: 14px system-ui, sans-serif; }
.solar-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; padding: 0; }
.solar-sr:focus-within { left: 14px; top: 12px; width: auto; height: auto; clip: auto; overflow: visible; z-index: 5; display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.solar-sr button { padding: 6px 12px; border-radius: 10px; border: 2px solid transparent; background: var(--void-ink); color: var(--void); font: 600 13px system-ui, sans-serif; }
.solar-sr button:focus-visible { border-color: var(--signal); outline: none; }

.el-tile { display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 9px; background: var(--fam); color: var(--el-ink);
  position: relative; flex: none; line-height: 1; }
.el-tile b { font-size: 24px; font-weight: 700; }
.el-tile small { position: absolute; top: 5px; left: 6px; font-size: 11px; font-weight: 600; opacity: .8; }
.el-tile.lg { width: 64px; height: 64px; } .el-tile.lg b { font-size: 29px; }
.el-tile.xl { width: 112px; height: 112px; border-radius: 16px; box-shadow: 0 6px 18px rgba(23, 42, 70, .18); }
.el-tile.xl b { font-size: 52px; } .el-tile.xl small { font-size: 16px; top: 9px; left: 11px; }
.prompt-el { margin: 10px 0 6px; }
.el-card { display: grid; gap: 10px; margin-top: 12px; text-align: left; }
.el-photo { margin: 0; border-radius: 14px; overflow: hidden; background: #0e1c33; aspect-ratio: 16 / 10; box-shadow: inset 0 0 0 3px var(--fam); }
.el-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.el-photo figcaption { font-size: var(--t-xs); color: var(--ink-3); padding: 4px 2px 0; }
.el-photo.none { display: grid; place-items: center; background: repeating-linear-gradient(135deg, var(--fam) 0 14px, color-mix(in srgb, var(--fam) 70%, #fff) 14px 28px); }
.el-photo.none span { font-size: 56px; font-weight: 700; color: var(--el-ink); opacity: .55; }
.el-head { display: flex; gap: 12px; align-items: center; }
.el-name { font-size: var(--t-l); font-weight: 600; }
.el-fam { font-size: var(--t-s); color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.el-fam i { width: 12px; height: 12px; border-radius: 3px; background: var(--fam); }
.el-facts { font-size: var(--t-s); color: var(--ink-2); }
.el-card p { margin: 0; }
.el-seen { font-weight: 500; }
.el-note { font-size: var(--t-s); color: var(--ink-2); }
.el-credit { font-size: 11px; color: var(--ink-3); }
.el-credit a { color: inherit; }
.tour-card .el-tile { margin-right: 2px; }
/* In a game the card sits under the answer: a small square photo beside the words. */
.el-card.compact { grid-template-columns: 104px 1fr; gap: 12px; align-items: start; }
.el-card.compact .el-photo { aspect-ratio: 1; }
.el-card.compact .el-photo figcaption { display: none; }
.el-card.compact .el-photo.none span { font-size: 34px; }
.el-card.compact .el-body { display: grid; gap: 4px; font-size: var(--t-s); }
.viz-list { list-style: none; margin: 0 auto; padding: 0; max-width: 520px; display: grid; gap: 8px; }
.viz-list button { display: flex; align-items: center; justify-content: flex-start; gap: 12px; width: 100%; padding: 10px 14px; border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .06); color: #fff; font: inherit;
  text-align: left; cursor: pointer; transition: background .15s, border-color .15s; }
.viz-list button:hover { background: rgba(255, 255, 255, .1); }
.viz-list button:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
.viz-list .n { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .14); font-weight: 600; font-size: var(--t-s); }
.viz-list .t { font-weight: 500; }
.viz-list li[data-state="focus"] button { border-color: var(--signal); background: rgba(255, 201, 60, .2); }
.viz-list li[data-state="focus"] .n { background: var(--signal); color: var(--on-signal); }
.viz-list li[data-state="good"] button { border-color: var(--good); background: rgba(35, 160, 102, .25); }
.viz-list li[data-state="bad"] button { border-color: var(--bad); background: rgba(217, 72, 59, .25); }
.viz-list li[data-state="todo"] button { opacity: .6; }
.viz-list .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- top bar ---------------------------------------------------------------- */
#top {
  position: fixed; top: 0; left: 0; right: 0; height: var(--top-h); z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: env(safe-area-inset-top, 0px) max(18px, env(safe-area-inset-right, 0px)) 0 max(18px, env(safe-area-inset-left, 0px));
  background: var(--chrome); color: #fff;
}
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none;
  font-weight: 700; font-size: var(--t-l); letter-spacing: -0.02em; }
.brand svg { width: 28px; height: 28px; color: var(--signal); }
/* The two-tone wordmark (brand.js wordmark()): "merang" takes the mark's boomerang colour. The
   deep signal reads on light cards (a logotype, so no contrast minimum); the top bar is always dark. */
.wm-b { color: var(--signal-deep); }
#top .wm-b { color: var(--signal); }
#tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
#tabs[hidden] { display: none; }  /* signed out: nothing behind them yet */
#tabs a { color: #c4cfde; text-decoration: none; padding: 8px 14px; border-radius: 999px; white-space: nowrap; font-weight: 500; }
#tabs a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
#tabs a.on { color: var(--on-signal); background: var(--signal); font-weight: 600; }
.who { display: flex; align-items: center; gap: 8px; border: 0; background: rgba(255, 255, 255, .08); color: inherit;
  border-radius: 999px; padding: 4px 14px 4px 4px; cursor: pointer; font: 500 var(--t-s) var(--font); }
.who:empty { display: none; }
.who .name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who:hover { background: rgba(255, 255, 255, .16); }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #fff;
  font-weight: 700; font-size: var(--t-s); flex: none; }

/* --- panel -------------------------------------------------------------------- */
#panel {
  --pad-b: 24px;  /* bottom padding, which the sticky act zone (.act) reaches through */
  position: fixed; z-index: 5; top: calc(var(--top-h) + 16px); left: calc(16px + var(--safe-l)); width: var(--panel-w);
  /* --app-h is what the keyboard leaves (js/layout.js): a tablet's keyboard covers the panel's bottom. */
  max-height: calc(100% - var(--top-h) - 32px); max-height: calc(var(--app-h, 100%) - var(--top-h) - 32px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--fog); border-radius: 22px; padding: 22px 22px var(--pad-b);
  box-shadow: var(--panel-shadow);
  border-top: 8px solid var(--subject);
  transition: max-height .25s ease;
}
#panel:empty { display: none; }
#panel[data-band="capitals"] { --subject: var(--capitals); }
#panel[data-band="countries"] { --subject: var(--countries); }
#panel[data-band="regions"] { --subject: var(--regions); }
#panel[data-band="flags"] { --subject: var(--flags); }
#panel[data-band="geo"] { --subject: var(--physical); }
#panel[data-band="astronomy"] { --subject: var(--space); }
#panel > * + * { margin-top: 14px; }
#panel > .handle + * { margin-top: 0; }

.handle { display: none; }

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: var(--t-2xl); font-weight: 700; }
h2 { font-size: var(--t-l); font-weight: 650; margin-top: 22px !important; }
h3 { font-size: var(--t-s); font-weight: 600; color: var(--ink-2); }
p { margin: 0; }
.eyebrow { font-size: var(--t-s); font-weight: 600; color: var(--subject); }
#panel:not([data-band]) .eyebrow { color: var(--ink-2); }
.lead { font-size: var(--t-l); line-height: 1.4; color: var(--ink); }
.muted { color: var(--ink-2); }
.small { font-size: var(--t-s); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.bar-top { display: flex; align-items: center; gap: 10px; }
.bar-top .eyebrow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: var(--t-s); color: var(--ink-2); white-space: nowrap; }

/* --- buttons: pressable, they sink when tapped ------------------------------------ */
button, .btn {
  font: 600 var(--t-m)/1 var(--font); border-radius: 14px; padding: 12px 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  border: 2px solid transparent; color: var(--ink); background: var(--card);
  transition: transform .08s ease, box-shadow .08s ease, background-color .15s ease;
}
.primary {
  background: var(--signal); color: var(--on-signal); border-color: var(--press);
  box-shadow: 0 4px 0 var(--press);
}
.primary:hover { background: #ffd35f; }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--press); }
.ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.ghost:hover { border-color: var(--ink-3); }
.ghost:active { transform: translateY(1px); }
.ghost.danger { color: var(--bad); }
.big { width: 100%; padding: 16px 20px; font-size: var(--t-l); border-radius: 16px; }
button.link { background: none; border: 0; padding: 4px; color: var(--ink-2); text-decoration: underline; font-weight: 500; font-size: var(--t-s); }
button:disabled { opacity: .45; cursor: default; transform: none; }
:focus-visible { outline: 3px solid var(--countries); outline-offset: 2px; }

/* --- inputs --------------------------------------------------------------------------- */
input[type=text], input[type=search], input[type=email], select {
  width: 100%; font: 500 var(--t-l)/1.2 var(--font); padding: 14px 16px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
}
select { font-size: var(--t-m); padding: 10px 12px; margin-top: 6px; }
input[type=text]:focus, input[type=search]:focus, input[type=email]:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 4px rgba(255, 201, 60, .45); }
input.good { border-color: var(--good); background: var(--good-field); }
input.bad { border-color: var(--bad); background: var(--bad-field); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.field, .field-l { display: block; font-size: var(--t-s); font-weight: 500; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--t-m); }
label.check input { width: 20px; height: 20px; accent-color: var(--ink); }
input.code { font-family: Menlo, Consolas, monospace; font-size: var(--t-2xl); letter-spacing: .3em; text-align: center; }

/* --- the question ------------------------------------------------------------------------ */
.prompt { user-select: none; -webkit-user-select: none; cursor: default; padding: 4px 0 2px; }
.prompt-flag { line-height: 0; margin-bottom: 10px; }
.prompt-flag.xl { margin: 10px 0 12px; }
/* A landmark's photo (the question, or shown with the answer) and its credit. Tall ones (towers) are
   fitted, not cropped: cropping the CN Tower or Big Ben leaves a stump. */
.photo { margin: 10px 0 6px; }
/* Sized to the space: a quarter of the screen's height, 96 to 240 px; never cropped (contain). Tap to enlarge (js/zoom.js). */
.photo { position: relative; }
.photo img { display: block; width: 100%; height: auto; max-height: 240px; max-height: clamp(96px, 24svh, 240px); object-fit: contain; border-radius: 12px; background: var(--line); }
.photo figcaption { font-size: var(--t-xs); color: var(--ink-2); margin-top: 4px; line-height: 1.3; }
.photo figcaption a { color: inherit; }
.note a { color: var(--link); }
.flagimg.xl { width: auto; height: 135px; height: clamp(72px, 15svh, 135px); aspect-ratio: 4 / 3; border-radius: 10px; box-shadow: var(--flag-xl-shadow); }
.prompt-flag.xl { position: relative; width: fit-content; }
/* Typing: the image steps down to a thumbnail so the question and the box stay above the keyboard. */
/* A photo question: the photo is the one thing that gives way. The panel becomes a column in which
   only the prompt's photo shrinks (to 72 px, whole, letterboxed), so the question, the photo and the
   answer box fit together before anything has to scroll. */
#panel:has(#prompt .photo) { display: flex; flex-direction: column; }
#panel:has(#prompt .photo) > * { flex-shrink: 0; }
#panel:has(#prompt .photo) > #prompt { flex-shrink: 1; min-height: 0; display: flex; flex-direction: column; }
#prompt > * { flex-shrink: 0; }
#prompt > .photo { flex-shrink: 1; min-height: 0; display: flex; flex-direction: column; }
#prompt > .photo img { flex: 0 1 auto; min-height: 72px; }
body.kb .photo img { max-height: 72px; }
body.kb .flagimg.xl { height: 60px; }
body.kb .photo figcaption { display: none; }
/* and on a phone the progress lines step aside while typing: the question and the box come first. */
@media (max-height: 760px) { body.kb #panel :is(.progress.today, .deckline) { display: none; } }
/* Enlarge: over a photo's corner; beside a flag (never over it), and only where flags are drawn small. */
.zoom-btn { position: absolute; top: 6px; right: 6px; z-index: 1; display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 10px; background: var(--chrome); color: var(--on-chrome); opacity: .85; }
.zoom-btn:hover { opacity: 1; }
.zoom-btn svg { width: 20px; height: 20px; }
.prompt-flag .zoom-btn { display: none; top: auto; right: auto; bottom: 0; left: calc(100% + 10px); }
.zoomed { width: 100%; height: 100%; max-width: 100vw; max-height: 100vh; margin: 0; padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
  border: 0; background: transparent; color: var(--on-chrome); }
.zoomed[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.zoomed::backdrop { background: var(--scrim-deep); }
.zoomed img { display: block; max-width: 100%; max-height: calc(100% - 120px); object-fit: contain; border-radius: 12px; }
.zoomed img.flag { width: min(92vw, 720px); height: auto; aspect-ratio: 4 / 3; object-fit: cover; box-shadow: var(--flag-xl-shadow); }
.zoomed-cap { font-size: var(--t-s); text-align: center; max-width: 60ch; opacity: .9; }
.zoomed-cap a { color: inherit; }
.prompt-q { font-size: var(--t-m); color: var(--ink-2); }
.prompt-title { font-size: var(--t-3xl); font-weight: 750; letter-spacing: -0.03em; line-height: 1.05; margin: 2px 0 6px;
  overflow-wrap: anywhere; }
.prompt-sub { font-size: var(--t-s); color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.hint-tc { font-size: var(--t-xs); color: var(--ink-3); }
.hintline { font-size: var(--t-m); color: var(--ink-2); min-height: 1em; }
.hintline:empty { display: none; }
.answer { font-size: var(--t-2xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; display: flex; align-items: center; gap: 10px; }
.verdict { border-radius: 16px; padding: 14px 16px; background: var(--card); border: 2px solid var(--line); }
.verdict.good { background: var(--good-soft); border-color: var(--good-edge); color: var(--good-deep); }
.verdict.bad { background: var(--bad-soft); border-color: var(--bad-edge); color: var(--bad-deep); }
.verdict.info { background: var(--info-soft); border-color: var(--info-edge); }
.verdict:not(.info) { animation: pop .22s ease-out; }
@keyframes pop { from { transform: scale(.96); opacity: .4; } to { transform: none; opacity: 1; } }
.note { font-size: var(--t-s); color: var(--ink-2); margin-top: 8px; }
.verdict.good .note, .verdict.bad .note { color: inherit; opacity: .85; }
.kbd { font: 600 11px/1 var(--font); border: 1.5px solid currentColor; border-radius: 6px; padding: 3px 5px; opacity: .7; }

/* --- keyboard (js/keys.js): key caps, the hint under an answer box, the ? sheet ----------- */
kbd { font: 600 11px/1 var(--font); border: 1.5px solid var(--line); border-bottom-width: 2.5px; border-radius: 6px;
  padding: 2px 5px; background: var(--card); color: var(--ink-2); white-space: nowrap; }
.kbhint { font-size: var(--t-xs); color: var(--ink-3); margin-top: 2px; }
@media (hover: none) { .kbhint { display: none; } }
.ghost.armed { color: var(--bad); border-color: var(--bad); }
.keys-sheet { border: 0; border-radius: 18px; padding: 20px 22px; max-width: min(460px, 92vw); background: var(--card);
  color: var(--ink); box-shadow: var(--panel-shadow); }
.keys-sheet::backdrop { background: var(--scrim); }
.keys-sheet h2 { margin: 0 0 12px; font-size: var(--t-l); }
.keys-sheet table { border-collapse: collapse; width: 100%; font-size: var(--t-s); }
.keys-sheet th { text-align: left; padding: 6px 14px 6px 0; white-space: nowrap; vertical-align: top; font-weight: 400; }
.keys-sheet td { padding: 6px 0; color: var(--ink-2); }
.keys-sheet tbody.everywhere tr:first-child > * { border-top: 1px solid var(--line); padding-top: 10px; }
.keys-sheet form { margin-top: 14px; display: flex; justify-content: flex-end; }
/* --- share (js/share.js): the desktop dialog; phones use their own share sheet -------------- */
.share-btn { width: 100%; margin-top: 10px; }
.share-sheet h2 .wm { white-space: nowrap; }
.share-copy { display: flex; gap: 8px; margin: 12px 0; }
.share-copy input { flex: 1; min-width: 0; font: inherit; font-size: var(--t-s); padding: 8px 10px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--fog); color: var(--ink); }
.share-to { display: flex; flex-wrap: wrap; gap: 6px; }
.share-to .btn { padding: 8px 12px; font-size: var(--t-s); }
.share-qr { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.share-qr img { border-radius: 10px; flex: none; background: #fff; }
.share-qr p { margin: 0; }

.pill { font-size: var(--t-xs); font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--card); color: var(--ink-2); }
.pill-new { background: var(--signal); color: var(--on-signal); }
.pill-review { background: var(--review-soft); color: var(--review-deep); }
.pill-learning { background: var(--learning-soft); color: var(--learning-deep); }

/* --- home ------------------------------------------------------------------------------------ */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: 16px; padding: 12px 14px; }
.stat b { display: block; font-size: var(--t-xl); font-weight: 700; letter-spacing: -0.02em; }
.stat b small { font-size: var(--t-s); font-weight: 500; color: var(--ink-3); }
.stat > span { font-size: var(--t-s); color: var(--ink-2); }
.stat .bar { margin-top: 8px; }
.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: var(--t-xs); color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend i.hollow { border: 1.5px solid var(--ink-3); }

.decklist { display: grid; gap: 8px; }
.deckrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border-radius: 14px;
  color: var(--ink); text-decoration: none; border: 2px solid transparent; }
.deckrow:hover { border-color: var(--line); }
.deckrow .deckname { flex: 1; font-weight: 500; min-width: 0; }
.deckrow .deckdue { font-size: var(--t-s); font-weight: 600; background: var(--signal); color: var(--on-signal); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.deckrow.done .deckdue { background: var(--good-soft); color: var(--good-deep); }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.dot-capitals { background: var(--capitals); }
.dot-countries { background: var(--countries); }
.dot-regions { background: var(--regions); }
.dot-flags { background: var(--flags); }
.dot-physical { background: var(--physical); }

.hello { display: flex; align-items: center; gap: 10px; }
.hello .eyebrow { flex: 1; }
.streak { font-size: var(--t-xs); font-weight: 600; background: var(--press); color: var(--signal); padding: 4px 10px; border-radius: 999px; }
.mastery { background: var(--card); border-radius: 16px; padding: 6px 14px; }
.mrow { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 4px 10px; padding: 10px 0; }
.mrow + .mrow { border-top: 1.5px dotted var(--line); }
.mname { font-weight: 600; }
.mnum { font-size: var(--t-s); color: var(--ink-2); }
.mnum b { color: var(--ink); font-size: var(--t-m); }
.mrow .bar { grid-column: 2 / -1; }
a.mrow { color: inherit; text-decoration: none; margin: 0 -8px; padding: 10px 8px; border-radius: 10px; }
a.mrow:hover { background: var(--fog); }
a.mrow .mname::after { content: " ›"; color: var(--ink-3); font-weight: 500; }

/* --- play picker ----------------------------------------------------------------------------- */
.step { display: flex; align-items: center; gap: 10px; margin-top: 22px !important; }
.step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--on-ink); display: grid; place-items: center;
  font-weight: 700; font-size: var(--t-s); }
.step-t { font-weight: 650; font-size: var(--t-l); letter-spacing: -0.01em; }
.cards3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cards2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pick { flex-direction: column; align-items: flex-start; justify-content: flex-start; text-align: left; gap: 4px;
  padding: 12px; border-radius: 16px; background: var(--card); border: 2px solid var(--line); height: 100%; line-height: 1.25; }
.pick b { font-size: var(--t-m); font-weight: 650; }
.pick small { font-size: var(--t-xs); color: var(--ink-2); font-weight: 400; }
.pick:hover { border-color: var(--ink-3); }
.pick.on { border-color: var(--sel); box-shadow: 0 3px 0 var(--sel); }
.pick svg { width: 30px; height: 30px; margin-bottom: 4px; }
.pick[data-subject="capitals"] svg { color: var(--capitals); }
.pick[data-subject="countries"] svg { color: var(--countries); }
.pick[data-subject="regions"] svg { color: var(--regions); }
.pick[data-subject^="geo/"] svg { color: var(--physical); }
.pick[data-subject^="astronomy/"] svg { color: var(--space); }
.where-row.parts { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-pick { padding: 7px 12px; border-radius: 999px; border: 2px solid var(--chip-edge); background: var(--card); color: var(--ink); font: inherit; font-size: var(--t-s); cursor: pointer; }
.chip-pick small { color: var(--ink-2); margin-left: 4px; }
.chip-pick.on { border-color: var(--physical); background: rgba(18, 133, 143, .12); font-weight: 600; }
.sets-head { margin-top: 12px; font-size: var(--t-s); font-weight: 600; color: var(--ink-2); }
/* The physical world's sets: smaller cards under the four subjects. */
/* As many columns as fit: three plain 1fr columns can't shrink below "Mountains" and pushed the third
   column out of the panel (by 6 px on desktop, 60 px on a 360 px phone, more with a Windows scrollbar). */
.cards3.sets { margin-top: 8px; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); }
.pick.mini { flex-direction: row; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; }
.pick.mini svg { width: 22px; height: 22px; margin: 0; flex: none; }
.pick.mini b { font-size: var(--t-s); min-width: 0; overflow-wrap: break-word; }
.pick[data-subject].on { background: color-mix(in srgb, var(--subject) var(--tint), var(--card)); }
.pick[data-mode] svg { color: var(--ink); width: 24px; height: 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { padding: 8px 12px; border-radius: 999px; font-size: var(--t-s); font-weight: 500; background: var(--card);
  border: 2px solid var(--line); gap: 7px; }
.chip-btn small { font-size: var(--t-xs); color: var(--ink-3); font-weight: 500; }
.chip-btn:hover { border-color: var(--ink-3); }
.chip-btn.on { background: var(--subject); border-color: var(--subject); color: var(--on-subject); }
.chip-btn.on small { color: var(--on-subject); opacity: .8; }
#scopes h3 { margin: 14px 0 6px; }
/* Where: a breadcrumb, a search box and the places one layer down (where.js). */
#scopes > * + * { margin-top: 8px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: var(--t-s); }
.crumb { padding: 4px 6px; border-radius: 8px; font: 500 var(--t-s)/1.2 var(--font); background: none; color: var(--ink-2);
  text-decoration: underline; text-underline-offset: 3px; }
.crumb:hover { color: var(--ink); background: var(--card); }
.crumb.here { padding: 4px 6px; font-weight: 650; color: var(--ink); }
.crumbs .sep { color: var(--ink-3); }
#where-q { font-size: var(--t-m); padding: 10px 14px; }
.places { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#where-list > * + * { margin-top: 6px; }
.place { width: 100%; justify-content: flex-start; gap: 8px; padding: 10px 10px 10px 12px; text-align: left;
  font: 500 var(--t-s)/1.25 var(--font); background: var(--card); border: 2px solid var(--line); border-radius: 12px; }
.place:hover { border-color: var(--ink-3); }
.place .pname { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.place .via { font-size: var(--t-xs); color: var(--ink-2); font-weight: 400; }
.place small { font-size: var(--t-xs); color: var(--ink-3); white-space: nowrap; }
.place .chev { font-size: var(--t-l); line-height: 1; color: var(--ink-3); margin-left: -2px; }
.place.all { font-weight: 650; }
.place.holds { border-color: var(--subject); }
.place.on { background: var(--subject); border-color: var(--subject); color: var(--on-subject); }
.place.on small, .place.on .chev, .place.on .via { color: var(--on-subject); opacity: .85; }
.none { margin: 4px 0 0; }
.pick.cant { opacity: .5; }
.go-why { margin: 0 0 8px; color: var(--ink-2); text-align: center; }
.sticky-go { position: sticky; bottom: calc(-1 * var(--pad-b)); margin-top: 20px !important; }
.go-wrap { position: sticky; bottom: calc(-1 * var(--pad-b)); padding: 14px 0 0; margin: 20px -2px 0 !important; background: linear-gradient(transparent, var(--fog) 30%); }
/* The act zone: what the player does next (the answer box and its buttons, the choices, Next). It
   sticks to the bottom of the panel, so a photo, a long note or a verdict above it scrolls behind it
   instead of pushing it out of sight. Sticky can't leave its parent: put .act on a child of #panel. */
#panel > .act { position: sticky; bottom: calc(-1 * var(--pad-b)); z-index: 1; margin-top: 2px;
  padding-top: 12px; padding-bottom: var(--pad-b); background: linear-gradient(to bottom, transparent, var(--fog) 12px); }
#panel > .act:last-child { margin-bottom: calc(-1 * var(--pad-b)); }

/* --- people -------------------------------------------------------------------------------- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.person { flex-direction: column; gap: 10px; padding: 16px 8px; background: var(--card); border: 2px solid var(--line);
  border-radius: 18px; font-weight: 600; min-width: 0; }
/* A long name wraps to two lines and then ends in "…"; it never widens its cell. */
.person > span:last-child { max-width: 100%; line-height: 1.2; overflow-wrap: break-word; word-break: break-word;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.person:hover { border-color: var(--ink); }
.person .avatar { width: 58px; height: 58px; font-size: var(--t-xl); }
.person.add .avatar { background: var(--fog); color: var(--ink-2); border: 2px dashed var(--ink-3); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--card); padding: 0; box-shadow: 0 0 0 2px var(--line); }
.swatch.on { box-shadow: 0 0 0 3px var(--ink); }

/* --- type them all -------------------------------------------------------------------------- */
.test-head { position: sticky; top: -22px; background: var(--fog); margin: -6px -4px 0; padding: 6px 4px 12px; z-index: 1; }
.timer { font-size: var(--t-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--bad); }
.big-score { font-size: var(--t-3xl); font-weight: 750; letter-spacing: -0.03em; line-height: 1.05; }
.big-score span { font-size: var(--t-l); font-weight: 500; color: var(--ink-3); margin-left: 6px; }
.board { columns: 2; column-gap: 16px; font-size: var(--t-s); }
.board h3 { margin: 12px 0 4px; break-after: avoid; }
.slot { display: flex; justify-content: space-between; gap: 6px; padding: 3px 0; border-bottom: 1.5px dotted var(--line);
  break-inside: avoid; cursor: default; user-select: none; -webkit-user-select: none; min-height: 26px; }
.slot .c { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .a { font-weight: 600; text-align: right; white-space: nowrap; }
.board.blank .slot .a { text-align: left; }
.slot.found .a { color: var(--good); }
.slot.missed .a { color: var(--bad); }

/* best and record next to the stopwatch */
.bests { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--t-s); color: var(--ink-2); margin: 2px 0 8px; }
.bests b { color: var(--ink); font-variant-numeric: tabular-nums; }
.bests small { color: var(--ink-3); }
.bests.big { font-size: var(--t-m); background: var(--card); border-radius: 14px; padding: 10px 14px; margin: 12px 0; }
.typo { min-height: 1.3em; font-size: var(--t-s); color: var(--good); margin: 4px 0 2px; }
.badge { display: inline-block; font-weight: 700; padding: 5px 12px; border-radius: 999px; margin: 6px 0 2px; }
.badge.record { background: var(--signal); color: var(--on-signal); }
.badge.pb { background: var(--good-soft); color: var(--good-deep); }
.big-score .time { font-size: var(--t-xl); font-weight: 650; color: var(--ink-2); margin-left: 12px; }

/* sections: per-continent (or subregion) counts */
.sections { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.sec { font-size: var(--t-xs); font-weight: 600; background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.sec .n, .board h3 .n { color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.board h3 .n { font-size: var(--t-xs); margin-left: 4px; }
.sec.complete { background: var(--good-soft); border-color: var(--good); color: var(--good-deep); }
.sec.complete .n, .board h3.complete .n { color: var(--good); }

/* world and region decks: one list, newest first */
.board.flat { columns: 1; }
.slot.done .lead { display: flex; gap: 6px; align-items: center; min-width: 0; }
.slot.done .lead .flagimg { flex: none; }
.slot.new { animation: slot-new 1.2s ease-out; }
@keyframes slot-new { from { background: var(--good-flash); } to { background: transparent; } }
#todo.todo { margin-top: 10px; }

/* flags: one big flag at a time, in the sticky head */
.flagq { text-align: left; padding: 2px 0 6px; }
.flagq .prompt-flag.xl { margin: 6px 0 6px; }
.typo.bad { color: var(--bad); }
.typo.info { color: var(--ink-2); }
.typo .flagimg { margin-right: 2px; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
/* Multiple choice and Order (G5) */
.mc-opts { display: grid; gap: 8px; }
.mc-opt, .order-opt { display: flex; align-items: center; justify-content: flex-start; gap: 10px; text-align: left; width: 100%; }
.mc-opt .kbd { flex: none; }
.mc-opt.right { border-color: var(--good); background: rgba(35, 160, 102, .15); color: var(--ink); opacity: 1; }
.mc-opt.wrong { border-color: var(--bad); background: rgba(217, 72, 59, .12); color: var(--ink); opacity: 1; }
.order-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.order-opt.bad { animation: shake .35s; border-color: var(--bad); }
.order-done { columns: 2; }
.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair-col { display: grid; gap: 8px; align-content: start; }
.pair-l, .pair-r { width: 100%; min-height: 48px; justify-content: center; text-align: center; }
.pair-l.on { border-color: var(--signal); background: rgba(255, 201, 60, .2); }
.pair-l.right, .pair-r.right { border-color: var(--good); background: rgba(35, 160, 102, .15); color: var(--ink); opacity: 1; }
.pair-r.bad { animation: shake .35s; border-color: var(--bad); }

/* a finished section or board: banner + confetti over the map; never blocks typing */
.celebrate { position: fixed; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; }
.celebrate .burst { position: absolute; left: 50%; top: 42%; }
.celebrate .burst, .celebrate .banner { left: calc(50% + var(--panel-w) / 2 + 10px); }  /* the middle of the map beside the panel */
.celebrate .burst i { position: absolute; width: 9px; height: 13px; border-radius: 2px; opacity: 0;
  animation: confetti calc(var(--d) * 1.9) cubic-bezier(.2, .7, .4, 1) forwards; }
@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  55% { transform: translate(var(--x), var(--y)) rotate(calc(var(--r) * .6)); opacity: 1; }
  100% { transform: translate(calc(var(--x) * 1.2), calc(var(--y) + 420px)) rotate(var(--r)); opacity: 0; }
}
.celebrate .banner { position: absolute; left: 50%; top: 26%; transform: translate(-50%, 0); display: grid; gap: 2px; text-align: center;
  background: var(--chrome); color: #fff; padding: 14px 26px; border-radius: 18px; box-shadow: 0 12px 34px rgba(23, 42, 70, .3);
  animation: banner 2.8s ease forwards; white-space: nowrap; }
.celebrate.big .banner { animation-duration: 4.2s; padding: 18px 34px; }
.celebrate .banner b { font-size: var(--t-xl); color: var(--signal); }
.celebrate.big .banner b { font-size: var(--t-2xl); }
.celebrate .banner span { font-size: var(--t-s); opacity: .85; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(.9); }
  10%, 80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -8px) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .celebrate .burst { display: none; } }

/* --- pin, tour, explore ----------------------------------------------------------------------- */
.rounds { list-style: none; padding: 0; margin: 0; font-size: var(--t-s); }
.rounds li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1.5px dotted var(--line); }
.rounds li span { display: flex; gap: 6px; align-items: center; }
.progress { height: 6px; border-radius: 9px; background: var(--track-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--subject); transition: width .3s ease; }
/* Learn: today's bar, then the deck line (how much of the deck is learned). */
.progress.today { height: 5px; margin-top: 8px; }
.deckline { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: var(--t-s); color: var(--ink-2); }
.deckline > span:first-child { white-space: nowrap; }
.deckline .bar { flex: 1; height: 6px; min-width: 40px; }
.deckline .plus { white-space: nowrap; font-weight: 700; color: var(--good-text); animation: plus 3.2s ease forwards; }
@keyframes plus { 0% { opacity: 0; transform: translateY(4px); } 15%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.test-head .progress { margin-top: 6px; }
/* Pin it: one segment per round, coloured by how close the pin was. */
.segs { display: flex; gap: 4px; margin-top: 8px; }
.segs i { flex: 1; height: 6px; border-radius: 9px; background: var(--track-2); transition: background .3s ease; }
.segs i.now { box-shadow: 0 0 0 2px var(--ink-2); } /* not the subject colour: Capitals red would read as a miss */
@media (prefers-reduced-motion: reduce) { .deckline .plus { animation: none; } .progress i, .segs i { transition: none; } }
.tour-card { display: flex; gap: 14px; align-items: center; }
.tour-card .prompt-title { font-size: var(--t-2xl); margin: 0; }
.tour-nav button { flex: 1; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: var(--t-s); background: var(--card);
  border-radius: 14px; padding: 12px 14px; margin: 14px 0 0; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; font-weight: 500; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: var(--t-xs); font-weight: 600; color: #fff; }
.result { width: 100%; justify-content: flex-start; margin-top: 6px; background: var(--card); border: 2px solid var(--line); }
.result span:first-of-type { flex: 1; text-align: left; }
.country-card > * + * { margin-top: 12px; }
.order { display: grid; gap: 6px; margin-top: 8px; }
.order-row { display: flex; justify-content: space-between; align-items: center; background: var(--card); border-radius: 12px; padding: 6px 12px; }
.credits { color: var(--ink-3); }

.flagimg { display: inline-block; vertical-align: -2px; border-radius: 3px; box-shadow: 0 0 0 1px var(--flag-edge); object-fit: cover; }
.flagimg.lg { width: 64px; height: 48px; border-radius: 6px; }

#toast { position: fixed; z-index: 20; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--chrome); color: #fff; padding: 12px 18px; border-radius: 14px; pointer-events: none;
  transition: .25s; font-weight: 500; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- leaderboards (#/boards, a line on home and on Type them all) --------------------------------- */
.weekline { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--card); border-radius: 14px; color: var(--ink); text-decoration: none; font-size: var(--t-s); }
.weekline .go { font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.weekline:hover .go { color: var(--ink); }
.weekline[hidden], .boardline[hidden] { display: none; }
.boardline { display: block; color: var(--ink-2); }
.boardline:hover { color: var(--ink); }
.boards-who { background: var(--card); border-radius: 14px; padding: 12px 14px; }
.boards-who > * + * { margin-top: 10px; }
.boards-who.first { border: 2px solid var(--signal-deep); }
.tbl.board td { white-space: normal; }
.tbl.board tr.you td { background: #fff6d6; font-weight: 600; }
.tbl.board tr.gap td { text-align: center; color: var(--ink-3); padding: 2px; }
.tbl.board .pill { background: var(--signal); color: var(--ink); }

/* --- admin (#/admin): a wide panel of tables over the map --------------------------------------- */
body.admin #panel { width: min(1100px, calc(100% - 32px)); }
.admin-stats { grid-template-columns: repeat(4, 1fr); }
.admin-stats .stat small { color: var(--ink-3); }
.scroll { overflow-x: auto; background: var(--card); border-radius: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-s); }
.tbl th, .tbl td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.tbl th { font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td { white-space: nowrap; }
.tbl td.msg { white-space: normal; min-width: 260px; overflow-wrap: anywhere; }
.tbl .pill { font-size: 11px; padding: 1px 6px; border-radius: 9px; background: var(--fog); color: var(--ink-2); }
.tbl .state { font-weight: 600; }
.tbl .st-waiting .state { color: var(--signal-deep); }
.tbl .st-stuck .state { color: var(--bad); }
.tbl .st-active .state { color: var(--good); }
.tbl .st-quiet .state { color: var(--ink-3); }
details > summary { cursor: pointer; color: var(--ink-2); margin-bottom: 8px; }
.chart { background: var(--card); border-radius: 14px; padding: 12px 14px 10px; }
.chart .readout { min-height: 1.4em; font-weight: 600; }
.chart .plot { position: relative; height: 140px; margin-top: 8px; padding-left: 22px; border-bottom: 1px solid var(--ink-3); }
.chart .ymax { position: absolute; left: 0; top: -2px; color: var(--ink-3); }
.chart .cols { display: flex; align-items: flex-end; gap: 2px; height: 100%; }
.chart .day { flex: 1; height: 100%; position: relative; display: flex; align-items: flex-end; padding: 0; border: 0;
  border-radius: 0; background: none; box-shadow: none; min-width: 0; cursor: default; }
.chart .day i { display: block; width: 100%; min-height: 0; background: var(--countries); border-radius: 4px 4px 0 0; }
.chart .day:hover, .chart .day.on { background: var(--fog); }
.chart .day em { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-style: normal;
  font-size: 10px; color: var(--ink); }
.chart .xaxis { display: flex; justify-content: space-between; margin-top: 20px; padding-left: 22px; }
.chart .legend { margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chart .key-bar { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--countries); }
.chart .key-up { margin-left: 10px; color: var(--ink); font-size: 10px; }

/* --- feedback (#/feedback, js/feedback.js) and its list on the admin page ------------------------ */
.fb-kinds { border: 0; padding: 0; margin: 0; }
.fb-kinds legend { margin-bottom: 8px; }
.fb-kind { position: relative; cursor: pointer; }
.fb-kind input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.fb-kind:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.fb-kind:has(input:focus-visible) { outline: 3px solid var(--countries); outline-offset: 2px; }
textarea.fb-msg { display: block; width: 100%; margin-top: 6px; min-height: 140px; resize: vertical;
  font: 400 var(--t-m)/1.45 var(--font); padding: 12px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink); }
textarea.fb-msg:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 4px rgba(255, 201, 60, .45); }
.fb-count { min-height: 1.2em; margin: -8px 0 0; }
.fb-link { margin-top: 14px; }
.fb-list { display: grid; gap: 8px; }
.fb-item { background: var(--card); border-radius: 14px; padding: 12px 14px; border-left: 4px solid var(--line); }
.fb-item.unread { border-left-color: var(--signal-deep); }
.fb-item .fb-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; font-size: var(--t-s); }
.fb-item .fb-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 4px; }
.fb-item .fb-k { font-weight: 650; }
.fb-item .fb-k.problem { color: var(--bad); }
.fb-item .fb-k.praise { color: var(--good); }
.fb-item .fb-read { margin-left: auto; }

/* --- dark: the same field card at night ----------------------------------------------------
   Same layout, same bold yellow buttons, same subject colours (a step brighter so they read on
   navy). The panel is a deep friendly blue, never black; cards sit a shade lighter so the
   layering still shows, and buttons keep their dark edge so they still look pressable.
   js/theme.js sets data-theme (light, dark, or the device's own setting). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef3f8;
  --ink-2: #b4c1d3;
  --ink-3: #8595ae;
  --fog: #1c2c44;
  --card: #273a56;
  --line: #3b506e;
  --signal-deep: #f0b628;
  --capitals: #ff7c56;
  --countries: #5ea8f2;
  --regions: #a48ef2;
  --flags: #2fc28f;
  --physical: #2cb2bc;
  --space: #8c90f6;
  --chemistry: #e8ad4a;
  --good: #3ccb89;
  --bad: #ff7366;
  --learning: #f9a877;
  --young: #66b6e6;
  --mature: #3ccb89;
  --chrome: #0f1c30;
  --press: #0a1424;
  --sel: var(--signal);
  --on-signal: #172a46;
  --on-subject: #0f1c30;
  --on-ink: #172a46;
  --track: #344863;
  --track-2: #344863;
  --chip-edge: var(--line);
  --tint: 24%;
  --good-field: #1f4134; --bad-field: #4a2a2f;
  --good-soft: #1d4335; --good-edge: #2f7d5a; --good-deep: #b2f0d0; --good-flash: #2a6e4f; --good-text: #6fe2aa;
  --bad-soft: #4a2830; --bad-edge: #94474a; --bad-deep: #ffc6bd;
  --info-soft: #3f3a28; --info-edge: #82702f;
  --review-soft: #22426b; --review-deep: #b0d6fc;
  --link: #9cc9f7;
  --learning-soft: #4f3527; --learning-deep: #ffc8a3;
  --flag-edge: rgba(255, 255, 255, .2);
  --flag-float: rgba(0, 0, 0, .7);
  --flag-xl-shadow: 0 0 0 1px rgba(255, 255, 255, .16), 0 6px 18px rgba(0, 0, 0, .35);
  --panel-shadow: 0 18px 50px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3), 0 0 0 1px rgba(255, 255, 255, .06);
  --scrim: rgba(0, 0, 0, .6);
  --scrim-deep: rgba(0, 0, 0, .94);
  --on-chrome: #f3f6fb;
}
:root[data-theme="dark"] #panel:not([data-band]) { border-top-color: #48638c; }
:root[data-theme="dark"] .deckrow:not(.done) .deckdue .muted { color: #4b5d78; }  /* on the yellow pill */
:root[data-theme="dark"] #toast, :root[data-theme="dark"] .celebrate .banner { box-shadow: 0 0 0 1px rgba(255, 255, 255, .12), 0 12px 34px rgba(0, 0, 0, .45); }
:root[data-theme="dark"] .maplibregl-ctrl-group { background: var(--card); box-shadow: 0 0 0 1px var(--line); }
:root[data-theme="dark"] .maplibregl-ctrl-group button + button { border-top-color: var(--line); }
:root[data-theme="dark"] .maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(1) brightness(1.4); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib { background: rgba(28, 44, 68, .8); color: var(--ink-2); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib a { color: var(--ink-2); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1); }

/* --- layouts (docs/LAYOUT.md) -------------------------------------------------------------------------
   Four, chosen by shape: the side panel above is the default. Each sets --layout, which js/layout.js
   reads (JS never repeats these breakpoints); map.js measures camera padding from the drawn panel. */

/* The top bar on narrow screens: icons and short tabs. */
@media (max-width: 720px), (orientation: landscape) and (max-height: 519px) {
  :root { --top-base: 54px; }
  #top { gap: 8px; padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: max(10px, env(safe-area-inset-right, 0px)); }
  .brand span { display: none; }
  #tabs a { padding: 7px 10px; font-size: var(--t-s); }
  .who { padding: 3px; }
  .who .name { display: none; }
}

/* Short screens: smaller question type, so the question, its image and the answer box fit together. */
@media (max-height: 760px) { :root { --t-3xl: 34px; --t-2xl: 26px; } }
@media (max-height: 700px) {
  /* Match: each side's six cards in two columns, so the board is three rows tall. */
  .pair-col { grid-template-columns: 1fr 1fr; gap: 6px; }
  .pairs { gap: 8px; }
  .pair-l, .pair-r { min-height: 44px; padding: 6px 8px; font-size: var(--t-s); }
}
@media (max-height: 560px) {
  :root { --t-3xl: 28px; --t-2xl: 22px; --t-xl: 21px; }
  /* Order: the cards four across, so eight of them are two rows. */
  .order-opts { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
  .order-opt { justify-content: center; text-align: center; padding: 6px; font-size: var(--t-s); }
  #panel > * + * { margin-top: 8px; }
  .deckline { margin-top: 2px; }
  .photo { margin: 4px 0 2px; }
}

/* A narrow panel (a phone's sheet, a phone on its side): leaner cards and boards. */
@media (max-width: 599px), (orientation: landscape) and (max-height: 519px) {
  .admin-stats { grid-template-columns: 1fr 1fr; }
  .pick { padding: 10px; }
  .pick small { display: none; }
  .board { columns: 1; }
  .flagimg.lg { width: 52px; height: 39px; }
  .solar-ui { right: 8px; bottom: 8px; gap: 6px; }
  .solar-zoom { grid-auto-flow: column; gap: 4px; }
  .solar-layout button { padding: 6px 9px; font-size: 13px; }
  .solar-note { top: 6px; bottom: auto; right: 10px; left: 10px; font-size: 11px; }
  .solar-label { font-size: 11px; padding: 1px 6px; }
  .explore-switch a { padding: 6px 8px; }
  .pt-zoom { right: 8px; bottom: 8px; gap: 4px; }
  .viz-list { gap: 6px; }
  .viz-list button { padding: 6px 10px; }
  .prompt-flag .zoom-btn { display: grid; }
  /* Four choices as a 2 x 2 grid: half the height, so a photo or flag question keeps its room. */
  .mc-opts { grid-template-columns: 1fr 1fr; }
  .mc-opt { min-height: 52px; padding: 8px 10px; font-size: var(--t-s); line-height: 1.2; }
}

/* Sheet: portrait phones and tablets. The panel is a bottom sheet you can fold away; the map is above.
   It sits on the keyboard where the browser overlays one (--kb, iOS) and never runs under the top bar. */
@media (orientation: portrait) and (max-width: 1099px) {
  :root { --layout: sheet; }
  #panel { --pad-b: calc(18px + env(safe-area-inset-bottom, 0px));
    top: auto; bottom: var(--kb, 0px); left: 0; right: 0; width: auto;
    max-height: 62%; max-height: min(62svh, calc(var(--app-h, 100svh) - var(--top-h) - 8px));
    border-radius: 22px 22px 0 0; padding: 0 16px var(--pad-b); }
  /* A photo in the panel (a first meeting, or after the answer): a bit more room for it. */
  #panel:has(#prompt .photo) { max-height: 72%; max-height: min(72svh, calc(var(--app-h, 100svh) - var(--top-h) - 8px)); }
  /* Typing: the sheet takes everything above the keyboard but a strip of map. */
  body.kb #panel { max-height: calc(var(--app-h, 100svh) - var(--top-h) - 48px); }
  /* ...all of it, top bar included, when an image is the question: the map is blank then anyway. */
  body.kb:has(#prompt.asks-image) #top { display: none; }
  body.kb #panel:has(#prompt.asks-image) { max-height: calc(var(--app-h, 100svh) - 8px); }
  /* The handle: a 44 px tall strip (the bar is drawn near its top), overlapping the first row's top. */
  .handle { display: block; position: relative; z-index: 2; width: 100%; height: 44px; padding: 0; margin: 0 0 -14px;
    border: 0; background: none; cursor: pointer; }
  .handle::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 9px; background: var(--ink-3); margin: 0 auto; position: absolute; top: 10px; left: 0; right: 0; }
  body.sheet-down #panel { max-height: 132px; overflow: hidden; }
  body.admin:not(.sheet-down) #panel { width: auto; max-height: 88%; }
  body.admin.sheet-down #panel { width: auto; }
  .test-head { top: 0; padding-top: 14px; }
  .celebrate .burst, .celebrate .banner { left: 50%; }
  .celebrate .burst { top: 30%; }
  .celebrate .banner { top: 14%; }
  /* A view in #stage (the list, the periodic table, the solar system) ends where the sheet begins. */
  #stage { left: 0; bottom: calc(var(--panel-h, 58%) + var(--kb, 0px)); padding: 12px; }
}

/* Tall sheet: portrait tablets and narrow windows. A floating, centred sheet up to 55% tall. */
@media (orientation: portrait) and (min-width: 600px) and (max-width: 1099px) {
  :root { --layout: sheet-tall; }
  #panel { --pad-b: calc(22px + env(safe-area-inset-bottom, 0px));
    left: max(16px, calc(50% - 340px)); right: max(16px, calc(50% - 340px)); bottom: calc(12px + var(--kb, 0px));
    max-height: 55%; max-height: min(55svh, calc(var(--app-h, 100svh) - var(--top-h) - 24px));
    border-radius: 22px; padding: 0 24px var(--pad-b); }
  body.kb #panel { max-height: calc(var(--app-h, 100svh) - var(--top-h) - 72px); }
  body.sheet-down #panel { max-height: 140px; }
  #stage { bottom: calc(var(--panel-h, 55%) + 12px + var(--kb, 0px)); }
}

/* Side, compact: phones on their side. A full-height side panel under a slim top bar. */
@media (orientation: landscape) and (max-height: 519px) {
  :root { --layout: side-compact; --top-base: 48px; --panel-w: clamp(300px, 42vw, 380px); }
  #panel { --pad-b: 14px; top: calc(var(--top-h) + 8px); left: calc(8px + var(--safe-l));
    max-height: calc(var(--app-h, 100svh) - var(--top-h) - 16px);
    padding: 12px 16px var(--pad-b); border-radius: 16px; border-top-width: 6px; }
  #panel > * + * { margin-top: 10px; }
  #stage { left: calc(var(--panel-w) + 16px + var(--safe-l)); }
  /* Typing on a phone on its side leaves ~150 px: the top bar steps aside for the panel. */
  body.kb #top { display: none; }
  body.kb #panel { top: 4px; max-height: calc(var(--app-h, 100svh) - 8px); }
}

/* The image in the map's space. While a photo or flag is the question (#prompt.asks-image) the map is
   blank, so on a phone or tablet the image is drawn there, large, and the panel keeps only the question
   and the answer box. It goes back into the panel once the answer (a .verdict) or a map hint shows,
   and while a keyboard is up (a thumbnail then: the strip of map left is too small for it). */
@media (orientation: portrait) and (max-width: 1099px), (orientation: landscape) and (max-height: 519px) {
  body:not(.kb) #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image :is(.photo, .prompt-flag.xl) {
    position: fixed; z-index: 4; margin: 0; width: auto; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 6px; pointer-events: none; }
  body:not(.kb) #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image .photo img { flex: 0 1 auto; min-height: 0; width: auto; max-width: 100%; max-height: 100%; border-radius: 14px; box-shadow: var(--panel-shadow); }
  /* A flag fills its box, whole (contain, no frame: a frame would outline the letterbox). */
  body:not(.kb) #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image .flagimg.xl { flex: 1 1 0; min-height: 0; width: 100%; height: auto; max-height: 300px; aspect-ratio: auto;
    object-fit: contain; border-radius: 0; box-shadow: none;
    filter: drop-shadow(0 0 1px var(--flag-float)) drop-shadow(0 8px 18px var(--flag-float)); }
  body:not(.kb) #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image .prompt-flag.xl .zoom-btn { display: none; }
  body:not(.kb) #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image .photo figcaption { flex: none; max-width: 100%; margin: 0; padding: 3px 10px; border-radius: 8px; background: var(--fog); color: var(--ink-2); text-align: center; }
  body:not(.kb) #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image :is(.photo, .prompt-flag.xl) :is(a, button) { pointer-events: auto; }
  body:not(.kb) #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image .zoom-btn { position: static; display: grid; flex: none; }
}
@media (orientation: portrait) and (max-width: 1099px) {
  body:not(.kb) #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image :is(.photo, .prompt-flag.xl) { top: calc(var(--top-h) + 12px); left: 12px; right: 12px; bottom: calc(var(--panel-h, 50%) + var(--kb, 0px) + 12px); }
}
@media (orientation: landscape) and (max-height: 519px) {
  body:not(.kb) #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image :is(.photo, .prompt-flag.xl) { top: calc(var(--top-h) + 8px); left: calc(var(--panel-w) + 20px + var(--safe-l)); right: max(60px, env(safe-area-inset-right, 0px)); bottom: 10px; }
}
/* Landscape and typing (a phone on its side, a tablet): the image stays beside the panel, above the keyboard. */
@media (orientation: landscape) {
  body.kb #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image :is(.photo, .prompt-flag.xl) {
    position: fixed; z-index: 4; margin: 0; width: auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; pointer-events: none; top: calc(var(--top-h) + 8px); left: calc(var(--panel-w) + 20px + var(--safe-l)); right: max(10px, env(safe-area-inset-right, 0px)); bottom: calc(var(--kb, 0px) + 6px); }
  body.kb #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image .photo img { flex: 0 1 auto; min-height: 0; width: auto; max-width: 100%; max-height: 100%; border-radius: 10px; }
  body.kb #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image .flagimg.xl { flex: 1 1 0; min-height: 0; width: 100%; height: auto; max-height: none; aspect-ratio: auto; object-fit: contain; border-radius: 0; box-shadow: none;
    filter: drop-shadow(0 0 1px var(--flag-float)) drop-shadow(0 8px 18px var(--flag-float)); }
  body.kb #panel:not(:has(.verdict, .hintline:not(:empty))) #prompt.asks-image :is(.zoom-btn, figcaption) { display: none; }
}

/* --- touch: 44 px targets wherever the pointer is a finger (phones, tablets) ---------------------
   Desktop keeps its tighter sizes; a mouse doesn't need them. Inline links in prose keep their
   font but get a 44 px tall hit area. tools/ui/smoke-sizes.js checks this at every touch size. */
@media (pointer: coarse) {
  button:not(.handle), .btn, select, input[type=text], input[type=search], input[type=email] { min-height: 44px; }
  button:not(.handle):not(.link):not(.crumb) { min-width: 44px; }
  #tabs a { display: inline-flex; align-items: center; min-height: 44px; }
  .brand, .who { min-height: 44px; min-width: 44px; }
  .who { padding-top: 6px; padding-bottom: 6px; }
  label.check { min-height: 44px; }
  .swatch { width: 44px; height: 44px; }
  .crumb { display: inline-flex; align-items: center; }
  .pt-zoom button, .solar-zoom button { width: 44px; height: 44px; }
  .explore-switch a { min-height: 44px; }
  #panel :is(p, li, figcaption, .note, .el-credit) > a:not(.btn) { display: inline-block; padding: 14px 0; margin: -14px 0; }
}
/* The narrowest phones: the brand mark goes (Home is a tab) so Settings isn't cut off. */
@media (max-width: 380px) { .brand { display: none; } #tabs a { padding-left: 9px; padding-right: 9px; } }
.maplibregl-ctrl-bottom-right { margin-right: env(safe-area-inset-right, 0px); margin-bottom: env(safe-area-inset-bottom, 0px); }

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