/* ════════════════════════════════════════════════════════════════════
   MapMosh — styles. Design language: cream paper (#f5f3ec), ink black
   (#0b0b0b), signal orange (#d85023), pastel panels, hard offset
   shadows, heavy condensed labels. Desktop only.
   ════════════════════════════════════════════════════════════════════ */

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

:root {
  --paper: #f5f3ec;
  --ink: #0b0b0b;
  --accent: #d85023;
  --peach: #ffd6a5;
  --mint: #caffbf;
  --lemon: #fdffb6;
  --lilac: #bdb2ff;
  --shadow: 3px 3px 0 var(--ink);
}

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

.hidden { display: none !important; }

/* ── Mobile blocker ─────────────────────────────────────────────────── */
#mobile-message {
  display: none;
  text-align: center;
  background: #fff;
  padding: 40px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  max-width: 400px;
  margin: 40px auto;
}
#mobile-message h2 { color: #333; margin-bottom: 10px; }
#mobile-message p { color: #666; line-height: 1.5; }

/* ── 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;
}
.logo { font-size: 26px; font-weight: 900; letter-spacing: -1px; }
.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; }
.btn-signin {
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  transition: all .1s ease;
}
.btn-signin:active { box-shadow: 0 0 0 var(--ink); transform: translate(3px, 3px); }

/* ── 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: var(--peach); }
.sidebar .box-2 { flex: 6; background: var(--mint); min-height: 0; }
.sidebar .box-3 { flex: 2; background: var(--lemon); }

.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;
}
.country-row:hover:not(.done) { border-color: var(--ink); background: rgba(255,255,255,.45); }
.country-row.selected {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.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;
}
.country-row .dot.empty { background: transparent; border-color: rgba(11,11,11,.45); }
.country-row.selected .dot.empty { border-color: var(--paper); }

.list-scroll::-webkit-scrollbar { width: 8px; }
.list-scroll::-webkit-scrollbar-thumb { background: rgba(11,11,11,.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 floating over the map */
#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;
}
.tb-btn:hover:not(:disabled) { background: var(--lemon); }
.tb-btn.active { background: var(--ink); color: var(--paper); }
.tb-btn:disabled { opacity: .4; cursor: not-allowed; }
#tb-submit { background: var(--accent); color: #fff; border-color: var(--ink); }
#tb-submit:hover:not(:disabled) { background: #b8431d; }
.tb-sep { width: 2px; background: rgba(11,11,11,.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;
  transition: opacity .18s ease, transform .18s ease;
  max-width: 70%;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.good { background: #156b2d; }
#toast.warn { background: var(--accent); }

/* Country completion labels on the map */
.paint-label {
  background: rgba(11,11,11,.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 while exploring the reveal */
#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;
  transition: all .1s ease;
}
.btn-hard:hover { background: var(--lemon); }
.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:hover { background: #222; }

/* ── Footer ─────────────────────────────────────────────────────────── */
.footer {
  background: var(--lilac);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
}
.footer a { color: var(--ink); }

/* ── Start menu overlay ─────────────────────────────────────────────── */
#menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}
.menu-inner { max-width: 760px; padding: 40px 24px; text-align: center; }
.menu-logo { font-size: 56px; font-weight: 900; letter-spacing: -2.5px; }
.menu-logo span { color: var(--accent); }
.menu-tag { font-size: 15px; font-weight: 700; opacity: .7; margin: 6px 0 30px; }

.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;
}
.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;
  transition: all .1s ease;
}
.continent-card:hover { background: var(--lemon); transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.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(11,11,11,.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;
}
#sum-title { font-size: 26px; font-weight: 900; letter-spacing: -.8px; }
.sum-stats { display: flex; gap: 26px; margin: 14px 0 16px; align-items: baseline; }
#sum-score { font-size: 38px; font-weight: 900; color: var(--accent); }
#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; }

/* ── 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;
}
.lb-pill:hover { background: rgba(255,255,255,.55); }
.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(11,11,11,.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(11,11,11,.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(--mint); }
.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;
}
.mp-cont:hover { background: var(--lemon); }
.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;
}
.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(11,11,11,.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(--lemon); 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;
}
.mp-leave-btn:hover { background: var(--accent); color: #fff; }
#mp-banner.paused { background: #555; }
