:root {
  --ink: #e6fbff;
  --ink-2: rgba(214, 244, 250, .66);
  --ink-3: rgba(214, 244, 250, .42);
  --cyan: #8ff3ff;
  --petrol: #3a87a3;
  --glass: rgba(8, 26, 32, .52);
  --glass-2: rgba(12, 36, 44, .72);
  --line: rgba(143, 243, 255, .16);
  --line-2: rgba(143, 243, 255, .32);
  --r: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: #06141a; }
body { font-family: var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; }
svg { display: block; }

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; cursor: grab; }
#scene:active { cursor: grabbing; }

/* brand */
.brand {
  position: fixed; top: calc(16px + var(--safe-t)); left: calc(18px + var(--safe-l));
  display: flex; align-items: center; gap: 10px; pointer-events: none; z-index: 3;
  color: var(--cyan); text-shadow: 0 0 18px rgba(0, 0, 0, .6);
}
.brand svg { width: 22px; height: 22px; filter: drop-shadow(0 0 6px rgba(143, 243, 255, .5)); }
.brand div { display: flex; flex-direction: column; line-height: 1.05; }
.brand strong { font-size: 12px; letter-spacing: .32em; font-weight: 600; color: var(--ink); }
.brand span { font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-2); }

/* intro */
.intro {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% 60%, rgba(6, 20, 26, .25), rgba(3, 10, 13, .86));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: opacity .9s ease, visibility .9s, backdrop-filter .9s;
}
body.started .intro { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-card { max-width: 440px; text-align: center; }
.eyebrow { text-wrap: balance; margin: 0 0 14px; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--cyan); opacity: .85; }
.intro h1 {
  margin: 0; font-weight: 250; font-size: clamp(40px, 9vw, 68px); letter-spacing: -.01em; line-height: 1;
  background: linear-gradient(180deg, #f2feff 20%, #8fe9f7 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { margin: 18px auto 30px; max-width: 34ch; color: var(--ink-2); font-size: 15px; line-height: 1.55; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 12px; padding: 15px 26px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-2); background: linear-gradient(180deg, rgba(143, 243, 255, .18), rgba(58, 135, 163, .16));
  box-shadow: 0 0 0 1px rgba(143, 243, 255, .05) inset, 0 10px 40px rgba(58, 216, 255, .18);
  font-size: 15px; letter-spacing: .02em; transition: transform .2s ease, box-shadow .2s ease, background .2s;
}
.btn-primary svg { width: 18px; height: 18px; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(143, 243, 255, .1) inset, 0 14px 50px rgba(58, 216, 255, .3); }
.btn-ghost { display: block; margin: 14px auto 0; background: none; border: 0; color: var(--ink-3); font-size: 13px; cursor: pointer; padding: 8px; }
.btn-ghost:hover { color: var(--ink-2); }

/* hint + arrival */
.hint {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; margin: 0; z-index: 2; pointer-events: none;
  font-size: 12.5px; color: var(--ink-2); letter-spacing: .04em; opacity: 0; transition: opacity .8s ease;
}
.hint svg { width: 18px; height: 18px; animation: sway 2.4s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: translateX(-5px); } 50% { transform: translateX(5px); } }
body.started:not(.looked) .hint { opacity: 1; transition-delay: 1.2s; }

.arrival {
  position: fixed; left: 0; right: 0; top: calc(17vh + var(--safe-t)); margin: 0; text-align: center; z-index: 2; pointer-events: none;
  opacity: 0; transform: translateY(8px); transition: opacity 1.6s ease, transform 1.6s ease;
}
.arrival span { display: block; font-size: clamp(30px, 6vw, 46px); font-weight: 250; letter-spacing: .3em; text-indent: .3em; text-transform: uppercase; text-shadow: 0 0 30px rgba(143, 243, 255, .35); }
.arrival small { display: block; margin-top: 10px; font-size: 12px; color: var(--ink-2); letter-spacing: .12em; text-transform: uppercase; }
body.arrived .arrival { opacity: 1; transform: none; transition-delay: .6s; }

/* transport */
.transport {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 4px; padding: 6px 8px; width: min(560px, calc(100vw - 24px - var(--safe-l) - var(--safe-r)));
  border-radius: 999px; background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
  opacity: 0; transition: opacity .8s ease .4s;
}
body.started .transport { opacity: 1; }
.tbtn {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--ink); transition: background .2s, transform .15s;
  touch-action: none;
}
.tbtn svg { width: 18px; height: 18px; }
.tbtn:hover { background: rgba(143, 243, 255, .08); }
.tbtn.held, .tbtn:active { background: rgba(143, 243, 255, .16); transform: scale(.94); }
.tbtn.play { width: 46px; height: 46px; background: rgba(143, 243, 255, .14); border: 1px solid var(--line-2); }
.tbtn.play svg { width: 20px; height: 20px; }
.tbtn.play .i-pause, .tbtn.play.playing .i-play { display: none; }
.tbtn.play.playing .i-pause { display: block; }
.tbtn.restart { opacity: .55; }
body.arrived .tbtn.restart { opacity: 1; color: var(--cyan); }
.progress { position: relative; flex: 1; height: 40px; margin: 0 8px; cursor: pointer; touch-action: none; }
.progress .track { position: absolute; left: 0; right: 0; top: 50%; height: 3px; margin-top: -1.5px; border-radius: 3px; background: rgba(143, 243, 255, .14); overflow: hidden; }
.progress .fill { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, var(--petrol), var(--cyan)); }
.progress .knob { position: absolute; top: 50%; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 12px rgba(143, 243, 255, .8); }

/* panel */
.panel-toggle {
  position: fixed; top: calc(14px + var(--safe-t)); right: calc(14px + var(--safe-r)); z-index: 6;
  width: 44px; height: 44px; border-radius: 14px; cursor: pointer; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  transition: background .2s, opacity .3s;
}
.panel-toggle svg { width: 20px; height: 20px; }
.panel-toggle:hover { background: var(--glass-2); }
.panel-toggle[aria-expanded="true"] { opacity: 0; pointer-events: none; }

.panel {
  position: fixed; top: calc(14px + var(--safe-t)); right: calc(14px + var(--safe-r)); z-index: 7;
  width: min(320px, calc(100vw - 28px - var(--safe-l) - var(--safe-r)));
  max-height: calc(100dvh - 120px - var(--safe-t) - var(--safe-b)); overflow: auto;
  padding: 6px 16px 16px; border-radius: 20px; background: var(--glass-2); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(22px) saturate(1.4); backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  transform-origin: top right; transform: translateY(-6px) scale(.96); opacity: 0; visibility: hidden;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .22s ease, visibility .28s;
}
.panel.open { transform: none; opacity: 1; visibility: visible; }
.panel-head { display: flex; align-items: center; gap: 10px; height: 44px; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-2); }
.panel-head > span:first-child { flex: 1; }
.fps { font-variant-numeric: tabular-nums; letter-spacing: .04em; text-transform: none; color: var(--ink-3); }
.x { width: 32px; height: 32px; border: 0; border-radius: 10px; background: rgba(143, 243, 255, .06); cursor: pointer; display: grid; place-items: center; }
.x svg { width: 16px; height: 16px; }
.panel section { padding: 12px 0; border-top: 1px solid var(--line); }
.panel h3 { margin: 0 0 10px; display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 500; letter-spacing: .02em; }
.meta, output { font-size: 12px; font-weight: 400; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.panel section.row { display: flex; align-items: center; justify-content: space-between; }
.panel section.row h3 { margin: 0; gap: 10px; justify-content: flex-start; }

.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chip {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 12px; cursor: pointer; text-align: left;
  font-size: 12.5px; background: rgba(143, 243, 255, .04); border: 1px solid transparent; color: var(--ink-2); transition: all .2s;
}
.chip:hover { background: rgba(143, 243, 255, .08); color: var(--ink); }
.chip.on { border-color: var(--line-2); background: rgba(143, 243, 255, .1); color: var(--ink); }
.sw { flex: none; width: 16px; height: 16px; border-radius: 50%; background: linear-gradient(135deg, var(--a) 30%, var(--b)); box-shadow: 0 0 10px color-mix(in srgb, var(--b) 50%, transparent); }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 8px 2px; border-radius: 9px; font-size: 12px; color: var(--ink-2); cursor: pointer; transition: all .2s; }
.seg button.on { background: rgba(143, 243, 255, .16); color: var(--ink); box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--petrol), rgba(143, 243, 255, .25)); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--petrol), rgba(143, 243, 255, .25)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7.5px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 4px rgba(143, 243, 255, .15), 0 0 14px rgba(143, 243, 255, .6); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 4px rgba(143, 243, 255, .15); }

.switch { position: relative; width: 46px; height: 28px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(143, 243, 255, .1); border: 1px solid var(--line); transition: background .25s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink-2); transition: transform .25s cubic-bezier(.2, .8, .2, 1), background .25s; }
.switch input:checked + span { background: rgba(58, 135, 163, .65); border-color: var(--line-2); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--ink); box-shadow: 0 0 10px rgba(143, 243, 255, .7); }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; }

@media (max-width: 520px) {
  .brand span { display: none; }
  .tbtn { width: 38px; height: 38px; }
  .transport { gap: 0; padding: 5px 6px; }
  .progress { margin: 0 6px; }
  .lede { font-size: 14px; }
  .eyebrow { font-size: 10px; letter-spacing: .16em; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .arrival { top: 10vh; }
  .hint { bottom: calc(76px + var(--safe-b)); }
  .panel { max-height: calc(100dvh - 28px); }
}
@media (prefers-reduced-motion: reduce) { .hint svg { animation: none; } }
