*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#07111f;color:#f4f8ff;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;touch-action:none}body{padding:env(safe-area-inset-top) 0 env(safe-area-inset-bottom)}#game{position:relative;width:100%;height:100%;min-height:100svh;overflow:hidden;background:radial-gradient(ellipse at 50% 40%,#17334a 0%,#0b1a2b 55%,#07111f 100%)}#scene{position:absolute;inset:0;width:100%;height:100%;display:block}.topbar{position:absolute;top:calc(14px + env(safe-area-inset-top));left:18px;right:18px;display:flex;justify-content:space-between;align-items:center;pointer-events:none}.brand{display:flex;align-items:center;gap:10px}.brand-mark{width:36px;height:36px;display:grid;place-items:center;background:#163d56;border:1px solid #3b7797;border-radius:10px;font-size:21px}.brand strong,.brand small{display:block;letter-spacing:2px}.brand strong{font-size:12px}.brand small{font-size:8px;color:#8faec2;margin-top:3px}.status{font-size:10px;letter-spacing:1.5px;color:#b7d3e3;display:flex;align-items:center;gap:7px}.live-dot{width:7px;height:7px;border-radius:50%;background:#65e6b0;box-shadow:0 0 10px #65e6b0}.hud{position:absolute;top:calc(68px + env(safe-area-inset-top));left:18px;right:18px;display:flex;justify-content:space-between;pointer-events:none}.readout{background:#071522a8;border:1px solid #41617a66;border-radius:9px;padding:8px 11px;min-width:84px;backdrop-filter:blur(8px)}.readout small{display:block;color:#8faec2;font-size:8px;letter-spacing:1.3px}.readout strong{font-size:19px;display:inline-block;margin:3px 5px 0 0;font-variant-numeric:tabular-nums}.readout small:last-child{display:inline;color:#8faec2}.center-mark{position:absolute;left:50%;top:44%;width:30px;height:30px;transform:translate(-50%,-50%);opacity:.65;pointer-events:none}.center-mark span{position:absolute;left:14px;top:0;width:1px;height:30px;background:#d9edf8}.center-mark i{position:absolute;top:14px;left:0;width:30px;height:1px;background:#d9edf8}.bottom-panel{position:absolute;left:12px;right:12px;bottom:calc(10px + env(safe-area-inset-bottom));padding:13px 14px 10px;background:#071522dc;border:1px solid #41617a80;border-radius:17px;backdrop-filter:blur(12px)}.control-row{display:flex;justify-content:space-between;gap:18px}.control-label{display:flex;justify-content:space-between;gap:12px;color:#9db9ca;font-size:9px;letter-spacing:1.2px;margin-bottom:8px}.control-label strong{color:#f4f8ff}.steer{display:flex;flex-direction:column;align-items:center;gap:4px}.steer>div{display:flex;gap:4px}.steer button{width:43px;height:34px}.steer button,.secondary{border:1px solid #426b85;background:#15344a;color:#eff8ff;border-radius:8px;font-size:15px}.steer button:active,.secondary:active{background:#28617c}.throttle-area{flex:1;max-width:48%;padding-top:1px}.throttle-area input{width:100%;accent-color:#58c8d9;margin:13px 0}.throttle-scale{display:flex;justify-content:space-between;color:#7897aa;font-size:8px;letter-spacing:1px}.action-row{display:flex;gap:8px;margin-top:12px}.secondary{flex:1;padding:10px 7px;font-size:9px;letter-spacing:1px}.hint{text-align:center;color:#7897aa;font-size:9px;margin:9px 0 0}.loading{position:absolute;inset:0;display:grid;place-items:center;background:#07111f;color:#c8e4f3;font-size:13px;letter-spacing:1px;transition:opacity .4s;pointer-events:none}.loading.hidden{opacity:0}@media(min-width:700px){.bottom-panel{left:50%;right:auto;transform:translateX(-50%);width:460px}.topbar,.hud{left:30px;right:30px}.readout{min-width:110px}}

/* Landscape-first flight deck */
@media (orientation:landscape) and (max-height:600px){
  .topbar{top:calc(8px + env(safe-area-inset-top));left:14px;right:14px}
  .brand-mark{width:30px;height:30px;font-size:18px}
  .hud{top:calc(48px + env(safe-area-inset-top));left:14px;right:14px;justify-content:flex-start;gap:8px}
  .readout{min-width:78px;padding:5px 8px}
  .readout strong{font-size:16px}
  .bottom-panel{left:14px;right:14px;bottom:calc(7px + env(safe-area-inset-bottom));padding:8px 12px 7px;border-radius:13px}
  .control-row{align-items:center;gap:22px}
  .stick-area{display:flex;align-items:center;gap:8px}
  .stick-area .control-label{margin:0;writing-mode:vertical-rl;transform:rotate(180deg);font-size:7px}
  .steer{display:grid;grid-template-columns:27px 52px 27px;grid-template-rows:22px 22px;gap:2px;align-items:center}
  .steer>button:first-child{grid-column:2;grid-row:1}
  .steer>div{display:contents}
  .steer>div button:first-child{grid-column:1;grid-row:2}
  .steer>div button:last-child{grid-column:3;grid-row:2}
  .steer>button:last-child{grid-column:2;grid-row:2}
  .steer button{width:100%;height:21px;font-size:10px;border-radius:6px}
  .throttle-area{max-width:none;flex:1}
  .throttle-area input{margin:5px 0}
  .action-row{margin-top:5px;max-width:300px;margin-left:auto}
  .secondary{padding:6px 5px;font-size:7px}
  .hint{display:none}
  .center-mark{top:43%}
}


/* PTFS-inspired touch layout: left joystick, right throttle */
.bottom-panel{left:14px;right:14px;bottom:calc(10px + env(safe-area-inset-bottom));display:flex;align-items:flex-end;justify-content:space-between;gap:20px;padding:0;background:transparent;border:0;backdrop-filter:none;pointer-events:none;transform:none;width:auto}
.joystick-area,.right-controls{pointer-events:auto;background:#071522dc;border:1px solid #41617a80;border-radius:15px;backdrop-filter:blur(12px);padding:10px 12px}
.joystick-area{display:flex;flex-direction:column;align-items:center;gap:7px}
.joystick-area .control-label{margin:0;font-size:8px}
.joystick{width:126px;height:126px;border-radius:50%;border:2px solid #5d8299;background:radial-gradient(circle,#29495e 0%,#102b3d 72%);position:relative;touch-action:none;box-shadow:inset 0 0 0 8px #ffffff0a}
.joystick-cross{position:absolute;background:#8ca9ba55;pointer-events:none}
.joystick-cross.horizontal{height:1px;left:12px;right:12px;top:50%}
.joystick-cross.vertical{width:1px;top:12px;bottom:12px;left:50%}
.joystick-knob{position:absolute;width:48px;height:48px;left:50%;top:50%;transform:translate(-50%,-50%);border-radius:50%;border:2px solid #9ac9dc;background:linear-gradient(145deg,#39728f,#15374d);box-shadow:0 3px 12px #0008;pointer-events:none}
.right-controls{display:flex;flex-direction:column;justify-content:center;gap:10px;width:min(42vw,360px)}
.right-controls .throttle-area{max-width:none;width:100%}
.right-controls .throttle-area input{width:100%;margin:8px 0;accent-color:#58c8d9}
.right-controls .action-row{display:flex;gap:8px;margin:0;max-width:none}
.right-controls .secondary{flex:1;padding:9px 6px;font-size:8px}
.right-controls .throttle-scale{font-size:8px}
@media (orientation:landscape) and (max-height:600px){
 .bottom-panel{left:14px;right:14px;bottom:calc(7px + env(safe-area-inset-bottom));width:auto;transform:none;align-items:flex-end}
 .joystick-area,.right-controls{padding:8px 10px}
 .joystick{width:112px;height:112px}
 .joystick-knob{width:42px;height:42px}
 .right-controls{width:min(38vw,330px)}
 .right-controls .action-row{margin:0}
 .right-controls .secondary{padding:7px 5px}
 .hint{display:none}
}
@media (orientation:portrait){
 .bottom-panel{align-items:flex-end;gap:8px}
 .joystick{width:104px;height:104px}
 .right-controls{width:48vw}
 .joystick-area,.right-controls{padding:8px}
}


/* Aircraft construction mode */
.top-actions{display:flex;align-items:center;gap:12px;pointer-events:auto}
.mode-button,.part-button,.test-flight{border:1px solid #47758f;background:#12344a;color:#eff8ff;border-radius:9px;padding:9px 14px;font-size:10px;letter-spacing:1px;font-weight:700}
.mode-button{pointer-events:auto}
.builder-panel{position:absolute;left:14px;right:14px;bottom:calc(10px + env(safe-area-inset-bottom));padding:10px;background:#071522eF;border:1px solid #41617a;border-radius:14px;display:flex;align-items:center;gap:10px;backdrop-filter:blur(12px)}
.builder-panel.hidden{display:none}
.builder-heading{display:flex;flex-direction:column;gap:4px;min-width:125px}.builder-heading strong{font-size:10px;letter-spacing:1.3px}.builder-heading span{font-size:8px;color:#91adbf}
.builder-tools{display:flex;gap:6px;flex:1;justify-content:center;flex-wrap:wrap}.part-button{padding:10px 11px;font-size:9px}.part-button.selected{background:#27617a;border-color:#8bd5e6}.test-flight{background:#17634e;border-color:#55b99b;white-space:nowrap}
body.build-mode .hud,body.build-mode .center-mark,body.build-mode .bottom-panel{display:none}
@media(max-width:650px){.builder-panel{flex-wrap:wrap;justify-content:center}.builder-heading{width:100%;flex-direction:row;justify-content:space-between}.builder-tools{order:2}.test-flight{order:3;width:100%}.part-button{padding:9px 10px}}
