/* ════════════════════════════════════════════════════════════════════
   MapMosh — styles. Design language: cream paper (#f5f3ec), ink black
   (#152843), signal orange (#166534), pastel panels, hard offset
   shadows, heavy condensed labels. Desktop grid + a coarse-pointer mobile
   layout (bottom sheet + thumb toolbar) at the end of this file.
   ════════════════════════════════════════════════════════════════════ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --paper:     #f5f3ec;
  --ink:       #152843;
  --accent:    #166534;
  /* Functional utility colours — named by role, not hue. */
  --hover:     #ffd6a5;   /* warm hover state (buttons, cards) */
  --success:   #caffbf;   /* saved / confirmed state */
  --highlight: #fdffb6;   /* personal rank, win row, active selection */
  --subtle:    #bdb2ff;   /* reserved — available for future use */
  --shadow:    3px 3px 0 var(--ink);

  /* ── Motion tokens ───────────────────────────────────────────────── */
  --dur-q:       100ms;  /* micro: shadow snap, dot flip              */
  --dur-b:       200ms;  /* base: hover sweep, underline              */
  --dur-enter:   330ms;  /* entrance: list rows, toolbar              */
  --dur-big:     500ms;  /* big: modal stamp, score pop, wiggle       */
  --dur-roll:    900ms;  /* score counter digit roll                  */
  --ease-snap:   cubic-bezier(0.25, 0, 0.3, 1);
  --ease-bounce: cubic-bezier(0.3, 0, 0, 1.6);
  --ease-spring: cubic-bezier(0.2, 0, 0, 1.85);
  --sh-hov:      6px 6px 0 var(--ink);  /* hover / lifted shadow      */
  --sh-big:      9px 9px 0 var(--ink);  /* modal / big moment shadow  */
  --lift:        translate(-3px, -3px); /* hover lift offset          */
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ── Bottom-sheet handle (mobile only — hidden on desktop) ──────────────── */
.sheet-handle { display: none; }

/* ── Frame ──────────────────────────────────────────────────────────── */
#desktop-layout {
  width: 100%;
  height: 100%;
  padding: 15px;
  display: grid;
  grid-template-rows: 60px 1fr 40px;
  gap: 15px;
}

.box { border-radius: 6px; border: 1px solid rgba(0,0,0,.1); }

/* ── Header ─────────────────────────────────────────────────────────── */
.header {
  background: var(--paper);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
}
/* display:inline-block + transform-origin needed for wiggle animation */
.logo {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -1px;
  display: inline-block;
  transform-origin: center bottom;
  color: var(--ink);          /* keep "Map" navy when the logo is an <a> */
  text-decoration: none;
  cursor: pointer;
}
/* "Mosh" in accent — typeLogo injects <em> for this */
.logo em { font-style: normal; color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 16px; }

.badge-beta {
  border: 1.5px solid var(--accent);
  color: var(--accent);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  border-radius: 2px;
}
.nav-link {
  text-decoration: none;
  color: #555;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .5px;
  margin-right: 8px;
}
.nav-link:hover { color: var(--ink); }

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  padding: 10px 18px;
  cursor: pointer;
  border-radius: 4px;
  letter-spacing: .5px;
}
.btn-multiplayer { background: var(--ink); color: #fff; border: none; }

/* ── Ko-fi button ───────────────────────────────────────────────────── */
.btn-kofi {
  background: var(--accent);
  color: #fff;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition:
    transform var(--dur-b) var(--ease-bounce),
    box-shadow var(--dur-b) var(--ease-snap),
    background var(--dur-b) var(--ease-snap);
}
/* White underline sweep on hover */
.btn-kofi::after {
  content: '';
  position: absolute; bottom: 0; left: 0;
  width: 0; height: 3px;
  background: rgba(255,255,255,.55);
  transition: width var(--dur-b) var(--ease-snap);
}
.btn-kofi:hover::after { width: 100%; }
.btn-kofi:hover { background: #1a7a3f; transform: var(--lift); box-shadow: var(--sh-hov); }
.btn-kofi:active { box-shadow: 0 0 0 var(--ink); transform: translate(3px, 3px); }

.visitor-count {
  font-size: 12px;
  font-weight: 800;
  color: #555;
  letter-spacing: .2px;
  white-space: nowrap;
}

/* Mobile-only nav row: hidden on desktop */
.nav-mobile { display: none; }

/* Mobile action bar: hidden on desktop */
#action-bar { display: none; }

/* ── Main grid ──────────────────────────────────────────────────────── */
.main-content {
  display: grid;
  grid-template-columns: 336px 1fr;
  gap: 15px;
  min-height: 0;
}
.sidebar { display: flex; flex-direction: column; gap: 15px; min-height: 0; }

.sidebar .box-1 { flex: 2; background: #e8e5dc; }
.sidebar .box-2 { flex: 6; background: var(--paper); min-height: 0; }
.sidebar .box-3 { flex: 2; background: #edeae1; }

.panel-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.5px;
  opacity: .65;
  margin-bottom: 8px;
}

/* ── Box 1: HUD ─────────────────────────────────────────────────────── */
.box-1 { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.hud-top { display: flex; justify-content: space-between; align-items: baseline; }
#hud-continent { font-size: 21px; font-weight: 900; letter-spacing: -.5px; }
#hud-mode {
  font-size: 10px; font-weight: 900; letter-spacing: 1px;
  background: var(--ink); color: var(--paper);
  padding: 3px 8px; border-radius: 3px;
}
.hud-current { font-size: 13px; font-weight: 700; }
.hud-current .label { opacity: .6; font-weight: 700; }
#hud-country.placeholder { opacity: .55; font-style: italic; }
.hud-stats { display: flex; gap: 14px; margin-top: auto; }
.hud-stat .v { font-size: 17px; font-weight: 900; }
.hud-stat .k { font-size: 9px; font-weight: 800; letter-spacing: 1px; opacity: .6; }

/* ── Box 2: country checklist ───────────────────────────────────────── */
.box-2 { padding: 12px 8px 12px 14px; display: flex; flex-direction: column; }
.list-scroll { flex: 1; overflow-y: auto; padding-right: 6px; min-height: 0; }
#country-list { columns: 2; column-gap: 10px; }

.country-row {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  break-inside: avoid;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  margin-bottom: 2px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-b) var(--ease-snap), background var(--dur-b) var(--ease-snap);
}
.country-row:hover:not(.done) { border-color: var(--ink); background: rgba(0,92,43,.05); }
.country-row.selected {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
/* Hovering over an already-selected row: accent background keeps text visible. */
.country-row.selected:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.country-row.done { cursor: default; opacity: .85; }
.country-row .cr-name {
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.country-row .cr-stat { font-size: 10px; font-weight: 900; }
.country-row .dot {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid var(--ink);
  flex-shrink: 0;
  transition: background var(--dur-q) var(--ease-snap), border-color var(--dur-q) var(--ease-snap);
}
.country-row .dot.empty { background: transparent; border-color: rgba(21,40,67,.45); }
.country-row.selected .dot.empty { border-color: var(--paper); }

.list-scroll::-webkit-scrollbar { width: 8px; }
.list-scroll::-webkit-scrollbar-thumb { background: rgba(21,40,67,.35); border-radius: 4px; }

/* ── Box 3: leaderboard placeholder ─────────────────────────────────── */
.box-3 { padding: 12px 14px; overflow: hidden; }
.lb-placeholder { font-size: 12px; font-weight: 600; opacity: .65; line-height: 1.5; }

/* ── Map area ───────────────────────────────────────────────────────── */
.content-area {
  position: relative;
  overflow: hidden;
  z-index: 1;
  background: #eee;
}
.content-area.brush-on { cursor: crosshair; }
.content-area.brush-pan { cursor: grab; }

/* ── Toolbar ────────────────────────────────────────────────────────── */
#toolbar {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex; gap: 6px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 5px;
}
.tb-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .5px;
  padding: 7px 12px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background var(--dur-b) var(--ease-snap), color var(--dur-q) var(--ease-snap), transform var(--dur-q) var(--ease-snap);
}
/* Accent underline sweep — all non-active, non-submit toolbar buttons */
.tb-btn::after {
  content: '';
  position: absolute; bottom: 0; left: 0;
  width: 0; height: 2px; background: var(--accent);
  transition: width var(--dur-b) var(--ease-snap);
}
.tb-btn:not(.active):hover:not(:disabled)::after { width: 100%; }
/* Explicit color: var(--ink) prevents cream text lingering on yellow bg during active→inactive transition */
.tb-btn:hover:not(:disabled):not(#tb-submit) { background: var(--highlight); color: var(--ink); }
.tb-btn:active:not(:disabled) { transform: translate(2px, 2px); }
/* Active tool: ink fill + heartbeat ring */
.tb-btn.active {
  background: var(--ink);
  color: var(--paper);
  animation: tb-pulse 1.4s ease infinite;
}
.tb-btn.active::after { display: none; }
.tb-btn:disabled { opacity: .4; cursor: not-allowed; }
/* Submit button — keeps orange through all states */
#tb-submit { background: var(--accent); color: #fff; border-color: var(--ink); }
#tb-submit::after { background: rgba(255,255,255,.45); }
#tb-submit:hover:not(:disabled) { background: #104d28; color: #fff; }
#tb-submit:active:not(:disabled) { background: #0b3a1e; color: #fff; transform: translate(2px, 2px); }
.tb-sep { width: 2px; background: rgba(21,40,67,.25); margin: 2px 1px; }

/* ── Toast ──────────────────────────────────────────────────────────── */
#toast {
  position: absolute;
  top: 62px; left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 1000;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
  max-width: 70%;
  text-align: center;
}
/* Bouncy slide-in replaces the old linear transition */
#toast.show { animation: toast-slide-in var(--dur-enter) var(--ease-bounce) both; }
#toast.good { background: #156b2d; }
#toast.warn { background: var(--accent); }

/* Country completion labels on the map */
.paint-label {
  background: rgba(21,40,67,.82);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .3px;
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
  width: max-content !important;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* ── Back-to-results / .btn-hard ────────────────────────────────────── */
#back-to-results {
  position: absolute;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
}
.btn-hard {
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .5px;
  padding: 10px 18px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: var(--shadow);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    transform var(--dur-b) var(--ease-bounce),
    box-shadow var(--dur-b) var(--ease-snap),
    background var(--dur-b) var(--ease-snap);
}
.btn-hard::after {
  content: '';
  position: absolute; bottom: 0; left: 0;
  width: 0; height: 3px; background: var(--accent);
  transition: width var(--dur-b) var(--ease-snap);
}
.btn-hard:hover::after { width: 100%; }
.btn-hard:hover { background: var(--highlight); transform: var(--lift); box-shadow: var(--sh-hov); }
.btn-hard:active { box-shadow: 0 0 0 var(--ink); transform: translate(3px, 3px); }
.btn-hard.primary { background: var(--ink); color: var(--paper); }
.btn-hard.primary::after { background: var(--accent); }
.btn-hard.primary:hover { background: #222; }

/* ── Footer ─────────────────────────────────────────────────────────── */
.footer {
  background: #e0ddd4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
}
.footer a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1.5px solid transparent;
  transition: color .15s var(--ease-snap), border-color .15s var(--ease-snap);
}
.footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Start menu overlay — split-screen ──────────────────────────────── */
#menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

/* ── Left panel: dark marketing / explainer ─────────────────────────── */
.menu-left {
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 52px;
  overflow-y: auto;
}
.menu-left-content { max-width: 420px; width: 100%; }

.menu-hero {
  font-size: clamp(32px, 3.8vw, 52px);
  font-weight: 900;
  letter-spacing: -1.5px;
  line-height: 1.08;
  margin-bottom: 36px;
}
.menu-hero em {
  color: var(--accent);
  font-style: normal;
}

.menu-how-label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  opacity: .5;
  margin-bottom: 20px;
  text-transform: uppercase;
}

.menu-steps {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 36px;
}

.menu-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.menu-step-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255,255,255,.25);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px;
  background: rgba(255,255,255,.07);
  color: var(--paper);
}
.menu-step-icon svg { width: 100%; height: 100%; }

.menu-step-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.2px;
  margin-bottom: 2px;
}
.menu-step-desc {
  font-size: 13px;
  font-weight: 500;
  opacity: .65;
  line-height: 1.4;
}

.menu-cta {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  opacity: .8;
  padding-top: 16px;
}
.menu-cta a {
  color: var(--accent);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.menu-cta a:hover { color: #22c55e; }

/* ── Left panel trust strip ─────────────────────────────────────────── */
.menu-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 18px 0;
  border-top: 1px solid rgba(255,255,255,.13);
  border-bottom: 1px solid rgba(255,255,255,.13);
  margin-bottom: 18px;
}
.menu-trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(245,243,236,.8);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 20px;
  padding: 4px 10px;
  white-space: nowrap;
}
/* Green dot — factual guarantees */
.menu-trust-badge.menu-trust-yes::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}
/* Cream dot — softer, opinionated promise */
.menu-trust-badge.menu-trust-soft::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(245,243,236,.55);
  flex-shrink: 0;
}

/* ── Right panel: game UI (cream) ───────────────────────────────────── */
.menu-inner {
  background: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  text-align: center;
  overflow-y: auto;
}
/* menu-logo uses .logo styles above; em = accent colour (typeLogo uses em for Mosh) */
.menu-logo { font-size: 56px; font-weight: 900; letter-spacing: -2.5px; }
.menu-logo em { color: var(--accent); font-style: normal; }
.menu-tag { font-size: 15px; font-weight: 700; opacity: .7; margin: 6px 0 30px; }

/* ── Landing leaderboard teaser (desktop right panel) ───────────────── */
.menu-lb-teaser {
  width: 100%;
  margin-top: 24px;
  border-top: 2px solid var(--ink);
  padding-top: 14px;
  text-align: left;
}
.menu-lb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.menu-lb-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.5px;
  opacity: .55;
}
.menu-lb-viewall {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .5px;
  color: var(--accent);
  text-decoration: none;
}
.menu-lb-viewall:hover { text-decoration: underline; }
.menu-lb-list { display: flex; flex-direction: column; gap: 4px; }
.menu-lb-loading {
  font-size: 12px; font-weight: 600; opacity: .5;
}
.menu-lb-row {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(21,40,67,.05);
  border: 1.5px solid rgba(21,40,67,.1);
}
.menu-lb-rank {
  font-size: 11px;
  font-weight: 900;
  opacity: .45;
  text-align: center;
}
.menu-lb-rank.gold   { color: #b8930a; opacity: 1; }
.menu-lb-rank.silver { color: #777;    opacity: 1; }
.menu-lb-rank.bronze { color: #8b5c2a; opacity: 1; }
.menu-lb-name {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-lb-name .lb-star { color: var(--accent); margin-right: 2px; }
.menu-lb-continent {
  font-size: 10px;
  font-weight: 700;
  opacity: .5;
  white-space: nowrap;
}
.menu-lb-score {
  font-size: 12px;
  font-weight: 900;
  color: var(--accent);
  white-space: nowrap;
}

.mode-row { display: flex; gap: 12px; justify-content: center; margin-bottom: 30px; }
.mode-card {
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 12px 26px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  transition: background var(--dur-b) var(--ease-snap), box-shadow var(--dur-b) var(--ease-snap);
}
.mode-card.active { background: var(--ink); color: var(--paper); box-shadow: var(--shadow); }
.mode-card:disabled { opacity: .45; cursor: not-allowed; }
.mode-card small { display: block; font-size: 9px; font-weight: 800; opacity: .7; margin-top: 2px; }

.menu-sub { font-size: 12px; font-weight: 900; letter-spacing: 1.5px; opacity: .6; margin-bottom: 14px; }

#continent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.continent-card {
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  padding: 18px 16px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: var(--shadow);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    transform var(--dur-b) var(--ease-bounce),
    box-shadow var(--dur-b) var(--ease-snap),
    background var(--dur-b) var(--ease-snap);
}
/* Accent underline sweep */
.continent-card::after {
  content: '';
  position: absolute; bottom: 0; left: 0;
  width: 0; height: 3px; background: var(--accent);
  transition: width var(--dur-b) var(--ease-snap);
}
.continent-card:hover::after { width: 100%; }
.continent-card:hover { background: rgba(0,92,43,.04); transform: var(--lift); box-shadow: var(--sh-hov); }
.continent-card:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.cc-name { font-size: 17px; font-weight: 900; letter-spacing: -.3px; }
.cc-count { font-size: 11px; font-weight: 700; opacity: .6; }

.boot-error { font-size: 14px; font-weight: 700; color: var(--accent); padding: 20px; }

/* ── Summary modal ──────────────────────────────────────────────────── */
#summary-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(21,40,67,.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.summary-panel {
  width: min(520px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 26px 26px 20px;
  transform-origin: center top; /* anchor point for stamp entrance */
}
#sum-title { font-size: 26px; font-weight: 900; letter-spacing: -.8px; }
.sum-stats { display: flex; gap: 26px; margin: 14px 0 16px; align-items: baseline; }
/* display:inline-block required for scale animation */
#sum-score { font-size: 38px; font-weight: 900; color: var(--accent); display: inline-block; }
#sum-max { font-size: 14px; font-weight: 800; opacity: .55; }
.sum-stat .k { font-size: 9px; font-weight: 800; letter-spacing: 1px; opacity: .6; display: block; }
#sum-avg { font-size: 22px; font-weight: 900; }

#sum-list {
  flex: 1;
  overflow-y: auto;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  padding: 8px 2px;
  margin-bottom: 16px;
  min-height: 90px;
}
.sum-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 4px;
}
.sum-row.skipped { opacity: .5; }

.sum-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Summary share row ───────────────────────────────────────────────── */
.sum-share-row {
  display: flex;
  margin-bottom: 10px;
}
.sum-share-btn {
  flex: 1;
  text-align: center;
  background: var(--success);
}
.sum-share-btn:hover {
  background: #a8f0bc;
}

/* ── Box 3: leaderboard (Phase 3) ───────────────────────────────────── */
.box-3 { display: flex; flex-direction: column; min-height: 0; }
.lb-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.lb-head .panel-title { margin-bottom: 0; }
#lb-pills { display: flex; gap: 3px; }
.lb-pill {
  font-family: inherit;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .5px;
  padding: 3px 5px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--dur-b) var(--ease-snap);
}
.lb-pill:hover { background: rgba(255,255,255,.55); color: var(--ink); }
.lb-pill.active { background: var(--ink); color: var(--paper); }

.lb-scroll { flex: 1; overflow-y: auto; margin-top: 8px; min-height: 0; }
.lb-scroll::-webkit-scrollbar { width: 6px; }
.lb-scroll::-webkit-scrollbar-thumb { background: rgba(21,40,67,.35); border-radius: 3px; }

.lb-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 2px;
}
.lb-rank { font-size: 10px; font-weight: 900; opacity: .55; min-width: 24px; }
.lb-nick { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { font-weight: 900; }

.lb-me {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1.5px solid rgba(21,40,67,.35);
  font-size: 11px;
  font-weight: 900;
}

@keyframes lbPulse {
  0%, 100% { transform: none; box-shadow: none; }
  25% { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--ink); }
  50% { transform: none; box-shadow: none; }
  75% { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--ink); }
}
.box-3.pulse { animation: lbPulse .9s ease; }

/* ── Summary: server verification + nickname (Phase 3) ──────────────── */
.sum-server {
  font-size: 12px;
  font-weight: 800;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  margin-bottom: 12px;
  background: #fff;
}
.sum-server.submitting { opacity: .65; }
.sum-server.saved { background: var(--success); }
.sum-server.offline { background: #eee; opacity: .8; }
.sum-server:empty { display: none; }

.sum-nick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.sum-nick input {
  flex: 1;
  min-width: 180px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 10px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: #fff;
}
.sum-nick input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.nick-msg { width: 100%; font-size: 11px; font-weight: 700; margin: 0; }
.nick-msg.good { color: #156b2d; }
.nick-msg.bad { color: var(--accent); }

/* ── Multiplayer panel & lobby (Phase 4) ────────────────────────────── */
.mp-card { max-width: 460px; margin: 0 auto; text-align: center; }
.mp-title { font-size: 20px; font-weight: 900; letter-spacing: -.3px; margin-bottom: 4px; }
.mp-note { font-size: 12px; font-weight: 600; opacity: .7; margin-bottom: 16px; }
.mp-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.linklike {
  background: none; border: none; font: inherit; font-size: 12px; font-weight: 800;
  color: var(--accent); cursor: pointer; text-decoration: underline; padding: 0;
}

.mp-continent-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px;
}
.mp-cont {
  font-family: inherit; font-size: 13px; font-weight: 800;
  padding: 12px 8px; background: #fff; border: 2px solid var(--ink);
  border-radius: 5px; cursor: pointer;
  transition: background var(--dur-b) var(--ease-snap);
}
.mp-cont:hover { background: var(--highlight); color: var(--ink); }
.mp-cont.active { background: var(--ink); color: var(--paper); box-shadow: var(--shadow); }

.mp-cpp { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.mp-cpp button {
  font-family: inherit; font-size: 13px; font-weight: 800; min-width: 56px;
  padding: 9px 10px; background: #fff; border: 2px solid var(--ink);
  border-radius: 5px; cursor: pointer;
  transition: background var(--dur-b) var(--ease-snap);
}
.mp-cpp button.active { background: var(--ink); color: var(--paper); }

.code-input {
  font-family: inherit; font-size: 22px; font-weight: 900; letter-spacing: 4px;
  text-align: center; text-transform: uppercase;
  width: 100%; max-width: 280px; padding: 12px; margin: 4px auto 6px;
  display: block; border: 2px solid var(--ink); border-radius: 6px; background: #fff;
}
.mp-card input:focus, .code-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#mp-nick-input {
  font-family: inherit; font-size: 15px; font-weight: 700; text-align: center;
  width: 100%; max-width: 280px; padding: 11px; margin: 0 auto 8px; display: block;
  border: 2px solid var(--ink); border-radius: 6px; background: #fff;
}

/* Lobby overlay */
#lobby-overlay {
  position: fixed; inset: 0; z-index: 2100;
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
}
.lobby-panel {
  width: min(480px, 92vw);
  background: #fff; border: 2px solid var(--ink); border-radius: 10px;
  box-shadow: 6px 6px 0 var(--ink); padding: 26px;
}
.lobby-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.lobby-label { font-size: 10px; font-weight: 900; letter-spacing: 1.5px; opacity: .6; }
.lobby-code {
  font-size: 40px; font-weight: 900; letter-spacing: 6px;
  color: var(--accent); line-height: 1.1;
}
.lobby-meta {
  font-size: 13px; font-weight: 800; padding: 8px 0 16px;
  border-bottom: 2px solid var(--ink); margin-bottom: 14px;
}
.lobby-players { display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.lobby-player {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--paper);
  border: 1.5px solid var(--ink); border-radius: 6px;
  font-size: 14px; font-weight: 800;
}
.lobby-player.offline { opacity: .45; }
.lp-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #1ea83c; border: 1.5px solid var(--ink); flex-shrink: 0;
}
.lobby-player.offline .lp-dot { background: #bbb; }
.lp-name { flex: 1; }
.lp-host {
  font-size: 9px; font-weight: 900; letter-spacing: 1px;
  background: var(--ink); color: var(--paper); padding: 2px 7px; border-radius: 3px;
}
.lobby-status { font-size: 12px; font-weight: 700; opacity: .75; margin: 14px 0; min-height: 16px; text-align: center; }
.lobby-actions { display: flex; gap: 10px; justify-content: space-between; }

/* ── Multiplayer in-game (Phase 4b) ─────────────────────────────────── */
#mp-banner {
  position: absolute; top: 58px; left: 50%; transform: translateX(-50%);
  z-index: 1000;
  background: var(--ink); color: var(--paper);
  font-size: 13px; font-weight: 800; letter-spacing: .3px;
  padding: 8px 16px; border-radius: 6px; box-shadow: var(--shadow);
  white-space: nowrap; max-width: 80%; overflow: hidden; text-overflow: ellipsis;
}
#mp-banner.mine { background: var(--accent); }

#mp-scoreboard { display: flex; flex-direction: column; height: 100%; }
#mp-scores { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; overflow-y: auto; }
.mp-score-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border: 1.5px solid transparent; border-radius: 5px;
  background: rgba(255,255,255,.4); font-size: 12px; font-weight: 800;
}
.mp-score-row.active { border-color: var(--ink); background: #fff; box-shadow: 2px 2px 0 var(--ink); }
.ms-dot { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--ink); flex-shrink: 0; }
.ms-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-prog { font-size: 10px; font-weight: 800; opacity: .6; }
.ms-score { font-weight: 900; min-width: 42px; text-align: right; }

#mp-results {
  position: fixed; inset: 0; z-index: 2100;
  background: rgba(21,40,67,.45);
  display: flex; align-items: center; justify-content: center;
}
#mpr-title { font-size: 26px; font-weight: 900; letter-spacing: -.8px; margin-bottom: 16px; }
.mpr-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.mpr-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border: 2px solid var(--ink); border-radius: 6px;
  background: var(--paper); font-size: 15px; font-weight: 800;
}
.mpr-row.win { background: var(--highlight); box-shadow: 3px 3px 0 var(--ink); }
.mpr-rank { font-size: 16px; font-weight: 900; min-width: 32px; }
.mpr-name { flex: 1; }
.mpr-score { font-weight: 900; }

/* ── Multiplayer resilience UI (Phase 4c) ───────────────────────────── */
.mp-sb-head { display: flex; justify-content: space-between; align-items: center; }
.mp-leave-btn {
  font-family: inherit; font-size: 10px; font-weight: 900; letter-spacing: 1px;
  padding: 4px 10px; background: #fff; color: var(--ink);
  border: 2px solid var(--ink); border-radius: 4px; cursor: pointer;
  transition: background var(--dur-b) var(--ease-snap);
}
.mp-leave-btn:hover { background: var(--accent); color: #fff; }
#mp-banner.paused { background: #555; }

/* ── Solo in-game scoreboard (box-3) ────────────────────────────────── */
#solo-scoreboard { display: flex; flex-direction: column; height: 100%; }
.solo-scores-scroll {
  flex: 1; overflow-y: auto; margin-top: 8px; min-height: 0;
}
.solo-scores-scroll::-webkit-scrollbar { width: 6px; }
.solo-scores-scroll::-webkit-scrollbar-thumb { background: rgba(21,40,67,.35); border-radius: 3px; }

.solo-score-row {
  display: flex; align-items: baseline; gap: 7px;
  font-size: 12px; font-weight: 700; padding: 3px 2px;
  opacity: .45;
}
.solo-score-row.done { opacity: 1; }
.solo-score-row .ms-dot {
  /* re-use .ms-dot but align to baseline row — nudge down slightly */
  position: relative; top: 1px; flex-shrink: 0;
}
.ss-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-pct  { font-size: 10px; font-weight: 900; opacity: .7; min-width: 28px; text-align: right; }
.ss-pts  { font-weight: 900; min-width: 38px; text-align: right; }

.ss-divider {
  margin: 7px 0 4px;
  font-size: 9px; font-weight: 900; letter-spacing: .6px;
  text-transform: uppercase; opacity: .4;
  border-top: 1.5px solid rgba(21,40,67,.2); padding-top: 6px;
}


.lb-star { color: #166534; margin-left: 5px; font-size: 12px; }
.lb-row.supporter .lb-nick { font-weight: 800; }
.lb-supporter {
  display: block; text-align: center; margin-top: 10px; padding: 9px;
  font-size: 12px; font-weight: 800; letter-spacing: .3px;
  color: var(--accent); text-decoration: none;
  border: 2px dashed var(--accent); border-radius: 6px;
  transition: background var(--dur-b) var(--ease-snap), border-style var(--dur-b) var(--ease-snap);
}
.lb-supporter:hover { background: var(--accent); color: #fff; border-style: solid; }

.lb-full-link {
  display: block; text-align: center; margin-top: 8px;
  font-size: 11px; font-weight: 800; letter-spacing: .5px;
  color: var(--ink); text-decoration: none; opacity: .65;
  transition: opacity var(--dur-b) var(--ease-snap);
}
.lb-full-link:hover { opacity: 1; text-decoration: underline; }


/* ════════════════════════════════════════════════════════════════════
   ANIMATION SYSTEM — keyframes + JS-toggled modifier classes
   ════════════════════════════════════════════════════════════════════

   JS usage summary
   ────────────────
   Logo type       → typeLogo(el)  (call on load; re-call to replay)
   Country cascade → add .cascading + animationDelay per row in renderCountryList()
   Toolbar pulse   → .tb-btn.active  (CSS-only, no JS needed)
   Toast           → existing show/hide pattern unchanged — animation auto-plays
   Country tick    → wrap ✓ text in <span class="cr-tick">
   Summary stamp   → .summary-panel.classList.add('stamping')  (remove on animationend)
   Score pop       → #sum-score.classList.add('popping')       (remove on animationend)
   LB shimmer      → add .flashing per .lb-row with 65 ms stagger, remove on animationend
   Score roller    → see ui.js — buildScoreRoller() + rollScoreTo()
   ════════════════════════════════════════════════════════════════════ */

/* ── Logo typing cursor ─────────────────────────────────────────────── */
/* typeLogo() in ui.js builds innerHTML; only cursor CSS lives here       */
.logo-cursor {
  display: inline-block;
  width: 3px; height: .82em;
  background: var(--ink);
  margin-left: 2px;
  vertical-align: text-top;
  border-radius: 1px;
  animation: cursor-blink 0.55s ease infinite;
}
@keyframes cursor-blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}
@keyframes cursor-fade {
  from { opacity: 1; }
  to   { opacity: 0; width: 0; margin: 0; }
}

/* ── Country list cascade ────────────────────────────────────────────── */
@keyframes cascade-in {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
/* JS sets animation-delay inline (i * 35ms) before adding this class */
.country-row.cascading {
  animation: cascade-in var(--dur-enter) var(--ease-bounce) both;
}

/* ── Toolbar active-tool pulse ───────────────────────────────────────── */
@keyframes tb-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(21,40,67,0); }
  50%       { box-shadow: 0 0 0 3px rgba(21,40,67,.18); }
}
/* .tb-btn.active rule above references this keyframe */

/* ── Toast bounce entrance ───────────────────────────────────────────── */
@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-18px); }
  55%  { transform: translateX(-50%) translateY(5px); opacity: 1; }
  78%  { transform: translateX(-50%) translateY(-2px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}
/* #toast.show rule above references this keyframe */

/* ── Country completion tick ─────────────────────────────────────────── */
@keyframes tick-pop {
  from { transform: scale(0) rotate(-50deg); opacity: 0; }
  62%  { transform: scale(1.4) rotate(8deg); opacity: 1; }
  82%  { transform: scale(.92) rotate(-2deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
/* Wrap the ✓ character in <span class="cr-tick"> in renderCountryList */
.cr-tick {
  display: inline-block;
  animation: tick-pop var(--dur-big) var(--ease-spring) both;
}

/* ── Summary modal stamp entrance ───────────────────────────────────── */
@keyframes summary-stamp {
  0%   { opacity: 0; transform: scale(1.07) translateY(-18px); box-shadow: 0 0 0 var(--ink); }
  62%  { opacity: 1; transform: scale(.98) translateY(4px); box-shadow: var(--sh-big); }
  82%  { transform: scale(1.01) translateY(-1px); }
  100% { transform: scale(1) translateY(0); box-shadow: 6px 6px 0 var(--ink); }
}
.summary-panel.stamping {
  animation: summary-stamp var(--dur-big) var(--ease-spring) forwards;
}

/* ── Score number pop ────────────────────────────────────────────────── */
@keyframes score-pop {
  0%   { transform: scale(1); }
  36%  { transform: scale(1.22); filter: brightness(1.08); }
  66%  { transform: scale(.95); }
  100% { transform: scale(1); }
}
#sum-score.popping { animation: score-pop var(--dur-big) var(--ease-spring); }

/* ── Leaderboard row shimmer ─────────────────────────────────────────── */
@keyframes lb-row-flash {
  0%   { background: transparent; }
  20%  { background: var(--highlight); transform: translateX(-3px); }
  80%  { background: var(--highlight); transform: translateX(0); }
  100% { background: transparent; }
}
.lb-row.flashing { animation: lb-row-flash var(--dur-big) var(--ease-snap); }

/* ── Score digit roller ──────────────────────────────────────────────── */
/* Column container — overflow:hidden masks digits above/below current */
.score-digit-col {
  position: relative;
  overflow: hidden;
  height: 1em;
  width: .62em;
  display: inline-block;
}
/* Stack of 10 digit spans; JS translates Y to reveal target digit */
.score-digit-trk {
  position: absolute;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}
.score-digit-trk span { height: 1em; line-height: 1; display: block; text-align: center; }

/* ════════════════════════════════════════════════════════════════════════
   MOBILE / TOUCH LAYOUT
   Activated by a coarse pointer on a small viewport (matches the JS capability
   check in main.js, which adds .is-mobile to <html>). Desktop and large tablets
   keep the original grid. The drawing input — one finger draws, two fingers
   pan/zoom — works on ANY touch device regardless of this layout.
   ════════════════════════════════════════════════════════════════════════ */
@media (pointer: coarse) and (max-width: 820px) {

  :root {
    --tb-h: 56px;   /* bottom sheet peek height — thumb toolbar is gone */
    --peek: 48px;
    --ab-h: 46px;   /* action bar height */
    --sab: env(safe-area-inset-bottom, 0px);  /* Android gesture bar / iOS home indicator */
  }

  body {
    height: 100dvh;
    overscroll-behavior: none;
  }

  /* Frame → header + action bar on top, map fills the rest, footer hidden */
  #desktop-layout {
    height: 100dvh;
    padding: 0;
    gap: 0;
    /* Row 2 is `auto` (not a fixed --ab-h) so it collapses to 0 when the action
       bar is display:none. Children are pinned to explicit rows below — without
       that, a hidden action bar lets grid auto-placement pull .main-content up
       into row 2 (~46px) and push the hidden footer into the 1fr row, which
       collapsed the map to a thin strip with empty space beneath it. */
    grid-template-rows: 48px auto 1fr;
  }
  #desktop-layout > .header       { grid-row: 1; }
  #desktop-layout > #action-bar   { grid-row: 2; }
  #desktop-layout > .main-content { grid-row: 3; }
  #desktop-layout > .footer       { grid-row: 4; }
  .footer { display: none; }

  /* Slim header — logo + mobile nav only */
  .header {
    height: 48px;
    padding: 0 12px;
    border-radius: 0;
    border-left: none; border-right: none; border-top: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .logo { font-size: 20px; }
  .header .nav-right { display: none; }

  /* Mobile nav: MP + supporter star */
  .nav-mobile {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .btn-multiplayer-mobile {
    font-size: 11px;
    font-weight: 900;
    padding: 6px 10px;
    letter-spacing: .5px;
  }
  .btn-nav-supporter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 900;
    color: var(--accent);
    text-decoration: none;
    width: 32px;
    height: 32px;
    border: 2px solid var(--accent);
    border-radius: 4px;
    line-height: 1;
  }
  .btn-nav-supporter:hover { background: var(--accent); color: #fff; }
  .btn-nav-lb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    text-decoration: none;
    width: 32px;
    height: 32px;
    border: 2px solid var(--ink);
    border-radius: 4px;
    line-height: 1;
  }
  .btn-nav-lb:hover { background: var(--ink); }

  /* ── Multiplayer is desktop-only ──────────────────────────────────────
     MP controls (Submit / Clear) live in #toolbar, which is hidden on the
     mobile layout, and the MP scoreboard has no room in the sheet. Rather
     than ship a dead-end, hide the MP entry points on phones. Touch tablets
     and laptops stay on the desktop grid (>820px) and keep multiplayer. */
  .btn-multiplayer-mobile { display: none; }
  #mode-mp { display: none; }
  .mode-row { justify-content: center; }

  /* ── Action bar: CLEAR / SKIP / SUBMIT just below the header ── */
  #action-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: var(--paper);
    border-bottom: 2px solid var(--ink);
    z-index: 1600;
    position: relative;
  }
  /* Hidden until a game starts — same JS call as #toolbar */
  #action-bar.hidden { display: none !important; }

  .ab-btn {
    flex: 1;
    font-family: inherit;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .5px;
    height: 34px;
    border: 2px solid var(--ink);
    border-radius: 4px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    transition: background var(--dur-b) var(--ease-snap);
  }
  .ab-btn:disabled { opacity: .38; }
  .ab-btn:active:not(:disabled) { transform: translate(1px, 1px); }
  .ab-btn.ab-submit {
    flex: 1.8;
    background: var(--accent);
    color: #fff;
    border-color: var(--ink);
  }
  .ab-btn.ab-submit:active:not(:disabled) { background: #0b3a1e; }

  /* Hide the floating map toolbar entirely on mobile — action bar replaces it */
  #toolbar { display: none !important; }

  /* Map fills the whole content row.
     height: 100% is critical — without it the map's inset:0 anchors to a
     zero-height box, Leaflet's pixel maths are wrong, and touches below the
     fold are intercepted by the action-bar's rendered area above. */
  .main-content {
    display: block;
    position: relative;
    height: 100%;
    min-height: 0;
  }
  .content-area, #map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  /* Pinch handles zoom; hide Leaflet's +/- so they don't sit under the header */
  .leaflet-control-zoom { display: none !important; }

  /* Stop the browser panning/zooming the page while a finger is drawing */
  #map.brush-on { touch-action: none; }

  /* ── Bottom sheet (the former sidebar) ────────────────────────────────
     Collapsed: only the grab handle + compact HUD peek above the bottom.
     Open (.sheet-open on <html>): slides up to reveal the boxes.
     --tb-h is now the peek height since there's no thumb toolbar. */
  .sidebar {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    height: 72dvh;
    gap: 0;
    padding: 0;
    /* Reserve the device's bottom inset so the open sheet's last row (the
       Supporter button) sits above the Android gesture bar / iOS home bar. */
    padding-bottom: var(--sab);
    background: var(--paper);
    border: none;
    border-top: 2px solid var(--ink);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -6px 18px rgba(21,40,67,.18);
    /* Collapsed: leave the peek PLUS the bottom inset visible, so the grip and
       its label clear the gesture bar instead of merging with it. */
    transform: translateY(calc(100% - var(--peek) - var(--sab)));
    transition: transform var(--dur-enter) var(--ease-snap);
    z-index: 1500;
  }
  .is-mobile.sheet-open .sidebar { transform: translateY(0); }
  /* The handle's safe-area padding is only needed for the collapsed peek; in the
     open sheet the sidebar's own padding-bottom handles the inset, so reset it
     to avoid a gap between the grip and the HUD. */
  .is-mobile.sheet-open .sheet-handle { height: var(--peek); padding-bottom: 0; }

  /* Grab handle + one-line HUD — the only part visible when collapsed */
  .sheet-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    /* Grow by the bottom inset and pad it out, so the grip + label live in the
       top `--peek` region and the inset becomes empty space over the gesture bar. */
    height: calc(var(--peek) + var(--sab));
    padding-bottom: var(--sab);
    flex-shrink: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
  }
  .sheet-grip {
    width: 38px; height: 4px; border-radius: 3px;
    background: rgba(21,40,67,.3);
    transition: background var(--dur-b) var(--ease-snap);
  }
  .sheet-hud {
    font-size: 12px; font-weight: 800; letter-spacing: .2px;
    color: var(--ink); opacity: .85;
    max-width: 88vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sheet-handle.nudge .sheet-grip { animation: sheet-nudge .9s var(--ease-bounce) 2; }
  @keyframes sheet-nudge {
    0%, 100% { transform: translateY(0);   background: rgba(21,40,67,.3); }
    50%      { transform: translateY(-4px); background: var(--accent); }
  }

  /* Boxes stack & scroll below the handle once the sheet is open */
  .sidebar .box-1,
  .sidebar .box-2,
  .sidebar .box-3 {
    flex: none;
    border: none;
    border-top: 1px solid rgba(21,40,67,.12);
    border-radius: 0;
  }
  .sidebar .box-2 { flex: 1 1 auto; min-height: 0; }
  .sidebar .box-1 { padding: 8px 12px; }

  /* The global leaderboard and MP scoreboard don't fit the collapsed sheet,
     but the in-game solo scoreboard does — it's the live feedback that makes
     the game readable on a phone. Show it, with its list capped so the
     country picker keeps room. (MP is gated on mobile, so #mp-scoreboard
     never appears here anyway — hidden for safety.) */
  .sidebar #lb-wrap,
  .sidebar #mp-scoreboard { display: none; }
  .sidebar .box-3 { flex: none; max-height: 36vh; }
  .sidebar #solo-scoreboard { height: auto; }
  .sidebar .solo-scores-scroll { max-height: 26vh; }

  /* Bigger tap targets in the country list */
  #country-list { columns: 2; }
  .country-row { padding: 8px 8px; font-size: 13px; margin-bottom: 3px; }
  .country-row .dot { width: 11px; height: 11px; }

  /* Floating overlays clear the slim header + action bar */
  #toast { top: calc(48px + var(--ab-h) + 8px); max-width: 86%; }
  #mp-banner { top: calc(48px + var(--ab-h) + 6px); }
  /* Sheet peek now includes --sab (safe-area inset), so the button must too,
     otherwise it sits behind the grab handle on gesture-nav devices. */
  #back-to-results { bottom: calc(var(--peek) + var(--sab) + 14px); }

  /* ── Start menu: single-column on mobile (left panel hidden) ──────── */
  #menu-overlay {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .menu-left { display: none; }
  .menu-inner {
    padding: 32px 20px 48px;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    justify-content: flex-start;
    align-items: center;
    min-height: 100dvh;
  }
  .menu-logo { font-size: 38px; letter-spacing: -1.5px; }
  .menu-tag { font-size: 13px; margin: 4px 0 20px; }
  .mode-row { flex-wrap: nowrap; justify-content: center; }
  #continent-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .continent-card { padding: 12px 10px; }
  .cc-name { font-size: 14px; }
  .mp-continent-grid { grid-template-columns: repeat(2, 1fr) !important; }
  /* Leaderboard teaser is desktop-only — on mobile the header 🏆 link covers this */
  .menu-lb-teaser { display: none; }

  /* ── Summary modal ───────────────────────────────────────────────────── */
  .summary-panel { width: 92vw; max-height: 88dvh; padding: 18px 16px 14px; }
  #sum-title { font-size: 20px; }
  #sum-score { font-size: 30px; }
  .sum-actions { flex-wrap: wrap; }
  .sum-actions .btn-hard { flex: 1 1 44%; }
  .sum-share-btn { font-size: 14px; padding: 12px 18px; }
}

/* Coarse-pointer devices that AREN'T phone-sized (tablets, touch laptops) keep
   the desktop grid, but still shouldn't fight the browser while drawing. */
@media (pointer: coarse) and (min-width: 821px) {
  #map.brush-on { touch-action: none; }
}

/* ── Back-navigation confirm dialog ─────────────────────────────────────
   Shown by ui.showConfirmDialog() when the player taps Back mid-game.
   z-index 3000 sits above the summary modal (2000) and lobby (2100).   */
#confirm-dialog {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(21, 40, 67, 0.55);
  display: flex; align-items: center; justify-content: center;
  animation: confirm-fade-in var(--dur-b) var(--ease-snap);
}
#confirm-dialog.hidden { display: none !important; }

@keyframes confirm-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes confirm-stamp {
  from { transform: scale(0.88) translateY(8px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);   opacity: 1; }
}

.confirm-panel {
  width: min(360px, 90vw);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--sh-big);
  padding: 28px 24px 22px;
  animation: confirm-stamp var(--dur-enter) var(--ease-bounce);
}
.confirm-title {
  font-size: 18px; font-weight: 900; letter-spacing: -.3px;
  margin-bottom: 10px; color: var(--ink);
}
.confirm-msg {
  font-size: 14px; font-weight: 600; line-height: 1.5;
  opacity: .8; margin-bottom: 22px;
}
.confirm-actions {
  display: flex; gap: 10px; justify-content: flex-end;
}
.confirm-leave {
  background: var(--ink); color: var(--paper);
}
.confirm-leave:hover { background: #2a4a72; transform: var(--lift); }
