:root {
  --bg: rgba(18, 20, 24, 0.82);
  --fg: #f2f3f5;
  --muted: #a3a8b2;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #ff4b4b;
  color-scheme: dark;
}

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0d10;
  color: var(--fg);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}

#globe { position: absolute; inset: 0; }
#globe .cesium-viewer-bottom { bottom: 64px; }

.panel {
  position: absolute;
  background: var(--bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 12px;
  z-index: 2;
}

button {
  font: inherit;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
}
button.on { background: var(--fg); color: #111; border-color: var(--fg); }
button:hover:not(.on) { border-color: var(--muted); }

#title { top: 16px; left: 16px; padding: 10px 14px; }
#title h1 { margin: 0; font-size: 16px; letter-spacing: 0.01em; }
#title p { margin: 2px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }

#layers { top: 16px; right: 16px; padding: 6px; display: flex; gap: 6px; }

#legend {
  left: 16px; bottom: 88px; margin: 0; padding: 8px 12px; list-style: none;
  display: grid; gap: 2px; font-size: 13px; color: var(--muted);
}
#legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }

#train {
  top: 72px; right: 16px; width: 300px; max-height: calc(100% - 180px);
  padding: 14px 16px; overflow: auto;
}
#train h2 { margin: 0 24px 0 0; font-size: 18px; }
#train-to { margin: 2px 0 10px; color: var(--muted); }
#close { position: absolute; top: 8px; right: 8px; border: 0; font-size: 18px; padding: 0 8px; }
#train-facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0 0 10px; }
#train-facts dt { color: var(--muted); }
#train-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
#train-stops { margin: 0 0 12px; padding: 0; list-style: none; font-size: 13px; }
#train-stops li { display: flex; gap: 10px; padding: 2px 0; color: var(--muted); }
#train-stops li.next { color: var(--fg); font-weight: 600; }
#train-stops li.past { opacity: 0.45; }
#train-stops time { font-variant-numeric: tabular-nums; min-width: 40px; }
#follow { width: 100%; }

#clock {
  left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  width: min(760px, calc(100% - 32px)); box-sizing: border-box;
}
#play { width: 36px; padding: 4px 0; }
#speeds { display: flex; gap: 4px; }
#scrub { flex: 1; min-width: 60px; accent-color: var(--accent); }
#time { display: grid; text-align: right; line-height: 1.1; font-variant-numeric: tabular-nums; }
#time strong { font-size: 18px; }
#time span { color: var(--muted); font-size: 12px; }

#credits { right: 16px; bottom: 88px; padding: 6px 12px; max-width: 320px; font-size: 12px; color: var(--muted); }
#credits summary { cursor: pointer; }
#credits a { color: var(--fg); }

@media (max-width: 640px) {
  #title { top: 12px; left: 12px; right: 12px; }
  #layers { top: auto; bottom: 112px; right: 12px; }
  #legend { display: none; }
  #train { top: auto; bottom: 112px; left: 12px; right: 12px; width: auto; max-height: 45%; }
  #clock { flex-wrap: wrap; bottom: 12px; width: calc(100% - 24px); }
  #time { margin-left: auto; }
  #now { order: 4; }
  #scrub { order: 5; flex: 1 1 120px; }
  #credits { bottom: 112px; left: 12px; right: auto; }
}
