:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --ocean: #0a1c29;
  --ocean-glow: #1c3f57;
  --land: #8a9678;
  --land-stroke: #4c5640;
  --graticule: rgba(255, 255, 255, 0.07);
  --highlight: #f5a623;
  --correct: #22c55e;
  --incorrect: #ef4444;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --accent: #38bdf8;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  justify-content: center;
  padding: 16px;
}

#app {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

header {
  text-align: center;
}

header h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
}

#date-display {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

#stats-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 600;
}

#game-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#map-wrap {
  position: relative;
  background: var(--ocean);
  border-radius: var(--radius);
  padding: 8px;
  border: 1px solid #22334a;
  overflow: hidden;
}

#map {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
  cursor: grab;
}

#map:active {
  cursor: grabbing;
}

#zoom-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
}

#zoom-controls button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#zoom-controls button:hover {
  border-color: var(--accent);
}

#map-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(15, 23, 42, 0.6);
  padding: 3px 10px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 2;
}

.map-inner.smooth-zoom {
  transition: transform 0.3s ease-out;
}

.sphere-bg {
  pointer-events: none;
}

.graticule {
  stroke: var(--graticule);
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.sphere-outline {
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.country {
  fill: var(--land);
  stroke: var(--land-stroke);
  stroke-width: 0.5;
  vector-effect: non-scaling-stroke;
}

.country.target {
  fill: var(--highlight);
  stroke: #fff;
  stroke-width: 1;
  filter: url(#target-glow);
}

.country.target.reveal-correct {
  fill: var(--correct);
}

#feedback {
  min-height: 1.4em;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
}

#feedback.correct { color: var(--correct); }
#feedback.incorrect { color: var(--incorrect); }

#options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.option-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #334155;
  border-radius: var(--radius);
  padding: 14px 10px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.option-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.option-btn:disabled {
  cursor: default;
}

.option-btn.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #06240f;
}

.option-btn.incorrect {
  background: var(--incorrect);
  border-color: var(--incorrect);
  color: #2a0808;
}

#next-btn {
  align-self: center;
  background: var(--accent);
  color: #052330;
  border: none;
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

#next-btn:hover { filter: brightness(1.08); }

.hidden { display: none !important; }

#results {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  text-align: center;
}

#results h2 {
  margin: 0;
}

#results .score-big {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--highlight);
  font-variant-numeric: tabular-nums;
}

#results .score-big .score-max {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-dim);
}

#results .score-sub {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: -8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 24px;
  width: 100%;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat strong {
  color: var(--text);
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.stat span {
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.stat-wide {
  grid-column: 1 / -1;
}

.share-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.share-btn:hover {
  background: #24344a;
}

.round-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.round-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.9rem;
}

.round-list li.correct { border-left: 3px solid var(--correct); }
.round-list li.incorrect { border-left: 3px solid var(--incorrect); }

.come-back {
  color: var(--text-dim);
  font-size: 0.9rem;
}

footer {
  text-align: center;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
}

@media (min-width: 480px) {
  #options {
    grid-template-columns: 1fr 1fr;
  }
}
