/* Vector airframe, native browser text and live instruments. One responsive layout. */
body.flying {
  --cockpit-height: 25vh;
}
body.flying header {
  height: 40px;
  padding: 0 18px;
  background: #07121190;
}
body.flying .brand {
  font-size: 22px;
  gap: 12px;
}
body.flying .brand > span:last-child {
  font-size: 16px;
  letter-spacing: 0.5px;
}
body.flying .brand small,
body.flying .flight-bottom,
body.flying .phase-status,
body.flying #flight-name,
body.flying #aircraft-status,
body.flying .flight-side,
body.flying #approach-button,
body.flying #pause-button,
body.flying #flight-help,
body.flying #combat-messages #targeting-panel {
  display: none !important;
}
body.flying .flight-top {
  top: 48px;
  right: 12px;
  left: auto;
}
body.flying #warning {
  top: 70px;
  max-width: 75%;
  font-size: 15px;
  text-align: center;
  z-index: 3;
}
body.flying #overlay {
  inset: 40px 0 0;
}
#cockpit {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--cockpit-height);
  z-index: 2;
  pointer-events: none;
  color: #baf37d;
  font: 13px/1.3 var(--mono);
  transform-origin: 0 0;
  contain: layout style;
}
#cockpit-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.cockpit-shell {
  fill: #20252b;
  stroke: #818c96;
  stroke-width: 2;
}
.cockpit-rim {
  fill: #404952;
  stroke: #97a2ac;
  stroke-width: 1;
}
.cockpit-seams {
  fill: none;
  stroke: #4d5863;
  stroke-width: 3;
}
.cockpit-trim {
  fill: none;
  stroke: #b4bec7;
  stroke-width: 2;
}
.cockpit-fasteners {
  fill: #15191e;
  stroke: #77828d;
  stroke-width: 1;
}
.cockpit-instruments {
  position: absolute;
  inset: 5% 2% 3%;
  display: grid;
  grid-template-columns: 1.08fr 1.06fr 0.72fr 1.3fr;
  gap: 1.5%;
  align-items: stretch;
}
#cockpit .cockpit-screen {
  min-width: 0;
  min-height: 0;
  position: relative;
  padding: 8px;
  border: 1px solid #737f8b;
  border-radius: 4px;
  background: #03100b;
  box-shadow:
    0 0 0 4px #293139,
    0 0 0 5px #52606d,
    inset 0 0 12px #0d2215;
  pointer-events: auto;
  overflow: hidden;
}
#cockpit-weapons {
  margin-top: 26px;
  transform: perspective(1000px) rotateY(10deg) skewY(-3deg) translateY(-12px);
  transform-origin: right center;
}
#cockpit-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  min-width: 0;
  margin-top: 26px;
  transform: perspective(1000px) rotateY(-10deg) skewY(3deg) translateY(-20px);
  transform-origin: left center;
}
#cockpit #cockpit-engine {
  margin-top: 12px;
}
#cockpit #cockpit-controls {
  flex: 0 0 auto;
  padding: 5px 8px;
}
#cockpit #cockpit-guide,
#cockpit #cockpit-landing {
  flex: 1;
}
#cockpit [hidden] {
  display: none !important;
}
#cockpit
  :is(
    #stores-display,
    #landing-guidance,
    #landing-attitude,
    #fuel-status,
    #flight-config,
    #phase-guide,
    #open-guide,
    #damage-status
  ) {
  position: static;
  inset: auto;
  width: auto;
  height: auto;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  transform: none;
  overflow: visible;
}
#cockpit button {
  cursor: pointer;
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
}
#cockpit button:focus-visible {
  outline: 1px solid #c7f9a0;
  outline-offset: 2px;
}
#cockpit #stores-display {
  display: grid;
  height: 100%;
  grid-template-columns: 34% minmax(0, 1fr);
  grid-template-rows: 19px minmax(0, 1fr) 19px;
  gap: 2px 7px;
}
#cockpit .stores-heading {
  grid-column: 1/-1;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  border-bottom: 1px solid #345038;
  font-size: 11px;
  white-space: nowrap;
}
#cockpit .stores-heading small {
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10px;
  color: #8bb07d;
}
#cockpit #stores-display svg {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  height: 100%;
  min-height: 0;
}
#cockpit .stores-health {
  grid-row: 3;
  grid-column: 1/-1;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}
#cockpit .store-options {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-auto-rows: minmax(0, 1fr);
  min-height: 0;
  gap: 2px;
}
#cockpit .store-option {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  padding: 0 2px;
  font: 11px/1.2 var(--mono);
  text-align: left;
  border-bottom: 1px solid #203a25;
}
#cockpit .store-option span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#cockpit .store-option kbd {
  font: inherit;
  padding: 0;
  border: 0;
  background: none;
}
#cockpit .store-option.selected {
  color: #e3ffb1;
  background: #46632b40;
}
#cockpit #cockpit-radar {
  margin-top: 0;
  display: grid;
  grid-template-rows: 18px minmax(0, 1fr) 22px;
  gap: 2px;
}
#cockpit #map-heading {
  display: flex;
  justify-content: space-between;
  margin: 0;
  font: 11px var(--mono);
  letter-spacing: 0;
  color: #aad58a;
}
#cockpit #map-range {
  font: inherit;
  white-space: nowrap;
}
#cockpit #radar {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  cursor: zoom-in;
}
#cockpit #target-data {
  font: 10px/1.15 var(--mono);
  overflow: hidden;
  color: #92b581;
}
#cockpit #target-data[data-lock='acquiring'] {
  color: #ffe28b;
  animation: radar-acquiring 0.8s ease-in-out infinite;
}
#cockpit #target-data[data-lock='locked'] {
  color: #d6ffa5;
}
@keyframes radar-acquiring {
  50% {
    opacity: 0.4;
  }
}
#cockpit #fuel-status {
  min-height: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
}
#cockpit #fuel-gauge {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 4px;
}
#cockpit #fuel-label {
  font-size: 11px;
}
#cockpit #fuel-value {
  position: static;
  inset: auto;
  font-size: 24px;
  font-weight: 600;
}
#cockpit #fuel-meter {
  grid-column: 1/-1;
  height: 7px;
  border: 1px solid #466938;
  background: #122917;
}
#cockpit #fuel-fill {
  display: block;
  height: 100%;
  background: currentColor;
  stroke: none;
}
#cockpit .cockpit-range {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#cockpit #fuel-range {
  font-size: 15px;
}
#cockpit #fuel-quantity {
  font-size: 10px;
  color: #88a77a;
}
#cockpit #g-load {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #304c31;
  padding-top: 7px;
  font-size: 18px;
}
#cockpit #throttle-status {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 5px;
}
#cockpit .throttle-track {
  width: 100%;
  height: 5px;
  background: #1b331e;
}
#cockpit #throttle-fill {
  display: block;
  height: 100% !important;
  background: #9fdb72;
}
#cockpit :is(#fuel-status[data-level='low'], #g-load[data-level='warning']) {
  color: #ffdb81;
}
#cockpit
  :is(
    #fuel-status[data-level='critical'],
    #fuel-status[data-level='empty'],
    #g-load[data-level='danger']
  ) {
  color: #ff8d7b;
}
#cockpit #flight-config > div {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px 9px;
}
#cockpit #config-engine {
  display: none;
}
#cockpit #flight-config > div > button {
  font: 12px/1.4 var(--mono);
  text-align: left;
  white-space: nowrap;
  color: #91cb78;
}
#cockpit #flight-config > div > button[data-state='active'] {
  color: #ffe18a;
}
#cockpit #flight-config > div > button[data-state='danger'] {
  color: #ff8c7a;
}
#cockpit #config-countermeasures {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 10px;
  background: #03100b;
  color: #98d7c4;
}
#cockpit #phase-guide {
  height: 100%;
  display: flex;
  flex-direction: column;
}
#cockpit .guide-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  color: #759e72;
}
#cockpit #guide-title {
  display: none;
}
#cockpit #guide-steps {
  display: flex;
  flex-direction: column;
  gap: 5px;
  list-style: none;
  margin: 5px 0 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}
#cockpit #guide-steps li {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font: 12px/1.3 var(--mono);
}
#cockpit #guide-steps kbd {
  flex: 0 0 auto;
  font: inherit;
  color: #d3efac;
  border: 0;
  background: none;
  padding: 0;
}
#cockpit #guide-steps li > span {
  min-width: 0;
}
#cockpit #cockpit-landing {
  display: none;
}
#cockpit.cockpit-landing #cockpit-guide {
  display: none;
}
#cockpit.cockpit-landing #cockpit-landing {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 8px;
}
#cockpit #landing-attitude {
  min-height: 0;
  align-self: start;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
  gap: 4px;
  font: 10px/1.2 var(--mono);
}
#cockpit #landing-attitude > strong {
  display: none;
}
#cockpit .landing-angles,
#cockpit .landing-pitch {
  display: flex;
  align-items: center;
  gap: 3px;
}
#cockpit .landing-angles svg {
  width: 35px;
  height: 39px;
  flex-shrink: 0;
}
#cockpit .landing-pitch svg {
  width: 38px;
  height: 30px;
  flex-shrink: 0;
}
#cockpit .landing-angles div,
#cockpit .landing-pitch div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
#cockpit .landing-angles span,
#cockpit .landing-pitch small {
  display: none;
}
#cockpit .landing-bank {
  display: flex;
  flex-direction: column;
  gap: 3px;
  grid-column: 1/-1;
}
#cockpit #landing-guidance {
  align-self: start;
  font: 10px/1.2 var(--mono);
}
#cockpit #landing-guidance .eyebrow,
#cockpit #landing-guidance > small {
  display: none;
}
#cockpit #approach-stage {
  line-height: 11px;
  margin-top: 0;
  display: block;
  font-size: 10px;
  margin-bottom: 2px;
}
#cockpit #approach-checks {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#cockpit #approach-checks > div {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  font: 10px/1.15 var(--mono);
  gap: 4px;
  padding: 0;
}
#cockpit #approach-instruction {
  margin: 5px 0 0;
  font-size: 10px;
}
#cockpit #landing-route-button {
  position: absolute;
  bottom: 5px;
  right: 5px;
  font-size: 10px;
  color: #c1b0ff;
  background: #03100b;
}
body.flying.wreck-view #cockpit,
body.flying.rear-view #cockpit {
  display: none !important;
}
#overlay #mission-card {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #39563b;
}
#overlay .mission-card-heading {
  display: flex;
  justify-content: space-between;
  color: #94b184;
}
#overlay #mission-card-name {
  margin: 8px 0;
  font: 22px var(--display);
}
#overlay .mission-goal-group ul {
  list-style: none;
  padding: 0;
}
#overlay .mission-goal-group li {
  display: flex;
  gap: 10px;
  margin: 9px 0;
  font: 13px/1.4 var(--mono);
}
#overlay .goal-done {
  color: #baf37d;
}
#overlay .goal-failed {
  color: #ff967e;
}
@media (max-width: 1100px) {
  .cockpit-instruments {
    inset: 14% 1.5% 3%;
    gap: 1%;
    grid-template-columns: 1.05fr 1fr 0.7fr 1.2fr;
  }
  #cockpit .cockpit-screen {
    padding: 5px;
  }
  #cockpit .stores-heading small {
    display: none;
  }
  #cockpit #stores-display {
    grid-template-columns: 28% minmax(0, 1fr);
    gap: 2px;
  }
  #cockpit .store-option,
  #cockpit #flight-config > div > button {
    font-size: 10px;
  }
  #cockpit #guide-steps li {
    font-size: 10px;
    gap: 4px;
  }
  #cockpit #fuel-value {
    position: static;
    inset: auto;
    font-size: 20px;
  }
  #cockpit #cockpit-controls {
    padding: 4px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #cockpit #target-data {
    animation: none !important;
  }
}

/* Independent message lifetimes; no framed panel over the central flight view. */
body.flying #combat-messages {
  left: auto;
  right: 18px;
  top: 90px;
  bottom: calc(var(--cockpit-height) + 12px);
  width: clamp(240px, 28vw, 370px);
  transform: none;
  pointer-events: none;
}
body.flying #flight-message-feed {
  position: absolute;
  inset: 0 0 48px;
  overflow: hidden;
  pointer-events: none;
}
body.flying .flight-message {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: right;
  text-shadow:
    0 1px 3px #000,
    0 0 7px #06100a;
  color: #c7efa2;
  font: 12px/1.4 var(--mono);
  transition:
    transform 1.15s ease-out,
    opacity 1.3s ease-out;
  will-change: transform, opacity;
}
body.flying .flight-message strong {
  font: 600 12px/1.4 var(--mono);
}
body.flying .flight-message p {
  margin: 4px 0 0;
  color: #acbea2;
  font: 12px/1.4 var(--mono);
}
body.flying .flight-message[data-level='warning'] {
  color: #f5cf86;
}
body.flying #flight-toast,
body.flying #lock-label,
body.flying #lock-hint,
body.flying #weapon-solution {
  display: none !important;
}
body.flying #combat-messages #targeting-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
  padding: 0;
  margin: 0;
  background: none;
  border: 0;
  box-shadow: none;
}
body.flying #targeting-panel .targeting-row {
  justify-content: flex-end;
}
body.flying #lock-button {
  pointer-events: auto;
  background: none;
  border: 0;
  padding: 3px 0;
  color: #baf37d;
  font: 11px var(--mono);
}
body.flying #lock-progress {
  height: 2px;
  width: 100%;
  background: #72955322;
  margin: 4px 0 0;
  border: 0;
}
body.flying.rear-view #combat-messages {
  bottom: 24px;
}
@media (prefers-reduced-motion: reduce) {
  body.flying .flight-message {
    transition: opacity 0.25s;
  }
}

body.flying .flight-message[data-level='radio'] strong {
  color: #a6dce5;
  letter-spacing: 0.5px;
}
body.flying .flight-message[data-level='radio'] p {
  color: #e0ead7;
  font-size: 12px;
}

/* Radio dialogue has its own left-hand stream; operational messages stay right. */
body.flying #radio-message-feed {
  /* Radio captions stay above the physical cabin, like the right-hand feed. */
  z-index: 4;
  position: absolute;
  left: 18px;
  top: 90px;
  bottom: calc(var(--cockpit-height) + 12px);
  width: clamp(240px, 28vw, 370px);
  overflow: hidden;
  pointer-events: none;
}
body.flying #radio-message-feed .flight-message {
  text-align: left;
  left: 0;
  right: auto;
}
body.flying #flight-message-feed {
  bottom: 0;
}
body.flying.rear-view #radio-message-feed {
  bottom: 24px;
}

#mission-control-view {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #020b0bed;
  display: grid;
  place-items: center;
  padding: 18px;
  color: #d8e8d1;
  backdrop-filter: blur(5px);
}
#mission-control-view[hidden] {
  display: none;
}
.control-room {
  width: min(1320px, 100%);
  height: min(920px, 100%);
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #081512;
  border: 1px solid #74905b77;
  padding: 20px;
}
.control-room-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #536d4e66;
  padding-bottom: 14px;
}
.control-room h2 {
  font: 32px var(--display);
  margin: 4px 0;
  color: #c3f18e;
}
.control-room-header p {
  margin: 0;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font: 12px/1.5 var(--mono);
}
.control-room-header p span {
  color: #9aaf95;
}
.control-room button {
  color: #c3f18e;
  cursor: pointer;
  white-space: nowrap;
}
.control-room-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 22px;
  flex: 1;
  min-height: 0;
  padding-top: 16px;
}
.control-chart {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.control-chart-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font: 12px var(--mono);
  padding-bottom: 10px;
}
.control-chart-bar button {
  padding: 8px;
}
#mission-control-map {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1;
  background: #0a1712;
  border: 1px solid #385534;
}
.control-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font: 11px/1.7 var(--mono);
  padding-top: 10px;
  color: #9cae93;
}
.control-legend span:first-child {
  color: #c3f18e;
}
.control-legend span:nth-child(2) {
  color: #82c6e5;
}
.control-legend span:nth-child(3) {
  color: #f2b482;
}
.control-checklist {
  overflow: auto;
  padding-right: 8px;
  font: 13px/1.5 var(--mono);
  min-height: 0;
}
.control-checklist h3,
.control-checklist h4 {
  font: 12px var(--mono);
  letter-spacing: 1px;
  color: #9fbc8b;
  margin: 0 0 12px;
}
.control-checklist .mission-goal-group {
  margin: 8px 0 22px;
}
.control-checklist ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.control-checklist .mission-goal-group li {
  display: flex;
  gap: 9px;
  margin: 10px 0;
  color: #d8e8d1;
}
.control-checklist .goal-done {
  color: #baf37d !important;
}
.control-checklist .goal-failed {
  color: #f09580 !important;
}
.control-checklist h4 span {
  float: right;
}
.control-checklist summary {
  cursor: pointer;
  border-top: 1px solid #536d4e66;
  padding: 14px 0;
  color: #9fbc8b;
  font-size: 12px;
}
#control-contacts li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 7px 0;
  font-size: 12px;
}
#control-contacts b {
  white-space: nowrap;
  font-weight: 400;
}
.control-sensor-note {
  font: 12px/1.6 var(--mono);
  color: #90a187;
  border-top: 1px solid #536d4e66;
  padding-top: 14px;
}
@media (max-width: 800px) {
  #mission-control-view {
    padding: 8px;
  }
  .control-room {
    padding: 12px;
  }
  .control-room-body {
    grid-template-columns: 1fr;
    overflow: auto;
    display: block;
  }
  .control-chart {
    height: 55vh;
    min-height: 280px;
  }
  .control-checklist {
    overflow: visible;
    margin-top: 22px;
  }
  .control-room-header p {
    gap: 4px;
  }
  .control-room-header button {
    font-size: 10px;
    padding: 10px;
  }
  .control-chart-bar {
    font-size: 10px;
  }
}

#graphics-error {
  position: fixed;
  inset: 100px 10% auto;
  z-index: 10000;
  padding: 24px;
  border: 1px solid #df9273;
  background: #201914;
  color: #ffe2c9;
  font: 16px/1.6 sans-serif;
}

@media (max-height: 760px) {
  #cockpit #fuel-quantity {
    display: none;
  }
  #cockpit #g-load {
    font-size: 16px;
    padding-top: 4px;
  }
  #cockpit #fuel-status {
    gap: 4px;
  }
  #cockpit #approach-instruction {
    display: none;
  }
}

#cockpit .landing-angles b,
#cockpit .landing-angles small,
#cockpit .landing-pitch small {
  margin: 0;
}
#cockpit .landing-pitch {
  border: 0;
  padding: 0;
}
#cockpit .landing-bank {
  padding: 0;
  justify-content: start;
}
#cockpit #cockpit-landing {
  align-items: start;
}

/* Airframe geometry surrounds the eye; transparent window openings retain the world. */
#cockpit-interior {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}
body.flying.wreck-view #cockpit-interior,
body.flying.rear-view #cockpit-interior,
body.spectating #cockpit-interior {
  display: none !important;
}

/* A single physical HUD-glass plane, shared by all rendering backends. */
#hud-glass-display {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1;
  pointer-events: none;
  transform-origin: 0 0;
}
body.flying.wreck-view #hud-glass-display,
body.flying.rear-view #hud-glass-display,
body.spectating #hud-glass-display {
  display: none !important;
}

#mission-countdown {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80%;
  color: #b0cbac;
  font: 13px monospace;
  text-align: center;
  text-shadow:
    0 1px 3px #000,
    0 0 3px #000;
  pointer-events: none;
  z-index: 4;
}
#mission-countdown[data-level='soon'] {
  color: #e2cb86;
}
#mission-countdown[data-level='urgent'] {
  color: #ef9b82;
}
