:root {
  --bg: #04060b; --ink: #cfe9ff; --dim: #6f8aa6; --cy: #26e6ff; --mg: #ff35d8; --am: #ffb62e;
  --panel: rgba(8, 18, 32, .72); --line: rgba(120, 180, 230, .28);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; overscroll-behavior: none; touch-action: none; color: var(--ink); font-family: var(--mono); }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: #04060b; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: none; }
#brand { position: absolute; left: calc(14px + var(--sal)); top: calc(12px + var(--sat)); display: flex; gap: 10px; align-items: center; }
#brand .logo { width: 30px; height: 30px; border: 1px solid var(--line); background: rgba(10,24,40,.6); display: grid; place-items: center; font-weight: 800; font-size: 17px; }
#brand b { display: block; letter-spacing: .28em; font-size: 14px; }
#brand span { display: block; font-size: 7.5px; letter-spacing: .16em; color: var(--dim); margin-top: 2px; }
#gpu { position: absolute; right: calc(14px + var(--sar)); top: calc(12px + var(--sat)); display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); padding: 5px 10px; font-size: 9px; letter-spacing: .12em; }
#gpu i { width: 6px; height: 6px; border-radius: 50%; background: var(--cy); box-shadow: 0 0 8px var(--cy); }

#deck { position: absolute; right: calc(14px + var(--sar)); top: calc(48px + var(--sat)); width: min(250px, 66vw); background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: auto; }
#deck-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 11px 12px; letter-spacing: .16em; font-size: 10px; }
#deck-toggle b { font-size: 16px; color: var(--cy); }
#deck-body { padding: 4px 12px 12px; display: grid; gap: 10px; font-size: 9px; letter-spacing: .12em; color: var(--dim); }
#deck.collapsed #deck-body { display: none; }
#deck label { display: grid; gap: 6px; }
#deck input[type=range] { width: 100%; accent-color: var(--cy); }
.chips { display: flex; gap: 4px; }
.chips button { flex: 1; padding: 7px 0; border: 1px solid var(--line); font-size: 9px; letter-spacing: .1em; color: var(--ink); background: rgba(10,26,44,.5); }
.chips button.on { border-color: var(--cy); color: var(--cy); box-shadow: inset 0 0 12px rgba(38,230,255,.25); }
#deck .row { display: flex; gap: 6px; }
#deck .row button { flex: 1; padding: 8px 4px; border: 1px solid var(--line); color: var(--ink); font-size: 8.5px; letter-spacing: .08em; background: rgba(10,26,44,.5); }

#stats { position: absolute; left: calc(14px + var(--sal)); bottom: calc(10px + var(--sab)); display: flex; gap: 12px; font-size: 8px; letter-spacing: .14em; color: rgba(160,190,220,.6); }
#stats b { color: rgba(200,225,250,.9); font-weight: 600; }

#speedo { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(26px + var(--sab)); text-align: center; text-shadow: 0 0 14px rgba(38,230,255,.6); }
#speedo b { font-size: 40px; font-weight: 300; letter-spacing: .04em; }
#speedo span { font-size: 9px; letter-spacing: .3em; color: var(--dim); margin-left: 6px; }
#speedo em { display: block; font-style: normal; font-size: 9px; letter-spacing: .22em; color: var(--dim); margin-top: -2px; }

.pedal { position: absolute; bottom: calc(46px + var(--sab)); width: 112px; height: 112px; border-radius: 50%; pointer-events: auto !important; touch-action: none;
  border: 1px solid rgba(120,200,255,.35); background: radial-gradient(circle at 50% 35%, rgba(60,120,170,.28), rgba(8,16,28,.55)); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center; letter-spacing: .22em; font-size: 12px; font-weight: 700; color: var(--ink); box-shadow: 0 0 24px rgba(38,230,255,.12), inset 0 0 22px rgba(38,230,255,.1); }
#btn-gas { right: calc(22px + var(--sar)); }
#btn-brake { left: calc(22px + var(--sal)); }
#btn-gas span { color: var(--cy); } #btn-brake span { color: var(--mg); }
#btn-gas.down { background: radial-gradient(circle at 50% 35%, rgba(38,230,255,.55), rgba(8,40,60,.6)); box-shadow: 0 0 36px rgba(38,230,255,.6); transform: scale(.96); }
#btn-brake.down { background: radial-gradient(circle at 50% 35%, rgba(255,53,216,.5), rgba(50,8,44,.6)); box-shadow: 0 0 36px rgba(255,53,216,.55); transform: scale(.96); }

#fare { position: absolute; left: calc(14px + var(--sal)); top: calc(54px + var(--sat)); display: flex; align-items: baseline; gap: 8px; font-size: 9px; letter-spacing: .2em; color: var(--dim); }
#fare b { font-size: 18px; color: var(--am); letter-spacing: .06em; text-shadow: 0 0 10px rgba(255,182,46,.5); }
#mission { position: absolute; left: 50%; transform: translateX(-50%); top: calc(96px + var(--sat)); width: min(78vw, 320px); text-align: center; background: var(--panel); border: 1px solid var(--line); padding: 8px 12px 10px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#m-title { font-size: 10px; letter-spacing: .26em; color: var(--cy); }
#m-sub { font-size: 9px; letter-spacing: .1em; color: var(--ink); margin-top: 4px; min-height: 12px; }
#m-bar { height: 3px; background: rgba(120,180,230,.2); margin-top: 8px; display: none; }
#m-bar i { display: block; height: 100%; width: 0; background: var(--cy); box-shadow: 0 0 8px var(--cy); }
#mission.boarding #m-bar { display: block; }
#toast { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); text-align: center; font-size: 15px; letter-spacing: .24em; color: var(--am); text-shadow: 0 0 18px rgba(255,182,46,.7); opacity: 0; transition: opacity .35s; white-space: pre-line; }
#toast.show { opacity: 1; }
#edge-warn { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-size: 11px; letter-spacing: .3em; color: var(--mg); text-shadow: 0 0 14px var(--mg); animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

#marker { position: absolute; left: 0; top: 0; width: 0; height: 0; }
#marker-arrow { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border: 2px solid var(--am); transform: rotate(45deg); box-shadow: 0 0 16px var(--am), inset 0 0 8px rgba(255,182,46,.5); }
#marker.edge #marker-arrow { border-width: 0; border-top: 3px solid var(--am); border-right: 3px solid var(--am); width: 18px; height: 18px; left: -9px; top: -9px; box-shadow: none; filter: drop-shadow(0 0 6px var(--am)); }
#marker-label { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); white-space: nowrap; font-size: 9px; letter-spacing: .16em; color: var(--am); text-shadow: 0 0 8px #000; }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; transition: opacity .9s ease; }
#title.out { opacity: 0; pointer-events: none; }
#title-bg { position: absolute; inset: 0; background: #04060b url(assets/ui/hero.jpg) center/cover no-repeat; transition: opacity 1.2s ease; }
#title.live #title-bg { opacity: 0; }
#title::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(2,4,10,.55), rgba(2,4,10,0) 30%, rgba(2,4,10,0) 45%, rgba(2,4,10,.85)); pointer-events: none; }
#title-in { position: relative; z-index: 2; flex: 1; display: flex; flex-direction: column; align-items: center; padding: calc(60px + var(--sat)) 22px calc(28px + var(--sab)); }
.t-logo { font-size: clamp(34px, 11vw, 56px); font-weight: 800; letter-spacing: .26em; margin-right: -.26em; text-shadow: 0 0 24px rgba(38,230,255,.55), 0 0 60px rgba(255,53,216,.35); }
.t-logo em { font-style: normal; color: var(--am); text-shadow: 0 0 24px rgba(255,182,46,.7); }
.t-sub { margin-top: 10px; font-size: 9px; letter-spacing: .3em; color: var(--dim); text-align: center; }
.t-spacer { flex: 1; }
#load { width: min(300px, 80vw); text-align: center; margin-bottom: 18px; }
#load-bar { height: 3px; background: rgba(120,180,230,.2); } #load-bar i { display: block; height: 100%; width: 0; background: var(--cy); box-shadow: 0 0 10px var(--cy); transition: width .25s; }
#load-txt { margin-top: 10px; font-size: 9px; letter-spacing: .22em; color: var(--dim); }
#t-menu { width: min(340px, 90vw); display: grid; gap: 12px; }
.t-row { display: grid; gap: 6px; font-size: 8.5px; letter-spacing: .2em; color: var(--dim); }
#start { margin-top: 6px; padding: 17px 0; border: 1px solid var(--cy); color: var(--cy); font-size: 14px; font-weight: 700; letter-spacing: .34em; background: rgba(8,36,52,.55); box-shadow: 0 0 28px rgba(38,230,255,.35), inset 0 0 22px rgba(38,230,255,.15); animation: pulse 2s ease-in-out infinite; pointer-events: auto; }
@keyframes pulse { 50% { box-shadow: 0 0 44px rgba(38,230,255,.6), inset 0 0 28px rgba(38,230,255,.3); } }
.t-help { font-size: 9px; line-height: 1.6; letter-spacing: .06em; color: rgba(190,215,240,.7); text-align: center; }
.t-help b { color: var(--ink); }
#title .chips button { pointer-events: auto; }

#rotate { position: fixed; inset: 0; z-index: 50; background: rgba(2,4,10,.96); display: grid; place-content: center; text-align: center; letter-spacing: .1em; }
#rotate div { font-size: 54px; color: var(--cy); }
#fatal { position: fixed; inset: 0; z-index: 60; background: #04060b; padding: 40px 24px; font-size: 12px; line-height: 1.6; color: var(--mg); white-space: pre-wrap; overflow: auto; user-select: text; -webkit-user-select: text; touch-action: auto; }
