:root{color-scheme:dark;--bg:#0c191d;--panel:#163139;--text:#f2f8e8;--muted:#b9d3c9;--green:#8aea79;--gold:#ffda75;--line:#86b5a93b}
*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{margin:0;min-height:100%;background:var(--bg);color:var(--text);font-family:system-ui,-apple-system,"Segoe UI",sans-serif}
body{min-height:100dvh;display:grid;place-items:center}
button{min-width:44px;min-height:44px;display:inline-flex;align-items:center;justify-content:center;gap:7px;background:#163139;color:inherit;border:1px solid #6b9a8d88;border-radius:11px;padding:7px 13px;line-height:1.1;font-family:inherit;font-weight:800;font-size:clamp(13px,1.8vw,17px);cursor:pointer;touch-action:manipulation;user-select:none;-webkit-tap-highlight-color:transparent}
button:hover:not(:disabled){filter:brightness(1.14)}
button:active:not(:disabled){translate:0 1px}
button:focus-visible{outline:3px solid var(--green);outline-offset:2px}
button:disabled{cursor:default;opacity:.55}
button img,.chip img,.flight-stats img{width:24px;height:24px;object-fit:contain;flex:none}
#game{position:relative;isolation:isolate;width:min(100vw,177.78dvh);aspect-ratio:16 / 9;max-width:1600px;overflow:hidden;background:#174a63}
.scene,canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
canvas{background:#286c8d}
.top{position:absolute;inset:max(9px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) auto max(12px,env(safe-area-inset-left));display:flex;align-items:center;justify-content:space-between;gap:8px;z-index:2}
.brand{display:flex;align-items:center;gap:8px;color:#fff8df;text-shadow:0 2px 2px #123443,0 0 12px #173b50;white-space:nowrap}
.brand img{width:clamp(26px,5vw,58px);height:clamp(26px,5vw,58px);object-fit:contain;filter:drop-shadow(0 2px 3px #14221caa)}
.brand h1{font-size:clamp(17px,3.1vw,42px);font-weight:1000;font-style:italic;letter-spacing:-.045em;line-height:.95;margin:0}
.brand h1 span{color:#ffd36e;margin-left:.19em}
.brand p{font-size:clamp(9px,1.2vw,14px);letter-spacing:.13em;font-weight:900;margin:4px 0 0}
.wallet,.flight-stats,.actions,.steer,nav,.result-actions{display:flex;align-items:center;gap:7px}
.chip,.small-button{padding:5px 9px;display:inline-flex;align-items:center;gap:5px;white-space:nowrap;border-radius:10px;background:#10282eea;border:1px solid var(--line);font-size:clamp(12px,1.6vw,16px)}
.chip img{width:20px;height:20px}
.garage-label,.notice,.flight-hud{position:absolute;pointer-events:none;text-shadow:0 2px 4px #07232a;text-align:center}
.garage-label{top:22%;left:50%;translate:-50% 0;display:grid;gap:2px;white-space:nowrap}
.garage-label strong{font-size:clamp(17px,2.8vw,33px)}
.garage-label span{font-size:clamp(12px,1.4vw,16px);font-weight:750;color:#e5f9ec}
.flight-hud{top:16%;left:50%;translate:-50% 0;white-space:nowrap}
.distance{font-size:clamp(23px,4.1vw,52px);font-weight:1000;line-height:1}
.flight-stats{justify-content:center}
.flight-stats span{display:inline-flex;align-items:center;gap:3px;border-radius:7px;background:#10282edb;padding:3px 6px;font-size:clamp(12px,1.5vw,16px);font-weight:800}
.flight-stats img{width:18px;height:18px}
#combo{color:var(--gold)}
.notice{left:50%;top:35%;translate:-50% 0;max-width:90%;white-space:nowrap;font-size:clamp(15px,2.6vw,28px);font-weight:950;color:#ffebae}
.controls{z-index:2;position:absolute;bottom:0;left:0;right:0;padding:8px max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));background:linear-gradient(0deg,#081b1fee 0%,#0a221fe0 68%,#0a251600 100%)}
.rpm{width:min(370px,100%);margin:0 auto 6px;color:white;text-shadow:0 1px 3px #071721;font-weight:800}
.rpm-label{display:flex;justify-content:space-between;letter-spacing:.08em;font-size:12px}
.meter{position:relative;height:12px;background:#0c1c21;border:1px solid #c9e8d578;border-radius:999px;overflow:hidden;margin:3px 0}
#fill{background:linear-gradient(90deg,#ed963b,#ffdc75);width:0%;height:100%}
#perfectZone{position:absolute;inset:0 auto 0 72%;width:13%;background:#78ef7b77;border-inline:1px solid #afffb1}
#meter[data-good=yes] #fill{background:linear-gradient(90deg,#35b66a,#a5ff6a)}
#hint{text-align:center;font-size:clamp(12px,1.65vw,15px);color:#e4f4e7}
.actions,#flightControls{display:flex;justify-content:space-between;gap:8px;align-items:stretch}
.primary{background:linear-gradient(180deg,#ffe78d,#ffbe4c 55%,#ed982d);border:1px solid #ffebac;color:#3e220b;box-shadow:0 3px 0 #623a19;font-weight:950}
#launch{display:grid;gap:0;min-width:clamp(114px,23vw,234px);font-size:clamp(15px,2.5vw,26px);padding:5px 12px;touch-action:none}
#launch small{font-size:11px;line-height:1.1}
#lift,#dive{touch-action:none}
#lift[aria-pressed=true],#dive[aria-pressed=true]{background:#266152;border-color:var(--green)}
dialog{width:min(730px,calc(100vw - 28px));max-height:calc(100dvh - 24px);border-radius:20px;border:1px solid #a9cdb387;background:linear-gradient(142deg,#234950,#10292e 65%);color:var(--text);padding:clamp(12px,2.7vw,24px);box-shadow:0 14px 70px #0009;overscroll-behavior:contain}
dialog::backdrop{background:#061619a8}
.panel-head{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:12px}
.eyebrow{color:#9bd6bc;font-size:11px;font-weight:900;letter-spacing:.13em}
h2{margin:3px 0 0;font-size:clamp(20px,3.8vw,37px);line-height:1.04}
.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(135px,1fr));gap:8px}
.tile{display:grid;grid-template-rows:auto auto 1fr auto;gap:6px;min-width:0;padding:10px;border:1px solid var(--line);border-radius:12px;background:#10262d;text-align:left}
.tile img{width:52px;height:52px;object-fit:contain;justify-self:center}
.tile strong{font-size:14px;overflow-wrap:anywhere}
.tile p,#menuMessage{font-size:13px;line-height:1.3;color:var(--muted);margin:0}
.tile button{width:100%;font-size:13px;padding-inline:5px}
#menuMessage{margin-bottom:10px;color:var(--gold)}
#result{width:min(515px,calc(100vw - 28px));text-align:center}
.result-head img{width:clamp(44px,10vw,75px);height:clamp(44px,10vw,75px);object-fit:contain;display:block;margin:0 auto 3px}
.result-head p{margin:5px 0 9px;font-size:14px;color:var(--muted)}
.result-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin-bottom:12px}
.result-stats div{display:grid;gap:2px;padding:7px 4px;background:#11292e;border-radius:9px;border:1px solid var(--line)}
.result-stats b{font-size:clamp(15px,3vw,23px);color:var(--gold)}
.result-stats span{font-size:12px;color:var(--muted);overflow-wrap:anywhere}
.result-actions{justify-content:center}
@media (orientation:portrait){
 body{display:block}
 #game{width:100%;aspect-ratio:auto;min-height:100dvh;background:#10282d}
 .top{position:relative;inset:auto;padding:max(8px,env(safe-area-inset-top)) max(7px,env(safe-area-inset-right)) 8px max(7px,env(safe-area-inset-left))}
 .scene{position:relative;aspect-ratio:16 / 9;height:auto}
 .controls{position:relative;padding:10px max(9px,env(safe-area-inset-right)) max(14px,env(safe-area-inset-bottom)) max(9px,env(safe-area-inset-left));background:#10282d}
 .actions{flex-direction:column-reverse;gap:12px}
 nav{display:grid;grid-template-columns:repeat(3,minmax(0,1fr))}
 nav button{flex-direction:column;padding:5px 2px;font-size:12px;gap:3px}
 .brand{gap:4px}.brand p{font-size:8px}.wallet{gap:3px}.chip,.small-button{padding-inline:5px}.top .small-button{min-width:41px}
 .garage-label,.flight-hud{top:10%}.notice{top:34%}
}
@media (orientation:landscape) and (max-height:455px){
 .top{inset-block-start:max(5px,env(safe-area-inset-top))}
 .controls{padding-bottom:max(7px,env(safe-area-inset-bottom))}
 button img{width:20px;height:20px}
 .rpm{margin-bottom:3px}.meter{height:9px}.flight-hud{top:19%}
}
@media (orientation:landscape) and (max-height:320px){.top .small-button{min-height:36px}.garage-label{top:18%}.notice{top:42%}}
@media (max-width:350px){.brand p{letter-spacing:.06em}.brand img{display:none}.chip img{width:17px;height:17px}}

/* In a short landscape viewport keep all four shop/collection actions in view. */
@media (orientation:landscape) and (max-height:455px) and (min-width:510px){
 #garageDialog .tiles{grid-template-columns:repeat(4,minmax(0,1fr))}
 #garageDialog .tiles:has([data-buy]){grid-template-columns:repeat(5,minmax(0,1fr))}
 #garageDialog .tile{padding:7px;gap:4px}
 #garageDialog .tile img{width:40px;height:40px}
 #garageDialog .tile p{font-size:12px}
 #garageDialog .tile button{overflow-wrap:anywhere}
}
@media (orientation:portrait) and (min-width:290px){
 #garageDialog .tiles{grid-template-columns:repeat(2,minmax(0,1fr))}
 #garageDialog .tile p{overflow-wrap:anywhere}
}
@media (orientation:portrait) and (max-width:420px){
 #garageDialog{width:calc(100vw - 16px);padding:10px}
 #garageDialog .tile{padding:7px;gap:4px}
 #garageDialog .tile img{width:40px;height:40px}
 #garageDialog .tile p{font-size:12px;line-height:1.22;overflow-wrap:break-word}
}
