:root {
  --bg: #070a12;
  --edge-rgb: 0, 0, 0; /* fixed black under the home-indicator strip on phones */
  --glass: rgba(13, 19, 33, 0.72);
  --glass-2: rgba(22, 31, 52, 0.78);
  --line: rgba(255, 255, 255, 0.1);
  --text: #eaf2ff;
  --muted: #8d9bb8;
  --cyan: #5ec8ff;
  --amber: #ffb02e;
  --orange: #ff7a2e;
  --green: #43e08b;
  --red: #ff5a5a;
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  /* --safe-b-min: floor set by index.html for iPhone home-screen apps, where iOS can report a 0 inset */
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--safe-b-min, 0px));
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font-head: 'Orbitron', 'Segoe UI', system-ui, sans-serif;
  --font-ui: 'Rajdhani', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: rgb(var(--edge-rgb)); color: var(--text); font-family: var(--font-ui); font-weight: 600; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
/* absolute, not fixed: iOS 26 standalone apps leave a bottom gap under viewport-sized *fixed* layers */
body { position: relative; overflow: visible; } /* the root still clips; body must not cut the canvas short */
canvas#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
/* Fill the large viewport so the 3D scene also runs behind Safari's floating toolbar instead of leaving a black strip
   (the HUD stays in the visible area, so no control ends up under the toolbar). */
@supports (height: 100lvh) { canvas#scene { bottom: auto; height: 100lvh; } }
/* Hides the browser/home-indicator band on phones: a fade that matches the scene's bottom colour. */
#edge { display: none; position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--safe-b) + 14px); pointer-events: none;
  background: linear-gradient(to top, rgb(var(--edge-rgb)) 0, rgb(var(--edge-rgb)) var(--safe-b), rgba(var(--edge-rgb), 0) 100%); }
svg { width: 1em; height: 1em; fill: currentColor; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

#ui { position: absolute; inset: 0; pointer-events: none; }
/* Backgrounds that touch the bottom (modal veils, the phone sheet) bleed past it so no unfiltered strip of the scene
   shows under the home indicator / Safari's toolbar; their content stays above it (padding of the same amount).
   Only the backgrounds bleed: the UI layer itself keeps the visible size so no control is cut off. */
:root { --bleed: 160px; }
.screen.modal-bg { bottom: calc(-1 * var(--bleed)); padding-bottom: var(--bleed); }
.screen { position: absolute; inset: 0; display: none; pointer-events: none; }
.screen.active { display: block; }
.screen.center.active { display: flex; align-items: center; justify-content: center; flex-direction: column; }
.screen > * { pointer-events: auto; }
.modal-bg { background: radial-gradient(ellipse at center, rgba(3, 6, 14, 0.55), rgba(3, 6, 14, 0.85)); backdrop-filter: blur(6px); pointer-events: auto; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.92) translateY(10px); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* ---- logo / title ------------------------------------------------------ */
.logo-big { font-family: var(--font-head); font-weight: 800; font-size: clamp(34px, 8vw, 72px); letter-spacing: 0.06em; text-shadow: 0 0 40px rgba(94, 200, 255, 0.45); }
.logo-big span { background: linear-gradient(180deg, #fff, #5ec8ff 70%); -webkit-background-clip: text; background-clip: text; color: transparent; margin-left: 0.12em; }
#loading { background: radial-gradient(ellipse at 50% 30%, #101c3a, #05070d 70%); pointer-events: auto; gap: 18px; z-index: 5; }
.loadbar { width: min(320px, 70vw); height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), var(--amber)); transition: width 0.3s; }
#title { background: linear-gradient(180deg, rgba(5, 8, 16, 0.55), rgba(5, 8, 16, 0) 38%, rgba(5, 8, 16, 0) 60%, rgba(5, 8, 16, 0.7)); }
.title-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(7vh + var(--safe-t)) 24px calc(6vh + var(--safe-b)); text-align: center; pointer-events: none; }
.title-top, .title-bottom { display: flex; flex-direction: column; align-items: center; gap: 18px; pointer-events: none; }
.title-bottom > * { pointer-events: auto; }
.tagline { margin: 0; font-size: clamp(16px, 2.6vw, 22px); color: #c4d4f2; letter-spacing: 0.04em; }
.title-version { position: absolute; left: 0; right: 0; bottom: calc(10px + var(--safe-b)); text-align: center; font-size: 12px; letter-spacing: 0.08em; color: var(--muted); opacity: 0.7; pointer-events: none; }
.title-auth { min-height: 44px; display: flex; align-items: center; justify-content: center; }

/* ---- buttons / chips --------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 20px; border-radius: 14px; background: var(--glass-2); border: 1px solid var(--line); font-weight: 700; font-size: 18px; letter-spacing: 0.04em; transition: transform 0.12s, background 0.15s, border-color 0.15s, box-shadow 0.15s; }
.btn:hover { background: rgba(40, 56, 92, 0.9); border-color: rgba(255, 255, 255, 0.22); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(180deg, #3fb2ff, #1f7bff); border-color: #8fd4ff; box-shadow: 0 6px 24px rgba(40, 140, 255, 0.4); }
.btn.primary:hover { background: linear-gradient(180deg, #5fc0ff, #3a8bff); }
.btn.big { padding: 16px 34px; font-size: 24px; border-radius: 18px; font-family: var(--font-head); font-size: 20px; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { border-color: rgba(255, 90, 90, 0.5); color: #ff9a9a; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn svg { font-size: 1.2em; }
.chip { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(10px); font-size: 20px; }
.chip.btn-chip { cursor: pointer; font-size: 17px; }
.chip.btn-chip:hover { background: var(--glass-2); }
.chip.icon { padding: 8px 10px; }
.chip svg { font-size: 1.15em; }
.chip.coins b { font-family: var(--font-head); font-size: 0.92em; letter-spacing: 0.04em; color: #ffe08a; }
.chip.coins svg { filter: drop-shadow(0 0 6px rgba(255, 201, 51, 0.6)); }
.chip .avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.chip.bump { animation: bump 0.3s; }
@keyframes bump { 50% { transform: scale(1.12); } }

/* ---- hangar ------------------------------------------------------------ */
.topbar { position: absolute; top: calc(12px + var(--safe-t)); left: calc(16px + var(--safe-l)); right: calc(16px + var(--safe-r)); display: flex; align-items: center; gap: 14px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { font-family: var(--font-head); font-weight: 800; font-size: 18px; letter-spacing: 0.1em; margin-right: auto; text-shadow: 0 0 18px rgba(94, 200, 255, 0.4); }
.brand span { color: var(--cyan); margin-left: 0.1em; }
.topright { display: flex; gap: 8px; }
.topbar .coins { position: absolute; left: 50%; transform: translateX(-50%); }

.panel { position: absolute; right: calc(16px + var(--safe-r)); top: calc(70px + var(--safe-t)); bottom: calc(112px + var(--safe-b)); width: min(400px, 42vw); display: flex; flex-direction: column; background: var(--glass); border: 1px solid var(--line); border-radius: 20px; backdrop-filter: blur(16px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); overflow: hidden; }
.tabs { display: flex; padding: 8px; gap: 6px; border-bottom: 1px solid var(--line); }
.tab { flex: 1; padding: 10px 6px; border-radius: 12px; font-size: 16px; font-weight: 700; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; transition: 0.15s; }
.tab:hover { color: var(--text); }
.tab.active { background: rgba(94, 200, 255, 0.16); color: #fff; box-shadow: inset 0 0 0 1px rgba(94, 200, 255, 0.45); }
.panel-body > * { flex: none; }
.panel-body { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: #2a3a5c transparent; }

.card-up { position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: linear-gradient(180deg, rgba(30, 42, 70, 0.7), rgba(18, 26, 44, 0.7)); border: 1px solid var(--line); animation: pop 0.3s both; }
.card-up .ic { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 28px; background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.02)); border: 1px solid var(--line); color: var(--ic, var(--cyan)); }
.card-up .nm { font-size: 19px; font-weight: 700; letter-spacing: 0.03em; }
.card-up .ds { font-size: 14px; color: var(--muted); line-height: 1.15; margin: 1px 0 6px; font-weight: 500; }
.pips-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-bottom: 5px; }
.pips-row .lv { margin-left: auto; font-size: 12px; color: var(--muted); letter-spacing: 0.08em; white-space: nowrap; }
.pips { display: flex; gap: 2px; flex-wrap: wrap; }
.pips i { flex: none; width: 6px; height: 7px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); }
.pips i.on { background: var(--ic, var(--cyan)); box-shadow: 0 0 6px var(--ic, var(--cyan)); }
.card-up .st { font-size: 14px; color: #b9c9ea; }
.card-up .st b { color: #fff; }
.card-up .st .nx { color: var(--green); }
.buy { min-width: 96px; padding: 10px 12px; border-radius: 12px; background: linear-gradient(180deg, #ffbe3a, #ff8a1f); color: #2a1600; font-weight: 800; font-size: 17px; display: flex; flex-direction: column; align-items: center; gap: 0; line-height: 1.05; box-shadow: 0 4px 16px rgba(255, 150, 30, 0.3); transition: 0.12s; }
.buy small { font-size: 11px; letter-spacing: 0.1em; opacity: 0.75; }
.buy .cost { display: flex; align-items: center; gap: 4px; font-family: var(--font-head); font-size: 14px; }
.buy:hover { filter: brightness(1.1); }
.buy:active { transform: scale(0.96); }
.buy[disabled], .buy.cant { background: rgba(255, 255, 255, 0.08); color: #8d9bb8; box-shadow: none; cursor: not-allowed; }
.buy.max { background: rgba(67, 224, 139, 0.15); color: var(--green); box-shadow: inset 0 0 0 1px rgba(67, 224, 139, 0.4); cursor: default; }
.card-up.flash { animation: cardflash 0.6s; }
.buy.max.locked { background: rgba(255, 255, 255, 0.06); color: #8d9bb8; box-shadow: inset 0 0 0 1px var(--line); }
.pips.grouped { gap: 3px 5px; min-width: 0; }
.pips.grouped i { width: 5px; }
.pips .g { display: flex; gap: 2px; }
.pips i.lock { background: transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
.card-up .mk { font-size: 13px; color: #b9c9ea; line-height: 1.2; margin: 1px 0 6px; font-weight: 500; }
.card-up .mk b { color: var(--ic, var(--cyan)); font-family: var(--font-head); font-size: 12px; letter-spacing: 0.06em; margin-right: 3px; }
.card-up .mk .nx { color: var(--muted); }
.card-up .mk em { font-style: normal; color: #dfe9ff; }
.tier-card { position: relative; display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: linear-gradient(135deg, rgba(60, 90, 160, 0.55), rgba(24, 34, 60, 0.75)); border: 1px solid rgba(140, 190, 255, 0.35); animation: pop 0.3s both; }
.tier-card.ready { border-color: rgba(255, 200, 80, 0.7); box-shadow: 0 0 22px rgba(255, 180, 60, 0.18); }
.tier-card.flash { animation: cardflash 0.8s; }
.tier-badge { width: 58px; height: 58px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.04)); border: 1px solid rgba(255, 255, 255, 0.25); }
.tier-badge small { font-size: 10px; letter-spacing: 0.18em; color: var(--muted); }
.tier-badge b { font-family: var(--font-head); font-size: 24px; color: #fff; text-shadow: 0 0 12px rgba(120, 190, 255, 0.8); }
.tier-name { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; letter-spacing: 0.03em; }
.tier-stack { display: flex; flex-direction: column-reverse; gap: 2px; margin-left: auto; }
.tier-stack i { width: 16px; height: 5px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); }
.tier-stack i.on { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.tier-prog { position: relative; height: 14px; border-radius: 7px; background: rgba(0, 0, 0, 0.35); margin: 6px 0 5px; overflow: hidden; }
.tier-prog i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #5ec8ff, #ffd23a); border-radius: 7px; }
.tier-prog em { position: absolute; inset: 0; text-align: center; font-style: normal; font-size: 11px; font-weight: 700; line-height: 14px; letter-spacing: 0.08em; text-shadow: 0 1px 2px #000; }
.tier-sub { font-size: 13px; color: #b9c9ea; line-height: 1.2; }
.tier-sub b { color: #fff; }
.tier-sub b.ok { color: #ffd23a; }
.tier-buy small { display: flex; align-items: center; gap: 3px; }
.toast.gold { color: #ffd23a; border-color: rgba(255, 210, 60, 0.6); }
@keyframes cardflash { 0% { box-shadow: 0 0 0 0 rgba(94, 200, 255, 0.8); } 100% { box-shadow: 0 0 0 18px rgba(94, 200, 255, 0); } }

.dest { padding: 0; overflow: hidden; display: block; grid-template-columns: none; }
.dest .hero { height: 96px; position: relative; display: flex; align-items: flex-end; padding: 10px 14px; background-size: cover; }
.dest .hero h3 { margin: 0; font-family: var(--font-head); font-size: 22px; letter-spacing: 0.08em; text-shadow: 0 2px 10px #000a; }
.dest .hero .pad { position: absolute; right: 12px; top: 10px; font-size: 13px; color: #fff; background: #0007; padding: 2px 8px; border-radius: 99px; }
.dest .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.dest .bl { font-size: 15px; color: #b9c9ea; font-weight: 500; }
.dest .prog { height: 7px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.dest .prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--amber)); }
.dest .meta { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.dest .meta b { color: #fff; }
.dest.current { box-shadow: 0 0 0 2px var(--cyan); }
.dest .lockline { display: flex; align-items: center; gap: 8px; font-size: 15px; color: #ffd28a; }
.hero.earth { background: radial-gradient(circle at 70% 120%, #3a8c4a 0 24%, transparent 25%), linear-gradient(180deg, #1c63c8, #8ccaff); }
.hero.moon { background: radial-gradient(circle at 75% 130%, #8e8c88 0 30%, transparent 31%), radial-gradient(circle at 20% 25%, #2a58b0 0 9%, transparent 10%), linear-gradient(180deg, #02030a, #151a30); }
.hero.mars { background: radial-gradient(circle at 70% 130%, #a8452a 0 30%, transparent 31%), linear-gradient(180deg, #5a3646, #f0a874); }

.stat-chips { position: absolute; left: calc(16px + var(--safe-l)); top: calc(70px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.stat-chips .sc { display: flex; align-items: center; gap: 8px; padding: 5px 12px; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; font-size: 15px; backdrop-filter: blur(8px); }
.stat-chips .sc svg { color: var(--ic, var(--cyan)); }
.stat-chips .sc b { margin-left: auto; padding-left: 14px; font-family: var(--font-head); font-size: 13px; }
.stat-chips .sc span { color: var(--muted); }

.launchbar { position: absolute; left: 0; right: 0; bottom: calc(18px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding-right: min(420px, 44vw); }
.launchbar > * { pointer-events: auto; }
.site-line { display: flex; align-items: center; gap: 10px; font-size: 17px; padding: 4px 14px; background: var(--glass); border: 1px solid var(--line); border-radius: 99px; backdrop-filter: blur(8px); }
.site-line i { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); }
.btn.launch { min-width: 260px; background: linear-gradient(180deg, #ffb83a, #ff6a1f); border-color: #ffd9a0; color: #2a1000; box-shadow: 0 8px 36px rgba(255, 110, 30, 0.5); }
.btn.launch:hover { filter: brightness(1.1); background: linear-gradient(180deg, #ffc65a, #ff7a2f); }

/* ---- flight HUD -------------------------------------------------------- */
#hud { font-family: var(--font-ui); }
#hud > * { pointer-events: none; }
#hud .chip.btn-chip, #hud .engine-btn, #hud #btn-meter { pointer-events: auto; }
.hud-top { position: absolute; top: calc(10px + var(--safe-t)); left: calc(14px + var(--safe-l)); right: calc(14px + var(--safe-r)); display: flex; align-items: flex-start; gap: 14px; }
.alt-num { display: flex; align-items: baseline; gap: 6px; text-shadow: 0 2px 12px #0008; }
.alt-num b { font-family: var(--font-head); font-size: clamp(30px, 6vw, 46px); font-weight: 800; letter-spacing: 0.02em; }
.alt-num small { font-size: 18px; color: var(--cyan); font-weight: 700; }
.alt-zone { font-size: 15px; letter-spacing: 0.18em; text-transform: uppercase; color: #c4d4f2; text-shadow: 0 1px 6px #0009; }
.goalbar { flex: 1; max-width: 360px; margin: 6px auto 0; }
.goal-label { display: flex; justify-content: space-between; font-size: 14px; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 4px; text-shadow: 0 1px 6px #0009; }
.goal-track { position: relative; height: 8px; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line); border-radius: 8px; overflow: visible; }
.goal-track i { display: block; height: 100%; width: 0; border-radius: 8px; background: linear-gradient(90deg, var(--cyan), var(--amber)); box-shadow: 0 0 10px rgba(94, 200, 255, 0.6); }
.goal-track em { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; margin-left: -9px; transform: translateY(-50%); background: #fff; box-shadow: 0 0 12px #fff, 0 0 4px var(--cyan); left: 0; }
.hud-right { display: flex; gap: 8px; align-items: center; }

.gauges { position: absolute; left: calc(14px + var(--safe-l)); top: 50%; transform: translateY(-40%); display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.gauge.fuel { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 8px; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); font-size: 22px; color: #ff9a6a; }
.gauge.fuel b { font-family: var(--font-head); font-size: 12px; color: #fff; }
.gtrack { width: 12px; height: clamp(90px, 22vh, 190px); background: rgba(255, 255, 255, 0.1); border-radius: 8px; position: relative; overflow: hidden; }
.gtrack i { position: absolute; left: 0; right: 0; bottom: 0; height: 100%; background: linear-gradient(0deg, #ff5a2a, #ffd23a); border-radius: 8px; transition: height 0.08s linear; }
.gauge.fuel.low { animation: lowfuel 0.6s infinite; }
@keyframes lowfuel { 50% { box-shadow: 0 0 22px rgba(255, 70, 40, 0.8); border-color: #ff5a5a; } }
.hull { display: flex; flex-direction: column; gap: 5px; padding: 8px; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); }
.hull i { width: 22px; height: 22px; display: block; background: var(--green); clip-path: polygon(50% 0, 100% 18%, 100% 58%, 50% 100%, 0 58%, 0 18%); box-shadow: 0 0 10px var(--green); }
.hull i.off { background: rgba(255, 255, 255, 0.14); box-shadow: none; }
.hull i.hurt { animation: hurt 0.5s; }
@keyframes hurt { 0%, 60% { background: var(--red); transform: scale(1.4); } }
.speed { padding: 4px 10px; background: var(--glass); border: 1px solid var(--line); border-radius: 10px; font-size: 18px; display: flex; gap: 4px; align-items: baseline; }
.speed small { color: var(--muted); font-size: 12px; }

.banner { position: absolute; top: 21%; left: 0; right: 0; text-align: center; opacity: 0; transform: translateY(-14px) scale(0.96); transition: 0.35s; text-shadow: 0 4px 24px #000a; }
.banner.show { opacity: 1; transform: none; }
.banner .b-title { font-family: var(--font-head); font-weight: 800; font-size: clamp(26px, 6vw, 52px); letter-spacing: 0.12em; }
.banner .b-sub { font-size: clamp(14px, 2.4vw, 20px); letter-spacing: 0.28em; color: var(--cyan); text-transform: uppercase; margin-top: 4px; }
.banner.gold .b-title { color: #ffe07a; text-shadow: 0 0 30px rgba(255, 190, 40, 0.7); }
.banner.gold .b-sub { color: #fff; }
.banner.warn .b-title { color: #ff8a7a; }
.banner.warn .b-sub { color: #ffc2b8; }
.toasts { position: absolute; top: 40%; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { padding: 6px 16px; border-radius: 99px; background: var(--glass-2); border: 1px solid var(--line); font-size: 18px; letter-spacing: 0.1em; font-weight: 700; animation: toast 1.6s forwards; }
.toast.fuel { color: #ffb08a; border-color: rgba(255, 140, 90, 0.5); }
.toast.boost { color: #8ff0ff; border-color: rgba(94, 240, 255, 0.5); }
.toast.good { color: var(--green); border-color: rgba(67, 224, 139, 0.5); }
.toast.warn { color: #ffd28a; border-color: rgba(255, 190, 90, 0.5); }
@keyframes toast { 0% { opacity: 0; transform: translateY(10px) scale(0.9); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.combo { position: absolute; right: calc(18px + var(--safe-r)); top: 96px; font-family: var(--font-head); font-size: 22px; color: #ffe07a; text-shadow: 0 0 14px rgba(255, 190, 40, 0.8); opacity: 0; transition: opacity 0.2s; }
.combo.show { opacity: 1; }
.countdown { position: absolute; top: calc(34% - 90px); left: 0; right: 0; padding: 90px 0; pointer-events: none; text-align: center; font-family: var(--font-head); font-weight: 800; font-size: clamp(80px, 22vw, 190px); color: #fff; text-shadow: 0 0 60px rgba(94, 200, 255, 0.7); opacity: 0; }
.countdown.tick { animation: tick 0.9s ease-out; }
@keyframes tick { 0% { opacity: 0; transform: scale(1.8); } 20% { opacity: 1; } 100% { opacity: 0; transform: scale(0.8); } }
/* first-landing cinematic: letterbox bars, the flight HUD fades away */
.letterbox { position: absolute; left: 0; right: 0; height: 11vh; background: #000; transform: scaleY(0); transition: transform 0.6s ease; z-index: 0; }
.letterbox.top { top: 0; transform-origin: top; }
.letterbox.bot { bottom: 0; transform-origin: bottom; }
#hud.cinematic .letterbox { transform: scaleY(1); }
.hud-top, .gauges, .controls { transition: opacity 0.4s; }
#hud.cinematic .hud-top, #hud.cinematic .gauges, #hud.cinematic .controls, #hud.cinematic .combo, #hud.cinematic .fall-warn, #hud.cinematic .toasts, #hud.cinematic .speedup, #hud.cinematic .near { opacity: 0 !important; pointer-events: none !important; }
.fall-warn { position: absolute; top: 42%; left: 0; right: 0; text-align: center; font-family: var(--font-head); font-size: clamp(20px, 4vw, 34px); color: #ff6a5a; letter-spacing: 0.1em; opacity: 0; text-shadow: 0 0 24px rgba(255, 60, 40, 0.7); }
.fall-warn.show { opacity: 1; animation: blink 0.5s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.meter { position: absolute; left: 0; right: 0; bottom: calc(28px + var(--safe-b)); display: none; flex-direction: column; align-items: center; gap: 12px; }
.meter.show { display: flex; animation: pop 0.3s both; }
.meter-label { font-size: clamp(14px, 2.6vw, 20px); letter-spacing: 0.14em; text-shadow: 0 2px 10px #000a; text-align: center; padding: 0 16px; }
.meter-bar { position: relative; width: min(560px, 88vw); height: 34px; border-radius: 18px; background: linear-gradient(90deg, #321418, #3a2a14 50%, #14321f); border: 2px solid rgba(255, 255, 255, 0.35); box-shadow: 0 0 30px rgba(94, 200, 255, 0.35), inset 0 0 14px #0008; overflow: hidden; }
.zone { position: absolute; top: 0; bottom: 0; }
.zone.good { background: rgba(255, 214, 90, 0.5); }
.zone.great { background: rgba(120, 255, 130, 0.65); }
.zone.perfect { background: #fff; box-shadow: 0 0 18px #fff; }
.needle { position: absolute; top: -4px; bottom: -4px; width: 6px; margin-left: -3px; background: var(--cyan); border-radius: 4px; box-shadow: 0 0 14px var(--cyan), 0 0 3px #fff; }
#btn-meter { pointer-events: auto; min-width: 220px; }

.controls { position: absolute; left: 0; right: 0; bottom: calc(18px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.controls.hide { display: none; }
.steer-hint { font-size: 15px; color: #c4d4f2; letter-spacing: 0.06em; background: var(--glass); border-radius: 99px; padding: 4px 14px; border: 1px solid var(--line); transition: opacity 1s; }
.steer-hint span { color: var(--cyan); }
.engine-btn { display: flex; align-items: center; gap: 14px; padding: 12px 22px; border-radius: 20px; background: var(--glass); border: 2px solid rgba(255, 255, 255, 0.18); backdrop-filter: blur(10px); transition: 0.15s; min-width: 230px; }
.engine-btn:active { transform: scale(0.96); }
.eb-light { width: 22px; height: 22px; border-radius: 50%; background: var(--green); box-shadow: 0 0 16px var(--green); flex: none; }
.eb-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; margin-right: auto; }
.eb-text b { font-family: var(--font-head); font-size: 15px; letter-spacing: 0.14em; }
.eb-text small { font-size: 22px; font-weight: 700; color: var(--green); }
.engine-btn kbd { font-family: var(--font-ui); font-size: 12px; padding: 3px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line); color: var(--muted); }
.engine-btn.off { border-color: rgba(255, 90, 90, 0.6); }
.engine-btn.off .eb-light { background: var(--red); box-shadow: 0 0 16px var(--red); }
.engine-btn.off .eb-text small { color: var(--red); }
.engine-btn.empty { opacity: 0.55; }
@media (pointer: coarse) { .engine-btn kbd { display: none; } .engine-btn { padding: 14px 26px; } }
.stage-btn { border-color: rgba(94, 200, 255, 0.45); }
.sb-pips { display: flex; flex-direction: column-reverse; gap: 3px; flex: none; }
.sb-pips i { width: 20px; height: 7px; border-radius: 3px; background: rgba(255, 255, 255, 0.2); transition: 0.3s; }
.sb-pips i.cur { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.sb-pips i.gone { background: transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.stage-btn .eb-text small { color: var(--cyan); font-size: 17px; letter-spacing: 0.04em; }
.stage-btn.none, .stage-btn[disabled] { opacity: 0.5; border-color: rgba(255, 255, 255, 0.14); }
.stage-btn.none .eb-text small { color: var(--muted); }
.stage-btn.busy { border-color: rgba(255, 210, 120, 0.8); }
.stage-btn.busy .eb-text small { color: #ffd28a; }
.stage-btn.urgent { border-color: #ff9a3a; animation: stagePulse 0.7s infinite; }
.stage-btn.urgent .eb-text small { color: #ffb05a; }
.stage-btn.urgent .sb-pips i.cur { background: #ff9a3a; box-shadow: 0 0 12px #ff9a3a; }
@keyframes stagePulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 150, 60, 0.7); } 50% { box-shadow: 0 0 0 10px rgba(255, 150, 60, 0); transform: scale(1.04); } }

.hit-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(255, 40, 30, 0.38)); }
.hit-flash.on { animation: hitf 0.55s; }
@keyframes hitf { 0% { opacity: 1; } 100% { opacity: 0; } }
.surge-fx { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(80, 230, 255, 0.35)); transition: opacity 0.2s; }
.surge-fx.on { opacity: 1; }

/* ---- cards / modals ---------------------------------------------------- */
.card { width: min(440px, 92vw); max-height: 92vh; overflow: auto; padding: 22px; border-radius: 22px; background: linear-gradient(180deg, rgba(24, 34, 58, 0.96), rgba(12, 18, 32, 0.96)); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); display: flex; flex-direction: column; gap: 12px; animation: pop 0.3s both; }
.card h2 { margin: 0 0 4px; font-family: var(--font-head); letter-spacing: 0.1em; font-size: 22px; text-align: center; }
.card p { margin: 0; text-align: center; font-weight: 500; }
.row { display: flex; align-items: center; justify-content: space-between; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 18px; }
.row input[type='checkbox'] { width: 22px; height: 22px; accent-color: var(--cyan); }
.row select { background: #121a2c; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font: inherit; }
.help { font-size: 15px; color: #b9c9ea; font-weight: 500; }
.help b { color: #fff; font-size: 16px; }
.help ul { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 3px; }
.help em { color: var(--cyan); font-style: normal; font-weight: 700; }
.danger-row { border-bottom: 0; }
.acc-user { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.acc-user b { font-size: 20px; }
.acc-user:empty { display: none; }
.btn.signout { align-self: center; }

/* rocket avatars (the player's current rocket; never a Google photo) */
.rocket-avatar { width: 40px; height: 40px; object-fit: contain; flex: none; border-radius: 50%; background: radial-gradient(circle at 50% 40%, rgba(94, 200, 255, 0.28), rgba(94, 200, 255, 0.04) 70%); }
.rocket-avatar.big { width: 84px; height: 84px; align-self: center; box-shadow: inset 0 0 0 2px rgba(94, 200, 255, 0.5); }
.rocket-avatar:not([src]), .rocket-avatar.none { visibility: hidden; }
.chip .avatar.rocket-avatar { width: 26px; height: 26px; margin: -3px 0; }

/* pilot name */
.pilot-input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #0d1424; color: var(--text); font: inherit; font-size: 20px; text-align: center; user-select: text; -webkit-user-select: text; }
.pilot-input:focus { border-color: var(--cyan); outline: none; }
.pilot-input:disabled { opacity: 0.5; }
.pilot-err { min-height: 18px; color: #ff8a7a; font-size: 15px; text-align: center; }
.btn:disabled { opacity: 0.55; pointer-events: none; }

/* leaderboard */
.board-btn { font-family: var(--font-head); font-size: 15px; letter-spacing: 0.08em; }
.board { width: min(480px, 94vw); }
.board-tabs { padding: 0 0 8px; }
.board-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: min(52vh, 460px); overflow: auto; }
.board-row { display: grid; grid-template-columns: 34px 40px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.board-row .rk { font-family: var(--font-head); font-size: 16px; text-align: center; color: var(--muted); }
.board-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; }
.board-row .km { font-family: var(--font-head); font-size: 15px; color: var(--cyan); white-space: nowrap; }
.board-row.top1 .rk { color: #ffd23a; }
.board-row.top2 .rk { color: #d7e1f0; }
.board-row.top3 .rk { color: #e39a5b; }
.board-row.me { background: rgba(94, 200, 255, 0.14); border-color: rgba(94, 200, 255, 0.5); }
.board-me:empty { display: none; }
.board-me { padding-top: 6px; border-top: 1px dashed var(--line); }
.board-msg { padding: 18px 8px; text-align: center; color: var(--muted); font-weight: 500; }
#board-note:empty { display: none; }
#acc-google { display: flex; justify-content: center; min-height: 44px; }
.conflict-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.conflict { flex-direction: column; align-items: flex-start; gap: 4px; font-size: 14px; font-weight: 500; text-align: left; padding: 14px; }
.btn.conflict b { font-size: 20px; font-weight: 700; }

.results { gap: 10px; text-align: center; width: min(460px, 94vw); }
.res-head { font-family: var(--font-head); letter-spacing: 0.14em; font-size: 15px; color: var(--muted); text-transform: uppercase; }
.res-badge { min-height: 26px; font-family: var(--font-head); font-size: 15px; letter-spacing: 0.14em; color: #ffe07a; }
.res-badge.crash { color: #ff8a7a; }
.res-main { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.res-main b { font-family: var(--font-head); font-size: 54px; font-weight: 800; }
.res-main small { color: var(--cyan); font-size: 22px; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.res-grid div { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; font-size: 14px; color: var(--muted); }
.res-grid b { color: #fff; font-size: 20px; }
.res-earn { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 34px; padding: 6px; }
.res-earn svg { font-size: 1.1em; filter: drop-shadow(0 0 8px rgba(255, 201, 51, 0.7)); }
.res-earn b { font-family: var(--font-head); color: #ffe08a; }
.res-earn small { font-size: 14px; color: var(--muted); }
.res-unlock { min-height: 0; font-size: 16px; color: #ffd28a; }
.res-unlock.show { padding: 10px; border-radius: 12px; background: rgba(255, 176, 46, 0.12); border: 1px solid rgba(255, 176, 46, 0.4); }
.res-actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; margin-top: 4px; }

.toast-global { position: absolute; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 20; }

/* ---- mobile ------------------------------------------------------------ */
@media (max-width: 860px), (max-aspect-ratio: 1/1) {
  :root { --sheet-h: min(46vh, 430px); }
  .panel { top: auto; right: 0; left: 0; bottom: calc(-1 * var(--bleed)); width: auto; height: calc(var(--sheet-h) + var(--bleed)); border-radius: 22px 22px 0 0; padding-bottom: var(--bleed); border-left: 0; border-right: 0; border-bottom: 0; }
  /* the card list runs to the very bottom of the screen (no empty grey strip under it); its last card still
     scrolls clear of the home indicator */
  .panel .panel-body { padding-bottom: calc(12px + var(--safe-b)); }
  .stat-chips { display: none; }
  .launchbar { top: auto; bottom: calc(var(--sheet-h) + 14px); left: 0; right: 0; padding-right: 0; flex-direction: column; align-items: center; gap: 6px; }
  .site-line { font-size: 15px; padding: 2px 12px; }
  .btn.launch { min-width: 0; padding: 12px 34px; font-size: 18px; }
  .topbar .coins { position: static; transform: none; margin-left: auto; }
  .brand { margin-right: 0; font-size: 13px; letter-spacing: 0.06em; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: clip; flex: 0 1 auto; }
  #acc-label { display: none; }
  /* everything must fit on a 360-390px phone: tighter gaps, nothing pushed past the edge */
  .topbar { gap: 8px; left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); }
  .topbar .coins, .topright { flex: none; }
  .topright { display: flex; gap: 8px; }
  .topbar .chip { padding-left: 11px; padding-right: 11px; }
  .card-up { grid-template-columns: 44px minmax(0, 1fr) auto; padding: 10px; gap: 10px; }
  .card-up .ic { width: 44px; height: 44px; font-size: 24px; }
  .tier-card { grid-template-columns: 48px minmax(0, 1fr) auto; padding: 10px; gap: 10px; }
  .tier-badge { width: 48px; height: 48px; }
  .buy { min-width: 84px; }
  .goalbar { display: none; }
  .hud-top { gap: 8px; }
  .hud-right { margin-left: auto; }
  .gauges { transform: translateY(-50%); }
  .gtrack { height: clamp(80px, 16vh, 130px); }
  .meter-bar { width: 90vw; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .panel { top: calc(56px + var(--safe-t)); bottom: calc(80px + var(--safe-b)); width: min(380px, 46vw); right: calc(10px + var(--safe-r)); height: auto; padding-bottom: 0; left: auto; border-radius: 18px; border: 1px solid var(--line); }
  .panel .panel-body { padding-bottom: 12px; }
  .launchbar { top: auto; bottom: calc(10px + var(--safe-b)); padding-right: min(390px, 48vw); flex-direction: column; }
  .stat-chips { display: none; }
  .btn.big { padding: 10px 24px; }
  .gauges { top: 50%; bottom: auto; transform: translateY(-40%); flex-direction: column; align-items: flex-start; }
  .engine-btn { padding: 8px 16px; min-width: 180px; }
  .steer-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .btn.launch { animation: none; } }

/* ---- screen curtain (hangar <-> flight transition) ---------------------- */
#curtain { position: absolute; inset: 0; background: #03050b; opacity: 0; pointer-events: none; transition: opacity 0.38s ease; z-index: 30; }
#curtain.on { opacity: 1; pointer-events: auto; }

/* Results sit beside the action so the parachute descent stays visible behind the menu. */
#results.modal-bg { background: linear-gradient(90deg, rgba(3, 6, 14, 0) 25%, rgba(3, 6, 14, 0.55) 100%); backdrop-filter: none; }
#results.screen.center.active { align-items: center; justify-content: flex-end; padding: 0 0 calc(var(--safe-b) + 22px + var(--bleed)); }
@media (min-width: 900px) and (orientation: landscape) {
  #results.screen.center.active { align-items: flex-end; justify-content: center; padding: 0 6vw var(--bleed) 0; }
}
@media (orientation: portrait) {
  /* phones: card centred on screen, comfortably away from the bottom edge */
  #results.modal-bg { background: radial-gradient(ellipse at 50% 50%, rgba(3, 6, 14, 0.62) 30%, rgba(3, 6, 14, 0.25) 85%); }
  #results.screen.center.active { justify-content: center; padding: calc(var(--safe-t) + 12px) 0 calc(var(--safe-b) + 12px + var(--bleed)); }
}

/* #edge stays hidden: the scene runs edge to edge under the home indicator (thinnest possible strip) */
