:root {
  color-scheme: dark;
  --bg: #030404;
  --panel: #0d0d0d;
  --panel-soft: #141414;
  --line: #35240a;
  --line-strong: #9c6a06;
  --ink: #f3f0e9;
  --muted: #8a857d;
  --orange: #ff9f00;
  --orange-soft: #251600;
  --blue: #2f8cff;
  --green: #00d062;
  --amber: #ffd21f;
  --red: #ff3158;
  --violet: #b565ff;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 48% 28%, rgba(255, 159, 0, 0.08), transparent 34rem),
    linear-gradient(180deg, #020202 0%, #060606 100%);
  color: var(--ink);
  font-family:
    "Arial Narrow", "Roboto Condensed", "Segoe UI", Arial, sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  position: relative;
  min-height: 36px;
  border: 1px solid #282828;
  border-radius: 7px;
  background: #161616;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease,
    transform 90ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--orange);
  color: #020202;
  background: var(--orange);
}

button:active:not(:disabled),
button.is-confirming:not(:disabled) {
  transform: translateY(1px);
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 208, 98, 0.16);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.36;
}

.app {
  width: min(2048px, calc(100vw - 12px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px 0 14px;
}

.topbar {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  align-items: stretch;
  gap: 6px;
  min-height: 54px;
}

.station-tab {
  display: grid;
  place-items: center;
  border-radius: 8px 0 0 8px;
  background: var(--orange);
  color: #050505;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.topline {
  margin-top: 0;
  border-top: 14px solid #b97700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  font-size: clamp(2rem, 3vw, 3rem);
  font-weight: 300;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--orange);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.38em;
  text-transform: uppercase;
}

.resources {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid #242424;
  border-radius: 8px;
  background: #101010;
}

.resources.is-updated .resource {
  animation: resourcePulse 520ms ease;
}

@keyframes resourcePulse {
  0% {
    border-color: var(--green);
    box-shadow: 0 0 0 0 rgba(0, 208, 98, 0.3);
  }
  100% {
    border-color: #262626;
    box-shadow: 0 0 0 10px rgba(0, 208, 98, 0);
  }
}

.resource {
  min-width: 86px;
  padding: 0 12px 0 0;
  border-right: 1px solid #292929;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.resource:last-child {
  border-right: 0;
  padding-right: 0;
}

.resource strong {
  display: inline-block;
  margin-left: 7px;
  color: var(--orange);
  font-family: Consolas, "Courier New", monospace;
  font-size: 1rem;
}

.sound-toggle {
  min-height: 30px;
  padding: 0 12px;
  border-color: rgba(0, 208, 98, 0.35);
  background: rgba(0, 208, 98, 0.08);
  color: var(--green);
  white-space: nowrap;
}

.sound-toggle.is-off {
  border-color: rgba(255, 49, 88, 0.35);
  background: rgba(255, 49, 88, 0.08);
  color: var(--red);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 126px);
  gap: 6px;
  margin: 6px 0 10px;
}

.status-card {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0e0e0e;
}

.status-card {
  padding: 10px 12px 8px;
}

.status-card span,
.side-box span,
.location-card span,
.tactical-card span,
.panel-title span {
  color: #746b5e;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.status-card strong {
  display: block;
  margin: 4px 0 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.1rem;
}

.meter {
  height: 4px;
  background: #202020;
}

.meter span {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  transition: width 180ms ease;
}

.meter.red span {
  background: var(--red);
}

.meter.blue span {
  background: var(--blue);
}

.meter.amber span {
  background: var(--amber);
}

.toast-stack {
  position: fixed;
  top: 76px;
  left: 182px;
  z-index: 20;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  width: min(680px, calc(100vw - 220px));
  padding: 11px 14px;
  border: 1px solid var(--orange);
  border-left-width: 8px;
  border-radius: 8px;
  background: rgba(14, 14, 14, 0.98);
  color: var(--ink);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.command-shell {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 228px;
  gap: 12px;
  align-items: start;
}

.sidebar {
  display: grid;
  min-height: calc(100vh - 140px);
  align-content: start;
  gap: 10px;
}

.side-box,
.location-card {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101010;
}

.side-box strong,
.location-card strong {
  display: block;
  margin-top: 6px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.location-card {
  margin-top: auto;
}

.location-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.62rem;
}

.view-tabs,
.system-menu {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #1d1d1d;
}

.view-tabs button,
.system-menu button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 7px;
  background: #141414;
  color: var(--orange);
}

.view-tabs button.is-active {
  border-color: var(--orange);
  background: var(--orange);
  color: #020202;
}

.system-menu button {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.system-menu button:hover:not(:disabled),
.system-menu button.is-active:not(:disabled) {
  border-color: var(--orange);
  background: #1c1304;
  color: var(--orange);
}

.system-menu button:nth-child(2) {
  color: var(--violet);
}

.system-menu button:nth-child(3) {
  color: var(--orange);
}

.system-menu button:nth-child(4) {
  color: var(--green);
}

.system-menu button:nth-child(6) {
  color: var(--blue);
}

.system-menu button:nth-child(7) {
  color: var(--green);
}

.system-menu .mission-destination-button {
  display: grid;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  border-color: rgba(255, 159, 0, 0.38);
  background: rgba(255, 159, 0, 0.08);
}

.mission-destination-button span {
  color: var(--muted);
  font-size: 0.56rem;
}

.mission-destination-button strong {
  min-width: 0;
  color: var(--orange);
  font-size: 0.7rem;
  overflow-wrap: anywhere;
}

.content-deck {
  min-width: 0;
}

.view {
  display: none;
}

.layout.view.is-active,
.mission-view.view.is-active {
  display: grid;
}

.layout {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.mission-view {
  gap: 14px;
}

.mission-column {
  display: grid;
  gap: 14px;
}

.hero-console {
  position: relative;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(280px, 0.52fr);
  gap: 12px;
  padding: 26px 28px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #030303;
  overflow: hidden;
}

.hero-console::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--orange);
}

.hero-copy {
  grid-column: 1 / -1;
  z-index: 1;
}

.tactical-card {
  position: absolute;
  top: 28px;
  right: 28px;
  z-index: 2;
  min-width: 116px;
  padding: 16px 14px;
  border: 1px solid #242424;
  border-radius: 4px;
  background: #101010;
  text-align: center;
}

.tactical-card strong {
  display: block;
  margin-top: 8px;
  color: var(--blue);
  font-family: Consolas, "Courier New", monospace;
  text-transform: uppercase;
}

.moon-scene {
  position: relative;
  grid-column: 1 / -1;
  min-height: 360px;
  overflow: hidden;
  border: 4px solid #22242a;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 255, 255, 0.16), transparent 7rem),
    radial-gradient(circle at 50% 45%, rgba(60, 139, 255, 0.1), transparent 13rem),
    radial-gradient(circle at 12% 36%, rgba(255, 255, 255, 0.18) 0 1px, transparent 2px),
    radial-gradient(circle at 73% 24%, rgba(255, 255, 255, 0.16) 0 1px, transparent 2px),
    radial-gradient(circle at 28% 76%, rgba(255, 255, 255, 0.14) 0 1px, transparent 2px),
    #020307;
}

.moon-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04) 0 1px,
    transparent 1px 4px
  );
  opacity: 0.25;
}

.planet {
  position: absolute;
  width: 184px;
  height: 184px;
  left: 50%;
  top: 46%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.2), transparent 42%),
    linear-gradient(135deg, #24272c, #121316);
  box-shadow:
    0 0 0 10px rgba(255, 255, 255, 0.03),
    0 0 88px rgba(255, 255, 255, 0.13);
}

.station {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 62px;
  height: 62px;
  transform: translate(-50%, -50%);
  border: 7px solid var(--blue);
  border-radius: 14px;
  opacity: 0.8;
  rotate: 30deg;
}

.station span {
  position: absolute;
  display: none;
}

.orbit {
  position: absolute;
  left: 50%;
  top: 46%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
}

.orbit-a {
  width: 460px;
  height: 130px;
}

.orbit-b {
  width: 330px;
  height: 92px;
}

.scan-label {
  position: absolute;
  left: 50%;
  top: calc(46% + 104px);
  transform: translateX(-50%);
  padding: 5px 16px;
  border-radius: 999px;
  background: #151515;
  color: #8d8d8d;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.docks,
.shipyard,
.hire-list,
.crew-list,
.missions,
.log {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.docks {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0;
}

.shipyard,
.hire-list {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.dock,
.ship,
.hire-card,
.crew,
.mission,
.log-entry,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.dock,
.ship,
.hire-card,
.crew,
.mission,
.log-entry {
  padding: 12px;
}

.dock header,
.ship header,
.hire-card header,
.crew header,
.mission header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.ship-visual,
.enemy-visual,
.mission-visual,
.crew-portrait {
  flex: 0 0 auto;
  border-radius: 8px;
  background: #050505;
  filter: drop-shadow(0 0 14px rgba(255, 159, 0, 0.08));
}

.ai-asset-frame {
  position: relative;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--dept, var(--orange)) 45%, #252525);
  background: #050505;
  isolation: isolate;
}

.ai-asset-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ship-visual.ai-asset-frame img,
.enemy-visual.ai-asset-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.mission-scene-image-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #03050a;
}

.mission-scene-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transform: scale(0.9);
  transform-origin: center;
}

.ai-fallback {
  display: none;
}

.ai-asset-frame.is-missing > img {
  display: none;
}

.ai-asset-frame.is-missing > .ai-fallback {
  display: contents;
}

.ai-rank-badge {
  position: absolute;
  right: 5px;
  bottom: 5px;
  z-index: 2;
  min-width: 24px;
  padding: 3px 5px;
  border: 1px solid rgba(243, 240, 233, 0.7);
  border-radius: 4px;
  background: rgba(5, 5, 5, 0.82);
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.ai-rank-pips {
  position: absolute;
  left: 6px;
  bottom: 7px;
  z-index: 2;
  display: flex;
  gap: 3px;
}

.ai-rank-pips i {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--dept, var(--orange));
  box-shadow: 0 0 8px color-mix(in srgb, var(--dept, var(--orange)) 70%, transparent);
}

.ship-visual,
.enemy-visual {
  width: 112px;
  height: 56px;
}

.mission-visual {
  width: 66px;
  height: 66px;
}

.crew-portrait {
  width: 76px;
  height: 86px;
}

.crew-portrait.ai-asset-frame {
  flex: 0 0 76px;
  width: 76px;
  min-width: 76px;
  max-width: 76px;
  height: 86px;
  min-height: 86px;
  max-height: 86px;
  aspect-ratio: 76 / 86;
  align-self: flex-start;
  border-radius: 10px;
}

.ship-visual.ai-asset-frame,
.enemy-visual.ai-asset-frame {
  flex: 0 0 112px;
  width: 112px;
  min-width: 112px;
  max-width: 112px;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  aspect-ratio: 2 / 1;
  border-radius: 8px;
}

.crew header {
  align-items: center;
}

.dock header > div,
.ship header > div,
.crew header > div,
.mission header > div {
  min-width: 0;
  flex: 1 1 auto;
}

.meta,
.small,
.rank-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.rank-note {
  margin-bottom: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.stats-grid-six {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.shipyard-stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat {
  min-width: 0;
  padding: 8px;
  border-radius: 4px;
  background: #080808;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.stat strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.96rem;
}

.actions,
.save-actions,
.crew-actions,
.mission-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rename-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 10px 0;
}

.rename-row input {
  min-width: 0;
  min-height: 36px;
  border: 1px solid #282828;
  border-radius: 7px;
  background: #080808;
  color: var(--ink);
  padding: 0 10px;
  font-size: 0.76rem;
}

.rename-row input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 159, 0, 0.12);
}

.panel {
  min-height: 260px;
  overflow: hidden;
}

.full-panel {
  grid-column: 1 / -1;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #090909;
}

.crew-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.sort-controls {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sort-controls button {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 5px;
  font-size: 0.62rem;
}

.sort-controls button.is-active {
  border-color: var(--orange);
  background: var(--orange);
  color: #050505;
}

.tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid rgba(255, 159, 0, 0.35);
  border-radius: 999px;
  background: rgba(255, 159, 0, 0.08);
  color: var(--orange);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tag.warn {
  border-color: rgba(255, 210, 31, 0.34);
  background: rgba(255, 210, 31, 0.08);
  color: var(--amber);
}

.tag.ok {
  border-color: rgba(0, 208, 98, 0.34);
  background: rgba(0, 208, 98, 0.08);
  color: var(--green);
}

.tag.danger {
  border-color: rgba(255, 49, 88, 0.42);
  background: rgba(255, 49, 88, 0.1);
  color: var(--red);
}

.crew-vitals {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.rank-pill,
.xp-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  background: #080808;
  color: #c9c3b9;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.rank-pill {
  color: var(--ink);
}

.xp-pill {
  color: var(--muted);
}

.hire-card,
.crew,
.mission {
  border-color: color-mix(in srgb, var(--dept, var(--line)) 38%, var(--line));
}

.hire-card h2,
.crew h2,
.mission h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.department-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 999px;
  background: var(--dept, var(--orange));
  box-shadow: 0 0 18px color-mix(in srgb, var(--dept, var(--orange)) 68%, transparent);
}

.crew.assigned {
  border-color: rgba(0, 208, 98, 0.5);
}

.dock:has(.tag.danger) {
  border-color: rgba(255, 49, 88, 0.64);
}

textarea {
  width: calc(100% - 24px);
  min-height: 86px;
  margin: 12px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050505;
  color: var(--ink);
  padding: 10px;
  font-family: Consolas, "Courier New", monospace;
}

.log-panel {
  position: sticky;
  top: 10px;
  min-height: calc(100vh - 132px);
}

.log {
  grid-template-columns: 1fr;
  max-height: calc(100vh - 200px);
  overflow: auto;
}

.log-entry {
  position: relative;
  color: #b1aca4;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.72rem;
  line-height: 1.5;
}

.log-entry::before {
  content: ">";
  margin-right: 8px;
  color: var(--orange);
}

.log-entry.latest {
  border-color: rgba(255, 159, 0, 0.55);
  background: rgba(255, 159, 0, 0.08);
  color: var(--ink);
  animation: logHighlight 900ms ease;
}

@keyframes logHighlight {
  0% {
    box-shadow: inset 4px 0 0 var(--orange);
  }
  100% {
    box-shadow: inset 4px 0 0 transparent;
  }
}

.mission-panel .missions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#missionShipCard {
  padding: 12px;
}

.selected-mission {
  border-color: rgba(255, 159, 0, 0.68);
  background: linear-gradient(180deg, rgba(255, 159, 0, 0.08), var(--panel) 64%);
}

.mission-prep-grid {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.bar-stat {
  padding: 9px;
  border: 1px solid #242424;
  border-radius: 6px;
  background: #080808;
}

.bar-stat-head,
.mission-crew-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bar-stat-head strong,
.mission-crew-head strong {
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #050505;
}

.bar-track span {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
}

.bar-stat.red .bar-track span {
  background: var(--red);
}

.bar-stat.blue .bar-track span {
  background: var(--blue);
}

.bar-stat.amber .bar-track span {
  background: var(--amber);
}

.mission-ship-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mission-scene-art {
  position: relative;
  height: clamp(190px, 18vw, 260px);
  min-height: 190px;
  margin: 0 0 12px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--dept, var(--orange)) 46%, #242424);
  border-radius: 8px;
  background: #03050a;
  contain: layout paint;
  transform-origin: center;
  animation: missionSceneIn 240ms ease-out both;
}

.mission-scene-art svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 190px;
}

.mission-scene-art:has(.mission-scene-image) svg {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
}

.mission-scene-art::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 5px);
  opacity: 0.55;
}

.mission-scene-art figcaption {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  display: grid;
  gap: 3px;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  border: 1px solid rgba(255, 159, 0, 0.32);
  border-radius: 6px;
  background: rgba(5, 5, 5, 0.78);
  backdrop-filter: blur(8px);
}

.mission-scene-art figcaption strong {
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mission-scene-art figcaption span {
  color: var(--muted);
  font-size: 0.7rem;
}

.mission-current-crew-card,
.mission-crew-panel .crew {
  background: linear-gradient(180deg, color-mix(in srgb, var(--dept, var(--orange)) 8%, #0d0d0d), var(--panel));
}

.mission-crew {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  padding: 9px;
  border: 1px solid #242424;
  border-radius: 6px;
  background: #080808;
}

.mission-crew.empty-state {
  display: block;
}

.mission-crew-list {
  display: grid;
  gap: 7px;
}

.mission-crew-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--dept, var(--line)) 36%, #242424);
  border-radius: 6px;
  background: #050505;
}

.mission-crew-row .crew-portrait {
  flex: 0 0 42px;
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  aspect-ratio: 7 / 8;
  align-self: center;
}

.mission-crew-row .crew-portrait.ai-asset-frame {
  flex-basis: 42px;
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
}

.mission-crew-row strong {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 0.78rem;
}

.mission-crew-row span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
}

.crew-mini-stats {
  display: grid;
  gap: 4px;
  justify-items: end;
  font-family: Consolas, "Courier New", monospace;
}

.crew-mini-stats .warn {
  color: var(--amber);
}

.crew-mini-stats .danger {
  color: var(--red);
}

.save-panel {
  grid-column: 1 / -1;
  min-height: auto;
}

.save-console {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.manual-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.save-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.save-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.autosave-card {
  border-color: rgba(0, 208, 98, 0.35);
  background: linear-gradient(180deg, rgba(0, 208, 98, 0.05), var(--panel) 58%);
}

.empty-save {
  border-style: dashed;
}

.save-details {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.save-detail {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 34px;
  padding: 8px;
  border-radius: 6px;
  background: #080808;
}

.save-detail span {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.save-detail strong {
  min-width: 0;
  color: var(--ink);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.chance-box,
.battery {
  margin: 10px 0;
  padding: 9px;
  border: 1px solid #242424;
  border-radius: 6px;
  background: #080808;
}

.chance-head,
.battery-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.chance-head strong,
.battery-head strong {
  color: var(--orange);
}

.chance-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 0.76rem;
}

.chance-grid strong {
  color: var(--ink);
}

.mission-run {
  grid-column: 1 / -1;
  animation: missionPanelIn 180ms ease-out both;
  will-change: opacity, transform;
}

body.is-mission-step-refresh .expedition-panel,
body.is-mission-step-refresh .expedition-console,
body.is-mission-step-refresh .mission-run,
body.is-mission-step-refresh .mission-scene-art,
body.is-mission-step-refresh .mission-ship-card,
body.is-mission-step-refresh .mission-crew-panel,
body.is-mission-step-refresh #missionCrewList .crew {
  animation: none !important;
  transition-duration: 0.001ms !important;
  transform: none !important;
}

.mission-freeze-overlay {
  position: absolute;
  inset: 12px;
  z-index: 5;
  display: grid;
  gap: 12px;
  grid-template-rows: auto auto auto;
  pointer-events: none;
  background: var(--panel);
  opacity: 1;
  transition: opacity 160ms ease;
}

.mission-freeze-overlay.is-releasing {
  opacity: 0;
}

.mission-freeze-overlay > #missionActionDeck {
  order: 0;
}

.mission-freeze-overlay > #missionShipCard {
  order: 1;
  padding: 0;
}

.mission-freeze-overlay > .mission-crew-panel {
  order: 2;
}

.expedition-console {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 12px;
  grid-template-rows: auto auto auto;
}

.expedition-panel {
  min-height: 720px;
  overflow-anchor: none;
}

.expedition-console > #missionActionDeck {
  order: 0;
  min-height: 360px;
  overflow-anchor: none;
}

.expedition-console > #missionShipCard {
  order: 1;
  padding: 0;
  min-height: 320px;
  overflow-anchor: none;
}

.mission-ship-card {
  min-height: 308px;
  contain: layout paint;
}

.mission-ship-card header {
  min-height: 76px;
}

.mission-ship-card .ship-visual {
  width: 112px;
  height: 56px;
  flex: 0 0 112px;
  min-width: 112px;
  max-width: 112px;
  min-height: 56px;
  max-height: 56px;
  animation: none;
  transform: translateZ(0);
}

.dock .ship-visual.ai-asset-frame,
.ship .ship-visual.ai-asset-frame,
.mission-ship-card .ship-visual.ai-asset-frame {
  flex: 0 0 112px;
  width: 112px;
  min-width: 112px;
  max-width: 112px;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  aspect-ratio: 2 / 1;
}

.enemy-status-card .enemy-visual.ai-asset-frame {
  flex: 0 0 90px;
  width: 90px;
  min-width: 90px;
  max-width: 90px;
  height: 54px;
  min-height: 54px;
  max-height: 54px;
  aspect-ratio: 5 / 3;
}

.mission-crew-panel {
  order: 2;
  min-height: auto;
}

#missionCrewList .crew-portrait,
#missionCrewList .crew-portrait.ai-asset-frame {
  flex: 0 0 76px;
  inline-size: 76px;
  min-inline-size: 76px;
  max-inline-size: 76px;
  block-size: 86px;
  min-block-size: 86px;
  max-block-size: 86px;
  width: 76px;
  min-width: 76px;
  max-width: 76px;
  height: 86px;
  min-height: 86px;
  max-height: 86px;
  aspect-ratio: 76 / 86;
  align-self: flex-start;
}

#missionCrewList .crew-portrait.ai-asset-frame img {
  width: 76px;
  height: 86px;
  min-width: 76px;
  min-height: 86px;
  max-width: 76px;
  max-height: 86px;
  object-fit: cover;
}

.mission-actions-primary {
  align-items: center;
}

@keyframes missionPanelIn {
  from {
    opacity: 0.96;
    transform: translateY(2px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes missionSceneIn {
  from {
    opacity: 0.88;
    transform: scale(0.998);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mission-run,
  .mission-scene-art,
  .expedition-panel,
  .expedition-console,
  .expedition-console button {
    animation: none !important;
    transition-duration: 0.001ms !important;
    transform: none !important;
  }
}

.mission-actions {
  margin-top: 10px;
}

.mission-rulebook {
  display: grid;
  flex: 1 1 100%;
  gap: 6px;
  margin-bottom: 2px;
}

.mission-rulebook div {
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid #242424;
  border-radius: 6px;
  background: #080808;
}

.mission-rulebook strong {
  color: var(--orange);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.mission-rulebook span {
  color: var(--muted);
  font-size: 0.74rem;
}

.hall-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.hall-entry {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: 4px;
  background: #080808;
}

.hall-entry strong {
  color: var(--ink);
}

.hall-entry span {
  color: var(--muted);
  font-size: 0.72rem;
}

.battery-cells {
  display: grid;
  grid-template-columns: repeat(var(--cells, 5), minmax(14px, 1fr));
  gap: 5px;
}

.battery-cells span {
  height: 13px;
  border: 1px solid #2a2a2a;
  border-radius: 3px;
  background: #050505;
}

.battery.high .battery-cells span.filled {
  border-color: rgba(0, 208, 98, 0.55);
  background: var(--green);
}

.battery.mid .battery-cells span.filled {
  border-color: rgba(255, 210, 31, 0.58);
  background: var(--amber);
}

.battery.low .battery-cells span.filled {
  border-color: rgba(255, 49, 88, 0.62);
  background: var(--red);
}

.empty-state {
  min-height: 120px;
}

.upgrade-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.upgrade-actions button {
  min-height: 32px;
  font-size: 0.66rem;
}

@media (max-width: 1180px) {
  .command-shell {
    grid-template-columns: 140px minmax(0, 1fr);
  }

  .log-panel {
    position: static;
    grid-column: 1 / -1;
    min-height: auto;
  }

  .log {
    max-height: 220px;
  }
}

@media (max-width: 860px) {
  .app {
    width: min(100vw - 10px, 760px);
  }

  .topbar,
  .status-strip,
  .command-shell,
  .layout,
  .hero-console {
    grid-template-columns: 1fr;
  }

  .topline {
    min-height: 10px;
    border-top-width: 10px;
  }

  .resources {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .sidebar {
    min-height: auto;
  }

  .moon-scene {
    min-height: 300px;
  }

  .docks,
  .mission-panel .missions,
  .manual-slots,
  .stats-grid,
  .stats-grid-six {
    grid-template-columns: 1fr;
  }

  .save-detail {
    grid-template-columns: 1fr;
  }

  .toast-stack {
    left: 10px;
    right: 10px;
  }

  .toast {
    width: 100%;
  }
}
