/* Touch flight occupies its own gesture surface. Menus remain scrollable and zoomable. */
[hidden] { display: none !important; }
html, body { overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body { height: 100dvh; }
#hud, #universe, #touch-controls { touch-action: none; }
#hud, #hud *, button, button *, .start-screen h1 {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
button { touch-action: manipulation; }
#hud button, #touch-steer { touch-action: none; }
button.pressed { background: #9ce1ca; color: #09212a; border-color: #9ce1ca; }
dialog { overscroll-behavior: contain; touch-action: pan-y pinch-zoom; }
.wordmark { color: #f2ebdd; font-family: Arial, sans-serif; font-weight: 900; }
.wordmark span { color: #ef4c14; font-weight: 900; }
h1 { font-family: Arial, sans-serif; font-weight: 900; color: #ef4c14; }
h1 span { color: #f2ebdd; -webkit-text-stroke: 0; }
#dock-button {
  position: absolute; pointer-events: auto; top: 92px; left: 50%;
  transform: translateX(-50%); min-height: 46px; padding: 12px 20px;
  color: #daf5e8; background: #163d37ec; border-color: #91dbb881;
  font-size: 13px; z-index: 3;
}
#target-bracket {
  position: absolute; width: 48px; height: 48px; transform: translate(-50%, -50%);
  border: 2px solid #edb780; border-radius: 9px; box-shadow: 0 0 0 3px #08152380;
}
#target-bracket.ready { border-color: #9af1c4; }

@media (any-pointer: coarse), (max-width: 700px) {
  :root { --safe-bottom: env(safe-area-inset-bottom, 0px); --safe-top: env(safe-area-inset-top, 0px); }
  .topbar { padding: calc(14px + var(--safe-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left)); gap: 16px; }
  .wordmark { font-size: 13px; letter-spacing: -.2px; }
  .wordmark small, .sector, #log-button, .top-actions kbd { display: none; }
  .top-actions { gap: 10px; }
  .top-actions button { min-width: 54px; min-height: 44px; padding: 10px 12px; font-size: 12px; background: #102431b8; }
  #steer-dot, .flight-help { display: none; }
  #touch-controls {
    display: flex; position: absolute; z-index: 4;
    bottom: calc(18px + var(--safe-bottom)); left: max(18px, env(safe-area-inset-left)); right: max(18px, env(safe-area-inset-right));
    justify-content: space-between; align-items: end; gap: 18px; pointer-events: none;
  }
  #touch-steer {
    display: grid; place-items: center; flex: none; pointer-events: auto;
    width: clamp(104px, 30vw, 136px); aspect-ratio: 1;
    border: 1px solid #91c5cc66; border-radius: 50%; background: #08182780;
    box-shadow: inset 0 0 0 22px #91c5cc08; margin-bottom: 3px;
  }
  #touch-steer span { display: block; width: 36px; height: 36px; border: 1px solid #c3e8e67a; border-radius: 50%; background: #91c5cc55; pointer-events: none; }
  .touch-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 72px)); gap: 10px; pointer-events: auto; }
  .touch-actions button, #maneuver-drawer button { min-height: 54px; padding: 9px 4px; font: 600 12px 'Segoe UI', sans-serif; background: #102738d9; border: 1px solid #95b4c261; border-radius: 9px; }
  .touch-actions button.pressed, #maneuver-drawer button.pressed, #fly-toggle[aria-pressed=true] { background: #a0dfca; border-color: #b7f0dc; color: #0e292b; }
  #fly-toggle { border-color: #9adcc7b0; color: #c8f4e3; }
  #touch-fire { grid-column: 1 / -1; min-height: 46px; color: #f8d2ac; }
  #touch-fire.ready { border-color: #a7edc6; color: #c9f8dd; background: #204936ed; }
  #maneuver-drawer {
    position: absolute; right: 0; bottom: calc(100% + 14px); width: 180px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px;
    background: #081725f5; border: 1px solid #7fadb65c; border-radius: 13px; pointer-events: auto;
  }
  #maneuver-drawer button { min-height: 44px; font-size: 11px; }
  .flightdeck {
    bottom: calc(206px + var(--safe-bottom)); padding: 0 20px;
    align-items: center; gap: 14px; background: none;
  }
  .instruments { width: auto; display: flex; align-items: center; gap: 13px; }
  .speed { gap: 5px; }
  .speed strong { font-size: 27px; letter-spacing: -1px; }
  .speed span { font-size: 9px; }
  #drive-state { display: none; }
  .meter { width: 54px; margin: 0; }
  .meter label { font-size: 8px; letter-spacing: .2px; white-space: nowrap; }
  .meter label span { display: none; }
  .meter > div { height: 4px; margin-top: 7px; }
  .boost label { font-size: 0; }
  .boost label::before { content: 'BOOST'; font-size: 8px; }
  .cargo { min-width: 0; gap: 0; }
  .cargo > small, #score-total { display: none; }
  .cargo strong { font-size: 22px; white-space: nowrap; }
  .cargo em { font-size: 9px; }
  .maneuvers-open .flightdeck { visibility: hidden; }
  #notifications { top: calc(134px + var(--safe-top)); left: 20px; right: 20px; max-width: none; justify-items: center; }
  .toast { font-size: 11px; padding: 9px 13px; border-left: 0; border-radius: 5px; text-align: center; background: #081827d9; max-width: 310px; }
  .toast small { display: none; }
  #trick { top: calc(191px + var(--safe-top)); right: 22px; max-width: calc(100% - 44px); gap: 4px; }
  #trick small { display: none; }
  #trick strong { font-size: 20px; }
  #trick-score { font-size: 13px; }
  .poi { font-size: 11px; gap: 7px; }
  .poi small { font-size: 9px; margin-top: 3px; }
  #hint { top: calc(81px + var(--safe-top)); bottom: auto; padding: 0 26px; font: 11px 'Segoe UI', sans-serif; color: #a8c2cc; }
  #dock-button { top: calc(77px + var(--safe-top)); font-size: 12px; padding: 12px 18px; }
  #target-lock { top: calc(50% + 39px); font: 11px 'Segoe UI', sans-serif; padding: 0 24px; }
  dialog { padding: 24px; max-height: calc(100dvh - 36px - var(--safe-top)); }
  .panel-heading { margin-bottom: 26px; gap: 18px; }
  .panel-heading h2 { font-size: 25px; }
  #close-panel { min-width: 44px; min-height: 44px; }
  .menu-actions { gap: 12px; }
  .menu-actions button { min-height: 48px; }
  .setting { padding: 18px 0; gap: 20px; }
  .setting select, .setting input { font-size: 16px; }
  .upgrades, .catalog-grid, .controls-grid { grid-template-columns: 1fr; gap: 18px; }
  .upgrade { padding: 20px; }
  .upgrade p { min-height: 0; line-height: 1.7; }
  .upgrade button { min-height: 46px; }
  .destination-list { grid-template-columns: 1fr; gap: 12px; }
  .destination-list button { padding: 16px; line-height: 1.5; }
  .destination-list small { margin-top: 7px; }
  .chart { display: none; }
  .paints { gap: 12px; }
  .paint { min-height: 100px; width: calc(50% - 6px); }
  .start-screen { padding: 28px; align-items: center; }
  .start-copy { max-width: 100%; }
  .mission { margin-top: 38px; font-size: 9px; letter-spacing: 1.5px; }
  h1 { font-size: clamp(62px, 17vw, 92px); letter-spacing: -4px; }
  h1 i { right: 0; }
  .intro { font-size: 18px; }
  .start-description { font-size: 13px; max-width: 320px; }
  .start-controls, .ship-caption, .start-bottom { display: none; }
  .start-screen .fine { font-size: 10px; max-width: 290px; }
}
@media (any-pointer: coarse) and (orientation: landscape) {
  #touch-controls { left: max(26px, env(safe-area-inset-left)); right: max(26px, env(safe-area-inset-right)); }
  #touch-steer { width: 114px; }
  .flightdeck { left: 180px; right: 192px; width: auto; bottom: calc(22px + var(--safe-bottom)); padding: 0 20px; }
  .instruments { gap: 10px; }
  .meter { width: 42px; }
  #notifications { left: 175px; right: 190px; top: 107px; }
  #trick { top: 150px; right: 190px; }
  #maneuver-drawer { width: 356px; grid-template-columns: repeat(4, 1fr); }
  .mission { margin-top: 20px; }
  h1 { font-size: 64px; margin: 20px 0; }
  .intro { margin: 10px 0; }
  .start-description { display: none; }
  .start-screen .fine { margin: 10px 0; }
}
@media (max-width: 355px) {
  .topbar { gap: 8px; padding-left: 14px; padding-right: 14px; }
  .top-actions { gap: 6px; }
  .wordmark { font-size: 12px; }
  #touch-controls { left: 14px; right: 14px; gap: 12px; }
  .flightdeck { padding: 0 14px; }
  .instruments { gap: 9px; }
  .meter { width: 44px; }
}
@media (any-pointer: coarse) and (max-height: 500px) {
  .start-screen .mission { display: none; }
  .start-screen h1 { font-size: 48px; margin: 18px 0; }
  .start-screen .intro { font-size: 15px; margin: 8px 0 16px; }
  .start-screen .fine { margin: 6px 0; font-size: 9px; }
  .start-screen .start-copy > .fine:last-child { display: none; }
}
@media (pointer: fine) and (min-width: 701px) and (max-height: 600px) {
  .mission { margin-top: 20px; }
  h1 { font-size: 60px; margin: 16px 0; }
  .intro { margin: 12px 0; }
  .start-description { margin: 12px 0; font-size: 12px; }
  .start-controls { margin: 12px 0; }
  .start-bottom { display: none; }
  .primary { padding: 13px 20px; }
}
