:root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 17px;
  color: #f3f6ff;
  background: #0b1129;
  font-synthesis: none;
  --amber: #ffce6a;
  --muted: #c5d3e8;
  --panel: #13233d;
  --line: #526984;
}
* { box-sizing: border-box; }
html, body { height: 100%; overscroll-behavior: none; }
body { margin: 0; overflow: hidden; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #80e4ec; outline-offset: 4px; }
button:disabled { opacity: .55; cursor: default; }
.hidden { display: none !important; }
#game { height: 100dvh; min-height: 0; position: relative; overflow: hidden; }
canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 170px #03091899; background: linear-gradient(0deg,#040a25e6,transparent 24%,transparent 80%,#040a2570); }
h1, h2, h3 { font-family: inherit; }
h1 { font-size: clamp(40px,4.3vw,70px); line-height: 1.1; letter-spacing: -2px; margin: 20px 0; }
p { font-size: 17px; line-height: 1.55; color: var(--muted); }
.eyebrow { font-size: 15px; font-weight: 700; letter-spacing: .35px; line-height: 1.4; color: #c5d9ef; }
.amber { color: var(--amber); }
kbd { font-family: inherit; display: inline-block; white-space: nowrap; font-size: 15px; padding: 3px 6px; border: 1px solid #7388a3; border-radius: 4px; color: #ecf4ff; background: #14243d; line-height: 1.4; }

/* Opaque surfaces keep the same contrast over bright planets and dark space. */
.topbar { position: absolute; z-index: 5; inset: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: max(20px,env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)) 16px max(24px,env(safe-area-inset-left)); gap: 18px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { font-size: 18px; letter-spacing: 1.5px; font-weight: 700; color: #fff; text-decoration: none; display: flex; align-items: center; min-height: 44px; text-shadow: 0 2px 5px #020819; }
.brand > span:last-child { font-weight: 500; color: #d4deef; }
.brand-star { color: var(--amber); font-size: 32px; margin-right: 10px; line-height: 1; display: inline-flex; align-items: center; }
.chapter-badge { font-size: 15px; font-weight: 700; letter-spacing: .4px; line-height: 1.3; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--line); background: #101b32; border-radius: 24px; padding: 12px 18px; text-align: center; }
.live-dot { width: 7px; height: 7px; flex-shrink: 0; background: #95dbfc; border-radius: 50%; }
.divider { color: #a3b3cc; }
.top-actions { display: flex; gap: 8px; flex-shrink: 0; }
.icon-button { background: #13233d; border: 1px solid #61758f; color: #edf4ff; border-radius: 50%; width: 44px; height: 44px; font-size: 22px; }
.icon-button:hover { background: #2b4263; }
.icon-button svg { display: block; margin: auto; }
.sound-muted { border-style: dashed; }

.button { border: 0; border-radius: 10px; padding: 15px 20px; min-height: 52px; font-weight: 700; font-size: 17px; line-height: 1.35; display: inline-flex; align-items: center; justify-content: center; gap: 24px; transition: background .15s; }
.button.primary { background: var(--amber); color: #172039; box-shadow: 0 7px 25px #ffce6a18; }
.button.primary:hover { background: #ffdc91; }
.button.secondary { background: #263d5c; color: #f0f6ff; border: 1px solid #7890ad; }
.button.secondary:hover { background: #324e71; }
.text-button { pointer-events: auto; border: 0; background: transparent; color: #9ce7f4; font-size: 17px; min-height: 44px; padding: 10px 0; line-height: 1.4; text-decoration: underline; text-underline-offset: 4px; }
.text-button:hover { color: #ffdf9c; }

.start-screen { position: absolute; inset: 0; pointer-events: none; }
.start-screen button { pointer-events: auto; }
.start-card { position: absolute; left: 60%; top: 48%; transform: translateY(-50%); width: 36%; max-width: 490px; max-height: calc(100dvh - 220px); overflow-y: auto; overscroll-behavior: contain; pointer-events: auto; padding: 4px; scrollbar-color: #88a2c4 #14243d; }
.start-card > p { margin: 0 0 24px; color: #d2def0; }
.start-card .button { width: 100%; max-width: 340px; margin-bottom: 10px; }
.start-features { display: flex; flex-wrap: wrap; gap: 8px; font-size: 15px; line-height: 1.4; color: #c5d3e8; margin: 12px 0 18px; }
.start-features i { font-style: normal; color: #a8bdd7; }
.mini-controls { display: flex; flex-wrap: wrap; gap: 14px; font-size: 15px; color: #c5d3e8; }
.mini-controls > span { display: flex; align-items: center; gap: 4px; }
.planet-caption { position: absolute; left: 7%; top: 68%; display: flex; flex-direction: column; gap: 5px; width: max-content; max-width: 42%; padding: 16px 20px; background: #10213b; border: 1px solid #6685a7; border-radius: 14px; box-shadow: 0 8px 28px #02081855; }
.planet-caption strong { font-size: 28px; line-height: 1.15; letter-spacing: -.5px; color: #fff; }
.planet-caption > span:not(.eyebrow) { font-size: 17px; line-height: 1.4; color: #d5e4f6; }
.planet-caption small { font-size: 15px; line-height: 1.4; color: #c5d3e8; }
.route { position: absolute; bottom: max(24px,env(safe-area-inset-bottom)); left: 5%; right: 5%; display: flex; align-items: center; gap: 24px; padding: 10px 16px; border-radius: 12px; background: #101c33; }
.route-label { font-size: 15px; font-weight: 600; letter-spacing: .4px; color: #c5d3e8; white-space: nowrap; }
#planet-route { flex: 1; display: flex; align-items: center; justify-content: space-between; position: relative; gap: 8px; }
#planet-route:before { content: ''; position: absolute; top: 9px; left: 4%; right: 4%; height: 1px; background: #6685a7; }
.route-planet { position: relative; display: flex; align-items: center; flex-direction: column; gap: 9px; font-size: 15px; line-height: 1.2; color: #c7d7ed; min-width: 56px; }
.route-planet i { border-radius: 50%; width: 15px; height: 15px; background: var(--planet); margin-top: 2px; box-shadow: inset -4px -3px 4px #0008; }
.route-planet.current { color: #fff; font-weight: 700; }
.route-planet.current i { box-shadow: 0 0 0 4px #79bfff30,0 0 0 5px #98cbff; }
.route-finish { color: var(--amber); font-size: 30px; margin-top: -16px; }

/* Ground HUD is read-only; camera drags pass through every label. */
#ground-hud { pointer-events: none; }
#capture-button { pointer-events: auto; }
.mission-card { position: absolute; top: 108px; left: 24px; width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.mission-card h2 { font-size: 26px; line-height: 1.2; letter-spacing: -.4px; margin: 8px 0; }
.mission-card p { font-size: 17px; line-height: 1.45; margin: 0 0 16px; color: #d0def1; }
.enemy-progress { display: flex; gap: 5px; }
.enemy-progress i { flex: 1; height: 8px; border-radius: 3px; background: #5a6d88; }
.enemy-progress i.done { background: var(--amber); }
.enemy-progress i:nth-child(5) { margin-right: 7px; }
.mission-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 15px; line-height: 1.4; color: #d0def1; }
.mission-foot span:last-child { color: #ffdc91; text-align: right; }
.crosshair { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); font-size: 25px; color: #fff; font-weight: 300; text-shadow: 0 0 5px #000; }
.aim-ready { color: #9cf1dc !important; text-shadow: 0 0 12px #71fbd7 !important; transform: translate(-50%,-50%) scale(1.2); }
.bottom-hud { position: absolute; bottom: max(20px,env(safe-area-inset-bottom)); left: 24px; right: 24px; display: flex; justify-content: space-between; align-items: end; gap: 18px; }
.health-panel, .sword-panel { background: var(--panel); border: 1px solid var(--line); padding: 12px 16px; border-radius: 11px; min-width: 140px; }
.health-panel .eyebrow, .sword-panel .eyebrow { font-size: 15px; letter-spacing: .3px; }
#hearts { color: #ffb1a6; font-size: 23px; letter-spacing: 1px; line-height: 1.25; margin-top: 4px; white-space: nowrap; }
.sword-panel { display: flex; gap: 12px; align-items: center; }
.sword-panel strong { display: block; font-size: 17px; line-height: 1.35; color: #ffdfaa; }
.sword-symbol { font-size: 28px; color: var(--amber); }
.ground-instructions { font-size: 15px; color: #e0eafd; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; padding: 9px 12px; max-width: 620px; background: #10213b; border-radius: 10px; }
.ground-instructions kbd:not(:first-child) { margin-left: 4px; }
.compass { position: absolute; top: 108px; right: 24px; font-size: 15px; line-height: 1.4; color: #e1efff; background: #10213b; border: 1px solid var(--line); border-radius: 16px; padding: 10px 16px; max-width: 320px; text-align: center; }
.capture { position: absolute; left: 50%; bottom: 158px; transform: translateX(-50%); color: #e5f4ff; background: #172a47; border: 1px solid #84a6cf; font-size: 15px; min-height: 44px; padding: 10px 14px; }
.mouse-look-hint { position: absolute; left: 50%; bottom: 108px; transform: translateX(-50%); font-size: 15px; line-height: 1.4; color: #e1efff; background: #10213b; padding: 9px 14px; border-radius: 9px; max-width: 90%; text-align: center; pointer-events: none; }
.boss-hud { position: absolute; top: 108px; left: 50%; transform: translateX(-50%); width: 360px; max-width: calc(100% - 32px); text-align: center; background: #261d30; border: 1px solid #9d7989; border-radius: 14px; padding: 14px 18px; }
.boss-hud > span { font-size: 17px; font-weight: 700; letter-spacing: .4px; color: #ffdf9c; }
.boss-hud > div { height: 12px; background: #605163; border-radius: 6px; margin: 10px 0; overflow: hidden; }
.boss-hud i { display: block; height: 100%; background: linear-gradient(90deg,#f56c4f,#ffce6a); width: 100%; transition: width .2s; }
.boss-hud small { font-size: 15px; line-height: 1.4; color: #ffe0bd; }
.compass.boss-compass { top: 232px; left: 50%; right: auto; transform: translateX(-50%); max-width: 360px; }

.toast { position: absolute; left: 50%; bottom: 140px; transform: translateX(-50%); z-index: 15; background: #172b44; border: 1px solid #8fbdcd; border-radius: 12px; padding: 16px 22px; color: #f1f7ff; font-size: 17px; line-height: 1.45; box-shadow: 0 10px 45px #0006; max-width: 600px; width: max-content; text-align: center; animation: pop .25s ease; pointer-events: none; }
.toast strong { color: var(--amber); }
@keyframes pop { from { opacity: 0; translate: 0 12px; } to { opacity: 1; translate: 0 0; } }
.modal-backdrop { position: absolute; inset: 0; z-index: 30; background: #040b20d9; backdrop-filter: blur(14px); display: grid; place-items: center; padding: max(20px,env(safe-area-inset-top)) max(20px,env(safe-area-inset-right)) max(20px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left)); }
.modal { width: min(680px,100%); max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; background: #111f38; border: 1px solid #657f9f; border-radius: 22px; padding: 32px; box-shadow: 0 20px 90px #0007; scrollbar-color: #88a2c4 #14243d; }
.modal h2 { font-size: 32px; line-height: 1.2; letter-spacing: -.6px; margin: 12px 0 20px; }
.modal p, .modal li { font-size: 17px; color: #d0def1; line-height: 1.6; }
.modal ul { padding-left: 24px; }
.modal .button { margin-top: 10px; }
.modal-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.modal a { color: #9ce7f4; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.help-grid h3 { font-size: 20px; color: #ffda8a; line-height: 1.3; }
.help-grid p { font-size: 17px; }
.help-note { font-size: 15px !important; color: #c5d3e8 !important; line-height: 1.55; }
.sound-setting { display: block; color: #deebfc; font-size: 17px; line-height: 1.5; margin: 24px 0; }
.sound-setting output { float: right; color: var(--amber); }
.sound-setting input { display: block; width: 100%; min-height: 44px; margin-top: 10px; accent-color: var(--amber); }
.sound-setting input[type=text] { background: #09172b; border: 1px solid #8096b3; color: white; padding: 12px; font: inherit; border-radius: 8px; }
#parent-answer { font-size: 18px; }
.mute-setting { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 0; font-size: 17px; }
.mute-setting input { width: 24px; height: 24px; accent-color: var(--amber); }
.ending { text-align: center; }
.ending h1 { font-size: 52px; }
.ending .button { margin: auto; }
.ending .eyebrow { color: var(--amber); }

/* Telemetry has reserved rows so a changing value cannot move a held button. */
.flight-sidebar { position: absolute; right: 24px; top: 108px; bottom: 108px; width: 320px; border: 1px solid var(--line); background: #11203a; border-radius: 16px; padding: 18px; display: grid; grid-template-rows: minmax(0,1fr) auto; gap: 12px; }
.flight-sidebar > div:first-child { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #88a2c4 #14243d; padding-right: 3px; }
.flight-sidebar > div:last-child { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); column-gap: 8px; }
.flight-sidebar h2 { font-size: 26px; line-height: 1.2; letter-spacing: -.4px; min-height: 62px; margin: 8px 0 12px; }
.flight-sidebar p { font-size: 17px; line-height: 1.45; color: #d0def1; }
#flight-instruction { margin: 0; }
.flight-steps { display: flex; gap: 6px; margin: 18px 0 4px; }
.flight-steps span { height: 6px; flex: 1; background: #5b6e89; border-radius: 5px; }
.flight-steps span.active { background: #ffce6a; }
.flight-stat { grid-column: 1/-1; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 10px 0; height: 50px; font-size: 15px; line-height: 1.3; color: #c5d3e8; }
.flight-stat strong { color: #f0f6ff; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.flight-sidebar .button { width: 100%; font-size: 17px; padding: 12px; gap: 8px; }
#flight-action { grid-column: 1/span 2; min-height: 64px; height: 64px; padding: 6px 8px; flex-shrink: 0; transform: none; margin-top: 8px; }
#flight-subtext { grid-column: 1/-1; height: 68px; margin: 10px 0 0; overflow-y: auto; overscroll-behavior: contain; font-size: 15px; line-height: 1.4; color: #c5d3e8; }
.flight-legend { position: absolute; left: 24px; top: 108px; display: flex; flex-direction: column; gap: 10px; font-size: 15px; line-height: 1.35; color: #d0def1; padding: 12px 14px; background: #10213b; border: 1px solid #435e7e; border-radius: 12px; pointer-events: none; }
.legend-line { display: inline-block; width: 25px; height: 0; border-top: 2px dashed #ffce6a; margin-right: 9px; vertical-align: middle; }
.legend-line.cyan { border-style: solid; border-color: #6ce6ec; }
.legend-line.gray { border-color: #b0c5df; }
.flight-inline-legend { display: none; }
.flight-sidebar .flight-inline-legend.landing-legend { display: block; font-size: 15px; line-height: 1.4; margin: 12px 0 0; color: #d0def1; }
.flight-feedback { position: absolute; top: 108px; left: 50%; transform: translateX(-50%); width: min(390px,calc(100% - 400px)); background: #10213b; border: 1px solid #6685a7; border-radius: 16px; color: #edf7ff; padding: 10px 16px; font-size: 17px; line-height: 1.4; text-align: center; pointer-events: none; }
.flight-controls { position: absolute; left: 50%; bottom: max(18px,env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: #12223c; border: 1px solid var(--line); padding: 12px; border-radius: 13px; white-space: nowrap; }
.flight-controls button { background: #263d5c; border: 1px solid #7890ad; color: #f0f7ff; border-radius: 8px; height: 48px; min-width: 48px; padding: 0 10px; font-size: 17px; line-height: 1.2; }
.flight-controls button.selected { border-color: #ffce6a; color: #ffdf9c; background: #493e25; }
.flight-controls .boost-button { background: #ffce6a; color: #16263b; font-weight: 700; min-width: 136px; border: 0; }
.flight-controls .separator { height: 28px; width: 1px; background: #8397b2; }
.flight-controls span { font-size: 15px; color: #c5d3e8; }
.flight-controls button.demo-active { opacity: 1 !important; background: #ffdc83 !important; color: #142239 !important; border-color: #fff1ac !important; box-shadow: 0 0 0 3px #ffce6a55; }
.map-note { position: absolute; left: 24px; bottom: 28px; max-width: 230px; color: #c5d3e8; font-size: 15px; line-height: 1.4; padding: 8px 12px; background: #10213b; border-radius: 10px; pointer-events: none; }
.takeover { position: absolute; z-index: 22; left: 50%; top: 46%; transform: translate(-50%,-50%); width: min(480px,calc(100% - 40px)); max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; padding: 28px; background: #10223c; border: 2px solid #ffce6a; border-radius: 22px; box-shadow: 0 20px 90px #020812b8; text-align: center; }
.takeover h2 { font-size: 30px; line-height: 1.2; margin: 12px 0; }
.takeover p { font-size: 17px; line-height: 1.55; margin: 12px 0 22px; color: #d7e6f8; }
.takeover .button { width: 100%; font-size: 17px; }
#flight-demo { grid-column: 3; display: flex; position: static; width: auto; min-width: 0; height: 64px; margin-top: 8px; text-align: center; pointer-events: auto; }
#flight-demo button { width: 100%; height: 100%; min-height: 44px; pointer-events: auto; background: #193650; border: 1px solid #8edbe1; color: #f0fcff; border-radius: 10px; padding: 4px 6px; font: inherit; font-weight: 600; font-size: 15px; line-height: 1.3; }
#flight-demo-status { display: none; }

/* Independent thumb zones continue to work with two fingers or a trackpad. */
#touch-controls { position: absolute; left: 20px; bottom: 95px; display: flex; gap: 5px; }
#touch-controls button { background: #294263; border: 1px solid #87b8e1; color: #fff; border-radius: 9px; min-width: 48px; height: 48px; touch-action: none; }
.touch-device #touch-controls { inset: auto max(24px,env(safe-area-inset-right)) max(25px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left)); height: 156px; max-width: none; display: block; pointer-events: none; }
.touch-device #move-stick { position: absolute; left: 0; bottom: 0; width: 150px; height: 150px; border-radius: 50%; background: #19324c; border: 2px solid #87b8d5; box-shadow: inset 0 0 30px #07192b66; touch-action: none; pointer-events: auto; display: grid; place-items: center; }
.stick-label { position: absolute; top: 14px; font-size: 15px; font-weight: 600; letter-spacing: .4px; color: #e3f1ff; pointer-events: none; }
#stick-knob { width: 64px; height: 64px; border-radius: 50%; background: #76aaca; border: 2px solid #c2edfc; box-shadow: 0 4px 20px #06132855; pointer-events: none; }
.touch-actions { position: absolute; right: 0; bottom: 0; display: grid; grid-template-columns: 76px 100px; gap: 10px; align-items: end; pointer-events: auto; }
.touch-device #touch-controls .touch-actions button { width: 76px; height: 58px; border-radius: 18px; font-size: 17px; margin: 0; flex: none; background: #234060; }
.touch-device #touch-controls #touch-attack { grid-column: 2; grid-row: 1/3; width: 100px; height: 126px; border-radius: 30px; background: #ffce6a; color: #172840; font-weight: 800; font-size: 18px; border: 2px solid #ffe2a1; }
.touch-device .touch-look-label { position: absolute; right: 0; top: -29px; color: #e3f1ff; background: #10213b; padding: 4px 8px; border-radius: 6px; font-size: 15px; line-height: 1.4; letter-spacing: .3px; }
.touch-device .bottom-hud { bottom: calc(192px + env(safe-area-inset-bottom)); pointer-events: none; align-items: start; }
.touch-device .sword-panel { max-width: 245px; }
.touch-device .ground-instructions, .touch-device .capture, .touch-device .mini-controls { display: none !important; }
.touch-device .flight-controls button { height: 52px; }
.touch-device .toast { bottom: calc(286px + env(safe-area-inset-bottom)); }

@media (max-width: 1100px) {
  .route-label { display: none; }
  .ground-instructions { display: none; }
  .map-note { display: none; }
  .flight-feedback { top: 230px; left: calc((100% - 368px)/2); width: calc(100% - 408px); }
  .start-card { left: 56%; width: 40%; }
  .brand { font-size: 17px; letter-spacing: 1px; }
  .chapter-badge { padding: 11px 14px; }
}
@media (orientation: portrait) and (max-width: 1000px) {
  .start-card { left: 8%; width: 84%; max-width: none; top: auto; bottom: 126px; max-height: 44dvh; transform: none; }
  .start-card h1 { font-size: 48px; letter-spacing: -1.5px; margin: 16px 0; }
  .start-card > p { font-size: 18px; margin-bottom: 20px; }
  .start-card .button { max-width: 360px; }
  .planet-caption { left: 7%; top: 28%; max-width: 72%; }
  .route { left: 4%; right: 4%; bottom: max(24px,env(safe-area-inset-bottom)); gap: 12px; }
  .flight-sidebar { top: auto; left: 16px; right: 16px; bottom: calc(112px + env(safe-area-inset-bottom)); height: 330px; width: auto; grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-rows: minmax(0,1fr); gap: 22px; }
  .flight-sidebar h2 { min-height: 62px; }
  .flight-stat { height: 44px; padding: 7px 0; }
  #flight-subtext { height: 60px; }
  .flight-feedback { left: 50%; top: 230px; width: calc(100% - 64px); max-width: 560px; }
}
@media (max-width: 700px) {
  .topbar { padding: max(12px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) 12px max(16px,env(safe-area-inset-left)); gap: 8px; }
  .brand { font-size: 16px; letter-spacing: .5px; }
  .brand-star { margin-right: 6px; }
  .brand-star svg { width: 24px; height: 24px; }
  .top-actions { gap: 6px; }
  .chapter-badge { position: absolute; top: calc(66px + env(safe-area-inset-top)); left: 16px; right: 16px; min-height: 36px; font-size: 15px; letter-spacing: 0; padding: 7px 10px; border-radius: 12px; }
  .start-card { top: 34%; bottom: calc(130px + env(safe-area-inset-bottom)); left: 16px; width: calc(100% - 32px); max-height: none; padding: 16px; background: #101b32; border: 1px solid #435e7e; border-radius: 16px; }
  .start-card h1 { font-size: 36px; letter-spacing: -1px; margin: 12px 0; }
  .start-card > p { font-size: 17px; line-height: 1.5; margin-bottom: 16px; }
  .start-card .button { max-width: none; padding: 12px 16px; }
  .start-features { gap: 6px; margin: 8px 0; }
  .mini-controls { display: none; }
  .planet-caption { top: 120px; left: 16px; max-width: calc(100% - 32px); padding: 12px 16px; gap: 3px; }
  .planet-caption strong { font-size: 24px; }
  .planet-caption small { display: none; }
  .route { left: 16px; right: 16px; bottom: max(14px,env(safe-area-inset-bottom)); padding: 12px; }
  .route-finish { display: none; }
  #planet-route { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px 8px; }
  #planet-route:before { display: none; }
  .route-planet { flex-direction: row; justify-content: center; font-size: 15px; gap: 5px; min-width: 0; }
  .route-planet i { width: 11px; height: 11px; flex-shrink: 0; margin: 0; }
  .mission-card { top: calc(116px + env(safe-area-inset-top)); left: 16px; width: calc(100% - 32px); max-width: 350px; padding: 14px 16px; }
  .mission-card h2 { font-size: 24px; }
  .mission-card p { margin-bottom: 12px; }
  .compass { top: calc(340px + env(safe-area-inset-top)); right: 16px; max-width: calc(100% - 32px); padding: 8px 12px; }
  .bottom-hud { left: 16px; right: 16px; gap: 12px; }
  .health-panel, .sword-panel { min-width: 0; padding: 10px 12px; }
  #hearts { font-size: 21px; }
  .sword-panel { max-width: 53%; gap: 7px; }
  .sword-symbol { display: none; }
  .sword-panel strong { font-size: 17px; }
  .toast { font-size: 17px; width: calc(100% - 32px); bottom: 118px; padding: 12px 16px; }
  .modal-backdrop { padding: max(16px,env(safe-area-inset-top)) 16px max(16px,env(safe-area-inset-bottom)); }
  .modal { padding: 22px; }
  .modal h2 { font-size: 28px; }
  .help-grid { grid-template-columns: 1fr; gap: 0; }
  .help-grid h3 { margin: 14px 0 8px; }
  .modal-actions .button { flex: 1 1 auto; }
  .boss-hud { top: calc(116px + env(safe-area-inset-top)); }
  .compass.boss-compass { top: calc(252px + env(safe-area-inset-top)); width: calc(100% - 32px); }
  .touch-device #touch-controls { left: 16px; right: 16px; height: 132px; }
  .touch-device #move-stick { width: 126px; height: 126px; }
  .touch-device #stick-knob { width: 54px; height: 54px; }
  .touch-actions { grid-template-columns: 66px 94px; gap: 8px; }
  .touch-device #touch-controls .touch-actions button { width: 66px; height: 58px; }
  .touch-device #touch-controls #touch-attack { width: 94px; height: 124px; }
  .touch-device .touch-look-label { font-size: 15px; }
  .touch-device .bottom-hud { bottom: calc(186px + env(safe-area-inset-bottom)); }
  .touch-device .toast { bottom: calc(280px + env(safe-area-inset-bottom)); }
  .flight-sidebar { bottom: calc(138px + env(safe-area-inset-bottom)); height: 320px; grid-template-columns: 1fr; grid-template-rows: minmax(0,1fr) auto; gap: 10px; padding: 14px 16px; }
  .flight-sidebar.is-scrollable > div:first-child { padding-bottom: 30px; }
  .flight-sidebar.is-scrollable::after { content: 'Swipe ↑ for all flight steps'; position: absolute; bottom: 148px; left: 16px; right: 16px; background: #11203a; border-top: 1px solid #526984; color: #9ce7f4; font-size: 15px; line-height: 1.4; padding: 4px 0 0; pointer-events: none; }
  .flight-sidebar h2 { min-height: 0; font-size: 24px; margin: 6px 0 8px; }
  .flight-sidebar > div:last-child { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); column-gap: 10px; }
  .flight-stat { grid-column: auto; height: 66px; flex-direction: column; align-items: start; justify-content: center; gap: 4px; padding: 6px 0; }
  .flight-stat strong { text-align: left; }
  #flight-action { grid-column: 1/span 2; margin-top: 6px; min-height: 52px; height: 52px; font-size: 15px; padding: 4px 6px; }
  #flight-subtext { display: none; }
  .flight-steps { margin: 12px 0 4px; }
  .flight-controls { width: calc(100% - 32px); max-width: 430px; justify-content: center; flex-wrap: wrap; padding: 8px; gap: 6px; bottom: max(12px,env(safe-area-inset-bottom)); }
  .flight-controls button, .touch-device .flight-controls button { height: 44px; min-width: 48px; padding: 0 8px; }
  .flight-controls .boost-button { min-width: 136px; }
  .flight-controls .separator { width: 100%; height: 0; }
  .flight-controls span { display: none; }
  .flight-legend { display: none; }
  .flight-sidebar .flight-inline-legend { display: block; font-size: 15px; line-height: 1.4; margin: 12px 0 0; color: #d0def1; }
  .flight-feedback { top: calc(112px + env(safe-area-inset-top)); left: 50%; width: calc(100% - 32px); max-width: none; font-size: 17px; padding: 10px 12px; }
  #flight-demo { height: 52px; margin-top: 6px; }
  .takeover { top: 50%; padding: 22px; }
  .takeover h2 { font-size: 28px; }
}

/* Short windows retain readable text and scroll the narrative, not the controls. */
@media (max-height: 600px) and (orientation: landscape) {
  .topbar { padding-top: max(8px,env(safe-area-inset-top)); padding-bottom: 8px; gap: 10px; }
  .brand { font-size: 16px; }
  .chapter-badge { position: static; font-size: 15px; padding: 8px 12px; letter-spacing: 0; }
  .start-card { left: 54%; right: 20px; top: 74px; bottom: 20px; width: auto; max-height: none; transform: none; padding: 16px; background: #101b32; border: 1px solid #435e7e; border-radius: 16px; }
  .start-card h1 { font-size: 36px; letter-spacing: -1px; margin: 12px 0; }
  .start-card > p { font-size: 17px; margin-bottom: 16px; }
  .start-card .button { padding: 12px 16px; }
  .start-features { font-size: 15px; margin: 8px 0; }
  .mini-controls { display: none; }
  .planet-caption { top: 82px; bottom: auto; left: 24px; max-width: 46%; padding: 12px 16px; }
  .planet-caption strong { font-size: 26px; }
  .planet-caption small { display: none; }
  .route { left: 24px; right: 50%; bottom: max(20px,env(safe-area-inset-bottom)); padding: 12px; }
  .route-label, .route-finish { display: none; }
  #planet-route { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px 8px; }
  #planet-route:before { display: none; }
  .route-planet { font-size: 15px; min-width: 0; }
  .mission-card { top: 70px; left: max(16px,env(safe-area-inset-left)); width: 300px; padding: 12px 16px; }
  .mission-card h2 { font-size: 22px; margin: 5px 0; }
  .mission-card p { font-size: 17px; line-height: 1.4; margin-bottom: 10px; }
  .compass { top: 70px; right: max(16px,env(safe-area-inset-right)); max-width: 270px; font-size: 15px; }
  .bottom-hud { bottom: max(12px,env(safe-area-inset-bottom)); }
  .health-panel, .sword-panel { padding: 8px 12px; min-width: 0; }
  #hearts { font-size: 21px; }
  .ground-instructions, .mouse-look-hint { display: none; }
  .capture { bottom: 92px; }
  .touch-device #touch-controls { height: 112px; bottom: max(15px,env(safe-area-inset-bottom)); }
  .touch-device #move-stick { width: 112px; height: 112px; }
  .touch-device #stick-knob { width: 50px; height: 50px; }
  .touch-device .bottom-hud { left: 154px; right: 220px; bottom: max(15px,env(safe-area-inset-bottom)); justify-content: center; gap: 10px; }
  .touch-device .health-panel .eyebrow, .touch-device .sword-panel .eyebrow { display: none; }
  .touch-device .sword-panel { max-width: 210px; }
  .touch-device .touch-look-label { display: none; }
  .touch-device .touch-actions { grid-template-columns: 66px 90px; gap: 8px; }
  .touch-device #touch-controls .touch-actions button { width: 66px; height: 48px; }
  .touch-device #touch-controls #touch-attack { width: 90px; height: 104px; font-size: 18px; }
  .boss-hud { top: 70px; width: 340px; padding: 10px 16px; }
  .compass.boss-compass { top: 188px; max-width: 340px; }
  .toast, .touch-device .toast { bottom: 136px; font-size: 17px; max-width: 60%; }
  .modal { max-height: 90dvh; padding: 22px; }
  .flight-sidebar { left: auto; right: max(16px,env(safe-area-inset-right)); top: 70px; bottom: 82px; height: auto; width: 300px; padding: 12px 14px; grid-template-columns: 1fr; grid-template-rows: minmax(0,1fr) auto; gap: 8px; }
  .flight-sidebar h2 { font-size: 22px; min-height: 0; margin: 0 0 8px; }
  .flight-sidebar > div:first-child > .eyebrow { display: none; }
  .flight-sidebar.is-scrollable > div:first-child { padding-bottom: 28px; }
  .flight-sidebar.is-scrollable::after { content: 'Swipe ↑ for all flight steps'; position: absolute; bottom: 120px; left: 14px; right: 14px; background: #11203a; border-top: 1px solid #526984; color: #9ce7f4; font-size: 15px; line-height: 1.4; padding: 4px 0 0; pointer-events: none; }
  .flight-sidebar p { font-size: 17px; line-height: 1.4; }
  .flight-sidebar > div:last-child { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 0 8px; }
  .flight-stat { grid-column: auto; height: 52px; flex-direction: column; align-items: start; justify-content: center; gap: 2px; padding: 3px 0; font-size: 15px; }
  .flight-stat strong { text-align: left; }
  #flight-action { grid-column: 1/span 2; height: 44px; min-height: 44px; margin-top: 4px; padding: 2px 6px; font-size: 15px; }
  .flight-sidebar .flight-steps, #flight-subtext { display: none; }
  .flight-controls { left: 50%; bottom: max(10px,env(safe-area-inset-bottom)); width: auto; max-width: calc(100% - 32px); flex-wrap: nowrap; padding: 8px; gap: 6px; }
  .flight-controls button, .touch-device .flight-controls button { height: 44px; min-width: 44px; font-size: 17px; }
  .flight-controls .separator { width: 1px; height: 26px; }
  .flight-feedback { top: 70px; left: calc((100% - 348px)/2); width: calc(100% - 388px); max-width: 460px; font-size: 17px; }
  .flight-legend { display: none; }
  .flight-sidebar .flight-inline-legend { display: block; font-size: 15px; line-height: 1.4; margin: 12px 0 0; color: #d0def1; }
  .takeover { top: 50%; padding: 20px; width: 480px; max-height: 92dvh; }
  .takeover h2 { font-size: 26px; margin: 8px 0; }
  .takeover p { font-size: 17px; margin: 8px 0 16px; }
  #flight-demo { height: 44px; margin-top: 4px; }
}
/* Keep both adventure actions visible on the smallest landscape phones. */
@media (max-height: 450px) and (orientation: landscape) {
  .start-card:has(#begin-button) { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 14px; }
  .start-card:has(#begin-button) > .eyebrow,
  .start-card:has(#begin-button) > p,
  .start-card:has(#begin-button) > .start-features { display: none; }
  .start-card:has(#begin-button) h1 { flex-shrink: 0; font-size: 32px; line-height: 1.1; margin: 0 0 6px; }
  .start-card:has(#begin-button) .button { flex-shrink: 0; min-height: 52px; margin: 0; gap: 16px; }
  .start-card:has(#begin-button) .text-button { flex-shrink: 0; min-height: 44px; padding: 8px 0; text-align: left; }
}
@media (pointer: coarse) {
  .ground-instructions, .capture, .mini-controls { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .button, .toast, .boss-hud i { animation: none; transition: none; }
}

/* Holding controls never selects text, opens a callout, or zooms the game.
   Vertical panning remains available in narrative panels and help dialogs. */
html, body, #game { touch-action: pan-y; }
#game, #game * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#game input, #game textarea, #game [contenteditable="true"] { -webkit-user-select: text; user-select: text; touch-action: manipulation; }
#world, #flight, #touch-controls, .flight-controls, .flight-sidebar button, .takeover button, #flight-demo button { touch-action: none; }
#world:focus { outline: none; }
