/* App chrome stays outside the flight view and respects phone safe areas. */
html,body { min-height: 100%; overscroll-behavior: none; }
[hidden] { display: none !important; }
button,a { -webkit-tap-highlight-color: transparent; }
button,.answer,.primary,.app-download { touch-action: manipulation; }
#app-options { display: inline-flex !important; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0; font: 700 24px/1 Arial,sans-serif; }
body.playing .top-actions #app-options { display: inline-flex !important; width: 44px; height: 44px; }
.app-download { color: #efd098; text-decoration: underline; text-underline-offset: 4px; font-size: 14px; line-height: 1.5; }
.landing-play > .app-download { display: block; text-align: center; margin: 12px 0 0; }
#app-dialog { width: min(440px,calc(100% - 32px)); max-height: calc(100dvh - 40px); overflow-y: auto; margin: auto; padding: 24px; border: 1px solid #476087; border-radius: 16px; background: #0c2044; color: #f1f5fc; font: 16px/1.5 'Titillium Web',Arial,sans-serif; }
#app-dialog::backdrop { background: #020b1dcc; }
.app-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.app-dialog-heading h2 { margin: 0; font-size: 24px; }
#app-dialog button { min-height: 48px; padding: 10px 16px; border: 1px solid #61799e; border-radius: 8px; color: #f1f5fc; background: #18345a; font: inherit; cursor: pointer; }
#app-dialog #close-app-dialog { width: 44px; min-height: 44px; padding: 0; background: transparent; }
#app-dialog .app-version { color: #bdcce2; margin: 12px 0; }
#app-dialog .push-controls { padding-top: 20px; margin-top: 20px; border-top: 1px solid #476087; }
#app-dialog h3 { margin: 0 0 12px; font-size: 18px; }
#app-dialog #push-status,#app-dialog #push-setup-status,.app-network-note { margin: 12px 0 0; color: #bdcce2; }
#app-dialog #push-setup { display: none !important; }
#app-toast { position: fixed; left: 50%; bottom: max(20px,env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; border: 1px solid #476087; border-radius: 10px; background: #0c2044; color: #f1f5fc; z-index: 100; font: 14px/1.4 Arial,sans-serif; text-align: center; }
@media(max-width:600px) and (orientation:portrait) {
  .topbar { min-height: calc(60px + env(safe-area-inset-top)); padding: calc(8px + env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) 8px max(16px,env(safe-area-inset-left)); }
  .topbar .mission-top { display: none !important; }
  #welcome { top: calc(60px + env(safe-area-inset-top)); height: calc(100dvh - 60px - env(safe-area-inset-top)); padding: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  #welcome .landing-shell { display: flex; flex-direction: column; min-height: 100%; height: auto; gap: 14px; padding: 16px 20px max(24px,env(safe-area-inset-bottom)); }
  #welcome .landing-heading { order: 0; }
  #welcome #landing-title { font-size: clamp(34px,10vw,43px); line-height: 1.05; margin-block: 10px; }
  #welcome .landing-description { font-size: 16px; line-height: 1.4; }
  #welcome .landing-visual { order: 1; flex: none; height: clamp(145px,25dvh,220px); min-height: 0; width: 100%; margin: 0; }
  #welcome .landing-plane { inset: 0; width: 100%; height: 100%; object-fit: contain; transform: none; }
  #welcome .landing-wordmark { font-size: 68px; letter-spacing: -3px; }
  #welcome .landing-score { order: 2; width: 100%; margin: 0; padding: 12px 8px; }
  #welcome .landing-score strong { font-size: 26px; }
  #welcome .landing-play { order: 3; width: 100%; }
  #welcome #start { min-height: 56px; justify-content: center; }
  #welcome #start-status { font-size: 13px; line-height: 1.4; }
  #welcome .landing-guide { order: 4; width: 100%; margin: 0; }
  #welcome .landing-footer { order: 5; width: 100%; margin: 0; font-size: 12px; line-height: 1.4; }
  body.mobile-flight.playing .topbar { height: calc(56px + env(safe-area-inset-top)); min-height: 56px; }
  body.mobile-flight.playing .navigation,body.mobile-flight.playing #risk-hud { top: calc(68px + env(safe-area-inset-top)); }
  body.gate-question #quiz { width: calc(100% - 24px); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; padding: 20px 16px; }
  body.gate-question #quiz .question-title { font-size: clamp(23px,6vw,29px); line-height: 1.2; }
  body.gate-question #quiz .answer { min-height: 54px; font-size: 17px; line-height: 1.3; padding: 12px; }
}
@media(orientation:landscape) and (max-height:600px) {
  .topbar { padding-left: max(16px,env(safe-area-inset-left)); padding-right: max(16px,env(safe-area-inset-right)); }
  #welcome { overflow-y: auto; }
  #quiz { max-height: calc(100dvh - 20px); overflow-y: auto; }
  #quiz .answer { min-height: 44px; }
}

/* Playable mobile cockpit: flight stick on the left, large action buttons on the right. */
body.manual-flight.playing .topbar { height: calc(56px + env(safe-area-inset-top)); min-height: 56px; padding-block: calc(6px + env(safe-area-inset-top)) 6px; }
.manual-flight #world,.manual-flight .vignette { inset: 0 !important; height: 100% !important; }
.manual-flight .touch-controls { display: block !important; }
.manual-flight .compass-wrap,.manual-flight .systems,.manual-flight .map-panel,.manual-flight .quiz-progress,.manual-flight #bank-flight,.manual-flight #flight-passport,.manual-flight .bottom-controls,.manual-flight #control-guide,.manual-flight .flight-reticle,.manual-flight #flight-message,.manual-flight #risk-ladder,.manual-flight #risk-message,.manual-flight #risk-toast { display: none !important; }
.manual-flight #hud::after { height: 230px !important; background: linear-gradient(transparent,#031029d9) !important; border: 0 !important; pointer-events: none; }
body.manual-flight.playing .navigation { position: absolute; left: max(16px,env(safe-area-inset-left)); top: calc(70px + env(safe-area-inset-top)); right: auto; width: auto; max-width: calc(100% - 176px); min-height: 48px; height: auto; padding: 8px 12px; border-radius: 12px; background: #0b2049cf; transform: none; }
body.manual-flight.playing .navigation small { font-size: 12px; line-height: 1.3; }
body.manual-flight.playing .navigation strong { font-size: 19px; line-height: 1.2; }
body.manual-flight.playing .instruments { display: flex !important; position: absolute; top: calc(70px + env(safe-area-inset-top)); right: max(16px,env(safe-area-inset-right)); left: auto; bottom: auto; width: 142px; min-height: 50px; height: auto; padding: 7px 10px; gap: 10px; background: #0b2049cf; border-radius: 12px; transform: none; }
body.manual-flight.playing .instruments > div:not(.instrument-divider) { min-width: 0; flex: 1; }
body.manual-flight.playing .instruments > div:nth-child(n+4) { display: none !important; }
body.manual-flight.playing .instruments small,body.manual-flight.playing .instruments span { font-size: 10px; letter-spacing: 0; }
body.manual-flight.playing .instruments strong { font-size: 23px; line-height: 1.1; }
body.manual-flight.playing .instruments .instrument-divider { height: 24px; margin: 8px 0 0; }
body.manual-flight.playing #risk-hud { top: calc(130px + env(safe-area-inset-top)); left: auto; right: max(16px,env(safe-area-inset-right)); bottom: auto; width: auto; min-width: 80px; height: auto; min-height: 40px; padding: 7px 12px; border-radius: 10px; background: #0b2049cf; display: flex; gap: 8px; align-items: center; }
body.manual-flight.playing #risk-caption { display: block; font-size: 11px; margin: 0; }
body.manual-flight.playing #risk-multiplier { display: flex; gap: 4px; align-items: baseline; font-size: 20px; margin: 0; min-width: 0; }
body.manual-flight.playing #risk-multiplier span { font-size: 11px; }
#pilot-coach { position: absolute; left: max(16px,env(safe-area-inset-left)); top: calc(137px + env(safe-area-inset-top)); max-width: min(245px,calc(100% - 128px)); color: #e5edf9; font: 14px/1.4 'Titillium Web',Arial,sans-serif; text-shadow: 0 1px 4px #001025; pointer-events: none; }
body.manual-flight.playing #joystick { position: absolute; left: max(20px,env(safe-area-inset-left)); right: auto; bottom: calc(44px + env(safe-area-inset-bottom)); width: 130px; height: 130px; transform: none; pointer-events: auto; touch-action: none; }
body.manual-flight.playing #joystick-knob { width: 42px; height: 42px; left: calc(50% - 21px); top: calc(50% - 21px); }
body.manual-flight.playing #joystick small { top: calc(100% + 12px); font-size: 11px; letter-spacing: .6px; }
body.manual-flight.playing .touch-right { position: absolute; left: auto; right: max(16px,env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); width: 156px; display: grid !important; visibility: visible !important; gap: 8px; pointer-events: auto; }
body.manual-flight.playing .touch-right button { min-height: 46px; min-width: 0; padding: 8px; border: 1px solid #7d99c0; border-radius: 9px; background: #102a50ed; color: #edf4ff; font: 600 13px/1.2 'Titillium Web',Arial,sans-serif; touch-action: none; }
body.manual-flight.playing .touch-right button:disabled { opacity: .4; }
body.manual-flight.playing .touch-right #takeoff-button { min-height: 52px; border-color: #f0c97d; background: #edc27e; color: #0c2044; font-size: 15px; }
.pitch-actions,.flight-tools { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
body.manual-flight.playing #land-button[disabled],body.manual-flight.playing #touch-pause { display: none !important; }
body.gate-question #pilot-coach { display: none; }
@media(max-width:350px) and (orientation:portrait) {
 body.manual-flight.playing #joystick { left: 16px; width: 108px; height: 108px; bottom: calc(54px + env(safe-area-inset-bottom)); }
 body.manual-flight.playing .touch-right { width: 148px; right: 12px; }
 body.manual-flight.playing .navigation { left: 12px; padding: 8px; max-width: calc(100% - 166px); }
 body.manual-flight.playing .navigation small { font-size: 10px; }
 body.manual-flight.playing .instruments { right: 12px; width: 136px; }
 #pilot-coach { left: 12px; font-size: 13px; }
}
@media(orientation:landscape) and (max-height:600px) {
 body.manual-flight.playing #joystick { width: 100px; height: 100px; bottom: max(24px,env(safe-area-inset-bottom)); }
 body.manual-flight.playing .touch-right { bottom: max(12px,env(safe-area-inset-bottom)); width: 220px; grid-template-columns: 1fr 1fr; }
 body.manual-flight.playing #takeoff-button { grid-column: 1 / -1; min-height: 44px; }
 body.manual-flight.playing .pitch-actions,body.manual-flight.playing .flight-tools { gap: 6px; }
 body.manual-flight.playing .touch-right button { min-height: 44px; padding: 5px; font-size: 11px; }
 body.manual-flight.playing #land-button { grid-column: 1 / -1; }
 body.manual-flight.playing #risk-hud { right: 172px; top: calc(72px + env(safe-area-inset-top)); }
 #pilot-coach { top: calc(132px + env(safe-area-inset-top)); max-width: 230px; }
}

body.manual-flight.playing #world,body.manual-flight.playing .vignette{inset:0!important;height:100%!important}

/* A game title screen rather than a landing page. */
#welcome.game-menu { position: absolute; inset: 0; height: 100dvh; padding: 0; overflow: hidden; background: radial-gradient(ellipse at 70% 43%,#203f70 0,#10264d 38%,#06132d 78%); }
.game-menu .menu-airspace { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.menu-airspace::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg,#041126ed,transparent 58%); }
.menu-airspace i { position: absolute; width: 70vw; height: 70vw; max-width: 750px; max-height: 750px; right: -8vw; top: -10%; border: 1px solid #dcb87416; border-radius: 50%; box-shadow: 0 0 0 40px #dcb87408,0 0 0 120px #dcb87405; }
.menu-airspace img { position: absolute; right: -6%; top: 12%; width: 78%; height: 76%; object-fit: contain; filter: drop-shadow(0 28px 32px #020817b3); }
.menu-identity { position: absolute; left: max(8vw,24px); top: 24%; color: #f0c77e; text-align: left; }
.menu-identity > p { font: 800 28px/1 'Titillium Web',Arial,sans-serif; letter-spacing: 7px; margin: 0 0 5px; }
#welcome.game-menu #landing-title { margin: 0; color: #f5efdf; font: 800 clamp(90px,11vw,160px)/.88 'Titillium Web',Arial,sans-serif; letter-spacing: 8px; text-shadow: 0 5px 0 #02102c66; }
.menu-identity > span { display: block; margin-top: 18px; font: 600 12px/1.4 'Titillium Web',Arial,sans-serif; letter-spacing: 4px; color: #bdcce4; }
.menu-actions { position: absolute; bottom: max(7vh,28px); left: max(8vw,24px); width: min(330px,calc(100% - 40px)); display: grid; gap: 10px; text-align: center; }
#welcome.game-menu #start,#welcome.game-menu #resume { width: 100%; min-height: 58px; min-width: 0; margin: 0; justify-content: center; border-radius: 9px; border: 1px solid #f8dea5; padding: 14px 20px; background: linear-gradient(#f1d495,#d6a650); color: #101e37; font: 800 21px/1.2 'Titillium Web',Arial,sans-serif; letter-spacing: 2px; box-shadow: 0 4px 0 #97702e,0 10px 24px #02091f55; }
#welcome.game-menu #resume { background: #16345b; border-color: #617ba3; color: #e6efff; box-shadow: none; font-size: 16px; min-height: 48px; }
#menu-help { min-height: 44px; border: 0; border-radius: 8px; color: #ccdaec; background: transparent; font: 600 14px/1.3 'Titillium Web',Arial,sans-serif; letter-spacing: 1.5px; }
#welcome.game-menu #start-status { display: block; margin: 0; color: #a6bad7; font: 13px/1.4 'Titillium Web',Arial,sans-serif; }
.menu-actions .app-download { margin-top: 6px; font-size: 12px; letter-spacing: 1px; color: #c5aa78; }
.menu-best { position: absolute; bottom: max(6vh,25px); right: 7vw; color: #849cbd; font: 600 12px/1.4 'Titillium Web',Arial,sans-serif; letter-spacing: 1.5px; }
#game-guide { width: min(460px,calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; margin: auto; border: 1px solid #526d95; border-radius: 16px; padding: 26px; background: #0c2044; color: #e5eefc; font: 16px/1.5 'Titillium Web',Arial,sans-serif; }
#game-guide::backdrop { background: #020918cc; }
#game-guide h2 { margin: 0 0 20px; font-size: 30px; line-height: 1.1; }
#game-guide ol { padding-left: 22px; margin: 0 0 22px; }
#game-guide li { margin-bottom: 14px; color: #bfcfe6; }
#game-guide strong { display: block; color: #f1cd88; font-size: 18px; }
#close-game-guide { width: 100%; min-height: 50px; border: 1px solid #e1be7a; border-radius: 8px; background: #e8c27f; color: #10203b; font: 700 16px 'Titillium Web',Arial,sans-serif; }
@media(max-width:600px) and (orientation:portrait) {
 #welcome.game-menu { inset: 0; top: 0; height: 100dvh; }
 .menu-identity { top: calc(91px + env(safe-area-inset-top)); left: 20px; right: 20px; text-align: center; }
 .menu-identity > p { font-size: 20px; letter-spacing: 8px; }
 #welcome.game-menu #landing-title { font-size: clamp(82px,26vw,112px); letter-spacing: 8px; }
 .menu-identity > span { margin-top: 10px; font-size: 11px; letter-spacing: 3px; }
 .menu-airspace img { right: -13%; top: 22%; width: 126%; height: 45%; }
 .menu-airspace i { width: 110vw; height: 110vw; top: 19%; right: -5vw; }
 .menu-actions { left: 24px; right: 24px; bottom: max(38px,calc(22px + env(safe-area-inset-bottom))); width: auto; gap: 10px; }
 .menu-best { bottom: max(10px,env(safe-area-inset-bottom)); left: 20px; right: 20px; text-align: center; font-size: 10px; }
}
@media(max-height:650px) and (orientation:portrait) {
 .menu-identity { top: 76px; }
 #welcome.game-menu #landing-title { font-size: 78px; }
 .menu-identity > span { font-size: 10px; }
 .menu-actions { bottom: 28px; gap: 5px; }
 #welcome.game-menu #start { min-height: 51px; }
 .menu-airspace img { top: 21%; height: 45%; }
}
