:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --glass: rgba(8, 11, 18, 0.58);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 14px rgba(0, 0, 0, 0.55);
  --line: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.94);
  --dim: rgba(255, 255, 255, 0.62);
  --accent: #9fd0ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: #000; color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
/* legibility: every overlay line keeps a dark halo, whatever the scene does */
.top, .hud, .finale, .scrubber, .scroll-hint, .credits { text-shadow: var(--shadow); }
/* top and bottom scrims so header/footer never sit on raw white */
body::before, body::after { content: ''; position: fixed; left: 0; right: 0; z-index: 3; pointer-events: none; }
body::before { top: 0; height: 120px; background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0)); }
body::after { bottom: 0; height: 150px; background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.55)); }
html, body { overscroll-behavior: none; }
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; z-index: 0; }
#scroller { position: relative; z-index: -1; width: 1px; }
button { font: inherit; color: inherit; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* top bar */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: max(18px, env(safe-area-inset-top)) 28px 0; pointer-events: none; }
.brand { font-weight: 700; letter-spacing: 0.32em; font-size: 13px; }
.brand span { font-weight: 400; letter-spacing: 0.04em; color: var(--dim); }
.counter { font-size: 13px; letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.9); padding: 6px 14px; border-radius: 999px; background: rgba(6, 8, 14, 0.55); border: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); font-variant-numeric: tabular-nums; text-transform: uppercase; }
.ctrls { display: flex; gap: 8px; pointer-events: auto; }
.chip { cursor: pointer; border: 1px solid var(--line); background: rgba(6, 8, 14, 0.55); padding: 7px 14px; border-radius: 999px; font-size: 12px; letter-spacing: 0.04em; transition: background 0.25s, border-color 0.25s; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.chip:hover { background: rgba(40, 46, 60, 0.7); }
.chip.busy { color: var(--dim); }
.chip.busy::before { content: ''; display: inline-block; width: 9px; height: 9px; margin-right: 7px; vertical-align: -1px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chip.on { border-color: rgba(159, 208, 255, 0.6); background: rgba(159, 208, 255, 0.16); }
.chip:focus-visible, .tick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* stage card */
.hud { position: fixed; z-index: 4; background: rgba(8, 11, 18, 0.62); left: clamp(20px, 5vw, 72px); top: 50%; translate: 0 -50%; width: min(440px, 38vw); padding: 26px 28px 24px; border-radius: 22px; will-change: opacity, transform; transition: none; }
.hud .inner { transition: opacity 0.18s ease; }
.hud .inner.swap { opacity: 0; }
.eon { font-size: 11px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.year { font-size: 14px; letter-spacing: 0.06em; color: var(--dim); font-variant-numeric: tabular-nums; }
.title { margin: 6px 0 12px; font-size: clamp(30px, 3.4vw, 48px); line-height: 1.04; font-weight: 650; letter-spacing: -0.025em; }
.caption { margin: 0 0 18px; font-size: 15.5px; line-height: 1.55; color: rgba(255, 255, 255, 0.8); }
.stat { display: inline-block; font-size: 12.5px; line-height: 1.4; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); color: rgba(255, 255, 255, 0.86); }

/* finale */
/* hides instantly (no transition), fades in only when shown */
.finale { position: fixed; z-index: 4; left: 0; right: 0; bottom: 15vh; text-align: center; opacity: 0; visibility: hidden; transform: translateY(18px); transition: none; pointer-events: none; }
.finale.show { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition: opacity 1.4s ease, transform 1.4s ease; }
.f-small { font-size: 12px; letter-spacing: 0.4em; text-transform: uppercase; color: var(--accent); }
.f-big { font-size: clamp(42px, 7vw, 104px); font-weight: 700; letter-spacing: -0.035em; margin: 10px 0 8px; text-shadow: 0 0 40px rgba(120, 170, 255, 0.25); }
.f-sub { font-size: 16px; color: var(--dim); margin-bottom: 22px; }

/* scrubber */
/* touch first: the whole 44 px tall track is the hit area, nothing on the bar pans, selects or opens
   the iOS long-press callout, and the bar sits clear of the home indicator */
.scrubber { position: fixed; z-index: 5; left: 50%; translate: -50% 0; bottom: max(22px, calc(env(safe-area-inset-bottom) + 12px)); width: min(760px, calc(100vw - 40px)); padding: 4px 22px 8px; border-radius: 16px; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.track { position: relative; height: 44px; cursor: pointer; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.rail, .fill { position: absolute; left: 0; right: 0; top: 21px; height: 2px; border-radius: 2px; }
.rail { background: rgba(255, 255, 255, 0.16); }
.fill { background: linear-gradient(90deg, #ffb36b, #ff6b3d 25%, #8fd3ff 60%, #ffffff); transform-origin: 0 50%; transform: scaleX(0); }
.tick { position: absolute; top: 17px; touch-action: none; -webkit-touch-callout: none; width: 10px; height: 10px; margin-left: -5px; padding: 0; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.5); background: rgba(0, 0, 0, 0.6); cursor: pointer; transition: transform 0.2s, background 0.2s; }
.tick.on { background: #fff; transform: scale(1.25); }
@media (hover: hover) { .tick:hover { background: #fff; transform: scale(1.25); } }
.tick::after { content: attr(data-title); position: absolute; bottom: 18px; left: 50%; translate: -50% 0; white-space: nowrap; font-size: 11px; padding: 5px 9px; border-radius: 8px; background: rgba(10, 12, 18, 0.85); border: 1px solid var(--line); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
@media (hover: hover) { .tick:hover::after { opacity: 1; } }
.head { position: absolute; top: 14px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.15), 0 0 18px rgba(160, 210, 255, 0.9); pointer-events: none; }
.scale { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255, 255, 255, 0.6); margin-top: -8px; pointer-events: none; }

.scroll-hint { position: fixed; z-index: 4; left: 50%; translate: -50% 0; bottom: 120px; text-align: center; font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--dim); transition: opacity 0.8s; }
.scroll-hint i { display: block; width: 1px; height: 38px; margin: 12px auto 0; background: linear-gradient(#fff, transparent); animation: drip 1.8s ease-in-out infinite; }
.scroll-hint.hide { opacity: 0; }
@keyframes drip { 0% { transform: scaleY(0); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

.credits { position: fixed; z-index: 3; right: 20px; bottom: 8px; font-size: 10px; color: rgba(255, 255, 255, 0.5); letter-spacing: 0.02em; pointer-events: none; text-align: right; max-width: 46vw; }

/* loader */
#loader { position: fixed; inset: 0; z-index: 20; background: radial-gradient(ellipse at 50% 45%, #0b1020 0%, #000 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; transition: opacity 1.2s ease; }
#loader.done { opacity: 0; pointer-events: none; }
.orb { width: 92px; height: 92px; border-radius: 50%; margin-bottom: 18px; background: radial-gradient(circle at 35% 35%, #9fd0ff 0%, #2a5ca8 35%, #061226 70%); box-shadow: 0 0 60px rgba(90, 150, 255, 0.35), inset -14px -10px 30px rgba(0, 0, 0, 0.8); animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 90px rgba(90, 150, 255, 0.55), inset -14px -10px 30px rgba(0, 0, 0, 0.8); } }
.loader-title { font-weight: 700; letter-spacing: 0.5em; font-size: 20px; margin-right: -0.5em; }
.loader-sub { color: var(--dim); font-size: 13px; letter-spacing: 0.06em; margin-bottom: 14px; }
.bar { width: min(280px, 70vw); height: 2px; background: rgba(255, 255, 255, 0.12); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #8fd3ff, #fff); transform-origin: 0 50%; transform: scaleX(0); transition: transform 0.3s ease; }
.pct { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.hint { font-size: 11px; color: rgba(255, 255, 255, 0.4); letter-spacing: 0.04em; max-width: 80vw; text-align: center; }

/* fallback */
#fallback { position: fixed; inset: 0; z-index: 30; overflow: auto; background: #05070c; padding: 8vh 8vw; line-height: 1.5; }
#fallback ol { padding-left: 1.2em; }
#fallback li { margin-bottom: 12px; }
#fallback li span { color: var(--dim); }

/* small / tall screens */
@media (max-aspect-ratio: 23/20), (max-width: 760px) {
  .top { padding: max(14px, env(safe-area-inset-top)) 16px 0; flex-wrap: wrap; }
  .brand span { display: none; }
  .counter { order: 3; width: 100%; font-size: 11px; }
  .hud { left: 12px; right: 12px; top: auto; bottom: calc(104px + env(safe-area-inset-bottom)); translate: none; width: auto; padding: 18px 18px 16px; border-radius: 18px; }
  .title { font-size: 28px; margin: 4px 0 8px; }
  .caption { font-size: 14px; margin-bottom: 12px; }
  .stat { font-size: 11.5px; }
  .scrubber { padding: 2px 14px 6px; }
  .credits { left: 12px; right: 12px; max-width: none; text-align: center; bottom: 2px; font-size: 9px; }
  .scroll-hint { bottom: 46vh; }
  .finale { bottom: 18vh; }
}
@media (prefers-reduced-motion: reduce) { .scroll-hint i, .orb { animation: none; } }
/* drag (reference ruler feel): ticks near the finger grow, quickly, while the bar is pressed */
.scrubbing .tick { transform: scale(var(--g, 1)); transition: transform 0.08s; }
.scrubbing .tick.on { transform: scale(calc(1.25 * var(--g, 1))); }
