#hud {
  --cyan: #73e8ff;
  --edge: #369bc6;
  --frame: #041220;
  --red: #ff645e;
  --hud-inset: max(12px, env(safe-area-inset-left), env(safe-area-inset-right));
  color: #edfbff;
  font: 700 13px/1.25 system-ui, sans-serif;
}

.unified-header,
.canopy-readout,
.canopy-heading,
#fleet-panel,
#flight-control-surface,
.unified-modes a {
  border: 1px solid var(--edge);
  background: linear-gradient(155deg, #0b263df7, #041220f5 65%);
  box-shadow: inset 0 0 10px #0286bd44, 0 0 10px #008fcc44;
}

.unified-header {
  position: absolute;
  inset: max(8px, env(safe-area-inset-top)) var(--hud-inset) auto;
  max-width: none;
  min-height: 48px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding-inline: 14px;
  border-radius: 9px;
  text-transform: uppercase;
}

.unified-header a { color: #c8f5ff; text-decoration: none; pointer-events: auto; }
.unified-brand {
  display: grid;
  align-content: center;
  min-height: 44px;
  width: fit-content;
  letter-spacing: .14em;
}
.unified-header .unified-brand small { font-size: 9px; letter-spacing: .32em; }
.unified-header strong { font-size: clamp(13px, 1.8vw, 23px); letter-spacing: .09em; }
.unified-header .flight-plan-link { justify-self: end; display: grid; align-content: center; min-height: 44px; }

.canopy-telemetry {
  position: absolute;
  inset: max(65px, calc(env(safe-area-inset-top) + 60px)) var(--hud-inset) auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.canopy-telemetry > * { padding: 6px 14px; border-radius: 8px; text-align: center; }
.canopy-readout:first-child { justify-self: start; }
.canopy-readout:last-child { justify-self: end; }
.canopy-telemetry b { display: block; color: white; font: 700 clamp(14px, 2vw, 23px) ui-monospace, monospace; }
.canopy-heading {
  min-width: clamp(90px, 16vw, 210px);
  border-width: 0 0 1px;
  background: linear-gradient(0deg, #051627f0, #06162466);
  border-radius: 0 0 8px 8px;
}
#mission, #combat-status, #stats {
  position: absolute;
  inset: auto;
  min-height: 0;
  line-height: 1.35;
}
#mission { top: 126px; left: var(--hud-inset); max-width: min(325px, 44vw); }
#combat-status { top: 126px; right: var(--hud-inset); width: min(250px, 42vw); }
#combat-status [data-combat-message] { min-height: 0; }
#stats:not(.advanced-telemetry) { display: none; }
#stats.advanced-telemetry { display: block; top: 211px; left: var(--hud-inset); text-align: left; }
#notice { top: 39%; padding: 0 8px; text-shadow: 0 1px 5px #000; }
#reticle {
  left: calc(50% + var(--aim-x, 0vw));
  top: calc(50% + var(--aim-y, 0vh));
  opacity: .8;
  outline: 1px solid #52caff77;
  outline-offset: 10px;
}
#reticle.is-aiming { border-color: var(--red); outline-color: #ff645e99; }
#reticle.is-aiming::before, #reticle.is-aiming::after { background: var(--red); }
#shield-field { position: absolute; inset: 0; opacity: 0; box-shadow: inset 0 0 55px 10px #36c4ff80; transition: opacity .2s; }
#hud.shields-visible #shield-field { opacity: 1; }

#fleet-panel {
  position: absolute;
  z-index: 8;
  top: 204px;
  right: var(--hud-inset);
  width: min(250px, 36vw);
  border-radius: 9px;
  pointer-events: auto;
}
#fleet-panel summary, .unified-tools summary { cursor: pointer; touch-action: manipulation; }
#fleet-panel summary { min-height: 44px; padding: 13px 10px; text-transform: uppercase; }
#fleet-count { color: var(--cyan); padding-left: 4px; }
.fleet-panel-body {
  max-height: max(90px, calc(100dvh - 482px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 8px 8px;
}
#fleet-active { margin: 0 0 7px; color: var(--cyan); font-size: 12px; }
#fleet-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
#fleet-cards button {
  display: grid;
  grid-template-rows: 30px auto;
  align-items: center;
  min-height: 54px;
  padding: 3px;
  font-size: 10px;
  letter-spacing: .025em;
  touch-action: manipulation;
}
#fleet-cards button[aria-pressed="true"] { background: #123a53; border-color: var(--cyan); box-shadow: inset 0 0 8px #46b9e059; }
#fleet-cards button:disabled { opacity: .62; cursor: default; }
#fleet-cards img { width: 100%; height: 30px; object-fit: contain; }
#fleet-cards button:last-child { grid-column: 1 / -1; }

.unified-dock {
  position: absolute;
  z-index: 9;
  inset: auto var(--hud-inset) max(8px, env(safe-area-inset-bottom));
  display: grid;
  gap: 6px;
}
#flight-control-surface {
  --yoke-size: clamp(74px, 12dvh, 114px);
  position: relative;
  inset: auto;
  width: min(100%, 920px);
  justify-self: center;
  transform: none;
  display: grid;
  grid-template-areas: "left console right";
  grid-template-columns: var(--yoke-size) minmax(0, 1fr) var(--yoke-size);
  align-items: start;
  gap: clamp(6px, 2vw, 25px);
  padding: 8px clamp(6px, 2vw, 20px);
  border-radius: 10px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: auto;
}
#hud[data-camera="chase"] #flight-control-surface {
  border-color: transparent;
  background: none;
  box-shadow: none;
}
.unified-stick { display: grid; justify-items: center; gap: 5px; color: #d6f5ff; font-size: 11px; text-align: center; text-transform: uppercase; }
#flight-yoke.unified-yoke, #missile-lock.unified-yoke {
  --stick-color: #67c8ff;
  --stick-glow: #0079ff;
  position: relative;
  display: block;
  width: var(--yoke-size);
  height: var(--yoke-size);
  padding: 0;
  border: 2px solid var(--stick-color);
  border-radius: 50%;
  background: radial-gradient(circle, #061527 52%, #164677 74%, #020e21 76%);
  box-shadow: inset 0 0 10px var(--stick-glow), 0 0 10px var(--stick-glow);
  cursor: grab;
  touch-action: none;
}
#missile-lock.unified-yoke {
  --stick-color: #ff8079;
  --stick-glow: #f32b23;
  background: radial-gradient(circle, #22090c 52%, #731917 74%, #20080c 76%);
}
.yoke-dial { position: absolute; inset: 10%; border-radius: 50%; border: 1px solid var(--stick-color); opacity: .65; pointer-events: none; }
.yoke-dial::before, .yoke-dial::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--stick-color);
  clip-path: polygon(50% 0, 57% 13%, 43% 13%, 50% 0, 50% 100%, 43% 87%, 57% 87%, 50% 100%);
}
.yoke-dial::after { rotate: 90deg; }
#flight-yoke-knob, #missile-yoke-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44%;
  height: 44%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--stick-color);
  background: radial-gradient(circle at 36% 26%, var(--stick-color), #081521 78%);
  color: #fff;
  box-shadow: 0 0 9px var(--stick-glow);
  transform: translate(-50%,-50%);
  font: 700 24px/1 system-ui;
  font-style: normal;
  pointer-events: none;
}
.unified-console { min-width: 0; display: grid; gap: 6px; align-self: center; }
.unified-actions, .unified-tools { display: grid; gap: 5px; }
.unified-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.unified-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#flight-control-surface :is(.unified-actions, .unified-tools) button, .unified-tools summary {
  min-height: 44px;
  padding: 4px;
  overflow-wrap: anywhere;
  font: 750 clamp(10px, 1.2vw, 14px)/1.1 system-ui, sans-serif;
  text-transform: uppercase;
  touch-action: manipulation;
}
.unified-actions button { background: linear-gradient(155deg, #0d2c49, #071a2a); border-color: #4eb5f6; box-shadow: inset 0 0 9px #0077ce66; }
.unified-actions button[aria-pressed="true"] { background: #115674; border-color: #bcfaff; }
#missile-fire {
  width: 100%;
  min-height: 44px;
  padding: 4px 2px;
  background: linear-gradient(155deg, #38151b, #210d14);
  border-color: #c66a69;
  color: #ffe2e1;
  font-size: 12px;
  text-transform: uppercase;
  touch-action: manipulation;
}
#hud[data-missile-locked="true"] #missile-lock { --stick-color: #ffd778; --stick-glow: #fbb750; }
#hud[data-missile-locked="true"] #missile-fire {
  background: #ffd778;
  border-color: #fff1c4;
  color: #2a1409;
  box-shadow: 0 0 12px #ffc45c99;
}
.unified-system-readouts { display: flex; flex-wrap: wrap; gap: 7px 14px; padding: 0 0 8px; color: var(--cyan); }
.flight-stick { grid-template-areas: "yoke" "throttle" "rift"; }
.flight-stick #flight-yoke { grid-area: yoke; }
.flight-stick #flight-rift { grid-area: rift; }
.unified-throttle {
  grid-area: throttle;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: 100%;
  padding: 4px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #071b2de8;
  color: #edfbff;
  font-size: .6875rem;
  text-transform: none;
}
.unified-throttle output { color: var(--cyan); }
#flight-throttle {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 44px;
  margin: 0;
  accent-color: var(--cyan);
  touch-action: none;
  cursor: pointer;
}
@media (orientation: portrait) and (max-width: 500px) {
  .unified-throttle { grid-template-columns: 1fr; }
}
#flight-control-surface .pilot-settings :is(#world-control, #quality-control) { display: block; }
#flight-control-surface .systems-drawer { background: #071724; text-align: left; }
#flight-control-surface .secondary-flight-controls button { min-height: 44px; padding: 5px; }
#hud :is(a,button,summary,[tabindex]):focus-visible { outline: 2px solid white; outline-offset: 2px; }

.unified-modes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; pointer-events: auto; }
.unified-modes a {
  display: grid;
  grid-template-rows: clamp(35px, 7dvh, 72px) minmax(44px, 1fr);
  overflow: hidden;
  border-radius: 7px;
  color: #fff;
  text-align: center;
  text-decoration: none;
}
.unified-modes img { width: 100%; height: 100%; object-fit: cover; }
.unified-modes span { align-self: center; padding: .3rem .5rem; text-wrap: balance; }
.unified-modes small { display: block; color: #99ddf6; font-size: 10px; }
@media (min-width: 1050px) and (min-height: 661px) {
  #hud:has(#fleet-panel[open]) #flight-control-surface {
    width: min(calc(100% - 262px), 1060px);
    justify-self: start;
  }
  #fleet-panel .fleet-panel-body { max-height: calc(100dvh - 370px); }
}
@media (max-width: 760px), (max-height: 660px) {
  #fleet-panel { top: 177px; width: min(240px, 42vw); }
  .fleet-panel-body { max-height: max(85px, calc(100dvh - 388px)); }
  #mission, #combat-status { top: 112px; padding: 5px 7px; font-size: 9px; }
  #stats.advanced-telemetry { top: 175px; }
  .canopy-telemetry { font-size: 10px; }
  .unified-modes { grid-template-columns: repeat(6, minmax(118px, 1fr)); overflow-x: auto; padding-bottom: 3px; scrollbar-width: thin; }
  .unified-modes a { font-size: .75rem; }
  .unified-modes small { font-size: 9px; }
}
@media (max-width: 500px) {
  #hud { --hud-inset: max(6px, env(safe-area-inset-left), env(safe-area-inset-right)); }
  .unified-header { grid-template-columns: 1fr auto; padding-inline: 7px; }
  .unified-header strong { display: none; }
  .unified-header a { font-size: 11px; }
  #flight-control-surface { --yoke-size: clamp(54px, 16vw, 76px); grid-template-columns: var(--yoke-size) minmax(0, 1fr) var(--yoke-size); gap: 5px; }
  .unified-stick { font-size: 9px; }
  .unified-actions button:last-child { grid-column: 1 / -1; }
  .unified-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #flight-control-surface .unified-actions button { font-size: 11px; }
  #flight-control-surface .unified-tools button, .unified-tools summary { font-size: 9px; }
}
@media (max-height: 450px) and (orientation: landscape) {
  .unified-header { min-height: 38px; }
  .unified-header a { min-height: 36px; }
  .canopy-telemetry { top: 50px; }
  #mission, #combat-status { top: 93px; }
  #fleet-panel { top: 151px; }
  #flight-control-surface { --yoke-size: 60px; width: min(100%, 660px); }
  .unified-stick { font-size: 9px; }
  .unified-modes a { grid-template-rows: minmax(44px, auto); }
  .unified-modes img { display: none; }
  #notice { top: 33%; }
}
@media (prefers-reduced-motion: reduce) {
  #shield-field { transition: none; }
}

.flight-status-grid {
  position: absolute;
  inset: max(126px, calc(env(safe-area-inset-top) + 121px)) var(--hud-inset) auto;
  display: grid;
  grid-template-columns: minmax(0, 325px) minmax(0, 250px);
  justify-content: space-between;
  gap: 12px;
}
.flight-status-column {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}
.flight-status-column :is(#mission, #stats, #combat-status, #fleet-panel) {
  position: relative;
  inset: auto;
  width: 100%;
  max-width: none;
  min-width: 0;
  overflow-wrap: anywhere;
}
.flight-status-column #stats.advanced-telemetry { inset: auto; }
@media (max-width: 760px), (max-height: 660px) {
  .flight-status-grid {
    top: max(112px, calc(env(safe-area-inset-top) + 108px));
    grid-template-columns: minmax(0, 46%) minmax(0, 43%);
    gap: 8px;
  }
}
@media (max-height: 450px) and (orientation: landscape) {
  .flight-status-grid { top: 95px; }
}

/* Keep the flight view open between the readouts and approved controls. */
.unified-header button,
#flight-control-surface .unified-actions button,
#flight-control-surface .unified-tools button,
#flight-control-surface .unified-tools summary,
#flight-control-surface .pilot-settings :is(button,select) {
  min-height: 44px;
  font-size: .8125rem;
  color: #fff;
  background-color: #0b2537;
}
.unified-header button { justify-self: end; }
.unified-modes { grid-template-columns: repeat(4,minmax(0,1fr)); }
.unified-modes a { grid-template-rows: auto; min-height: 36px; }
.unified-modes img { display: none; }
.flight-status-column :is(#mission,#combat-status) {
  font-size: clamp(.6875rem,1.25vw,.875rem);
  background: #031321eb;
}
#flight-bearing {
  position: absolute;
  left: 50%;
  top: 39%;
  transform: translateX(-50%);
  color: #b8ffff;
  background: #031321eb;
  border: 1px solid #8affff;
  border-radius: .25rem;
  padding: .18rem .4rem;
  white-space: nowrap;
  font: 700 .8125rem system-ui,sans-serif;
}
#flight-missions {
  width: min(34rem,calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 1rem;
  color: #fff;
  background: #081b2a;
  border: 1px solid #6ae5ff;
  border-radius: .7rem;
}
#flight-missions::backdrop { background: #0009; }
#flight-missions label { display: grid; gap: .4rem; }
#flight-missions select { width: 100%; }
#flight-missions :is(button,select) { min-height: 44px; font: inherit; }
#flight-missions button { padding-inline: .8rem; }
@media (max-width: 500px) {
  #flight-control-surface .unified-tools { grid-template-columns: repeat(2,minmax(0,1fr)); }
  #flight-control-surface .unified-tools :is(button,summary),
  #flight-control-surface .unified-actions button { font-size: .6875rem; }
  .unified-modes a { font-size: .6875rem; }
}
@media (max-height: 450px) and (orientation: landscape) {
  .unified-modes { display: none; }
  .flight-status-grid { top: 77px; }
  .canopy-telemetry { top: 48px; }
  #flight-bearing { top: 42%; }
}
.unified-header button { pointer-events: auto; }
.unified-tools { grid-template-columns: repeat(4,minmax(0,1fr)); }
#hud.emergency-shields #shield-field { opacity: 1; }
@media (max-width: 500px) {
  #flight-control-surface .unified-tools { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

#quick-weapon, #missile-fire { min-height: 44px; min-width: 44px; }
#quick-weapon { padding: .25rem .5rem; }
#hud, body > canvas { -webkit-touch-callout: none; user-select: none; }
#hud button, body > canvas { touch-action: none; }

/* Use the original canopy art and a live next-waypoint radar in cockpit view. */
#hud > .cockpit-shell {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: var(--dashboard-opacity, .72);
  z-index: -1;
}
#hud[data-renderer="webgl"] > .cockpit-shell,
#hud:not([data-camera="cockpit"]) :is(.cockpit-shell, #navigation-radar) {
  display: none;
}
#navigation-radar {
  position: absolute;
  bottom: 25%;
  left: var(--hud-inset);
  width: clamp(56px, 8vw, 94px);
  aspect-ratio: 1;
  border: 1px solid #5bd9ff;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, transparent 0 17%, #57d7ff55 18% 19%, transparent 20% 23%),
    #051b2ac9;
  box-shadow: inset 0 0 16px #52d6ff35, 0 0 10px #52d6ff40;
  opacity: var(--dashboard-opacity, .72);
  overflow: hidden;
  pointer-events: none;
}
#navigation-radar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: conic-gradient(transparent 78%, #58edff80);
  animation: radar-sweep 3s linear infinite;
}
#navigation-radar i {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c4fffa;
  box-shadow: 0 0 8px #58edff;
  transform: translate(-50%, -50%);
}
@keyframes radar-sweep { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) {
  #navigation-radar::before { animation: none; }
}
.flight-view-actions {
  display: flex;
  justify-self: end;
  gap: 4px;
  pointer-events: auto;
}
.flight-view-actions button { white-space: nowrap; padding-inline: .5rem; }
body > canvas:not(.nvs-live-sky) { cursor: grab; }
body > canvas:not(.nvs-live-sky):active { cursor: grabbing; }

@media (max-width: 600px) and (orientation: portrait) {
  #hud > .cockpit-shell { object-fit: cover; object-position: center; }
  #navigation-radar { bottom: min(38%, 265px); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .unified-header {
    grid-template-columns: 1fr auto;
    min-height: 44px;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  .unified-header strong, .unified-header .unified-brand small { display: none; }
  .unified-header .unified-brand { font-size: 10px; }
  .canopy-telemetry {
    inset: max(54px, calc(env(safe-area-inset-top) + 48px)) 18% auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    font-size: 9px;
  }
  .canopy-telemetry > * { min-width: 0; padding: 2px 5px; }
  .canopy-telemetry b { font-size: 12px; }
  .flight-status-grid { top: max(94px, calc(env(safe-area-inset-top) + 88px)); }
  .flight-status-column :is(#mission, #combat-status) { font-size: 10px; padding: 3px 5px; }
  .flight-status-column #mission { max-width: 34ch; }
  .flight-status-column #fleet-panel:not([open]) { justify-self: end; width: auto; }
  #fleet-panel summary { padding: 7px; min-height: 36px; }
  .fleet-panel-body { max-height: min(100px, 22dvh); }
  .unified-modes { display: none; }
  #flight-control-surface {
    --yoke-size: clamp(52px, 17dvh, 82px);
    width: 100%;
    grid-template-columns: 90px minmax(0, 30rem) 90px;
    justify-content: space-between;
    align-items: end;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    pointer-events: none;
  }
  #flight-control-surface > * { pointer-events: auto; }
  .unified-stick { gap: 3px; }
  .unified-stick > span { display: none; }
  .missile-controls {
    grid-template-columns: repeat(2, 44px);
    justify-content: end;
    gap: 2px;
  }
  .missile-controls #missile-lock { grid-column: 1 / -1; }
  #quick-weapon, #missile-fire { font-size: 10px; }
  #flight-control-surface .unified-tools { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #flight-control-surface :is(.unified-actions,.unified-tools) button,
  #flight-control-surface .unified-tools summary { font-size: clamp(9px, 1.5vw, 12px); }
  .unified-console { align-self: end; gap: 4px; }
  #navigation-radar { bottom: calc(var(--hud-inset) + 74px); width: 48px; }
  #flight-bearing { top: 43%; }
  #notice { top: 29%; }
}

#hud[data-camera="cockpit"] #flight-control-surface {
  background: linear-gradient(155deg, #0b263d99, #0412209e);
}
#hud[data-renderer="webgl"][data-camera="cockpit"] #flight-control-surface {
  background: linear-gradient(155deg, rgb(11 38 61 / calc(var(--dashboard-opacity, .72) * .83)), rgb(4 18 32 / var(--dashboard-opacity, .72)));
}

@media (max-width: 500px) and (orientation: portrait) {
  #flight-control-surface {
    grid-template-columns: var(--yoke-size) minmax(0, 1fr) 90px;
    align-items: end;
  }
  .unified-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .unified-actions button:last-child { grid-column: auto; }
  #flight-control-surface .unified-actions button { font-size: 9px; }
  .unified-stick > span { display: none; }
  .missile-controls {
    grid-template-columns: repeat(2, 44px);
    justify-content: end;
    gap: 2px;
  }
  .missile-controls #missile-lock { grid-column: 1 / -1; }
  #quick-weapon, #missile-fire { font-size: 10px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #hud[data-camera="cockpit"] #flight-control-surface,
  #hud[data-renderer="webgl"][data-camera="cockpit"] #flight-control-surface { background: none; }
}

#nexus-dock:not([hidden]) {
  display: block;
  grid-column: 1/-1;
  border-color: #6adbef;
  color: #c1f7ff;
  min-height: 44px;
}
#nexus-docking {
  width: min(96vw, 1300px);
  height: min(93dvh, 900px);
  max-width: none;
  max-height: none;
  padding: 0;
  border: 1px solid #3b7185;
  border-radius: 12px;
  color: #e4f7ff;
  background: #070d19;
}
#nexus-docking[open] { display: grid; grid-template-rows: auto minmax(0,1fr); }
#nexus-docking::backdrop { background: #020710eb; }
#nexus-docking form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .35rem .7rem;
  border-bottom: 1px solid #294658;
}
#nexus-docking h2 { margin: 0; font: 600 .9rem system-ui, sans-serif; }
#nexus-docking button { min-height: 44px; }
#nexus-interior { display: block; width: 100%; height: 100%; border: 0; }

.unified-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 760px) {
  .unified-actions { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
#flight-control-surface :is(#side-thrust-left, #side-thrust-right) { touch-action: none; }
#flight-control-surface :is(#side-thrust-left, #side-thrust-right).active {
  background: #115674;
  border-color: #bcfaff;
}
#flight-avoidance {
  position: absolute;
  top: 36%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 6px;
  background: #21170eef;
  color: #ffdf9b;
  text-align: center;
  pointer-events: none;
}
#hud.menus-hidden :is(.unified-brand, .unified-header strong, .unified-modes,
  .flight-status-grid, .canopy-telemetry, .unified-tools, #jump, #shield-toggle,
  #navigation-radar, #quick-weapon) { display: none; }
#hud.menus-hidden .unified-header {
  display: flex;
  justify-content: flex-end;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}
#hud.menus-hidden #flight-control-surface {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  pointer-events: none;
}
#hud.menus-hidden #flight-control-surface > * { pointer-events: auto; }
#hud.menus-hidden .unified-actions { grid-template-columns: repeat(4, minmax(0, 106px)); justify-content: center; }
@media (max-width: 500px) and (orientation: portrait) {
  #hud.menus-hidden .unified-actions { grid-template-columns: repeat(2, minmax(0, 106px)); }
  #hud.menus-hidden .unified-actions button:last-child { grid-column: auto; }
}
#hud.menus-hidden #missile-fire { grid-column: 1 / -1; }
#hud.menus-hidden #flight-bearing { display: none; }

@media (max-height: 520px) and (orientation: landscape) {
  #flight-control-surface .unified-actions button:last-child { grid-column: auto; }
  .flight-view-actions button { min-height: 44px; }
}

#flight-brake.active { background: #715127; border-color: #ffdf9b; }

.unified-yoke.is-engaged .yoke-dial {
  border-color: var(--stick-color);
  box-shadow: inset 0 0 16px var(--stick-glow), 0 0 12px var(--stick-glow);
}
@media (max-height: 600px) and (orientation: landscape) {
  #flight-control-surface { grid-template-columns: calc(var(--yoke-size) + 60px) minmax(0, 30rem) 106px; }
  .flight-stick {
    grid-template-areas: "throttle yoke" "throttle rift";
    grid-template-columns: 54px var(--yoke-size);
    align-items: center;
  }
  .unified-throttle {
    align-self: stretch;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(44px, 1fr);
    justify-items: center;
  }
  #flight-throttle {
    width: 44px;
    height: 100%;
    writing-mode: vertical-lr;
    direction: rtl;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .missile-controls { grid-template-columns: repeat(2, 51px); gap: 4px; }
  #missile-fire, #quick-weapon, #flight-control-surface #flight-brake { min-height: 48px; }
}

#flight-navigation {
  max-width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  color: #d9faff;
  background: #071727;
  border: 1px solid #529ab4;
  border-radius: 1rem;
  padding: 1.25rem;
}
#flight-navigation::backdrop { background: #020713b8; }
#flight-navigation h2 { margin-top: 0; }
#flight-navigation label { display: block; margin: .65rem 0; }
#flight-navigation select,
#flight-navigation input[type="text"] {
  font: inherit;
  color: inherit;
  background: #0b2438;
  border: 1px solid #529ab4;
  border-radius: .4rem;
  padding: .5rem;
  max-width: 100%;
}
#flight-navigation .nav-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
#nav-transit {
  position: fixed;
  pointer-events: none;
  z-index: 7;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  text-align: center;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 6px #071021, 0 0 15px #071021;
  background: radial-gradient(ellipse at center, #5729a913 12%, #314bd58c 100%);
}
#nav-transit[data-mode="rift"] {
  background: radial-gradient(ellipse at center, #d7a8ff32 14%, #412079b8 100%);
}
#nav-transit[hidden] { display: none; }

#flight-rift {
  min-height: 44px;
  width: 100%;
  padding: .35rem;
  font-size: .88rem;
  border-color: #a979e9;
  color: #f0ddff;
  background: #281a43ed;
}
#nav-transit,
#nav-status,
#flight-destination { overflow-wrap: anywhere; }

/* Keep the center of the canopy clear during normal flight. */
#flight-control-surface .unified-console {
  align-self: end;
  justify-self: center;
  width: min(calc(100% - 8px), 11rem);
}
#flight-control-surface :is(.unified-actions, .unified-tools) {
  grid-template-columns: minmax(0, 1fr);
}
#flight-control-surface .unified-tools summary,
#flight-control-surface .unified-actions #flight-brake {
  font-size: .8125rem;
}
#flight-control-surface .systems-drawer {
  z-index: 12;
  touch-action: pan-y;
}
.systems-drawer h2 {
  margin: .6rem 0 .35rem;
  font-size: .875rem;
}
#flight-control-surface .secondary-flight-controls button {
  font: 650 .8125rem/1.2 system-ui, sans-serif;
  touch-action: pan-y;
}
#flight-control-surface .secondary-flight-controls :is(#side-thrust-left, #side-thrust-right) {
  touch-action: none;
}
.secondary-flight-controls button[aria-pressed="true"] {
  background: #115674;
  border-color: #bcfaff;
}
#flight-control-surface .systems-drawer .unified-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
#flight-control-surface .systems-drawer .unified-modes a { min-height: 44px; }
.flight-settings { margin-top: .55rem; }
#flight-control-surface .flight-settings > summary {
  text-transform: none;
}
#quick-weapon {
  min-width: 54px;
  padding: .2rem;
  font-weight: 700;
}
#armed-weapon { display: block; color: var(--cyan); }
#missile-system[hidden] { display: none; }
@media (max-width: 500px) and (orientation: portrait) {
  #flight-control-surface { grid-template-columns: max(68px, var(--yoke-size)) minmax(0, 1fr) 100px; }
}
@media (max-width: 500px) and (orientation: portrait), (max-height: 520px) and (orientation: landscape) {
  .missile-controls { grid-template-columns: 54px 44px; }
  #flight-control-surface .systems-drawer { max-height: min(52dvh, 350px); }
}
#weapon-picker {
  box-sizing: border-box;
  width: min(32rem, calc(100% - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  margin: auto;
  padding: .75rem;
  overflow: auto;
  overscroll-behavior: contain;
  color: #edfbff;
  background: #071724;
  border: 1px solid #489dbc;
  border-radius: .75rem;
  font: 650 .9375rem/1.2 system-ui, sans-serif;
}
#weapon-picker::backdrop { background: #020710a6; }
.weapon-picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}
.weapon-picker-heading h2 { margin: 0; font-size: 1rem; }
#weapon-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .4rem;
}
#weapon-picker button {
  min-height: 44px;
  font: inherit;
  cursor: pointer;
}
#weapon-options button {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem;
  text-align: left;
}
#weapon-options button[aria-pressed="true"] {
  background: #14506a;
  border-color: #9af1ff;
}
#weapon-options button:focus-visible { outline: 2px solid white; outline-offset: 1px; }
#weapon-options img {
  width: clamp(26px, 7vw, 44px);
  height: auto;
  flex: none;
  border-radius: .25rem;
}
#weapon-options small { display: block; color: #bce2ee; }
.weapon-bay { margin-top: .45rem; }
.weapon-bay summary { padding: .65rem 0; cursor: pointer; }
.weapon-bay img { display: block; max-width: 100%; height: auto; }

#john-hologram {
  position: fixed;
  z-index: 6;
  inset: auto;
  left: clamp(10px, calc(var(--john-x, 50vw) + 30px), calc(100vw - var(--john-width) - 10px));
  top: clamp(90px, calc(var(--john-y, 50dvh) - 146px), max(90px, 58dvh - 120px));
  --john-width: clamp(154px, 24vw, 260px);
  width: var(--john-width);
  padding: 9px 12px;
  border: 1px solid #88f0ff;
  border-radius: 10px;
  background: repeating-linear-gradient(#0e3248eb 0 2px, #062335f5 2px 4px);
  box-shadow: 0 0 28px #36def955, inset 0 0 22px #19b5e85c;
  color: #e9fcff;
  font-family: system-ui, sans-serif;
  line-height: 1.17;
  text-align: center;
  pointer-events: none;
}
#john-hologram[hidden] { display: none; }
#john-hologram :is(span, strong, b, small) { display: block; }
#john-hologram strong { font-size: clamp(.94rem, 2.1vw, 1.45rem); }
#john-hologram b {
  color: #ffd088;
  font-size: clamp(1.9rem, 4.4vw, 3.65rem);
  line-height: 1.02;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px #fa961d60;
}
#john-hologram .john-app-name { font-size: .76rem; color: #9beaff; margin-bottom: 3px; }
#john-hologram [data-john-joke] { margin-top: 4px; font-weight: 600; font-size: .82rem; }
#john-hologram small { color: #b0d6df; font-size: .63rem; margin-top: 5px; }
@media (max-width: 520px) and (orientation: portrait) {
  #john-hologram {
    top: clamp(95px, calc(var(--john-y, 50dvh) - 174px), max(95px, 58dvh - 142px));
    padding: 8px;
  }
}
@media (max-height: 485px) and (orientation: landscape) {
  #john-hologram {
    top: clamp(52px, calc(var(--john-y, 50dvh) - 115px), max(52px, 47dvh - 86px));
    padding: 5px 8px;
  }
}
