/* The 2D station uses straight-on captures from the same lit cabin models. */
#stage.fallback #station-flight {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  background: #10212b;
}
#stage.fallback .viewport {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  height: auto;
  min-height: 0;
  padding: 5px clamp(6px, 2vw, 26px) 10px;
  overflow: hidden;
  background:
    linear-gradient(#3a55583d 1px, transparent 1px) center / 28px 28px,
    linear-gradient(90deg, #3a55583d 1px, transparent 1px) center / 28px 28px,
    radial-gradient(ellipse at center, #304345, #10212b 76%);
}
#stage.fallback .labels {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: clamp(80px, 29vw, 164px);
  gap: 1px clamp(1px, 1vw, 10px);
  width: min(100%, 642px);
  overflow: visible;
  padding: 2px 0;
  border-block: 1px solid #536d69;
}
#stage.fallback .room-marker {
  position: relative;
  isolation: isolate;
  inset: auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  transform: none;
  align-content: end;
  justify-content: stretch;
  gap: 0 3px;
  padding: 0 3px 2px;
  border: 1px solid transparent;
  border-radius: 7px 7px 3px 3px;
  background: transparent;
  box-shadow: none;
}
#stage.fallback .room-marker::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: auto 5% 0;
  height: 28px;
  background: #0b1925;
  border: 1px solid #7082789c;
  border-radius: 4px;
}
#stage.fallback .room-marker:not(:disabled):hover { border-color: #ffe0a0a6; }
#stage.fallback .room-marker.selected {
  border-color: #ffe5a6;
  box-shadow: inset 0 0 15px #f8df8033;
}
#stage.fallback .room-marker.safe {
  border-color: #9ae4b653;
  background: radial-gradient(ellipse at 50% 68%, #4cdf963b, transparent 69%);
}
#stage.fallback .room-marker.lost {
  border-color: #ff8e7a;
  background: radial-gradient(ellipse at 50% 68%, #fd624768, #91363a3e);
}
#stage.fallback .room-marker.safe::before { background: #15372c; border-color: #86cba1; }
#stage.fallback .room-marker.lost::before { background: #492626; border-color: #ee937e; }
#stage.fallback .room-marker.lost::after { top: 4px; right: 5px; z-index: 1; }
#stage.fallback .room-marker :is(b, small, strong) {
  place-self: center;
  position: relative;
  z-index: 1;
  min-width: 0;
  font-size: 10px;
}
#stage.fallback .room-marker small { display: block; line-height: 1.05; text-wrap: balance; }
#stage.fallback .room-marker strong { font-size: 10px; line-height: 1; }
.fallback-cabin {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: calc(100% - 23px);
  object-fit: contain;
  pointer-events: none;
}
#stage.fallback .room-marker.lost .fallback-cabin { filter: saturate(.53) brightness(.78); }
.fallback-scout {
  --scout-width: clamp(34px, 9vw, 55px);
  position: absolute;
  z-index: 3;
  width: var(--scout-width);
  aspect-ratio: 133 / 240;
  transform: translate(-44.97%, -93.388%);
  pointer-events: none;
  background: url("assets/fallback/scout.webp") 0 0 / 500% 100% no-repeat;
  filter: drop-shadow(0 0 3px #87efe6b3) drop-shadow(0 2px 2px #040b11);
}
.fallback-scout::before {
  position: absolute;
  content: "";
  left: 45%;
  top: 92%;
  width: 63%;
  aspect-ratio: 2.7;
  border: 1px solid #a6ffdd;
  border-radius: 50%;
  transform: translate(-50%,-50%);
  opacity: .85;
}
.fallback-scout[data-moving="true"] { transition: left 445ms ease, top 445ms ease; }
.fallback-scout[data-pose="run"] { animation: fallback-leaps 155ms step-end infinite; }
.fallback-scout[data-pose="safe"] {
  background-position: 75% 0;
  filter: drop-shadow(0 0 5px #7de9a5) drop-shadow(0 2px 2px #040b11);
}
.fallback-scout[data-pose="lost"] {
  background-position: 100% 0;
  filter: drop-shadow(0 0 5px #ff8c72) drop-shadow(0 2px 2px #040b11);
}
.fallback-scout[data-pose="lost"]::before { border-color: #ff9a7c; }
@keyframes fallback-leaps {
  0% { background-position: 25% 0; }
  50% { background-position: 50% 0; }
}
.app[data-motion="off"] .fallback-scout { animation: none; transition: none; }
#stage.fallback .bay-payout {
  min-width: 0;
  padding: 5px 9px 6px;
  font-size: clamp(12px, 3.6vw, 17px);
}

#stage.fallback .flight-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 6px;
  background: #10262d;
  padding: 1px 8px;
}
#stage.fallback .flight-rail > #round-timer {
  position: relative;
  inset: auto;
  grid-area: 1 / 2 / span 2 / 3;
  width: clamp(90px, 25vw, 110px);
}
#stage.fallback .flight-rail > #door-control {
  position: relative;
  grid-area: 1 / 1;
  inset: auto;
  transform: none;
  max-width: 100%;
  justify-self: center;
}
#stage.fallback #door-control::after { display: none; }
#stage.fallback .airlock-controls {
  grid-area: 2 / 1;
  display: grid;
  justify-items: center;
  align-content: center;
  min-width: 0;
  background: none;
  border: 0;
  padding: 2px;
}
#stage.fallback .airlock-controls .launch-command { grid-area: 1 / 1; }
#stage.fallback .airlock-controls .station-telemetry {
  grid-area: 2 / 1;
  justify-content: center;
  text-align: center;
}
#stage.fallback .stage-footer { display: flex; justify-content: end; }
#stage.fallback #room-list:not([hidden]) {
  position: absolute;
  z-index: 12;
  inset: auto 8px 40px;
  max-width: 640px;
  max-height: min(55dvh, 500px);
  overflow: auto;
  margin: auto;
  background: #10242b;
  border: 1px solid #947e5b;
}
@media (max-width: 600px) and (orientation: portrait) {
  #stage.fallback #station-flight {
    height: calc(100dvh - 52px);
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  }
  #stage.fallback .viewport {
    align-content: stretch;
    padding-block: clamp(4px, 1dvh, 9px);
  }
  #stage.fallback .labels {
    min-height: 0;
    grid-auto-rows: minmax(0, min(19dvh, 168px));
    align-content: space-evenly;
  }
  #stage.fallback #station-flight > .station-deck .turn-stake[open] {
    position: absolute;
    z-index: 14;
    inset: auto 8px 106px;
    grid-area: auto;
    width: auto;
    max-width: 370px;
    max-height: calc(100% - 120px);
    margin-inline-start: auto;
    overflow: auto;
  }
  #stage.fallback #room-list:not([hidden]) { bottom: 53px; }
}

@media (max-width: 980px) and (max-height: 520px) and (orientation: landscape) {
  #stage.fallback {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 100dvh;
  }
  #stage.fallback #station-flight {
    --control-rail: clamp(175px, 31vw, 225px);
    grid-template-columns: minmax(0, 1fr) var(--control-rail);
    grid-template-rows: auto auto auto 1fr;
    min-height: 0;
  }
  #stage.fallback #round-status { grid-area: 1 / 1 / 2 / -1; padding-block: 4px; }
  #stage.fallback #round-status:has(#entry-guide:not([hidden])) { width: 100%; }
  #stage.fallback .blast-map-readout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
    align-items: center;
    gap: 4px 10px;
  }
  #stage.fallback .map-context { display: grid; gap: 0; padding: 0; }
  #stage.fallback #entry-guide li { padding-block: 2px; }
  #stage.fallback .viewport { grid-area: 2 / 1 / 5 / 2; }
  #stage.fallback .labels { grid-auto-rows: clamp(52px, 20dvh, 93px); }
  #stage.fallback .room-marker :is(b, small, strong) { font-size: 9px; }
  #stage.fallback .room-marker::before { height: 22px; }
  #stage.fallback .fallback-cabin { height: calc(100% - 16px); }
  #stage.fallback .fallback-scout { --scout-width: clamp(25px, 8.5dvh, 39px); }
  #stage.fallback .flight-rail {
    grid-area: 2 / 2;
    grid-template-columns: minmax(0, 1fr) 74px;
    align-content: start;
    justify-items: center;
    padding-inline: 3px;
  }
  #stage.fallback .flight-rail > #round-timer { width: 74px; min-height: 65px; padding: 5px 6px 7px; }
  #stage.fallback .flight-rail > #door-control { min-height: 44px; width: 100%; padding-inline: 3px; }
  #stage.fallback .airlock-controls { min-height: 25px; }
  #stage.fallback .station-telemetry { padding: 0; }
  #stage.fallback #stage-count { display: none; }
  #stage.fallback #station-flight > .station-deck { grid-area: 3 / 2; grid-template-columns: minmax(0, 1fr); padding: 3px 4px; gap: 3px; }
  #stage.fallback #station-flight > .station-deck :is(.station-switch, .turn-stake > summary) { min-height: 44px; padding-inline: 4px; }
  #stage.fallback #station-flight > .station-deck .turn-stake[open] {
    position: fixed;
    z-index: 14;
    inset: 50% calc(var(--control-rail) + 8px) auto auto;
    width: min(320px, calc(100% - var(--control-rail) - 16px));
    max-height: calc(100dvh - 26px);
    margin: 0;
    transform: translateY(-50%);
    overflow: auto;
    background: #132426 url("assets/signal-ledger.webp") center / 100% 100% no-repeat;
  }
  #stage.fallback .stage-footer { grid-area: 4 / 2; max-height: 46px; }
  #stage.fallback #room-list:not([hidden]) { inset: auto 8px 5px 8px; margin: 0 auto; }
}

@media (max-width: 650px) and (max-height: 360px) and (orientation: landscape) {
  #stage.fallback #station-flight > .station-deck { grid-template-rows: auto minmax(44px, auto); }
  #stage.fallback #station-flight > .station-deck .turn-stake:not([open]) {
    grid-row: 2;
    width: calc(100% - 72px);
  }
  #stage.fallback #station-flight > .stage-footer {
    grid-area: 3 / 2;
    z-index: 2;
    align-self: end;
    justify-self: end;
    width: 68px;
    height: 44px;
    margin: 0 4px 3px 0;
    padding: 0;
    border: 0;
    background: none;
  }
  #stage.fallback #room-list-toggle {
    width: 100%;
    white-space: normal;
    border-color: #688c865c;
    background: #193037;
  }
  #stage.fallback #room-list:not([hidden]) { right: calc(var(--control-rail) + 8px); }
  #stage.fallback #station-flight .flight-rail > #door-control { padding-inline: 5px; }
  #stage.fallback .flight-rail .hatch-caption { padding-inline: 4px; }
}
