:root {
  --bg: #050814;
  --gold: #f0c14b;
  --gold-dim: #c9a227;
  --dusk: #8aa0ff;
  --card: rgba(8, 12, 28, 0.88);
  --text: #f5f7fb;
  --muted: #9aa6c2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 800px at 70% 0%, #12204a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  padding: 24px 16px 40px;
}

.shell {
  width: min(1480px, 100%);
  display: grid;
  grid-template-columns: minmax(360px, 640px) minmax(280px, 1fr);
  gap: 36px;
  align-items: start;
}

.stage-wrap {
  width: 100%;
  max-width: min(640px, calc((100vh - 56px) * 9 / 16));
  margin: 0 auto;
}

.stage {
  position: relative;
  aspect-ratio: 9 / 16;
  width: 100%;
  border-radius: 28px;
  overflow: hidden;
  background: #040714;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  container-type: inline-size;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#map {
  pointer-events: none;
}

#pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: 22px 22px 0;
  text-align: center;
  z-index: 3;
  pointer-events: none;
}

.date-line {
  font-size: clamp(13px, 3.4cqi, 16px);
  letter-spacing: 0.08em;
  color: #d5dbea;
}

.clock-label {
  margin-top: 14px;
  font-size: clamp(13px, 3.4cqi, 16px);
  color: #c5cde0;
}

.clock {
  margin-top: 2px;
  font-size: clamp(48px, 16cqi, 76px);
  line-height: 1;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.timeline {
  margin: 10px auto 0;
  width: min(82%, 340px);
  pointer-events: auto;
}

.timeline input {
  width: 100%;
  appearance: none;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold) var(--fill, 0%), #3a4258 var(--fill, 0%));
  outline: none;
}

.timeline input::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #fff6d6;
}

.ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #8b93a7;
  margin-top: 4px;
}

.hud .speed-row {
  margin-top: 6px;
  opacity: 0.82;
}

.speed-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  pointer-events: auto;
  justify-content: center;
}

.speed-row button {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 0;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  cursor: pointer;
}

.speed-row button.active {
  background: var(--gold);
  color: #2a2108;
  font-weight: 650;
}

.controls .speed-row {
  justify-content: flex-start;
}

.title-card, .end-card, .toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  text-align: center;
}

.title-card {
  top: 28%;
  width: 86%;
  pointer-events: none;
}

.title-card .kicker {
  font-size: clamp(16px, 4.6cqi, 22px);
  color: #f3f6ff;
  text-shadow: 0 2px 16px rgba(0,0,0,0.5);
}

.title-card h1 {
  margin: 8px 0 10px;
  font-size: clamp(26px, 8cqi, 40px);
  font-weight: 700;
  line-height: 1.25;
  text-shadow: 0 4px 24px rgba(0,0,0,0.6);
}

.title-card .sub {
  color: var(--gold);
  font-size: clamp(13px, 3.6cqi, 17px);
}

.end-card {
  top: 24%;
  width: 86%;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 16px 14px 14px;
  backdrop-filter: blur(10px);
}

.end-card h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.end-card .hint {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 8px;
  align-items: center;
  margin: 7px 0;
  font-size: 12px;
}

.bar-row .name {
  text-align: right;
  color: #e8edf8;
}

.bar-track {
  position: relative;
  height: 18px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, #f0c14b, #f6d98a);
  border-radius: 99px;
}

.bar-fill.polar {
  background: linear-gradient(90deg, #7ea0ff, #d0dcff);
}

.bar-meta {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #2a2108;
  font-weight: 600;
}

.footer-note {
  margin-top: 12px;
  color: var(--gold);
  font-size: 12px;
}

.legal {
  margin-top: 6px;
  font-size: 9px;
  color: #7d869c;
}

.toast {
  top: 36%;
  min-width: 180px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.toast.dawn { background: rgba(240, 193, 75, 0.92); color: #2a2108; }
.toast.dusk { background: rgba(92, 108, 196, 0.92); color: #eef1ff; }

.badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.28);
}

.pin {
  position: absolute;
  white-space: nowrap;
  font-size: clamp(11px, 2.8cqi, 14px);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pin.east { transform: translate(0, -50%); }
.pin.west { transform: translate(-100%, -50%); flex-direction: row-reverse; }

.pin .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.18);
}

.pin.dawn .dot { background: var(--gold); }
.pin.dusk .dot { background: #8aa0ff; }
.pin.polar .dot { background: #d0dcff; }

.pin .label {
  background: rgba(20, 24, 40, 0.78);
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
}

.controls {
  padding-top: 8px;
}

.controls h2 {
  font-size: 28px;
  margin: 0 0 8px;
}

.lede {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 6px;
}

input[type="text"], input[type="date"], select {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 12px;
  font-size: 16px;
}

.suggest {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  background: #12182c;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}

.suggest li {
  padding: 10px 12px;
  cursor: pointer;
}

.suggest li:hover, .suggest li.active {
  background: rgba(240, 193, 75, 0.16);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.presets button, .play {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.presets button.active, .play {
  background: var(--gold);
  color: #2a2108;
  font-weight: 650;
}

.error {
  color: #ffb4b4;
  min-height: 1.2em;
  font-size: 13px;
  margin-top: 8px;
}

.countries {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.countries button {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.status {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .stage-wrap {
    max-width: min(420px, 100%);
  }
}
