:root {
  /* Paper atlas theme: cream paper, navy ink, gold */
  --bg: #F4EDDF;
  --ocean: #DCE5E1;
  --surface: #FBF7EE;
  --surface-2: #EFE6D3;
  --line: #DCCFB5;
  --text: #1E2A44;
  --muted: #7A6E58;
  --land: #E6D8BA;
  --land-hover: #D6C298;
  --land-out: #EEE6D4;
  --territory: #E2D7C0;
  --border: #B9A985;
  --green: #5E8030;
  --green-ink: #FBF7EE;
  --yellow: #D29B35;
  --yellow-ink: #845D12;
  --red: #B04A32;
  --gold: #B8862B;
  --accent: #1E2A44;
  --accent-2: #B8862B;
  --radius: 12px;
  --shadow: 0 14px 36px rgba(60, 45, 20, .16);
  --panel-w: 390px;
  --font-body: "Barlow", system-ui, -apple-system, sans-serif;
  --font-ui: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  --font-head: "Libre Caslon Text", Georgia, serif;
  --font-logo: "Libre Caslon Display", "Libre Caslon Text", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 21px; letter-spacing: -.01em; }
.brand b { color: var(--green); font-weight: 800; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(var(--green) 0 62%, var(--land) 62% 100%);
  box-shadow: inset 0 0 0 4px var(--surface), 0 0 0 2px var(--green);
}
.modes { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.mode-btn {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 999px;
  color: var(--muted); font-weight: 600; font-size: 14px; transition: background .15s, color .15s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.continent-select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 10px; font: inherit; font-size: 14px;
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); color: var(--muted); font-weight: 700;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 36px; height: 20px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform .2s; }
.toggle input:checked + .toggle-track { background: var(--red); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle input:checked ~ span:last-child { color: var(--red); font-weight: 600; }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── HUD ─────────────────────────────────────────────────────────────────── */
.hud {
  display: flex; gap: 10px; padding: 10px 18px; align-items: stretch;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.stat {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  padding: 6px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; min-width: 110px;
}
.stat-wide { flex: 1; min-width: 200px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat-label b { color: var(--text); font-size: 13px; letter-spacing: 0; margin-left: 4px; }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-value small { color: var(--muted); font-weight: 500; font-size: 15px; }
.stat-value.bump { animation: bump .45s ease; }
@keyframes bump { 40% { transform: scale(1.15); color: var(--green); } }
.progress { height: 9px; border-radius: 99px; background: var(--land); overflow: hidden; display: flex; margin-top: 5px; }
.progress-green { background: var(--green); transition: width .6s ease; }
.progress-yellow { background: var(--yellow); transition: width .6s ease; }
.mult { font-size: 13px; background: linear-gradient(90deg, #f59e0b, #ef4444); color: #fff; padding: 2px 7px; border-radius: 99px; vertical-align: middle; }
.timer.low { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ── Stage / map ─────────────────────────────────────────────────────────── */
.stage { flex: 1; position: relative; min-height: 0; }
.map-wrap { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 40%, #11203a 0%, var(--ocean) 55%, var(--bg) 100%); overflow: hidden; }
#map { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#map:active { cursor: grabbing; }
.graticule { fill: none; stroke: #ffffff; stroke-opacity: .04; vector-effect: non-scaling-stroke; }

.country {
  fill: var(--land); stroke: var(--border); stroke-width: .6px; vector-effect: non-scaling-stroke;
  transition: fill .5s ease, opacity .3s;
  cursor: pointer;
}
.country.hover { fill: var(--land-hover); }
.outline-hover { fill: none; stroke: #fff; stroke-width: 1.6px; vector-effect: non-scaling-stroke; }
.outline-sel { fill: none; stroke: #fff; stroke-width: 2.4px; vector-effect: non-scaling-stroke; animation: sel 1.4s ease-in-out infinite; }
.country.s-green { fill: var(--green); }
.country.s-yellow { fill: var(--yellow); }
.country.s-red { fill: var(--red); }
.country.s-green.hover { fill: #6ee7b7; }
.country.s-yellow.hover { fill: #fcd34d; }
.country.s-red.hover { fill: #fca5a5; }
.country.out { opacity: .22; pointer-events: none; }
.country.selected, .country.selected.hover { fill: var(--accent); }
@keyframes sel { 50% { stroke-opacity: .35; } }
.country.just-done { animation: done 1s ease; }
@keyframes done { 0% { filter: brightness(2.2); } 100% { filter: none; } }
.territory { fill: var(--territory); stroke: var(--border); stroke-width: .5px; vector-effect: non-scaling-stroke; pointer-events: none; }

.marker { fill: var(--land); stroke: var(--text); stroke-opacity: .55; stroke-width: 1px; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill .5s; }
.marker.hover { stroke: #fff; stroke-opacity: 1; stroke-width: 2px; fill: var(--land-hover); }
.marker.s-green { fill: var(--green); }
.marker.s-yellow { fill: var(--yellow); }
.marker.s-red { fill: var(--red); }
.marker.out { opacity: .2; pointer-events: none; }
.marker.selected { fill: var(--accent); stroke: #fff; stroke-opacity: 1; stroke-width: 2.5px; animation: sel 1.4s ease-in-out infinite; }

.loading { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--muted); }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--green); margin: 0 auto; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: rgba(10, 17, 30, .92); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; transform: translate(-50%, calc(-100% - 12px));
}
.tooltip img { height: 12px; vertical-align: -1px; margin-right: 6px; border-radius: 2px; }

.legend {
  position: absolute; left: 16px; bottom: 16px; display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted); background: rgba(10, 17, 30, .75); padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
}
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw-gray { background: var(--land); } .sw-green { background: var(--green); } .sw-yellow { background: var(--yellow); } .sw-red { background: var(--red); }

.zoom-ctrl { position: absolute; left: 16px; top: 16px; display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.zoom-ctrl button { width: 36px; height: 36px; border: 0; background: rgba(18, 29, 48, .9); font-size: 18px; color: var(--muted); }
.zoom-ctrl button + button { border-top: 1px solid var(--line); }
.zoom-ctrl button:hover { color: var(--text); background: var(--surface-2); }

.hint {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(10, 17, 30, .8); border: 1px solid var(--line); padding: 7px 16px; border-radius: 999px;
  font-size: 14px; color: var(--muted); pointer-events: none; transition: opacity .3s;
}
body.panel-open .hint { opacity: 0; }

/* ── Quiz panel ──────────────────────────────────────────────────────────── */
.panel {
  position: absolute; top: 16px; right: 16px; bottom: 16px; width: var(--panel-w);
  background: rgba(18, 29, 48, .97); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; overflow-y: auto; z-index: 4;
  animation: slideIn .25s ease;
  backdrop-filter: blur(6px);
}
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.steps { display: flex; gap: 6px; }
.step-dot { width: 30px; height: 6px; border-radius: 99px; background: var(--line); }
.step-dot.active { background: var(--accent); }
.step-dot.ok { background: var(--green); }
.step-dot.meh { background: var(--yellow); }
.step-dot.bad { background: var(--red); }
.skip-btn { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 4px 12px; border-radius: 99px; font-size: 13px; }
.skip-btn:hover { color: var(--text); border-color: var(--muted); }
.q-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 600; }
.q-title { font-size: 22px; font-weight: 700; margin: 4px 0 4px; line-height: 1.2; }
.q-sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; display: flex; justify-content: space-between; gap: 10px; }
.attempts { display: inline-flex; gap: 4px; align-items: center; }
.attempts i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.attempts i.used { background: var(--line); }
.worth { color: var(--green); font-weight: 600; }

.options { display: grid; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  font-size: 16px; font-weight: 500; transition: border-color .12s, background .12s, transform .08s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: #0f1a2d; }
.opt:active:not(:disabled) { transform: scale(.985); }
.opt kbd { font: 600 12px var(--font-ui); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; min-width: 22px; text-align: center; }
.opt.wrong { border-color: var(--red); background: rgba(248, 113, 113, .12); color: #fecaca; animation: shake .35s; }
.opt.correct { border-color: var(--green); background: rgba(52, 211, 153, .16); color: #d1fae5; }
.opt.reveal { border-color: var(--green); border-style: dashed; }
.opt:disabled { cursor: default; }
.opt:disabled:not(.correct):not(.wrong):not(.reveal) { opacity: .45; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

.flags { grid-template-columns: repeat(2, 1fr); }
.flag-opt { flex-direction: column; padding: 10px; gap: 6px; justify-content: center; }
.flag-opt img { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; border-radius: 4px; background: #0003; }
.flag-opt .flag-name { font-size: 12px; color: var(--muted); min-height: 15px; text-align: center; }
.flag-opt kbd { align-self: flex-start; margin-bottom: -26px; position: relative; z-index: 1; background: rgba(10,17,30,.8); }

.type-form { display: flex; gap: 8px; }
.type-input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px; outline: none;
}
.type-input:focus { border-color: var(--accent); }
.type-input.wrong { border-color: var(--red); animation: shake .35s; }
.type-input.correct { border-color: var(--green); }
.btn {
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; font-size: 15px;
  background: var(--accent); color: #06111f; transition: filter .15s, transform .08s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.98); }
.btn.green { background: var(--green); color: var(--green-ink); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--muted); }
.type-hint { margin-top: 10px; font-size: 14px; color: var(--muted); min-height: 20px; }
.type-hint b { color: var(--yellow); letter-spacing: .12em; }

.feedback { margin-top: 12px; min-height: 22px; font-weight: 600; font-size: 15px; }
.feedback.good { color: var(--green); }
.feedback.bad { color: var(--red); }

.float-points { position: fixed; pointer-events: none; font-weight: 800; font-size: 22px; color: var(--green); z-index: 50; animation: floatUp 1s ease forwards; text-shadow: 0 2px 10px #000; }
@keyframes floatUp { to { transform: translateY(-50px); opacity: 0; } }

/* ── Info card ───────────────────────────────────────────────────────────── */
.card-result { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.badge { padding: 4px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; }
.badge.green { background: rgba(52, 211, 153, .18); color: var(--green); }
.badge.yellow { background: rgba(251, 191, 36, .16); color: var(--yellow); }
.badge.red { background: rgba(248, 113, 113, .16); color: var(--red); }
.earned { margin-left: auto; font-size: 24px; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }
.info-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.info-flag { width: 104px; flex: none; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #0003; }
.info-name { font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.info-region { color: var(--muted); margin-top: 2px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.fact { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.fact span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.fact b { font-weight: 600; font-size: 15px; }
.fact.full { grid-column: 1 / -1; }
.breakdown { list-style: none; margin: 0 0 16px; padding: 0; font-size: 14px; border-top: 1px solid var(--line); }
.breakdown li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.breakdown li span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.breakdown .ok { color: var(--green); } .breakdown .meh { color: var(--yellow); } .breakdown .bad { color: var(--red); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1; }
.kbd-note { font-size: 12px; color: var(--muted); margin-top: 10px; text-align: center; }

/* ── Locks & learning sections ───────────────────────────────────────────── */
.country.locked:not(.selected), .marker.locked:not(.selected) { filter: saturate(.35) brightness(.72); }
.lock-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: rgba(251, 191, 36, .08); border: 1px dashed rgba(251, 191, 36, .45); color: #fde68a;
  border-radius: 10px; padding: 9px 12px; margin-bottom: 14px; font-size: 14px;
}
.lock-box b { font-variant-numeric: tabular-nums; color: var(--yellow); }
.lock-box .btn { padding: 7px 14px; font-size: 14px; }
.sticky-actions { position: sticky; bottom: -20px; z-index: 2; background: rgb(18, 29, 48); padding: 12px 0 14px; margin: 14px 0 -6px; border-top: 1px solid var(--line); }
.sticky-actions .kbd-note { flex-basis: 100%; margin-top: 2px; }
@media (max-width: 760px) { .sticky-actions { bottom: -16px; } }
.learn { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.learn h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.learn p { margin: 0; line-height: 1.55; font-size: 15px; }
.learn small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.learn.situation h4 { color: var(--red); }
.live { font-size: 10px; letter-spacing: .1em; background: rgba(248, 113, 113, .16); color: var(--red); padding: 2px 7px; border-radius: 99px; }
.muted { color: var(--muted); font-size: 14px; }
.mini-spin { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); vertical-align: -1px; margin-right: 6px; animation: spin 1s linear infinite; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.chips-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-right: 2px; }
.chip { font-size: 12.5px; background: rgba(248, 113, 113, .12); border: 1px solid rgba(248, 113, 113, .3); color: #fecaca; padding: 3px 9px; border-radius: 99px; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.events li { font-size: 14px; line-height: 1.45; padding-left: 12px; border-left: 2px solid var(--line); }
.events b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.wiki-link { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--accent); text-decoration: none; font-weight: 600; }
.wiki-link:hover { text-decoration: underline; }

/* ── Toasts & modals ─────────────────────────────────────────────────────── */
.toasts { position: fixed; top: 130px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; align-items: center; }
.toast { background: var(--surface-2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 999px; font-weight: 600; box-shadow: var(--shadow); animation: toastIn .3s ease, toastOut .4s ease 2.6s forwards; }
.toast.fire { background: linear-gradient(90deg, #b45309, #b91c1c); border-color: transparent; }
.toast.win { background: var(--green); color: var(--green-ink); border-color: transparent; }
@keyframes toastIn { from { transform: translateY(-12px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-12px); opacity: 0; } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(5, 9, 17, .72); display: grid; place-items: center; z-index: 70; padding: 16px; backdrop-filter: blur(3px); }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; animation: pop .25s ease; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -.02em; }
.modal h1 b { color: var(--green); }
.modal p { color: var(--muted); line-height: 1.5; margin: 0 0 14px; }
.modal ul.rules { margin: 0 0 18px; padding-left: 18px; color: var(--muted); line-height: 1.7; }
.modal ul.rules b { color: var(--text); }
.modal .actions { margin-top: 18px; }
.victory { text-align: center; }
.victory h1 { font-size: 34px; background: linear-gradient(90deg, var(--green), var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.vstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; text-align: left; }
.vstats .fact b { font-size: 20px; }
.struggled { text-align: left; }
.struggled h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 8px; }
.struggled ol { margin: 0; padding-left: 20px; line-height: 1.7; }
.struggled ol span { color: var(--muted); }
.trophy { font-size: 54px; line-height: 1; margin-bottom: 8px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .hud { flex-wrap: wrap; }
  .stat { min-width: 0; flex: 1; padding: 5px 10px; }
  .stat-wide { flex-basis: 100%; order: 10; }
  .stat-value { font-size: 18px; }
}
@media (max-width: 760px) {
  .topbar { padding: 8px 16px; gap: 8px; }
  .brand { font-size: 18px; }
  .modes { order: 3; width: 100%; justify-content: space-between; }
  .mode-btn { padding: 6px 8px; font-size: 13px; flex: 1; white-space: nowrap; }
  .hud { padding: 8px 16px; gap: 6px; }
  .stat-label { font-size: 10px; }
  .legend { display: none; }
  .hint { font-size: 13px; top: 10px; max-width: calc(100% - 100px); text-align: center; }
  .zoom-ctrl { top: auto; bottom: 16px; }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 62%; border-radius: 18px 18px 0 0; padding: 16px; animation-name: slideUp; }
  @keyframes slideUp { from { transform: translateY(30px); opacity: 0; } }
  .q-title { font-size: 19px; }
  .opt { padding: 10px 12px; font-size: 15px; }
  .flags { grid-template-columns: repeat(3, 1fr); }
  .flag-opt { padding: 6px; }
  .flag-opt kbd { display: none; }
  .vstats { grid-template-columns: repeat(2, 1fr); }
  .toasts { top: 150px; width: calc(100% - 32px); }
}

/* ── Paper atlas theme (overrides the old dark rules above) ──────────────── */
.brand { gap: 10px; }
.brand-mark { width: 30px; height: 30px; flex: none; background: none; box-shadow: none; border-radius: 0; }
.bm-paper { fill: var(--surface); }
.bm-gold { fill: var(--gold); }
.bm-ink { fill: none; stroke: var(--text); }
.brand-name { font-family: var(--font-logo); font-size: 26px; letter-spacing: .01em; line-height: 1; }
.brand-name b, .modal h1 b { color: var(--gold); font-weight: 400; }

.mode-btn, .continent-select, .toggle, .skip-btn, .btn, .hof-btn, .legend, .hint, .badge, .chip, .live { font-family: var(--font-ui); }
.mode-btn { font-size: 15px; letter-spacing: .02em; }
.modes { background: var(--surface); }
.mode-btn.active { background: var(--text); color: var(--surface); box-shadow: none; }
.mode-btn:hover:not(.active) { color: var(--text); }
.icon-btn, .continent-select { background: var(--surface); }
.toggle-thumb { background: var(--surface); box-shadow: 0 1px 2px rgba(30, 42, 68, .3); }

.topbar, .hud { background: var(--bg); }
.stat { background: var(--surface); font-family: var(--font-ui); }
.stat-label { font-size: 11px; letter-spacing: .16em; font-weight: 600; }
.stat-label b { font-weight: 700; }
.stat-value { font-size: 26px; font-weight: 600; }
.stat-value small { font-size: 17px; }
#hudStreak { color: var(--gold); }
.progress { background: var(--surface-2); }
.progress-yellow { background: var(--yellow); }
.mult { background: var(--gold); color: var(--surface); font-family: var(--font-ui); }
@keyframes bump { 40% { transform: scale(1.15); color: var(--gold); } }

.map-wrap { background: var(--ocean); }
.sphere { fill: var(--ocean); stroke: none; }
.graticule { stroke: #8C7B5A; stroke-opacity: .35; stroke-dasharray: 2 4; }
.country { stroke-width: .5px; }
.outline-hover { stroke: var(--text); stroke-width: 1.4px; }
.outline-sel { stroke: var(--gold); stroke-width: 2.6px; }
.country.s-green.hover { fill: #7A9B4B; }
.country.s-yellow.hover { fill: #E0B25A; }
.country.s-red.hover { fill: #C4664D; }
.country.out { opacity: .35; }
.country.just-done { animation: done 1s ease; }
@keyframes done { 0% { filter: brightness(1.35) saturate(1.3); } 100% { filter: none; } }
.marker { stroke: var(--text); stroke-opacity: .6; }
.marker.hover { stroke: var(--text); }
.marker.selected { stroke: var(--gold); }
.country.locked:not(.selected), .marker.locked:not(.selected) { filter: saturate(.4) brightness(.95); opacity: .7; }

.tooltip { background: var(--text); color: var(--surface); border-color: var(--text); font-family: var(--font-ui); font-size: 14px; }
.legend, .hint { background: rgba(251, 247, 238, .92); color: var(--muted); }
.zoom-ctrl button { background: rgba(251, 247, 238, .95); }
.zoom-ctrl button:hover { background: var(--surface-2); }

.panel { background: rgba(251, 247, 238, .98); backdrop-filter: none; }
.q-kicker { color: var(--gold); font-family: var(--font-ui); font-size: 13px; letter-spacing: .14em; }
.q-title, .info-name, .modal h1 { font-family: var(--font-head); font-weight: 700; letter-spacing: -.005em; }
.modal h1 { font-family: var(--font-logo); font-weight: 400; }
.step-dot { background: var(--surface-2); }
.attempts i.used { background: var(--surface-2); }
.opt { background: var(--surface); }
.opt:hover:not(:disabled) { border-color: var(--text); background: #F6EFE0; }
.opt.wrong { background: rgba(176, 74, 50, .1); color: var(--red); }
.opt.correct { background: rgba(94, 128, 48, .14); color: #3F5A1C; }
.flag-opt img, .info-flag { background: rgba(30, 42, 68, .06); }
.flag-opt kbd { background: rgba(251, 247, 238, .9); }
.type-input { background: var(--surface); }
.btn { background: var(--text); color: var(--surface); font-weight: 600; font-size: 16px; letter-spacing: .02em; }
.btn:hover { filter: none; background: #2C3B5C; }
.btn.green:hover { background: #6E9038; }
.btn.ghost:hover { background: var(--surface-2); }
.type-hint b, .lock-box b { color: var(--yellow-ink); }
.earned { font-family: var(--font-ui); font-weight: 700; }
.float-points { font-family: var(--font-ui); color: var(--green); text-shadow: 0 1px 0 var(--surface), 0 2px 8px rgba(251, 247, 238, .9); }

.badge.green { background: rgba(94, 128, 48, .14); }
.badge.yellow { background: rgba(210, 155, 53, .18); color: var(--yellow-ink); }
.badge.red { background: rgba(176, 74, 50, .12); }
.fact { background: var(--surface); }
.fact b, .breakdown li span:last-child { font-family: var(--font-ui); font-size: 16px; }
.breakdown .meh { color: var(--yellow-ink); }
.lock-box { background: rgba(210, 155, 53, .1); border-color: rgba(184, 134, 43, .5); color: var(--yellow-ink); }
.sticky-actions { background: var(--surface); }
.learn h4, .struggled h3, .events b, .chips-label, .fact span { font-family: var(--font-ui); letter-spacing: .12em; }
.learn h4 { color: var(--gold); }
.learn.situation h4 { color: var(--red); }
.live { background: rgba(176, 74, 50, .12); }
.chip { background: rgba(176, 74, 50, .08); border-color: rgba(176, 74, 50, .3); color: var(--red); }
.wiki-link { color: var(--text); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }

.toast { background: var(--text); color: var(--surface); border-color: var(--text); font-family: var(--font-ui); font-size: 16px; }
.toast.fire { background: var(--red); }
.toast.win { background: var(--green); color: var(--green-ink); }
.modal-backdrop { background: rgba(30, 42, 68, .45); backdrop-filter: none; }
.modal { background: var(--surface); }
.victory h1 { background: none; color: var(--text); }

@media (max-width: 760px) {
  .brand-name { font-size: 22px; }
  .brand-mark { width: 26px; height: 26px; }
  .stat-value { font-size: 20px; }
}

/* ── Round 2: close button, gentler outlines, smaller dots ───────────────── */
.panel { padding-top: 22px; }
.panel-x {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 22px; line-height: 1;
  display: grid; place-items: center; transition: background .15s, transform .15s;
}
.panel-x:hover { background: var(--surface-2); transform: rotate(90deg); }
.panel-head { padding-right: 44px; }
.panel > .lock-box:nth-child(2), .panel > .card-result:nth-child(2) { margin-right: 44px; }

.outline-hover { stroke: rgba(30, 42, 68, .45); stroke-width: 1px; }
.outline-sel { stroke: #fff; stroke-opacity: .9; stroke-width: 1.2px; animation: none; }
.country.selected, .country.selected.hover, .marker.selected { fill: var(--accent); }
.marker { stroke-width: .6px; stroke-opacity: .45; }
.marker.hover { stroke-width: 1px; }
.marker.selected { stroke: #fff; stroke-width: 1.2px; animation: none; }

/* Red edge glow when the map is dragged past its limits */
.map-wrap::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  box-shadow:
    inset calc(var(--glow-l, 0) * 70px) 0 calc(var(--glow-l, 0) * 60px) calc(var(--glow-l, 0) * -10px) rgba(214, 64, 52, .55),
    inset calc(var(--glow-r, 0) * -70px) 0 calc(var(--glow-r, 0) * 60px) calc(var(--glow-r, 0) * -10px) rgba(214, 64, 52, .55),
    inset 0 calc(var(--glow-t, 0) * 70px) calc(var(--glow-t, 0) * 60px) calc(var(--glow-t, 0) * -10px) rgba(214, 64, 52, .55),
    inset 0 calc(var(--glow-b, 0) * -70px) calc(var(--glow-b, 0) * 60px) calc(var(--glow-b, 0) * -10px) rgba(214, 64, 52, .55);
  transition: box-shadow .45s ease;
}

/* ── Round 2: brighter, happier colors ───────────────────────────────────── */
:root {
  --green: #2fa85a;
  --green-ink: #ffffff;
  --yellow: #f2b231;
  --yellow-ink: #8a5a00;
  --red: #e5604a;
  --accent: #2f6fe0;
  --land: #ecdfc2;
  --land-hover: #dfcb9f;
}
.country.s-green { fill: var(--green); }
.country.s-green.hover { fill: #43bf6d; }
.country.s-yellow.hover { fill: #f6c458; }
.country.s-red.hover { fill: #ee7a66; }
.btn.green:hover { background: #38b965; }
.opt.correct { background: rgba(47, 168, 90, .14); color: #1d6e3a; }
.progress-green { background: linear-gradient(90deg, #2fa85a, #4cc77a, #2fa85a); background-size: 200% 100%; animation: shimmer 3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Mode deck: big, colorful cards ──────────────────────────────────────── */
.mode-deck {
  display: flex; align-items: stretch; gap: 10px; padding: 10px 18px;
  background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
}
.mode-deck::-webkit-scrollbar { display: none; }
.deck-label {
  writing-mode: vertical-rl; transform: rotate(180deg); align-self: center;
  font: 700 10px/1.1 var(--font-ui); letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
  max-height: 64px; text-align: center;
}
.mode-card {
  flex: 1 1 0; min-width: 150px; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 16px; text-align: left;
  border: 2px solid color-mix(in srgb, var(--mc) 35%, transparent);
  background: color-mix(in srgb, var(--mc) 8%, var(--surface));
  color: var(--text); font-family: var(--font-ui);
  transition: transform .2s cubic-bezier(.3, 1.6, .5, 1), box-shadow .2s, background .2s, border-color .2s;
}
.mode-card:hover { transform: translateY(-3px); box-shadow: 0 10px 22px -10px var(--mc); border-color: var(--mc); }
.mode-card:active { transform: translateY(0) scale(.97); }
.mc-ico {
  width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 24px;
  background: color-mix(in srgb, var(--mc) 18%, var(--surface));
  transition: transform .3s;
}
.mc-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.mc-txt b { font-size: 18px; font-weight: 700; letter-spacing: .01em; }
.mc-txt small { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-card.active {
  background: var(--mc); border-color: var(--mc); color: #fff;
  box-shadow: 0 12px 26px -12px var(--mc), inset 0 -3px 0 rgba(0, 0, 0, .15);
  transform: translateY(-2px);
}
.mode-card.active small { color: rgba(255, 255, 255, .85); }
.mode-card.active .mc-ico { background: rgba(255, 255, 255, .22); animation: icoBounce 2.4s ease-in-out infinite; }
@keyframes icoBounce { 0%, 100% { transform: translateY(0) rotate(0); } 15% { transform: translateY(-4px) rotate(-8deg); } 30% { transform: translateY(0) rotate(4deg); } 45% { transform: rotate(0); } }
.mode-learn { position: relative; }
.mode-learn::after {
  content: "NEW"; position: absolute; top: -7px; right: 10px; font: 700 10px/1 var(--font-ui); letter-spacing: .1em;
  background: var(--red); color: #fff; padding: 3px 6px; border-radius: 6px;
}
body.pick-mode .mode-card:not(.active) { animation: wiggle 2.2s ease-in-out infinite; }
body.pick-mode .mode-card:nth-of-type(2) { animation-delay: .15s; } body.pick-mode .mode-card:nth-of-type(3) { animation-delay: .3s; }
body.pick-mode .mode-card:nth-of-type(4) { animation-delay: .45s; } body.pick-mode .mode-card:nth-of-type(5) { animation-delay: .6s; }
body.pick-mode .mode-card:nth-of-type(6) { animation-delay: .75s; }
@keyframes wiggle { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-5px); } 90% { transform: translateY(1px); } }
.mode-deck .continent-select { align-self: center; font-family: var(--font-ui); font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 2px solid #ee8a1c; }

/* ── Learn bar ───────────────────────────────────────────────────────────── */
.learn-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 18px;
  background: linear-gradient(90deg, rgba(47, 127, 224, .12), rgba(47, 127, 224, .03)); border-bottom: 1px solid var(--line);
  animation: dropIn .35s ease;
}
@keyframes dropIn { from { transform: translateY(-8px); opacity: 0; } }
.learn-bar-label { font: 700 13px var(--font-ui); letter-spacing: .1em; text-transform: uppercase; color: #2f7fe0; margin-right: 6px; }
.topic {
  font: 600 16px var(--font-ui); padding: 8px 14px; border-radius: 999px; border: 2px solid rgba(47, 127, 224, .35);
  background: var(--surface); color: var(--text); transition: transform .15s, background .15s;
}
.topic:hover { transform: translateY(-2px); }
.topic.on { background: #2f7fe0; color: #fff; border-color: #2f7fe0; }

/* ── Player chip & language switch ───────────────────────────────────────── */
.player { display: flex; align-items: center; gap: 8px; font-family: var(--font-ui); font-size: 15px; }
.player-hi b { font-weight: 700; }
.player-rank { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--yellow-ink); padding: 3px 9px; border-radius: 999px; font-weight: 600; font-size: 13px; }
.player-days { color: var(--red); font-weight: 700; }
.player-save {
  border: 0; background: none; color: var(--accent); font: 600 14px var(--font-ui); text-decoration: underline;
  text-underline-offset: 3px; padding: 0; animation: nudge 4s ease-in-out infinite;
}
.player-save.saved { color: var(--green); text-decoration: none; animation: none; cursor: default; }
@keyframes nudge { 0%, 88%, 100% { transform: none; } 92% { transform: translateX(-3px); } 96% { transform: translateX(3px); } }
.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface); }
.lang-switch button { border: 0; background: none; font: 700 13px var(--font-ui); padding: 5px 10px; border-radius: 999px; color: var(--muted); }
.lang-switch button.active { background: var(--text); color: var(--surface); }

@media (max-width: 760px) {
  .mode-deck { padding: 8px 16px; gap: 8px; }
  .deck-label { display: none; }
  .mode-card { min-width: 112px; padding: 8px 10px; gap: 8px; }
  .mc-ico { width: 32px; height: 32px; font-size: 18px; border-radius: 9px; }
  .mc-txt b { font-size: 15px; }
  .mc-txt small { display: none; }
  .player-save { font-size: 13px; }
  .player-rank, .player-days { display: none; }
  .learn-bar { padding: 8px 16px; overflow-x: auto; flex-wrap: nowrap; }
  .learn-bar-label { display: none; }
  .topic { white-space: nowrap; font-size: 14px; padding: 6px 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .mode-card, .mode-card.active .mc-ico, body.pick-mode .mode-card, .player-save, .progress-green { animation: none !important; transition: none; }
}

/* ── Learn mode overlays ─────────────────────────────────────────────────── */
.learn-flags { display: none; }
body.learn-on.t-flags .learn-flags { display: inline; }
.flag-fill { opacity: .95; }
.flag-mini { outline: 1px solid rgba(30, 42, 68, .3); }
.learn-labels { display: none; }
body.learn-on .learn-labels { display: inline; }
.learn-label {
  font-family: var(--font-ui); text-anchor: middle; fill: var(--text);
  stroke: rgba(251, 247, 238, .92); stroke-linejoin: round; paint-order: stroke;
}
body.t-flags .learn-label { stroke: rgba(255, 255, 255, .95); }
.l-name { font-weight: 700; }
.l-sub { font-size: .74em; font-weight: 600; fill: #4a4436; }
body.learn-on.t-regions .country[data-cont="Europe"] { fill: #8dbbea; }
body.learn-on.t-regions .country[data-cont="Asia"] { fill: #f4ad66; }
body.learn-on.t-regions .country[data-cont="Africa"] { fill: #ecc94f; }
body.learn-on.t-regions .country[data-cont="North America"] { fill: #92d394; }
body.learn-on.t-regions .country[data-cont="South America"] { fill: #ec93ae; }
body.learn-on.t-regions .country[data-cont="Oceania"] { fill: #a596e6; }
body.learn-on .country.selected { fill: var(--accent); }

/* ── Bonus mode ──────────────────────────────────────────────────────────── */
.country.pick-a, .marker.pick-a { fill: #2f6fe0 !important; }
.country.pick-b, .marker.pick-b { fill: #ee8a1c !important; }
.bonus-mark { pointer-events: none; }
.water-pulse { fill: rgba(47, 111, 224, .25); stroke: #2f6fe0; stroke-width: 1px; transform-origin: center; transform-box: fill-box; animation: waterPulse 1.6s ease-out infinite; }
.water-dot { fill: #2f6fe0; stroke: #fff; stroke-width: 1.2px; }
.water-q { fill: #fff; font: 700 6px var(--font-ui); text-anchor: middle; }
@keyframes waterPulse { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(2.4); opacity: 0; } }
.bonus-kicker { color: #c78a00; }
.options.two { grid-template-columns: 1fr 1fr; }
.options.two .opt { justify-content: center; font-size: 18px; padding: 16px 12px; }
.step-dot.small { width: 18px; }
.stars { display: flex; justify-content: center; gap: 8px; margin-bottom: 6px; }
.stars span { font-size: 54px; line-height: 1; color: #e2d8c3; }
.stars span.on { color: #f2b231; animation: starPop .5s cubic-bezier(.3, 1.8, .5, 1) both; text-shadow: 0 4px 14px rgba(242, 178, 49, .5); }
@keyframes starPop { from { transform: scale(0) rotate(-40deg); } }

/* ── Welcome, forms, misc ────────────────────────────────────────────────── */
.welcome { text-align: center; }
.welcome-globe { font-size: 64px; line-height: 1; margin-bottom: 8px; animation: globeSpin 6s ease-in-out infinite; }
@keyframes globeSpin { 0%, 100% { transform: rotate(-8deg) scale(1); } 50% { transform: rotate(8deg) scale(1.06); } }
.welcome .type-form { max-width: 380px; margin: 10px auto 0; }
.form-err { min-height: 20px; margin: 8px 0 0 !important; color: var(--red) !important; font-weight: 600; font-family: var(--font-ui); }
.fine { font-size: 13px; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #d4513b; }
.c-green { color: var(--green); } .c-yellow { color: var(--yellow-ink); } .c-red { color: var(--red); }
.ripple { pointer-events: none; }
.opt { text-align: start; }
.mode-card { text-align: start; }
.opt.correct { animation: correctPop .4s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes correctPop { 50% { transform: scale(1.04); } }

/* ── Hebrew (right to left) ──────────────────────────────────────────────── */
[dir="rtl"] body { font-family: "Heebo", var(--font-body); }
[dir="rtl"] .brand { direction: ltr; }
[dir="rtl"] .mode-card, [dir="rtl"] .topic, [dir="rtl"] .stat, [dir="rtl"] .btn, [dir="rtl"] .opt, [dir="rtl"] .player,
[dir="rtl"] .q-kicker, [dir="rtl"] .learn-label, [dir="rtl"] .toast, [dir="rtl"] .tooltip { font-family: "Heebo", var(--font-ui); }
[dir="rtl"] .q-title, [dir="rtl"] .info-name, [dir="rtl"] .modal h1 { font-family: "Frank Ruhl Libre", var(--font-head); }
[dir="rtl"] .stat-label, [dir="rtl"] .deck-label, [dir="rtl"] .learn-bar-label, [dir="rtl"] .fact span { letter-spacing: 0; }
[dir="rtl"] .panel-head { padding-right: 0; padding-left: 44px; }
[dir="rtl"] .panel-x { right: auto; left: 12px; }
[dir="rtl"] .panel > .lock-box:nth-child(2), [dir="rtl"] .panel > .card-result:nth-child(2) { margin-right: 0; margin-left: 44px; }
[dir="rtl"] .earned { margin-left: 0; margin-right: auto; }
[dir="rtl"] .events li { padding-left: 0; padding-right: 12px; border-left: 0; border-right: 2px solid var(--line); }
[dir="rtl"] .modal ul.rules { padding-left: 0; padding-right: 18px; }
[dir="rtl"] .mode-learn::after { right: auto; left: 10px; }
[dir="rtl"] .type-input[type="email"] { text-align: left; }
@media (prefers-reduced-motion: reduce) {
  .water-pulse, .welcome-globe, .stars span.on, .opt.correct { animation: none !important; }
}

/* Phone top bar: everything fits on two tidy rows */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .topbar-right { margin-left: 0; margin-inline-start: 0; width: 100%; justify-content: space-between; gap: 6px; flex-wrap: nowrap; }
  .hof-btn { font-size: 13px !important; padding: .35rem .65rem !important; white-space: nowrap; }
  .player { gap: 5px; font-size: 13px; min-width: 0; }
  .player-hi { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; }
  .player-save { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 96px; }
  .toggle > span:last-child { display: none; }
  .icon-btn { width: 30px; height: 30px; }
  .lang-switch button { padding: 4px 8px; }
}
@media (max-width: 760px) {
  .player-hi { flex: none; max-width: none; }
  .player-save { max-width: 64px; }
}
.player { cursor: pointer; }
@media (max-width: 760px) {
  .player-save:not(.saved) { max-width: none; font-size: 0; text-decoration: none; }
  .player-save:not(.saved)::before { content: "💾"; font-size: 18px; }
  .player-save.saved { font-size: 0; }
  .player-save.saved::before { content: "✓"; font-size: 15px; }
}
