:root {
  --bg: #12233f;
  --console: #0b1830;
  --panel: #182f55;
  --panel-2: #20406f;
  --ink: #f4f1e6;
  --muted: #9fb3d4;
  --yellow: #ffd23f;
  --sea: #8fc8ec;
  --sea-deep: #6fb3e0;
  --land: #f3e7c3;
  --land-other: #d9d4c4;
  --border: #6b5f48;
  --good: #2fbf71;
  --bad: #e5484d;
  --p1: #ff8a3d;
  --p2: #9b6bff;
  --lamp-off: #2b4777;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: "Nunito", "Trebuchet MS", system-ui, sans-serif; overflow: hidden;
  -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }

/* ---------- menu ---------- */
#menu { flex-direction: column; padding: 16px 24px; gap: 8px; overflow-y: auto; }
.brand { display: flex; align-items: center; justify-content: space-between; }
.logo { font-size: 34px; font-weight: 900; color: var(--yellow); letter-spacing: .5px;
  text-shadow: 0 3px 0 #b8860b; }
.logo .globe { text-shadow: none; }
.label { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 0; }
.menu-body { display: flex; flex-direction: column; gap: 14px; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.card { min-height: 124px; border-radius: 18px; padding: 16px 18px; text-align: left;
  background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 3px solid #2f5590;
  display: flex; flex-direction: column; gap: 4px; box-shadow: 0 6px 0 #081428; }
.card:active { transform: translateY(3px); box-shadow: 0 3px 0 #081428; }
.card { position: relative; overflow: hidden; }
.card .thumb { position: absolute; right: 8px; top: 8px; bottom: 8px; width: 46%; pointer-events: none; }
.card .thumb svg { width: 100%; height: 100%; }
.card .t, .card .s, .card .best { position: relative; max-width: 54%; }
.card .t { margin-top: 10px; }
.card .t { font-size: 24px; font-weight: 900; }
.card .s { font-size: 15px; color: var(--muted); font-weight: 700; }
.card .best { margin-top: auto; font-size: 15px; color: var(--yellow); font-weight: 800; }
.options { display: flex; flex-wrap: wrap; gap: 18px 28px; }
.opt-group { display: flex; flex-direction: column; gap: 6px; }
.seg { display: inline-flex; background: var(--console); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { min-width: 64px; height: 48px; border-radius: 10px; font-size: 18px; font-weight: 800; color: var(--muted); padding: 0 14px; }
.seg button.on { background: var(--yellow); color: #1b1b1b; }
.icon-btn { width: 52px; height: 52px; border-radius: 50%; background: var(--panel); font-size: 24px;
  display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon-btn.small { width: 44px; height: 44px; font-size: 18px; }

/* ---------- game ---------- */
#game { background: var(--console); }
.panel { width: 284px; flex: none; display: flex; flex-direction: column; background: var(--panel);
  border-right: 4px solid #0a1428; padding: 10px 10px 8px; gap: 8px; }
.panel-top { display: flex; align-items: center; gap: 8px; }
.card-title { font-weight: 900; font-size: 16px; line-height: 1.15; }
.scores { display: flex; gap: 6px; }
.score { flex: 1; border-radius: 12px; padding: 4px 8px; background: var(--console); border: 3px solid transparent;
  display: flex; align-items: baseline; justify-content: space-between; }
.score .who { font-weight: 800; font-size: 13px; color: var(--muted); }
.score .n { font-weight: 900; font-size: 26px; font-variant-numeric: tabular-nums; }
.score.turn { border-color: currentColor; }
.score.p1 { color: var(--p1); } .score.p2 { color: var(--p2); }
.score.p1 .who, .score.p2 .who { color: inherit; }
.questions { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.questions li { display: flex; align-items: center; gap: 8px; padding: 0 6px; border-radius: 8px; font-weight: 700;
  font-size: 14px; color: var(--muted); flex: 1 1 0; min-height: 0; max-height: 34px; white-space: nowrap; overflow: hidden; }
.questions li .lamp { width: 14px; height: 14px; border-radius: 50%; background: var(--lamp-off); flex: none;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.3); }
.questions li .q { overflow: hidden; text-overflow: ellipsis; }
.questions li.now { background: rgba(255,210,63,.14); color: var(--ink); }
.questions li.spin .lamp { background: var(--yellow); box-shadow: 0 0 10px 2px var(--yellow); }
.questions li.spin { background: rgba(255,210,63,.14); color: var(--ink); }
.questions li.now .lamp { background: var(--yellow); box-shadow: 0 0 10px 2px var(--yellow); animation: blink 1s steps(2) infinite; }
.questions li.right .lamp { background: var(--good); }
.questions li.wrong .lamp { background: var(--bad); }
.questions li.right, .questions li.wrong { color: var(--ink); }
@keyframes blink { 50% { opacity: .35; } }

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.prompt { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--console); min-height: 68px; }
.prompt-text { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.prompt .ask { font-size: 20px; color: var(--muted); font-weight: 800; }
.prompt .target { font-size: 32px; font-weight: 900; color: var(--yellow); line-height: 1.05; }
.tries { display: flex; gap: 6px; }
.tries i { width: 18px; height: 18px; border-radius: 50%; background: var(--yellow); display: block; }
.tries i.used { background: var(--lamp-off); }
.timer { height: 10px; background: #0a1326; }
.timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--good), var(--yellow)); transform-origin: left; }
.timer.low .timer-fill { background: var(--bad); }
.timer.off { visibility: hidden; }
.map-wrap { flex: 1; min-height: 0; background: var(--sea); position: relative; }
.map-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

svg .sea { fill: var(--sea); }
svg .other { fill: var(--land-other); stroke: #b9b2a0; stroke-width: .8; }
svg .lake { fill: var(--sea-deep); stroke: #5d9fcc; stroke-width: .5; pointer-events: none; }
svg .region { fill: var(--land); stroke: var(--border); stroke-width: 1.1; stroke-linejoin: round; transition: fill .2s; }
svg .region.hit-pad { stroke: transparent; stroke-width: 26; fill: none; pointer-events: stroke; }
svg .region.done-p1 { fill: #ffc59a; } svg .region.done-p2 { fill: #cdb7ff; }
svg .region.missed { fill: #f2b8ba; }
svg .region.flash-bad { fill: var(--bad); }
svg .region.flash-good { fill: var(--good); }
svg .region.reveal { animation: reveal .5s ease-in-out infinite alternate; }
@keyframes reveal { from { fill: var(--land); } to { fill: var(--good); } }
svg .leader { stroke: #1f3d6b; stroke-width: 2.2; stroke-dasharray: 3 3; pointer-events: none; }
svg .dot circle.vis { fill: #1f3d6b; stroke: #fff; stroke-width: 2.2; }
svg .dot circle.hit { fill: transparent; stroke: none; }
svg .dot.wrong circle.vis { fill: var(--bad); }
svg .dot.p1 circle.vis { fill: var(--p1); } svg .dot.p2 circle.vis { fill: var(--p2); }
svg .dot .star { fill: #e5484d; stroke: #fff; stroke-width: 1.4; stroke-linejoin: round; pointer-events: none; }
svg .dot.p1 .star, svg .dot.p2 .star, svg .dot.wrong .star { fill: #fff; stroke: #c0262d; }
svg .clabel { display: none; font-size: 18px; font-weight: 800; fill: #5a1215; paint-order: stroke; stroke: #fff; stroke-width: 3px; pointer-events: none; }
svg .clabel.show { display: block; }

.toast { position: absolute; left: 50%; top: 96px; transform: translateX(-50%) scale(.8); opacity: 0;
  background: #fff; color: #1b1b1b; font-weight: 900; font-size: 26px; padding: 10px 22px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3); transition: opacity .15s, transform .15s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) scale(1); }
.toast.good { background: var(--good); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- results ---------- */
#results { align-items: center; justify-content: center; background: radial-gradient(circle at 50% 30%, #23467c, var(--bg)); }
.results-box { text-align: center; padding: 20px; }
.stars { min-height: 76px; display: flex; justify-content: center; gap: 10px; }
.stars span { display: inline-block; animation: pop .4s backwards; }
.stars span.dim { filter: grayscale(1) brightness(.5); }
@keyframes pop { from { transform: scale(0); } }
#result-title { color: var(--yellow); font-size: 40px; margin: 6px 0 4px; font-weight: 900; }
.result-lines { font-size: 22px; font-weight: 800; display: flex; flex-direction: column; gap: 4px; }
.result-actions { display: flex; gap: 14px; justify-content: center; margin-top: 22px; }
.big-btn { background: var(--yellow); color: #1b1b1b; font-size: 22px; font-weight: 900; padding: 14px 28px;
  border-radius: 16px; box-shadow: 0 5px 0 #b8860b; }
.big-btn.alt { background: var(--panel-2); color: var(--ink); box-shadow: 0 5px 0 #0a1428; }
.big-btn:active { transform: translateY(3px); box-shadow: none; }

/* Portrait: question list goes on top as a strip. */
@media (orientation: portrait) {
  #game { flex-direction: column; }
  .panel { width: auto; border-right: 0; border-bottom: 4px solid #0a1428; }
  .questions { flex-direction: row; flex-wrap: wrap; gap: 4px; flex: none; }
  .questions li { flex: none; max-height: none; height: 26px; padding: 0 4px; }
  .questions li .q { display: none; }
  .questions li .lamp { width: 18px; height: 18px; }
}

/* long name lists (Africa, "All") scroll; rows keep a fixed height */
.questions { position: relative; min-height: 0; }
.questions.scroll { overflow-y: auto; gap: 0; -webkit-overflow-scrolling: touch; }
.questions.scroll li { flex: none; height: 32px; max-height: none; }
.questions.scroll::-webkit-scrollbar { width: 6px; }
.questions.scroll::-webkit-scrollbar-thumb { background: #3b6199; border-radius: 3px; }
.map-wrap svg { touch-action: none; }
.zoombar { position: absolute; left: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.zoombar button { min-width: 52px; height: 52px; border-radius: 14px; background: rgba(11,24,48,.88); color: var(--ink);
  font-size: 28px; font-weight: 900; box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.zoombar button:last-child { font-size: 15px; }
.zoombar button:active { transform: translateY(2px); }

/* islands whose marker was moved aside: a heavier outline keeps the tiny shape visible, a pin marks the real spot */
svg .region.tiny { stroke: #5b4a2e; }
svg .pin { fill: #e5484d; stroke: #fff; stroke-width: 1.2; pointer-events: none; }

/* outlines stay thin at any zoom, so tiny islands show their shape instead of a blob */
svg .region, svg .other, svg .lake, svg .leader { vector-effect: non-scaling-stroke; }
svg .region { stroke-width: 1px; }
svg .other { stroke-width: .7px; }
svg .lake { stroke-width: .5px; }
svg .leader { stroke-width: 1.6px; }
svg .region.tiny { stroke-width: 1.5px; }

/* settings sit above the cards so they are seen before a card is picked */
.options { background: var(--panel); border-radius: 16px; padding: 10px 16px 12px; }

/* settings screen */
.brand-btns, .set-head { display: flex; align-items: center; gap: 10px; }
#settings { flex-direction: column; padding: 16px 24px; gap: 14px; overflow-y: auto; }
.set-card { background: var(--panel); border-radius: 16px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.set-title { font-weight: 900; font-size: 22px; }
.set-sub { color: var(--muted); font-weight: 700; font-size: 16px; margin-top: 2px; }
.reset-area { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.confirm-text { font-weight: 800; font-size: 18px; max-width: 280px; }
.big-btn.danger { background: var(--bad); color: #fff; box-shadow: 0 5px 0 #8a2024; }
.big-btn:disabled { opacity: .4; box-shadow: none; }
.big-btn { font-size: 20px; padding: 12px 22px; }

/* "Show names": the answer written under each marker (off by default) */
svg .name { font-weight: 800; fill: #3a3326; text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: rgba(255,255,255,.75); }
