:root {
  --cyan: #19f3ff;
  --mag: #ff2bd6;
  --vio: #8a4dff;
  --bg: #04030c;
  --glass: rgba(8, 6, 28, 0.62);
  --line: rgba(25, 243, 255, 0.38);
  --text: #e8f7ff;
  --dim: rgba(200, 230, 255, 0.62);
  --head: 'Orbitron', 'Segoe UI', sans-serif;
  --body: 'Rajdhani', 'Segoe UI', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--bg); color: var(--text); font-family: var(--body); font-weight: 500; -webkit-text-size-adjust: 100%; }
@supports (height: 100dvh) { html, body { height: 100dvh; } }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(2, 1, 8, 0.55) 100%); }
.hidden { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
#hud, #intro { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* ── shared panel look ── */
.panel {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  box-shadow: inset 0 0 24px rgba(25, 243, 255, 0.06);
}

/* ── INTRO ── */
#intro {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; text-align: center; padding: 24px;
  background: radial-gradient(ellipse at center, rgba(4, 3, 12, 0.25) 0%, rgba(4, 3, 12, 0.82) 100%);
  transition: opacity 1.1s ease, visibility 1.1s;
}
#intro.leaving { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-inner { max-width: 640px; }
.eyebrow { font: 700 13px var(--head); letter-spacing: 0.42em; color: var(--cyan); display: inline-flex; align-items: center; gap: 12px; opacity: 0.9; }
.eyebrow i { width: 8px; height: 8px; background: var(--mag); border-radius: 50%; box-shadow: 0 0 12px var(--mag); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

#introTitle {
  position: relative; margin: 14px 0 2px; font: 900 clamp(64px, 15vw, 150px)/1 var(--head); letter-spacing: 0.06em; padding-left: 0.06em;
  background: linear-gradient(100deg, #fff 10%, var(--cyan) 45%, var(--mag) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px rgba(25, 243, 255, 0.45));
}
#introTitle::before, #introTitle::after {
  content: attr(data-text); position: absolute; inset: 0; padding-left: 0.06em; background: inherit; -webkit-background-clip: text; background-clip: text; color: transparent; opacity: 0.55; pointer-events: none;
}
#introTitle::before { animation: glitchA 4.5s infinite steps(1); }
#introTitle::after { animation: glitchB 4.5s infinite steps(1); }
@keyframes glitchA { 0%, 92%, 100% { transform: none; clip-path: inset(0 0 100% 0); } 93% { transform: translate(-6px, 0); clip-path: inset(20% 0 55% 0); } 96% { transform: translate(5px, 0); clip-path: inset(62% 0 12% 0); } }
@keyframes glitchB { 0%, 94%, 100% { transform: none; clip-path: inset(0 0 100% 0); } 95% { transform: translate(6px, 0); clip-path: inset(48% 0 30% 0); } 98% { transform: translate(-4px, 0); clip-path: inset(8% 0 70% 0); } }

.tagline { font: 700 clamp(14px, 2.6vw, 20px) var(--head); letter-spacing: 0.7em; padding-left: 0.7em; color: var(--dim); }
.lede { margin: 22px auto 0; max-width: 460px; font-size: clamp(17px, 2.6vw, 20px); line-height: 1.45; color: var(--dim); }

.cta {
  position: relative; margin-top: 34px; padding: 18px 44px; border: 0; background: transparent; color: #fff;
  font: 700 clamp(14px, 2.6vw, 17px) var(--head); letter-spacing: 0.3em; text-indent: 0.3em;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
  background: linear-gradient(100deg, rgba(25, 243, 255, 0.22), rgba(255, 43, 214, 0.22));
  box-shadow: inset 0 0 0 1px var(--cyan), 0 0 40px rgba(25, 243, 255, 0.35);
  transition: transform 0.2s, background 0.2s;
}
.cta:not(:disabled) { animation: ctaPulse 2.2s ease-in-out infinite; }
.cta:not(:disabled):hover { transform: scale(1.05); background: linear-gradient(100deg, rgba(25, 243, 255, 0.45), rgba(255, 43, 214, 0.45)); }
.cta:disabled { opacity: 0.55; cursor: wait; }
@keyframes ctaPulse { 50% { box-shadow: inset 0 0 0 1px var(--mag), 0 0 56px rgba(255, 43, 214, 0.5); } }
.hint { margin-top: 20px; font: 600 12px var(--head); letter-spacing: 0.32em; color: rgba(200, 230, 255, 0.45); }
.keys { margin-top: 30px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; font-size: 15px; color: var(--dim); }
.keys span { display: inline-flex; align-items: center; gap: 8px; }
kbd {
  font: 700 12px var(--head); min-width: 26px; padding: 4px 8px; text-align: center; color: var(--cyan);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: rgba(25, 243, 255, 0.08);
}

/* ── HUD ── */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; opacity: 0; transition: opacity 1.4s ease 0.6s; }
#hud.on { opacity: 1; }
#hud > * { pointer-events: auto; }
#hud > #brand, #hud > #autopilot, #hud > #helpHint, #hud > #touch { pointer-events: none; }

#brand { position: absolute; top: 18px; left: 22px; display: flex; flex-direction: column; text-shadow: 0 0 14px rgba(25, 243, 255, 0.6); }
#brand b { font: 900 24px var(--head); letter-spacing: 0.22em; }
#brand span { font: 600 11px var(--head); letter-spacing: 0.5em; color: var(--cyan); margin-top: 4px; }

#dest { position: absolute; top: 16px; right: 16px; width: 230px; padding: 10px 12px 12px; }
#destToggle { width: 100%; display: flex; justify-content: space-between; background: none; border: 0; padding: 4px 4px 8px; font: 700 12px var(--head); letter-spacing: 0.3em; color: var(--cyan); text-align: left; }
#destToggle em { font-style: normal; transition: transform 0.2s; }
#dest.closed #destToggle em { transform: rotate(-90deg); }
#dest.closed #destList { display: none; }
#destList { list-style: none; display: grid; gap: 4px; }
#destList li { display: flex; align-items: stretch; gap: 4px; }
.dest-go {
  flex: 1; display: flex; align-items: center; gap: 10px; padding: 9px 10px; text-align: left; background: rgba(255, 255, 255, 0.04); border: 1px solid transparent;
  font: 700 15px var(--body); letter-spacing: 0.12em; text-transform: uppercase; transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.dest-go:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--c, var(--cyan)); transform: translateX(-3px); }
.dest-go i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); flex: none; }
.dest-open { width: 36px; display: grid; place-items: center; text-decoration: none; color: var(--dim); background: rgba(255, 255, 255, 0.04); border: 1px solid transparent; font-size: 16px; transition: 0.15s; }
.dest-open:hover { color: #fff; border-color: var(--c); background: rgba(255, 255, 255, 0.1); }

#radarBox { position: absolute; left: 16px; bottom: 16px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
#radar { width: 160px; height: 160px; display: block; border-radius: 50%; }
#telemetry { display: flex; justify-content: space-between; gap: 6px; font: 600 9px var(--head); letter-spacing: 0.04em; color: var(--dim); white-space: nowrap; }
#telemetry b { color: var(--cyan); font-weight: 700; margin-left: 2px; }

#player { position: absolute; right: 16px; bottom: 16px; width: 300px; padding: 12px 14px; display: grid; gap: 10px; }
#np { display: flex; align-items: center; gap: 12px; min-width: 0; }
#spectrum { width: 64px; height: 30px; flex: none; }
#npText { min-width: 0; display: flex; flex-direction: column; }
#npTitle { font: 700 14px var(--head); letter-spacing: 0.08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#npSub { font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.06em; }
#ctrls { display: flex; align-items: center; gap: 6px; }
#ctrls button { width: 36px; height: 32px; background: rgba(255, 255, 255, 0.05); border: 1px solid transparent; font-size: 14px; transition: 0.15s; }
#ctrls button:hover { border-color: var(--cyan); background: rgba(25, 243, 255, 0.12); }
#vol { flex: 1; min-width: 0; accent-color: var(--cyan); height: 4px; }

#prompt {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; padding: 12px 22px;
  background: rgba(6, 4, 22, 0.78); border: 1px solid var(--c, var(--cyan)); color: #fff; font: 700 15px var(--head); letter-spacing: 0.2em;
  box-shadow: 0 0 34px color-mix(in srgb, var(--c, var(--cyan)) 55%, transparent), inset 0 0 20px color-mix(in srgb, var(--c, var(--cyan)) 18%, transparent);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  animation: promptIn 0.25s ease-out;
}
#prompt kbd { color: var(--c, var(--cyan)); border-color: var(--c, var(--cyan)); }
@keyframes promptIn { from { opacity: 0; transform: translate(-50%, 10px); } }

#autopilot { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); display: none; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
#autopilot.on { display: flex; }
#autopilot span { font: 700 13px var(--head); letter-spacing: 0.35em; color: var(--cyan); text-shadow: 0 0 14px var(--cyan); animation: blink 1.4s infinite; }
#autopilot em { font: normal 600 11px var(--head); letter-spacing: 0.3em; color: var(--dim); }

#helpHint { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 22px; font-size: 15px; color: var(--dim); transition: opacity 1s; white-space: nowrap; }
#helpHint.off { opacity: 0; }
#helpHint span { display: inline-flex; align-items: center; gap: 8px; }

/* ── MODAL ── */
#modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(2, 1, 8, 0.72); backdrop-filter: blur(6px); animation: fade 0.25s; }
@keyframes fade { from { opacity: 0; } }
.modal-card { position: relative; max-width: min(92vw, 760px); max-height: 90vh; overflow: auto; padding: 34px 38px; background: rgba(8, 6, 28, 0.9); }
#modalClose { position: absolute; top: 12px; right: 18px; background: none; border: 0; font-size: 20px; color: var(--dim); }
#modalClose:hover { color: var(--mag); }
.m-eyebrow { font: 700 12px var(--head); letter-spacing: 0.4em; color: var(--mag); }
.m-title { margin: 8px 0 18px; font: 900 clamp(22px, 4vw, 32px) var(--head); letter-spacing: 0.1em; }
.m-text p { margin-bottom: 14px; font-size: 20px; line-height: 1.5; color: var(--dim); }
.m-btn { display: inline-block; margin-top: 8px; padding: 12px 24px; border: 1px solid var(--cyan); color: #fff; text-decoration: none; font: 700 14px var(--head); letter-spacing: 0.2em; background: rgba(25, 243, 255, 0.12); }
.m-btn:hover { background: rgba(25, 243, 255, 0.3); }
.m-art { display: block; max-width: 100%; max-height: 68vh; margin: 0 auto; border: 1px solid var(--line); box-shadow: 0 0 60px rgba(25, 243, 255, 0.25); }

#fallback { position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 24px; text-align: center; background: var(--bg); }
#fallback h2 { font: 900 24px var(--head); letter-spacing: 0.1em; }
#fallback ul { list-style: none; display: grid; gap: 10px; }
#fallback a { display: block; padding: 12px 28px; border: 1px solid var(--cyan); color: #fff; text-decoration: none; font: 700 15px var(--head); letter-spacing: 0.2em; }

/* ── TOUCH CONTROLS ── */
#touch { display: none; }
#stick { position: absolute; left: 22px; bottom: calc(96px + var(--safe-b)); width: 120px; height: 120px; border-radius: 50%; border: 1px solid var(--line); background: rgba(8, 6, 28, 0.45); pointer-events: auto; touch-action: none; }
#stick i { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: radial-gradient(circle, rgba(25, 243, 255, 0.7), rgba(25, 243, 255, 0.15)); box-shadow: 0 0 20px rgba(25, 243, 255, 0.5); }
#tbtns { position: absolute; right: 18px; bottom: calc(96px + var(--safe-b)); display: grid; grid-template-columns: 1fr 1fr; gap: 10px; pointer-events: auto; }
#tbtns button { width: 64px; height: 56px; border: 1px solid var(--line); background: rgba(8, 6, 28, 0.55); font: 700 13px var(--head); touch-action: none; user-select: none; -webkit-user-select: none; }
#tbtns #tBoost { grid-column: 1 / 3; width: 100%; border-color: var(--mag); color: var(--mag); }
#tbtns button.held { background: rgba(25, 243, 255, 0.35); }

/* ── small / touch screens ── */
@media (max-width: 760px), (pointer: coarse) {
  #brand { top: 12px; left: 14px; } #brand b { font-size: 18px; }
  #dest { top: 10px; right: 10px; width: 190px; padding: 8px 10px; }
  #dest.closed { width: 150px; }
  #radarBox { left: 10px; top: 64px; bottom: auto; padding: 6px; }
  #radar { width: 96px; height: 96px; }
  #telemetry { display: none; }
  #player { left: 0; right: 0; bottom: 0; width: 100%; padding: 8px 12px calc(8px + var(--safe-b)); clip-path: none; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-width: 1px 0 0; }
  #vol, #bMute { display: none; }
  #prompt { bottom: calc(230px + var(--safe-b)); }
  #helpHint { display: none; }
  #autopilot { top: 60px; }
}
@media (pointer: coarse) { #touch { display: block; } #prompt { padding: 16px 30px; font-size: 16px; } }

/* phones in landscape: short screen, so shrink and re-flow everything */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  #brand b { font-size: 15px; } #brand span { font-size: 9px; letter-spacing: 0.4em; }
  #radarBox { top: 52px; left: 8px; }
  #radar { width: 80px; height: 80px; }
  #dest { top: 8px; right: 8px; width: 170px; padding: 6px 8px 8px; }
  #destToggle { padding: 2px 4px 5px; font-size: 10px; }
  #destList { gap: 3px; }
  .dest-go { padding: 5px 8px; font-size: 13px; }
  .dest-open { width: 30px; }
  #player { left: auto; right: 0; bottom: 0; width: 46%; min-width: 300px; grid-template-columns: minmax(0, 1fr) auto; padding: 4px 10px calc(4px + var(--safe-b)); }
  #spectrum { width: 40px; height: 22px; }
  #stick { width: 104px; height: 104px; left: 18px; bottom: calc(14px + var(--safe-b)); }
  #stick i { width: 46px; height: 46px; margin: -23px 0 0 -23px; }
  #tbtns { right: 14px; bottom: calc(62px + var(--safe-b)); gap: 8px; }
  #tbtns button { width: 56px; height: 46px; }
  #prompt { bottom: calc(70px + var(--safe-b)); padding: 12px 24px; }
  .intro-inner { max-width: 760px; } #introTitle { font-size: clamp(48px, 12vh, 90px); }
  .lede, .keys, .hint { display: none; } .cta { margin-top: 18px; }
}
/* while the nav menu is open on touch devices, tuck the flight buttons away */
@media (pointer: coarse) { #hud:has(#dest:not(.closed)) #tbtns { visibility: hidden; } }
/* very small phones */
@media (max-width: 380px) { #dest { width: 160px; } #dest:not(.closed) { width: 180px; } .dest-go { font-size: 14px; } }
@media (max-width: 760px) { #dest:not(.closed) { width: 200px; } }
@media (prefers-reduced-motion: reduce) { #introTitle::before, #introTitle::after { animation: none; } }
