:root {
  --void: #02030a;
  --void-2: #070b1c;
  --teal: #141d4a;
  --emerald: #46e6ff;
  --emerald-soft: #b9eeff;
  --cyan: #a3b4ff;
  --violet: #c98bff;
  --text: #eaf0ff;
  --muted: #95a0c2;
  --glass: rgba(8, 12, 32, 0.72);
  --edge: rgba(70, 200, 255, 0.28);
  --sans: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --gutter: clamp(14px, 3vw, 32px);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--void); color-scheme: dark; }
body { margin: 0; min-height: 100svh; background: var(--void); color: var(--text); font: 400 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--emerald-soft); }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.05; }
p { margin: 0; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); letter-spacing: .04em; }
:focus-visible { outline: 2px solid var(--emerald); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--emerald); color: var(--void); padding: 8px 14px; border-radius: 6px; font-weight: 600; }
.skip:focus { left: 8px; }

/* ================= Plain page (no JS, no WebGL, reduced motion) ================= */
.stage, .flash, .dissolve, .cursor-fx, .scanlines, .loader, .hud, .intro, .caption, .locnav, .rail, .tour-card, .scroll-hint, .labels, .reticle, .prompt, .help { display: none; }
.content { position: relative; max-width: 860px; margin: 0 auto; padding: clamp(56px, 10vh, 110px) var(--gutter) 40px; display: grid; gap: 18px; }
.plain-head { margin-bottom: 18px; }
.eyebrow { color: var(--emerald); font-size: 13px; text-transform: uppercase; }
.plain-title { font-size: clamp(40px, 7vw, 76px); margin: 12px 0 14px; }
.plain-lede { color: var(--muted); max-width: 52ch; font-size: 18px; }
.plain-note { margin-top: 14px; font-size: 13px; color: var(--muted); }
.loc { padding: clamp(20px, 3vw, 30px); border: 1px solid var(--edge); border-radius: 14px; background: linear-gradient(160deg, rgba(20,29,74,.35), rgba(2,3,10,.6)); }
.loc h2 { font-size: clamp(28px, 4vw, 40px); margin: 6px 0 12px; }
.loc p + p { margin-top: 10px; }
.loc-kicker { color: var(--emerald); font-size: 12.5px; text-transform: uppercase; }
.loc-pill { display: inline-block; font-size: 12px; color: var(--void); background: var(--emerald); padding: 3px 10px; border-radius: 999px; margin-bottom: 12px; }
.loc-list, .rules { margin: 14px 0 0; padding-left: 20px; display: grid; gap: 8px; color: #c7d9d1; }
.rules strong { color: var(--text); }
.loc-go { display: inline-flex; gap: 8px; margin-top: 18px; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--emerald); color: var(--text); text-decoration: none; font-weight: 600; transition: background .2s; }
.loc-go:hover { background: rgba(70,200,255,.14); }
.panel-close { display: none; }
.plain-3d { margin-top: 6px; }
.plain-3d button { background: none; border: 1px dashed var(--edge); color: var(--muted); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
html:not(.plain-reduced) .plain-3d { display: none; }
.foot { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; padding: 28px var(--gutter) 40px; color: var(--muted); font-size: 13px; }

/* ================= Booting ================= */
html.want-system .content, html.want-system .foot { display: none; }
html.want-system .loader { display: grid; position: fixed; inset: 0; z-index: 60; place-content: center; justify-items: center; gap: 16px; background: var(--void); color: var(--emerald); font-size: 13px; transition: opacity .6s; }
.loader-log { margin: 0; min-height: 5.2em; width: min(320px, 70vw); font-size: 12px; line-height: 1.3; color: var(--emerald); white-space: pre-wrap; }
.loader-pct { font-size: 11px; color: var(--muted); justify-self: end; width: min(320px, 70vw); text-align: right; }
.loader .bar { width: min(320px, 70vw); height: 2px; background: rgba(70,200,255,.15); overflow: hidden; }
.loader .bar i { display: block; height: 100%; width: 0; background: var(--emerald); transition: width .3s; }
.dots::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
html.system-ready .loader { opacity: 0; pointer-events: none; }

/* ================= System on ================= */
html.system-on body { overflow: hidden; }
html.system-on .stage { display: block; position: fixed; inset: 0; z-index: 0; }
.stage canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
html.system-on .scanlines { display: block; position: fixed; inset: 0; z-index: 5; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px); mix-blend-mode: multiply; opacity: .5; }
html.system-on .flash { display: block; position: fixed; inset: 0; z-index: 40; pointer-events: none; background: radial-gradient(circle at 50% 50%, #eef4ff, #46e6ff 40%, #02030a 75%); opacity: 0; }
.flash.on { animation: flash .9s ease-out; }
@keyframes flash { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }

/* HUD */
html.system-on .hud { display: flex; position: fixed; z-index: 30; top: 0; left: 0; right: 0; align-items: center; gap: 18px; padding: 14px var(--gutter); pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-brand { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 17px; letter-spacing: .02em; }
.hud-brand svg { width: 26px; height: 26px; color: var(--text); }
.hud-status { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.led { width: 7px; height: 7px; border-radius: 50%; background: #3a4d47; box-shadow: none; transition: background .4s, box-shadow .4s; }
html.state-universe .led, html.state-tunnel .led { background: var(--emerald); box-shadow: 0 0 10px var(--emerald); }
.hud-coords { font-size: 11px; color: rgba(149,160,194,.7); margin-left: auto; }
.hud-actions { display: flex; gap: 8px; }
.hud-btn { background: rgba(8,12,32,.6); border: 1px solid var(--edge); color: var(--text); padding: 7px 12px; border-radius: 7px; font: 500 12px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: border-color .2s, background .2s; }
.hud-btn:hover { border-color: var(--emerald); background: rgba(70,200,255,.12); }
.hud-btn[aria-pressed="true"] { background: rgba(70,200,255,.2); border-color: var(--emerald); }
html.state-universe .hud-btn-skip { display: none; }

/* Intro */
html.system-on.state-intro .intro, html.system-on.state-insert .intro { display: grid; }
.intro { position: fixed; z-index: 20; left: 0; right: 0; bottom: clamp(28px, 6vh, 64px); justify-items: center; text-align: center; gap: 12px; padding: 0 var(--gutter); pointer-events: none; transition: opacity .6s; }
.intro > * { pointer-events: auto; }
.intro-title { font-size: clamp(24px, 3.8vw, 52px); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; text-shadow: 0 0 30px rgba(70,200,255,.25); }
.intro-sub { color: var(--muted); font-size: clamp(15px, 1.4vw, 18px); }
.intro-cta { margin-top: 14px; background: rgba(2,3,10,.6); border: 1px solid var(--emerald); color: var(--emerald-soft); padding: 13px 22px; border-radius: 8px; font-size: 14px; text-transform: uppercase; cursor: pointer; animation: breathe 2.6s ease-in-out infinite; }
.intro-cta:hover { background: rgba(70,200,255,.16); color: var(--text); }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(70,200,255,.0); } 50% { box-shadow: 0 0 26px 2px rgba(70,200,255,.28); } }
html.state-insert .intro { opacity: 0; pointer-events: none; }
html.state-insert .intro > * { pointer-events: none; }

html.system-on .caption { display: block; position: fixed; z-index: 20; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; padding: 0 var(--gutter); font: 600 clamp(22px, 3.6vw, 48px)/1.15 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--text); text-shadow: 0 0 24px rgba(70,200,255,.45); opacity: 0; transition: opacity .8s; pointer-events: none; }
.caption.on { opacity: 1; }

/* Navigate mode */
html.system-on.state-universe .locnav { display: block; }
.locnav { position: fixed; z-index: 25; left: var(--gutter); bottom: var(--gutter); width: min(300px, calc(100vw - 2 * var(--gutter))); padding: 14px; background: var(--glass); border: 1px solid var(--edge); border-radius: 12px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: opacity .4s, transform .4s var(--ease); }
.locnav-title { font-size: 11px; color: var(--emerald); text-transform: uppercase; margin: 0 0 8px 4px; }
.locnav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.locnav a { display: grid; grid-template-columns: 28px 1fr; column-gap: 6px; padding: 8px 8px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; font-size: 15px; transition: background .2s; }
.locnav a span { grid-row: 1 / span 2; color: var(--emerald); font-size: 12px; padding-top: 3px; }
.locnav a small { color: var(--muted); font-size: 12px; font-weight: 400; }
.locnav a:hover, .locnav a.active { background: rgba(70,200,255,.12); }
.locnav-core { margin-top: 8px; width: 100%; background: none; border: 1px dashed var(--edge); color: var(--muted); padding: 8px; border-radius: 8px; cursor: pointer; font-size: 12px; text-transform: uppercase; }
.locnav-core:hover { color: var(--text); border-color: var(--emerald); }
html.explore .locnav { opacity: 0; transform: translateY(12px); pointer-events: none; }

/* World labels */
html.system-on.state-universe .labels { display: block; position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.label { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); font: 500 11px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--emerald-soft); white-space: nowrap; padding: 4px 8px; border-left: 1px solid var(--emerald); background: rgba(2,3,10,.5); opacity: .75; transition: opacity .25s, color .25s; }
.label b { display: block; color: var(--text); font-family: var(--sans); font-size: 13px; letter-spacing: .02em; text-transform: none; }
.label.hot { opacity: 1; color: var(--cyan); border-color: var(--cyan); }
.label.hidden { opacity: 0; }

/* Explore mode */
html.explore .reticle { display: block; position: fixed; z-index: 15; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border: 1px solid rgba(230,242,236,.6); border-radius: 50%; pointer-events: none; transition: transform .2s, border-color .2s; }
.reticle i { position: absolute; left: 50%; top: 50%; width: 2px; height: 2px; margin: -1px; background: var(--text); border-radius: 50%; }
.reticle.hot { transform: scale(1.5); border-color: var(--cyan); }
html.explore .help { display: block; position: fixed; z-index: 15; bottom: 18px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
html.system-on.state-universe .prompt { display: block; position: fixed; z-index: 15; left: 0; right: 0; top: calc(50% + 28px); text-align: center; font-size: 12px; color: var(--cyan); opacity: 0; transition: opacity .2s; pointer-events: none; }
.prompt.on { opacity: 1; }

/* Holographic panel (the same content as the plain page) */
html.system-on .content { display: none; position: fixed; z-index: 35; top: 72px; right: var(--gutter); bottom: var(--gutter); width: min(440px, calc(100vw - 2 * var(--gutter))); max-width: none; margin: 0; padding: 22px; overflow: auto; background: var(--glass); border: 1px solid var(--edge); border-radius: 14px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 0 0 1px rgba(70,200,255,.06), 0 30px 80px -30px rgba(0,0,0,.8); }
html.system-on.panel-open .content { display: block; animation: panel-in .55s var(--ease); }
@keyframes panel-in { from { opacity: 0; transform: translateX(24px); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: none; clip-path: inset(0 0 0 0); } }
html.system-on .content::before { content: ""; position: absolute; inset: 0; border-radius: 14px; pointer-events: none; background: linear-gradient(180deg, rgba(70,200,255,.08), transparent 30%); }
html.system-on .plain-head, html.system-on .plain-3d { display: none; }
html.system-on .loc { display: none; padding: 0; border: 0; background: none; }
html.system-on .loc.active { display: block; }
html.system-on .panel-close { display: inline-block; margin-top: 22px; background: none; border: 1px solid var(--edge); color: var(--muted); padding: 8px 12px; border-radius: 7px; cursor: pointer; font-size: 12px; text-transform: uppercase; }
html.system-on .panel-close:hover { color: var(--text); border-color: var(--emerald); }
html.system-on .foot { display: none; }

@media (max-width: 760px) {
  .hud { flex-wrap: wrap; gap: 10px; }
  .hud-status, .hud-coords { display: none !important; }
  .hud-actions { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
  .hud-btn { padding: 7px 9px; font-size: 11px; }
  #btn-mode { display: none; }
  html.system-on .content { top: auto; left: var(--gutter); right: var(--gutter); width: auto; max-height: 62svh; bottom: var(--gutter); }
  html.panel-open .locnav { display: none !important; }
  .locnav { left: var(--gutter); right: var(--gutter); width: auto; }
  .locnav ul { grid-template-columns: 1fr 1fr; }
  .locnav a small { display: none; }
  .label b { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================= Motion layer: dissolve, cursor, journey ================= */
html.system-on .dissolve { display: block; position: fixed; inset: 0; width: 100%; height: 100%; z-index: 45; pointer-events: none; }

/* Quantum cursor effect: drawn around the real pointer, which always stays visible. */
html.system-on .cursor-fx { display: block; position: fixed; inset: 0; width: 100%; height: 100%; z-index: 79; pointer-events: none; }
html.explore .cursor-fx { display: none; }

.intro-sound { background: none; border: 0; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; padding: 6px 10px; border-radius: 6px; }
.intro-sound:hover, .intro-sound[aria-pressed="true"] { color: var(--emerald-soft); }

/* Journey rail (right edge) */
html.system-on.state-universe .rail { display: block; }
.rail { position: fixed; z-index: 24; right: var(--gutter); top: 50%; transform: translateY(-50%); text-align: right; transition: opacity .4s; }
html.panel-open .rail { opacity: 0; pointer-events: none; }
html.explore .rail { opacity: 0; pointer-events: none; }
.rail-now { font-size: 11px; color: var(--emerald); margin: 0 0 10px; letter-spacing: .12em; }
.rail ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; justify-items: end; }
.rail button { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 3px 0; cursor: pointer; color: var(--muted); font: 500 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.rail button span { opacity: 0; transform: translateX(6px); transition: opacity .25s, transform .25s var(--ease); }
.rail button i { display: block; width: 14px; height: 1px; background: rgba(149,160,194,.5); transition: width .35s var(--ease), background .3s; }
.rail button:hover span, .rail button:focus-visible span, .rail button.now span { opacity: 1; transform: none; }
.rail button.now { color: var(--text); }
.rail button.now i { width: 34px; background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
.rail button.past i { background: rgba(70,200,255,.55); }

/* Info card for the journey's info stops */
html.system-on.state-universe .tour-card { display: block; }
.tour-card { position: fixed; z-index: 22; left: 50%; bottom: clamp(24px, 7vh, 64px); width: min(520px, calc(100vw - 2 * var(--gutter))); transform: translate(-50%, 16px); padding: 18px 22px; background: var(--glass); border: 1px solid var(--edge); border-radius: 14px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); opacity: 0; pointer-events: none; transition: opacity .5s, transform .6s var(--ease); }
.tour-card.on { opacity: 1; transform: translate(-50%, 0); }
.tour-index { font-size: 11px; color: var(--emerald); letter-spacing: .12em; margin-bottom: 6px; }
.tour-card h2 { font-size: clamp(22px, 2.4vw, 30px); margin-bottom: 8px; }
.tour-card p:last-child { color: #c7d9d1; font-size: 15px; }
html.panel-open .tour-card, html.explore .tour-card { opacity: 0; }
html.system-on.state-universe .locnav { bottom: auto; top: 76px; }

.scroll-hint { position: fixed; z-index: 21; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); display: none; align-items: center; gap: 10px; transition: opacity .5s; }
html.system-on.state-universe .scroll-hint { display: flex; }
.scroll-hint i { width: 1px; height: 22px; background: linear-gradient(var(--emerald), transparent); animation: hint 1.6s ease-in-out infinite; }
@keyframes hint { 0% { transform: scaleY(0); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } 100% { transform: scaleY(1); opacity: 0; } }
.scroll-hint.gone, html.panel-open .scroll-hint { opacity: 0; }

@media (max-width: 760px) {
  .rail { top: 64px; transform: none; }
  .rail ol { display: none; }
  .tour-card { bottom: 128px; padding: 14px 16px; }
  .tour-card p:last-child { font-size: 14px; }
  html.system-on.state-universe .locnav { top: auto; bottom: var(--gutter); }
  html.state-universe:not(.panel-open) .locnav ul { grid-template-columns: repeat(5, 1fr); }
  .locnav a { grid-template-columns: 1fr; text-align: center; font-size: 12px; padding: 6px 2px; }
  .locnav a span { grid-row: auto; }
  .locnav-title, .locnav-core { display: none; }
  .scroll-hint { bottom: 70px; }
}
