:root {
  --bg: #04060c;
  --ink: #e8f0f8;
  --muted: #93a4b8;
  --cyan: #5eead4;
  --gold: #f5c16c;
  --emerald: #34d399;
  --line: rgba(148, 196, 228, 0.22);
  --glass: rgba(8, 14, 24, 0.62);
  --danger: #fb7185;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button, input { font: inherit; color: inherit; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 6, 12, 0.92);
  z-index: 3;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 1.25rem; letter-spacing: 0.08em; }
.brand h1 span {
  display: block;
  margin-top: 2px;
  letter-spacing: 0.01em;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
}
.eyebrow {
  margin: 0;
  color: var(--cyan);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6d8, var(--gold) 42%, #7c4a12 70%);
  box-shadow: 0 0 16px var(--gold);
}

.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.tour-launch {
  position: relative;
  border-color: rgba(245, 193, 108, 0.75);
  background: rgba(16, 22, 18, 0.9);
  color: var(--gold);
  font-weight: 650;
  letter-spacing: 0.03em;
  padding: 8px 16px;
  box-shadow: 0 0 16px rgba(94, 234, 212, 0.28);
  animation: tourPulse 2.4s ease-out infinite;
}
.tour-launch:hover { border-color: var(--cyan); color: var(--cyan); }
.tour-launch.is-running { animation: none; color: var(--cyan); border-color: rgba(94, 234, 212, 0.8); }
.paper-link {
  border: 1px solid rgba(94, 234, 212, 0.45);
  background: rgba(8, 14, 24, 0.72);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--cyan);
  text-decoration: none;
  letter-spacing: 0.03em;
  font-weight: 600;
}
.paper-link:hover { border-color: var(--gold); color: var(--gold); }
.nav-btn {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(94, 234, 212, 0.45);
  background: rgba(8, 14, 24, 0.72);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--cyan);
  text-decoration: none;
  letter-spacing: 0.03em;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.nav-btn span { pointer-events: none; }
.github-btn:hover { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 16px rgba(245, 193, 108, 0.28); }
.lang-btn { color: var(--gold); border-color: rgba(245, 193, 108, 0.55); }
.lang-btn:hover { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 16px rgba(94, 234, 212, 0.28); }
html[lang="my"] body,
html[lang="my"] button,
html[lang="my"] .nav-btn,
html[lang="my"] .paper-link {
  font-family: "Noto Sans Myanmar", "Myanmar Text", "Pyidaungsu", "Avenir Next", "Segoe UI", system-ui, sans-serif;
}
html[lang="my"] .kicker,
html[lang="my"] .card h3,
html[lang="my"] .badge,
html[lang="my"] .tour-kicker {
  letter-spacing: 0;
  text-transform: none;
}
html[lang="my"] #mechanism,
html[lang="my"] #tour-title,
html[lang="my"] #tour-body,
html[lang="my"] .detail,
html[lang="my"] .card h3 {
  line-height: 1.55;
}
@keyframes tourPulse {
  0% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.55); }
  70% { box-shadow: 0 0 0 11px rgba(94, 234, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0); }
}

.tour-card {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 4;
  width: min(680px, calc(100% - 40px));
  padding: 14px 16px 12px;
  border-radius: 18px;
  background: rgba(7, 10, 16, 0.72);
  border: 1px solid rgba(94, 234, 212, 0.45);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45), 0 0 24px rgba(245, 193, 108, 0.16);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.tour-card.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.tour-progress {
  height: 3px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
#tour-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
}
.tour-kicker {
  margin: 0;
  color: var(--cyan);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
}
#tour-title {
  margin: 4px 0 0;
  color: var(--gold);
  font-size: 1.22rem;
  font-weight: 640;
  letter-spacing: 0.01em;
}
#tour-body {
  margin: 8px 0 0;
  color: #d7e2ec;
  font-size: 0.92rem;
  line-height: 1.45;
}
.tour-metric {
  display: inline-block;
  margin: 10px 0 0;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(245, 193, 108, 0.45);
  color: var(--gold);
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}
.tour-copy.tour-swap { animation: tourFade 0.45s ease; }
@keyframes tourFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.tour-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tour-controls button { background: rgba(255, 255, 255, 0.04); }
#tour-pause { color: var(--cyan); border-color: rgba(94, 234, 212, 0.7); }
.badge {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}
.badge.emerald { color: var(--emerald); border-color: rgba(52, 211, 153, 0.45); }
.badge.gold { color: var(--gold); border-color: rgba(245, 193, 108, 0.45); }

#stage { position: relative; flex: 1; min-height: 320px; }
#viewport { display: block; width: 100%; height: 100%; }
.vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.5) 100%);
}
#load-state {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.hud {
  position: absolute;
  top: 14px;
  width: min(300px, 34vw);
  padding: 14px 14px 12px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.hud-left { left: 14px; }
.hud-right {
  right: 14px;
  width: min(280px, 32vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100% - 28px);
  overflow: auto;
}
.kicker {
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.kicker:first-child { margin-top: 0; }
.epoch, .value, .time-readout {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
.epoch { margin: 0; font-size: 1.7rem; color: var(--cyan); }
.clock { margin: 2px 0 0; color: var(--gold); font-size: 0.78rem; }
#mechanism { margin: 2px 0 0; font-size: 1.15rem; line-height: 1.25; }
.phase-name { margin: 6px 0 0; color: var(--emerald); font-size: 0.82rem; }
.detail { margin: 8px 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }

.card {
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(148, 196, 228, 0.12);
}
.card:last-child { border-bottom: 0; padding-bottom: 0; }
.card h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.value { margin: 2px 0 0; font-size: 1.15rem; }
.sub { margin: 1px 0 4px; color: var(--muted); font-size: 0.75rem; min-height: 1em; }
.spark svg { display: block; width: 100%; height: 32px; }
.meter {
  position: relative;
  height: 6px;
  margin: 6px 0 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
#rm-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--danger), var(--gold), var(--emerald));
}
#rm-tick {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 12px;
  background: var(--ink);
}

footer {
  display: grid;
  grid-template-columns: 1.3fr auto auto;
  gap: 10px 16px;
  align-items: center;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line);
  background: rgba(4, 6, 12, 0.94);
  z-index: 3;
}
.transport, .markers, .cameras { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.time-readout { margin: 0 0 0 8px; min-width: 7.5rem; color: var(--cyan); font-size: 0.95rem; }

button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}
button:hover { border-color: rgba(94, 234, 212, 0.7); }
button.active, button.primary {
  background: rgba(94, 234, 212, 0.16);
  border-color: rgba(94, 234, 212, 0.8);
  color: var(--cyan);
}
.cameras button.active { color: var(--gold); border-color: rgba(245, 193, 108, 0.8); background: rgba(245, 193, 108, 0.12); }

.slider-wrap { grid-column: 1 / -1; position: relative; padding-top: 12px; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 0;
  border-radius: 999px;
  background: linear-gradient(90deg,
    rgba(94, 234, 212, 0.85) 0%,
    rgba(94, 234, 212, 0.85) 0.14%,
    rgba(245, 193, 108, 0.9) 0.14%,
    rgba(245, 193, 108, 0.9) 0.71%,
    rgba(148, 163, 184, 0.35) 0.71%,
    rgba(148, 163, 184, 0.35) 4.3%,
    rgba(251, 113, 133, 0.8) 4.3%,
    rgba(251, 113, 133, 0.8) 14.3%,
    rgba(148, 163, 184, 0.28) 14.3%,
    rgba(148, 163, 184, 0.28) 57%,
    rgba(52, 211, 153, 0.85) 57%,
    rgba(52, 211, 153, 0.85) 100%);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f8fbff;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  cursor: pointer;
}
.tick {
  position: absolute;
  top: 8px;
  width: 1px;
  height: 10px;
  transform: translateX(-50%);
  background: rgba(232, 240, 248, 0.55);
  pointer-events: none;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 980px) {
  header { align-items: flex-start; }
  .header-actions { width: 100%; }
  .hud { position: static; width: auto; max-height: none; }
  #stage { display: flex; flex-direction: column; }
  #viewport { height: 52vh; order: -1; flex: none; }
  .vignette { height: 52vh; }
  footer { grid-template-columns: 1fr; }
  .tour-card { width: min(680px, calc(100% - 24px)); max-height: 46vh; overflow: auto; }
}
@media (max-width: 768px) {
  body { height: auto; min-height: 100vh; overflow: auto; }
  header { padding: 10px 12px; }
  .brand h1 { font-size: 1.05rem; }
  .header-actions { gap: 8px; }
  .tour-launch, .paper-link, .nav-btn { padding: 7px 11px; font-size: 0.82rem; }
  #stage { flex: none; min-height: 0; }
  #viewport { height: 46vh; min-height: 240px; }
  .vignette { height: 46vh; min-height: 240px; }
  .hud, .hud-right {
    position: static;
    width: auto;
    max-height: none;
    margin: 8px 10px 0;
  }
  .tour-card,
  .tour-card.visible {
    position: static;
    left: auto;
    bottom: auto;
    width: auto;
    max-height: none;
    margin: 8px 10px 12px;
    transform: none;
  }
  .epoch { font-size: 1.35rem; }
  #mechanism { font-size: 1.02rem; }
}
