/* ============================================================
   GeoQuick — atlas / instrument-panel theme
   ============================================================ */

:root {
  --ink: #1b2838;          /* chart navy — primary text */
  --ink-soft: #55677c;     /* secondary text */
  --ink-faint: #8fa0b0;    /* labels, captions */
  --paper: #f1f4ee;        /* chart-paper background */
  --card: #ffffff;
  --sea: #d9e6e4;          /* map water */
  --line: #dbe3da;         /* hairlines */
  --accent: #0f7a63;       /* atlas teal — primary actions */
  --accent-deep: #0a5c4b;
  --accent-soft: #e2efe9;
  --amber: #d9930d;        /* compass amber — streaks, records */
  --amber-soft: #fbf1da;
  --correct: #1f9d5c;
  --correct-soft: #e0f3e8;
  --wrong: #d64550;
  --wrong-soft: #fbe5e7;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(27, 40, 56, 0.06), 0 3px 10px rgba(27, 40, 56, 0.05);
  --shadow-md: 0 4px 8px rgba(27, 40, 56, 0.06), 0 14px 28px rgba(27, 40, 56, 0.10);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: "Archivo", -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(1100px 500px at 80% -10%, #e6ede4 0%, transparent 60%),
    var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

#root { min-height: 100vh; }

.mono {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------- shared shell ---------- */

.shell {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px calc(40px + env(safe-area-inset-bottom));
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.eyebrow {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- header ---------- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-name {
  font-weight: 800;
  font-stretch: 115%;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  margin: 0;
}

.logo-name em {
  font-style: normal;
  color: var(--accent);
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ink);
}

.stat-pill svg { color: var(--ink-faint); }

.stat-pill.streak-hot {
  border-color: var(--amber);
  background: var(--amber-soft);
}
.stat-pill.streak-hot svg { color: var(--amber); }

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-deep); }

/* ---------- expedition route (signature progress) ---------- */

.route {
  position: relative;
  height: 26px;
  margin: 2px 4px 16px;
}

.route-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 2px dashed #c2cec2;
  transform: translateY(-50%);
}

.route-done {
  position: absolute;
  top: 50%;
  left: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  transform: translateY(-50%);
  transition: width 0.5s ease;
}

.route-pin {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: left 0.5s ease;
  color: var(--accent-deep);
  filter: drop-shadow(0 2px 2px rgba(27, 40, 56, 0.25));
}

.route-flag {
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
}

.route-count {
  position: absolute;
  right: 0;
  top: -14px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--ink-faint);
}

/* ---------- map card ---------- */

.map-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow-md);
}

.map-frame { width: 100%; aspect-ratio: 1 / 0.92; }

.leaflet-container { background: var(--sea); font: inherit; }
.leaflet-control-zoom { display: none !important; }

.map-question {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 9px 16px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.875rem;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.zoom-controls {
  position: absolute;
  bottom: 14px;
  right: 14px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.zoom-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.12s ease;
}
.zoom-btn:hover { background: var(--accent-soft); transform: scale(1.05); }
.zoom-btn:active { transform: scale(0.94); }

.country-label {
  background: rgba(255, 255, 255, 0.92);
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-family: "Archivo", sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

/* pause veil over the map */
.pause-veil {
  position: absolute;
  inset: 0;
  z-index: 1100;
  background: rgba(241, 244, 238, 0.82);
  backdrop-filter: blur(7px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 700;
}

/* ---------- clue chips ---------- */

.clues {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.clue {
  position: relative;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 10px 8px 9px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.clue-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.clue-value {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}

.flag-img {
  width: 54px;
  height: 38px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.flag-fallback {
  width: 54px;
  height: 38px;
  background: var(--line);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
}

/* ---------- answers ---------- */

.answers { display: flex; flex-direction: column; gap: 9px; }

.answer {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  text-align: left;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.2s ease, transform 0.1s ease;
}

.answer:not(:disabled):hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.answer:not(:disabled):active { transform: scale(0.99); }
.answer:disabled { cursor: default; }

.answer-key {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.answer.is-correct {
  border-color: var(--correct);
  background: var(--correct-soft);
}
.answer.is-correct .answer-key { background: var(--correct); border-color: var(--correct); color: #fff; }

.answer.is-wrong {
  border-color: var(--wrong);
  background: var(--wrong-soft);
  animation: shake 0.3s ease;
}
.answer.is-wrong .answer-key { background: var(--wrong); border-color: var(--wrong); color: #fff; }

.answer.is-dimmed { opacity: 0.45; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.kbd-hint {
  margin-top: 12px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-faint);
}
.kbd-hint kbd {
  font-family: "JetBrains Mono", monospace;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.6875rem;
}

/* ---------- primary buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 15px 26px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover {
  background: var(--accent-deep);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 122, 99, 0.3);
}

.btn-ghost {
  background: transparent;
  border: 2px solid var(--line);
  color: var(--ink-soft);
}
.btn-ghost:hover { border-color: var(--ink-soft); color: var(--ink); }

.btn-block { width: 100%; }

/* ---------- setup screen ---------- */

.setup-hero { text-align: center; margin: 26px 0 24px; }

.setup-title {
  font-size: 2.1rem;
  font-weight: 900;
  font-stretch: 118%;
  letter-spacing: -0.02em;
  margin: 10px 0 6px;
}
.setup-title em { font-style: normal; color: var(--accent); }

.setup-sub { color: var(--ink-soft); font-size: 0.9375rem; margin: 0; }

.region-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.region-card {
  position: relative;
  padding: 14px 14px 12px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.region-card:hover { border-color: var(--accent); }
.region-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.region-card.selected::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.region-card.span-2 { grid-column: span 2; }

.region-name { font-weight: 800; font-size: 1rem; display: block; }
.region-count { font-size: 0.75rem; color: var(--ink-soft); }
.region-best {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--amber);
}

.choice-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.choice-btn {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.choice-btn small { display: block; font-weight: 600; font-size: 0.6875rem; color: var(--ink-soft); }
.choice-btn:hover { border-color: var(--accent); }
.choice-btn.selected { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- completion ---------- */

.finish-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.finish-card {
  width: 100%;
  max-width: 460px;
  padding: 38px 30px 30px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.finish-medal { color: var(--amber); margin-bottom: 10px; }

.finish-title {
  font-size: 1.9rem;
  font-weight: 900;
  font-stretch: 115%;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.record-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 4px;
  padding: 6px 14px;
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  border-radius: 999px;
  color: var(--amber);
  font-weight: 800;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
}

.finish-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 22px 0;
}

.finish-stat {
  padding: 16px 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.finish-stat .value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
}
.finish-stat .label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.review-box {
  text-align: left;
  margin: 0 0 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  padding: 14px 14px 8px;
  max-height: 220px;
  overflow-y: auto;
}

.review-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.review-item:last-child { border-bottom: none; }
.review-item img { width: 34px; height: 24px; object-fit: cover; border-radius: 3px; box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.review-item .name { font-weight: 700; font-size: 0.875rem; }
.review-item .cap { font-size: 0.75rem; color: var(--ink-soft); }
.review-item .misses {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--wrong);
  background: var(--wrong-soft);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.finish-actions { display: flex; gap: 10px; }
.finish-actions .btn { flex: 1; }

/* ---------- scrollbar ---------- */

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: #c3cfc4; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8b8ab; }

/* ---------- motion & small screens ---------- */

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

@media (max-width: 380px) {
  .clues { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .clue { min-height: 78px; }
  .header-stats { gap: 6px; }
  .stat-pill { padding: 6px 9px; font-size: 0.875rem; }
}

/* touch devices: keyboard hints are noise */
@media (hover: none) and (pointer: coarse) {
  .kbd-hint { display: none; }
}

/* ---------- correct / wrong feedback ---------- */

.map-card { transition: box-shadow 0.2s ease; }

.map-card.map-correct {
  animation: mapGlow 0.9s ease;
}
@keyframes mapGlow {
  0% { box-shadow: var(--shadow-md); }
  25% { box-shadow: 0 0 0 4px rgba(31, 157, 92, 0.45), 0 10px 30px rgba(31, 157, 92, 0.3); }
  100% { box-shadow: var(--shadow-md); }
}

.map-question { transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease; }

.map-question.good {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
  animation: pillPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.map-question.bad {
  background: var(--wrong);
  border-color: var(--wrong);
  color: #fff;
}
@keyframes pillPop {
  0% { transform: translateX(-50%) scale(0.7); }
  55% { transform: translateX(-50%) scale(1.14); }
  100% { transform: translateX(-50%) scale(1); }
}

.answer.is-correct { animation: answerPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes answerPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

.bump { display: inline-block; animation: bump 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes bump {
  0% { transform: scale(1); }
  50% { transform: scale(1.45); }
  100% { transform: scale(1); }
}

/* confetti burst, anchored to the map card */
.confetti {
  position: absolute;
  left: 50%;
  bottom: 22%;
  z-index: 1200;
  pointer-events: none;
}
.confetti-piece {
  position: absolute;
  width: 9px;
  height: 9px;
  opacity: 0;
  animation-name: confettiFly;
  animation-timing-function: cubic-bezier(0.2, 0.7, 0.4, 1);
  animation-fill-mode: forwards;
}
.confetti-piece.shape-1 { border-radius: 50%; }
.confetti-piece.shape-2 { width: 4px; height: 13px; border-radius: 2px; }
@keyframes confettiFly {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) rotate(var(--rot)) scale(0.65); }
}

/* ---------- mobile fit: shorter map on short screens ---------- */

@media (max-height: 780px) {
  .map-frame { aspect-ratio: 1 / 0.74; }
  .shell { padding-top: 12px; }
  .route { margin-bottom: 12px; }
}

@media (max-height: 680px) {
  .map-frame { aspect-ratio: 1 / 0.6; }
  .clue { min-height: 72px; }
  .answer { padding: 12px 14px; }
  .header { margin-bottom: 10px; }
}

@media (max-height: 600px) {
  .map-frame { aspect-ratio: 1 / 0.5; }
}
