:root {
  --bg: #2b2c36;
  --panel: #353643;
  --ink: #e8e9ec;
  --muted: #9a9ba6;
  --line: #4a4b58;
  --land: #555665;
  --land-outline: #2b2c36;
  --visited: #84ade9;
  --visited-outline: #2b2c36;
  --accent: #84ade9;
  --ocean: #1f2028;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-weight: 500;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  letter-spacing: -0.01em;
}

.counter {
  margin: 0;
  font-size: 1rem;
  color: var(--muted);
}
.counter #count {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.5rem;
}

#map-container {
  position: relative;
  background: var(--panel);
  border-radius: 8px;
  padding: 0.5rem;
}

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

.zoom-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 5;
}
.zoom-controls button {
  background: rgba(43, 44, 54, 0.85);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms;
}
.zoom-controls button:hover { background: var(--line); }
.zoom-controls button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sphere {
  fill: var(--ocean);
  stroke: none;
}

.country {
  fill: var(--land);
  stroke: var(--land-outline);
  stroke-width: 0.5px;
  transition: fill 350ms cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
}
.country.visited {
  fill: var(--visited);
}
.country:hover {
  stroke: var(--ink);
  stroke-width: 1px;
}

.admin1 {
  fill: var(--land);
  stroke: var(--land-outline);
  stroke-width: 0.3px;
  transition: fill 350ms cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
}
.admin1.visited {
  fill: var(--visited);
}
.admin1:hover {
  stroke: var(--ink);
  stroke-width: 1px;
}

#tooltip .muted { color: var(--muted); font-size: 0.8em; }

#tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(20, 20, 26, 0.95);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--ink);
  white-space: nowrap;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.timeline {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  margin: 1.5rem 0 2rem;
  padding: 1rem 1.25rem;
  background: var(--panel);
  border-radius: 8px;
}

#play {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms;
}
#play:hover { background: #a4c4f3; }
#play:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.year-label {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

#year-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
}
#year-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  transition: transform 100ms;
}
#year-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
#year-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

#year-current {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--accent);
  min-width: 3.5rem;
  text-align: right;
}

@media (max-width: 720px) {
  main { padding: 1.25rem 1rem 2rem; }
  .timeline {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "play slider year"
      "min  .      max";
    gap: 0.5rem 0.75rem;
  }
  #play {
    grid-area: play;
    width: 2.75rem;
    height: 2.75rem;
  }
  #year-slider { grid-area: slider; }
  #year-current { grid-area: year; }
  #year-min { grid-area: min; }
  #year-max { grid-area: max; text-align: right; }
  .zoom-controls button {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.1rem;
  }
}

@media (pointer: coarse) {
  #year-slider { height: 6px; }
  #year-slider::-webkit-slider-thumb { width: 24px; height: 24px; }
  #year-slider::-moz-range-thumb { width: 24px; height: 24px; }
}
