:root {
  --ink: #1d2b44;
  --ink-2: #4a5a74;
  --paper: #ffffff;
  --cream: #fff8ea;
  --sun: #ffc93c;
  --sun-deep: #e8a400;
  --coral: #ff6b5b;
  --coral-deep: #d9473a;
  --sky: #5fb4ee;
  --mint: #3ec28f;
  --mint-deep: #24996c;
  --line: rgba(29, 43, 68, 0.12);
  --shadow: 0 10px 30px rgba(20, 40, 80, 0.22);
  --display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #5fb4ee; color: var(--ink); font-family: var(--body); overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
svg { width: 1em; height: 1em; display: block; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.layer { position: absolute; inset: 0; display: none; pointer-events: none; }
.layer.on { display: block; }
.layer.on > * { pointer-events: auto; }

/* ---------------------------------------------------------------- top */
.top { position: absolute; top: calc(10px + var(--safe-t)); left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); display: flex; justify-content: space-between; align-items: center; pointer-events: none; z-index: 5; }
.top > * { pointer-events: auto; }
.wallet { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, 0.92); padding: 6px 16px 6px 8px; border-radius: 999px; box-shadow: 0 4px 0 rgba(29, 43, 68, 0.15), var(--shadow); font-family: var(--display); font-size: 24px; letter-spacing: 0.02em; min-width: 110px; }
.wallet .coin { width: 30px; height: 30px; }
.wallet.bump { animation: bump 0.35s ease; }
@keyframes bump { 40% { transform: scale(1.12); } }
.round { width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, 0.92); display: grid; place-items: center; box-shadow: 0 4px 0 rgba(29, 43, 68, 0.15), var(--shadow); }
.round svg { width: 22px; height: 22px; }
.round:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(29, 43, 68, 0.15); }

/* ------------------------------------------------------------- hangar */
.panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--cream); border-radius: 26px 26px 0 0; box-shadow: 0 -10px 40px rgba(20, 40, 80, 0.25); padding: 16px max(16px, var(--safe-l)) calc(14px + var(--safe-b)) max(16px, var(--safe-r)); display: flex; flex-direction: column; gap: 12px; transform: translateY(110%); transition: transform 0.45s cubic-bezier(.2, .9, .25, 1.1); }
.panel.on { transform: none; }
.plane-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.names { min-width: 0; }
.names h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.names h1.pop { animation: titlePop 0.6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes titlePop { 0% { transform: scale(0.6); color: var(--coral); } 60% { transform: scale(1.15); } }
.names p { margin: 2px 0 0; font-weight: 800; color: var(--ink-2); font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; }
.planes { display: flex; gap: 6px; }
.planes button { width: 40px; height: 40px; border-radius: 12px; background: #fff; box-shadow: 0 3px 0 var(--line); display: grid; place-items: center; font-family: var(--display); font-size: 16px; color: var(--ink-2); }
.planes button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.planes button svg { width: 22px; height: 22px; }

.route { display: flex; flex-direction: column; gap: 4px; }
.route-bar { position: relative; height: 14px; border-radius: 999px; background: #ece2cc; overflow: visible; }
.route-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--sky), #4b8fe0); transition: width 0.8s cubic-bezier(.2, .9, .3, 1); }
.route-ticks span { position: absolute; top: 3px; width: 2px; height: 8px; background: rgba(255, 255, 255, 0.85); border-radius: 2px; }
.route-ticks span.seen { background: rgba(29, 43, 68, 0.35); }
.route-best { position: absolute; top: -18px; width: 22px; height: 22px; margin-left: -4px; color: var(--coral); transition: left 0.8s cubic-bezier(.2, .9, .3, 1); }
.route-best svg { width: 22px; height: 22px; }
.res-route { align-self: stretch; padding: 14px 4px 2px; }
.res-route .route-fill { transition: width 1.1s cubic-bezier(.2, .9, .3, 1) 0.15s; }
.res-route .route-fill.prev { background: #d9cdb2; transition: none; }
.route-labels { display: flex; justify-content: space-between; font-weight: 800; font-size: 13px; color: var(--ink-2); }
.route-labels span:last-child { color: var(--ink); }

.shop { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.up { position: relative; background: #fff; border-radius: 16px; padding: 8px 6px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 4px 0 var(--line); text-align: center; min-width: 0; transition: transform 0.12s; }
.up .ic { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #fff; margin-bottom: 2px; }
.up .ic svg { width: 22px; height: 22px; }
.up[data-t="wings"] .ic { background: #4b8fe0; }
.up[data-t="tail"] .ic { background: #9b6bdf; }
.up[data-t="launch"] .ic { background: #3ec28f; }
.up[data-t="engine"] .ic { background: #ff6b5b; }
.up[data-t="fuel"] .ic { background: #f39c34; }
.up[data-t="gold"] .ic { background: linear-gradient(135deg, #ffd65c, #e8a400); }
.up .lbl { font-weight: 900; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.up .tier { font-weight: 800; font-size: 13px; line-height: 1.15; min-height: 2.3em; display: flex; align-items: center; justify-content: center; color: var(--ink); overflow: hidden; }
.up .pips { display: flex; gap: 3px; height: 6px; margin: 1px 0 1px; }
.up .pips i { width: 6px; height: 6px; border-radius: 50%; background: #e6dcc6; }
.up .pips i.on { background: var(--ink-2); }
.up .gain { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); white-space: nowrap; font-family: var(--display); font-size: 15px; color: #fff; background: var(--mint-deep); padding: 2px 9px; border-radius: 999px; pointer-events: none; animation: gainUp 1.2s ease-out forwards; z-index: 2; }
@keyframes gainUp { 0% { opacity: 0; transform: translate(-50%, 6px) scale(0.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -34px) scale(1); } }
.up .lv { position: absolute; top: 8px; right: 8px; font-family: var(--display); font-size: 13px; color: var(--ink-2); }
.up .new { position: absolute; top: -6px; left: -4px; background: var(--coral); color: #fff; font-weight: 900; font-size: 11px; letter-spacing: 0.06em; padding: 2px 7px; border-radius: 999px; transform: rotate(-8deg); }
.up .buy { margin-top: 4px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 5px; background: var(--mint); color: #fff; border-radius: 12px; padding: 7px 4px; font-family: var(--display); font-size: 17px; box-shadow: 0 4px 0 var(--mint-deep); letter-spacing: 0.02em; }
.up .buy .coin { width: 18px; height: 18px; }
.up .buy:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--mint-deep); }
.up.poor .buy { background: #d9d2c3; box-shadow: 0 4px 0 #bfb6a3; color: #7d7564; }
.up.max .buy { background: var(--ink); box-shadow: 0 4px 0 #0c1424; }
.up.can { animation: canBuy 1.6s ease-in-out infinite; }
@keyframes canBuy { 50% { transform: translateY(-2px); } }
.up.bought { animation: bought 0.5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bought { 30% { transform: scale(0.94); } 70% { transform: scale(1.06); } }

.fly { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--coral); color: #fff; font-family: var(--display); font-size: 30px; letter-spacing: 0.04em; padding: 12px; border-radius: 20px; box-shadow: 0 6px 0 var(--coral-deep), 0 10px 24px rgba(217, 71, 58, 0.35); }
.fly svg { width: 30px; height: 30px; }
.fly:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--coral-deep); }

@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .panel { left: auto; top: calc(70px + var(--safe-t)); right: 16px; bottom: 16px; width: 420px; border-radius: 26px; transform: translateX(120%); justify-content: flex-end; }
  .shop { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-height: 640px) and (max-aspect-ratio: 1/1) {
  .up .ic { display: none; }
  .names h1 { font-size: 24px; }
  .fly { font-size: 24px; padding: 9px; }
}

/* ------------------------------------------------------------- launch */
.back { position: absolute; top: calc(66px + var(--safe-t)); left: calc(12px + var(--safe-l)); }
.pull-hint { position: absolute; width: 56px; height: 56px; color: var(--ink); filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); animation: pull 1.8s ease-in-out infinite; pointer-events: none; }
.pull-hint svg { width: 56px; height: 56px; }
@keyframes pull { 0%, 15% { transform: translate(0, 0); opacity: 0; } 25% { opacity: 1; } 70% { transform: translate(-70px, 50px); opacity: 1; } 85%, 100% { transform: translate(-70px, 50px); opacity: 0; } }
.power { position: absolute; left: 50%; bottom: calc(40px + var(--safe-b)); width: min(320px, 70vw); height: 18px; transform: translateX(-50%); background: rgba(255, 255, 255, 0.85); border-radius: 999px; overflow: hidden; box-shadow: var(--shadow); opacity: 0; transition: opacity 0.2s; }
.power.on { opacity: 1; }
.power-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--mint), var(--sun), var(--coral)); }
.dots span { position: absolute; width: 9px; height: 9px; margin: -4.5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(29, 43, 68, 0.35); pointer-events: none; }

/* ------------------------------------------------------------- flight */
.hud { position: absolute; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.dist { font-family: var(--display); color: #fff; text-shadow: 0 3px 0 rgba(29, 43, 68, 0.45), 0 0 18px rgba(29, 43, 68, 0.25); font-size: 54px; line-height: 1; display: flex; align-items: baseline; gap: 4px; margin-top: 46px; font-variant-numeric: tabular-nums; }
.dist small { font-size: 26px; }
.hud-row { display: flex; gap: 8px; }
.chip { display: flex; align-items: center; gap: 5px; background: rgba(255, 255, 255, 0.85); border-radius: 999px; padding: 4px 12px; font-weight: 900; font-size: 15px; font-variant-numeric: tabular-nums; }
.chip.gold { font-family: var(--display); font-weight: 400; font-size: 18px; }
.chip .coin { width: 18px; height: 18px; }
.fuel { display: flex; align-items: center; gap: 6px; color: #fff; filter: drop-shadow(0 2px 2px rgba(29, 43, 68, 0.4)); }
.fuel svg { width: 20px; height: 20px; }
.fuel-bar { width: 140px; height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.5); overflow: hidden; }
.fuel-fill { height: 100%; background: #fff; border-radius: 999px; }
.fuel.empty { opacity: 0.4; }
.zone-toast { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%) scale(0.8); font-family: var(--display); font-size: 40px; color: #fff; text-shadow: 0 4px 0 rgba(29, 43, 68, 0.45); opacity: 0; white-space: nowrap; pointer-events: none; text-align: center; }
.zone-toast small { display: block; font-family: var(--body); font-weight: 900; font-size: 15px; letter-spacing: 0.14em; text-transform: uppercase; }
.zone-toast.show { animation: toast 2.2s ease forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 20% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -70%) scale(1); } }
.burner { position: absolute; right: calc(18px + var(--safe-r)); bottom: calc(26px + var(--safe-b)); width: 84px; height: 84px; border-radius: 50%; background: var(--coral); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 0 var(--coral-deep), var(--shadow); }
.burner svg { width: 40px; height: 40px; }
.burner b { position: absolute; top: -4px; right: -4px; background: #fff; color: var(--coral); font-family: var(--display); font-size: 18px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; box-shadow: 0 2px 0 var(--line); }
.burner[disabled] { filter: grayscale(1); opacity: 0.6; }
.burner.go { animation: bump 0.4s; }
.pops span { position: absolute; font-family: var(--display); color: #ffe066; text-shadow: 0 2px 0 rgba(122, 74, 0, 0.6); font-size: 20px; pointer-events: none; animation: rise 0.9s ease-out forwards; white-space: nowrap; }
.pops span.big { color: #ff8cc6; font-size: 30px; text-shadow: 0 3px 0 rgba(120, 10, 70, 0.5); }
.pops span.word { color: #fff; font-size: 26px; text-shadow: 0 3px 0 rgba(29, 43, 68, 0.5); }
@keyframes rise { 0% { transform: translate(-50%, 0) scale(0.6); opacity: 0; } 20% { transform: translate(-50%, -10px) scale(1.1); opacity: 1; } 100% { transform: translate(-50%, -60px) scale(1); opacity: 0; } }

/* ------------------------------------------------------------ results */
#results.on { display: grid; place-items: center; background: rgba(20, 35, 60, 0.25); }
.card { background: var(--cream); border-radius: 26px; box-shadow: 0 6px 0 rgba(29, 43, 68, 0.12), var(--shadow); padding: 22px 20px 18px; width: min(380px, calc(100vw - 32px)); }
.result-card { display: flex; flex-direction: column; align-items: center; gap: 8px; animation: cardIn 0.5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes cardIn { from { transform: translateY(40px) scale(0.9); opacity: 0; } }
.kicker { margin: 0; font-weight: 900; font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--coral); }
.result-card h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 40px; line-height: 1; text-align: center; }
.res-dist { font-family: var(--display); font-size: 22px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.res-dist b { font-size: 36px; color: var(--ink); font-weight: 400; }
.record { background: var(--sun); color: var(--ink); font-family: var(--body); font-weight: 900; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; transform: rotate(-4deg); animation: bump 0.5s 0.4s; }
.lines { list-style: none; margin: 4px 0 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 4px; }
.lines li { display: flex; justify-content: space-between; font-weight: 800; font-size: 15px; padding: 6px 10px; background: #fff; border-radius: 10px; opacity: 0; transform: translateX(-12px); transition: opacity 0.2s, transform 0.25s; }
.lines li.in { opacity: 1; transform: none; }
.lines li b { font-family: var(--display); font-weight: 400; font-size: 17px; font-variant-numeric: tabular-nums; }
.lines li.hot { background: #fff1c2; }
.total { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 40px; margin-top: 2px; }
.total .coin { width: 36px; height: 36px; }
.unlock { width: 100%; background: var(--ink); color: #fff; border-radius: 16px; padding: 12px; text-align: center; display: flex; flex-direction: column; gap: 2px; animation: bump 0.6s; }
.unlock small { font-weight: 900; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--sun); }
.unlock b { font-family: var(--display); font-weight: 400; font-size: 26px; }
.cta { width: 100%; background: var(--mint); color: #fff; font-family: var(--display); font-size: 24px; letter-spacing: 0.03em; padding: 12px; border-radius: 16px; box-shadow: 0 5px 0 var(--mint-deep); margin-top: 6px; }
.cta:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--mint-deep); }

/* --------------------------------------------------------------- menu */
.modal.on { display: grid; place-items: center; background: rgba(20, 35, 60, 0.45); }
.menu-card { display: flex; flex-direction: column; gap: 10px; }
.menu-card h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 400; font-size: 32px; }
.row { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 12px 14px; font-weight: 800; box-shadow: 0 3px 0 var(--line); }
.row svg { width: 22px; height: 22px; }
.row span { flex: 1; text-align: left; }
.row.danger { color: var(--coral-deep); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stats div { background: #fff; border-radius: 12px; padding: 8px 10px; font-size: 12px; font-weight: 800; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.stats b { display: block; font-family: var(--display); font-weight: 400; font-size: 20px; color: var(--ink); letter-spacing: 0; text-transform: none; }
.build { margin: 0; text-align: center; font-size: 11px; color: var(--ink-2); opacity: 0.7; }

/* ------------------------------------------------------------- banner */
.banner { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); pointer-events: none; text-align: center; font-family: var(--display); font-size: 54px; color: #fff; text-shadow: 0 5px 0 rgba(29, 43, 68, 0.5); opacity: 0; white-space: nowrap; }
.banner small { display: block; font-family: var(--body); font-weight: 900; font-size: 16px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--sun); text-shadow: 0 2px 0 rgba(29, 43, 68, 0.5); }
.banner.show { animation: toast 2.6s ease forwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* The flight stick ring */
.stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.55); background: rgba(255, 255, 255, 0.12); pointer-events: none; display: grid; place-items: center; }
.stick i { width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, 0.75); box-shadow: 0 3px 10px rgba(20, 40, 80, 0.25); }
