@import url('https://fonts.googleapis.com/css2?family=Chivo+Mono:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --ink: #101617;
  --ink-soft: #1c2829;
  --paper: #e8e1ca;
  --paper-2: #d6ceb4;
  --mint: #30b7a9;
  --mint-dark: #167a74;
  --rust: #c25b35;
  --yellow: #f0d75b;
  --red: #e34f42;
  --blue: #67b9c8;
  --muted: #8f9487;
  --line: 2px solid var(--ink);
  --shadow: 5px 5px 0 var(--ink);
  --display: "Space Grotesk", "Arial Black", sans-serif;
  --mono: "Chivo Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--ink); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--ink);
  font-family: var(--mono);
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

.space { position: fixed; inset: 0; overflow: hidden; pointer-events: none; opacity: .58; }
.space i { position: absolute; width: 2px; height: 2px; background: var(--paper); box-shadow: 18vw 12vh var(--paper), 47vw 6vh var(--paper), 72vw 19vh var(--paper), 91vw 8vh var(--paper), 11vw 61vh var(--paper), 38vw 73vh var(--paper), 82vw 78vh var(--paper), 95vw 48vh var(--paper), 58vw 92vh var(--paper); }
.space i:nth-child(2) { left: 7vw; top: 31vh; transform: rotate(11deg); opacity: .4; }
.space i:nth-child(3) { left: 16vw; top: 8vh; transform: rotate(27deg); opacity: .22; }

.app-shell { position: relative; width: min(1440px, 100%); min-height: 100vh; margin: 0 auto; padding: 20px clamp(14px, 3vw, 44px) 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 58px; margin-bottom: 20px; }
.brand { display: inline-flex; align-items: center; gap: 12px; border: 0; background: transparent; color: var(--paper); padding: 0; cursor: pointer; font-family: var(--display); font-size: 1.25rem; font-weight: 800; letter-spacing: .08em; text-decoration: none; }
.brand-mark { position: relative; width: 34px; height: 34px; border: var(--line); background: var(--mint); transform: rotate(-3deg); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; background: var(--ink); }
.brand-mark::before { width: 16px; height: 5px; left: 7px; top: 7px; box-shadow: 0 12px var(--ink); }
.brand-mark::after { width: 5px; height: 17px; left: 14px; top: 6px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn, .small-btn { min-height: 38px; border: 1px solid #65706c; background: var(--ink-soft); padding: 8px 12px; cursor: pointer; text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; }
.icon-btn:hover, .small-btn:hover { border-color: var(--paper); background: #293637; }

.screen { min-width: 0; animation: enter .35s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.eyebrow { margin: 0 0 9px; color: var(--mint); font-size: .72rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.eyebrow::before { content: "// "; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--display); }

.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); min-height: calc(100vh - 130px); border: var(--line); background: var(--paper); color: var(--ink); box-shadow: 9px 9px 0 #050808; }
.hero-copy { display: flex; flex-direction: column; justify-content: center; padding: clamp(32px, 7vw, 94px); border-right: var(--line); }
.hero h1 { max-width: 730px; margin: 0; font-size: clamp(4.8rem, 12vw, 10rem); line-height: .76; letter-spacing: -.085em; }
.hero h1 span { display: block; color: var(--rust); }
.hero-sub { max-width: 620px; margin: 30px 0; font-size: clamp(1rem, 1.8vw, 1.3rem); line-height: 1.55; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.hero-note { margin: 0; color: #5a5d53; font-size: .72rem; }
.hero-art { position: relative; display: flex; align-items: flex-end; justify-content: center; min-height: 440px; padding: 50px 20px 0; overflow: hidden; background: var(--mint); }
.hero-art::before { content: "SC-03"; position: absolute; top: 28px; right: 32px; color: rgba(16,22,23,.18); font: 800 clamp(3rem, 7vw, 7rem)/1 var(--display); writing-mode: vertical-rl; }
.hero-art::after { content: "3 CREW  /  6 STATIONS  /  BAD ODDS"; position: absolute; right: 22px; bottom: 20px; font-size: .65rem; font-weight: 700; letter-spacing: .12em; }
.hero-crew { width: min(100%, 490px); height: auto; filter: drop-shadow(12px 12px 0 rgba(16,22,23,.22)); }

.primary-btn { min-height: 52px; border: var(--line); background: var(--yellow); color: var(--ink); padding: 12px 22px; box-shadow: 4px 4px 0 var(--ink); cursor: pointer; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; transition: transform .12s, box-shadow .12s; }
.primary-btn:hover { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--ink); }
.primary-btn:active { transform: translate(4px,4px); box-shadow: none; }
.primary-btn.rust { background: var(--rust); color: white; }
.primary-btn.dark { background: var(--ink); color: var(--paper); }
.primary-btn[disabled] { opacity: .42; cursor: not-allowed; transform: none; }

.page-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 32px 0 26px; }
.page-head h1 { max-width: 850px; margin: 0; font-size: clamp(2.5rem, 6vw, 5.5rem); line-height: .95; letter-spacing: -.055em; }
.page-head p:last-child { max-width: 520px; margin: 0; color: #adb4a7; line-height: 1.55; }

.contract-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; align-items: start; }
.contract-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.contract-card { position: relative; display: flex; min-height: 410px; flex-direction: column; border: var(--line); background: var(--paper); color: var(--ink); padding: 22px; box-shadow: var(--shadow); overflow: hidden; cursor: pointer; text-align: left; transition: transform .15s, box-shadow .15s; }
.contract-card:hover { transform: translate(-2px,-2px); box-shadow: 8px 8px 0 var(--ink), 9px 9px 0 var(--paper); }
.contract-card::before { content: attr(data-code); display: grid; position: absolute; width: 68px; height: 68px; top: 0; right: 0; place-items: center; background: var(--mint); border-left: var(--line); border-bottom: var(--line); font-weight: 800; }
.contract-card:nth-child(2)::before { background: var(--rust); color: white; }
.contract-card:nth-child(3)::before { background: var(--yellow); }
.contract-card h2 { max-width: 75%; margin: 42px 0 12px; font-size: 1.75rem; line-height: 1.02; letter-spacing: -.04em; }
.contract-flavor { min-height: 52px; color: #5c5f55; font-style: italic; line-height: 1.45; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 18px; }
.tag { border: 1px solid var(--ink); padding: 4px 7px; background: transparent; font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.contract-facts { margin: auto 0 20px; padding: 0; list-style: none; border-top: 1px solid #9b9988; }
.contract-facts li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid #aaa896; font-size: .72rem; }
.contract-facts strong { text-align: right; }
.reward { display: flex; align-items: baseline; justify-content: space-between; color: var(--mint-dark); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.reward strong { font: 800 1.7rem var(--display); }

.side-file { border: 1px solid #596361; padding: 18px; background: var(--ink-soft); }
.side-file h3 { margin-bottom: 14px; font-size: .9rem; letter-spacing: .1em; text-transform: uppercase; }
.mini-crew { display: grid; gap: 10px; }
.mini-crew-card { display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 10px; border-top: 1px solid #4e5957; padding-top: 10px; }
.mini-crew-card:first-child { border: 0; padding-top: 0; }
.avatar { position: relative; width: 48px; height: 54px; overflow: hidden; border: 1px solid var(--paper); background: var(--crew-color, var(--mint)); flex: 0 0 auto; }
.avatar img { width: 300%; height: 100%; max-width: none; transform: translateX(var(--portrait-shift, 0%)); }
.mini-crew-card strong { display: block; font: 700 .82rem var(--display); }
.mini-crew-card span { color: #8fa09b; font-size: .62rem; text-transform: uppercase; }
.account-line { display: flex; justify-content: space-between; margin-top: 18px; border-top: 1px solid #596361; padding-top: 14px; font-size: .72rem; }
.account-line strong { color: var(--yellow); }

.mission-top { display: grid; grid-template-columns: 1.2fr 2fr; gap: 14px; margin-bottom: 14px; }
.mission-id { display: flex; align-items: center; gap: 16px; min-width: 0; border: 1px solid #4a5654; background: var(--ink-soft); padding: 12px 15px; }
.cargo-glyph { display: grid; width: 45px; height: 45px; place-items: center; flex: 0 0 auto; border: 1px solid var(--ink); background: var(--rust); color: white; font: 800 1.1rem var(--display); }
.mission-id small { display: block; margin-bottom: 3px; color: #84918c; font-size: .6rem; letter-spacing: .1em; text-transform: uppercase; }
.mission-id strong { display: block; overflow: hidden; font: 700 clamp(.85rem, 1.6vw, 1.05rem) var(--display); text-overflow: ellipsis; white-space: nowrap; }
.resources { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid #4a5654; background: var(--ink-soft); }
.resource { min-width: 0; padding: 9px 12px; border-right: 1px solid #4a5654; }
.resource:last-child { border: 0; }
.resource-label { display: flex; justify-content: space-between; gap: 5px; color: #99a39f; font-size: .58rem; letter-spacing: .08em; text-transform: uppercase; }
.resource-label strong { color: var(--paper); font-size: .68rem; }
.microbar { height: 5px; margin-top: 7px; background: #071011; }
.microbar i { display: block; width: var(--value); height: 100%; background: var(--bar-color, var(--mint)); transition: width .2s; }

.route { display: flex; align-items: center; gap: 0; min-height: 35px; margin-bottom: 14px; padding: 0 8px; }
.route-node { display: grid; width: 25px; height: 25px; place-items: center; flex: 0 0 auto; border: 1px solid #6c7773; border-radius: 50%; background: var(--ink); color: #7d8984; font-size: .55rem; }
.route-node.done { border-color: var(--mint); background: var(--mint); color: var(--ink); }
.route-node.current { border-color: var(--yellow); color: var(--yellow); box-shadow: 0 0 0 4px rgba(240,215,91,.12); }
.route-line { height: 1px; flex: 1; background: #53605d; }
.route-line.done { background: var(--mint); }
.route-label { margin-left: 10px; color: #8d9994; font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }

.mission-layout { display: grid; grid-template-columns: minmax(560px, 1.5fr) minmax(300px, .72fr); gap: 14px; align-items: stretch; }
.ship-panel { border: var(--line); background: var(--paper-2); color: var(--ink); box-shadow: 6px 6px 0 #050808; }
.ship-head { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 8px 14px; border-bottom: var(--line); background: var(--paper); }
.ship-head strong { font: 800 .82rem var(--display); letter-spacing: .09em; }
.ship-head small { color: #65685f; font-size: .6rem; }
.stations { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); min-height: 425px; }
.station { position: relative; display: flex; min-height: 205px; flex-direction: column; border: 0; border-right: var(--line); border-bottom: var(--line); background: transparent; padding: 13px; color: var(--ink); cursor: pointer; text-align: left; overflow: hidden; }
.station:nth-child(3n) { border-right: 0; }
.station:nth-child(n+4) { border-bottom: 0; }
.station:hover { background: rgba(255,255,255,.23); }
.station.needed { background: rgba(240,215,91,.2); }
.station.critical { animation: critical 1s steps(2,end) infinite; background: rgba(227,79,66,.16); }
@keyframes critical { 50% { background: rgba(227,79,66,.32); } }
.station.selected-target { outline: 5px solid var(--mint); outline-offset: -7px; }
.station-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.station-no { color: #77796f; font-size: .58rem; }
.need-flag { display: none; background: var(--rust); color: white; padding: 3px 6px; font-size: .55rem; font-weight: 800; letter-spacing: .08em; }
.needed .need-flag, .critical .need-flag { display: inline-block; }
.station-icon { width: 42px; height: 42px; margin: 10px 0; }
.station-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; vector-effect: non-scaling-stroke; }
.station h3 { margin: 0; font-size: clamp(.82rem, 1.5vw, 1.05rem); letter-spacing: -.025em; }
.station-skill { margin-top: 3px; color: #71746b; font-size: .56rem; letter-spacing: .08em; text-transform: uppercase; }
.occupant { display: flex; align-items: center; gap: 8px; min-height: 40px; margin-top: auto; border-top: 1px solid #9f9e8d; padding-top: 9px; }
.occupant .avatar { width: 31px; height: 35px; border-color: var(--ink); }
.occupant strong { display: block; font: 700 .68rem var(--display); }
.occupant small { color: #64675e; font-size: .53rem; }
.occupant.empty { color: #77796f; font-size: .6rem; text-transform: uppercase; }
.station-output { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(16,22,23,.18); }
.station-output i { display: block; width: var(--output); height: 100%; background: var(--mint-dark); }

.event-panel { display: flex; min-height: 471px; flex-direction: column; border: 1px solid #4b5855; background: var(--ink-soft); }
.event-band { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 46px; padding: 9px 14px; background: var(--rust); color: white; }
.event-band.opportunity { background: var(--mint); color: var(--ink); }
.event-band.cruise { background: var(--blue); color: var(--ink); }
.event-band small { font-size: .58rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.event-band strong { font: 800 .78rem var(--display); letter-spacing: .06em; }
.event-body { display: flex; flex: 1; flex-direction: column; padding: clamp(18px, 2.5vw, 28px); }
.event-kicker { color: var(--rust); font-size: .65rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.event-panel.opportunity .event-kicker { color: var(--mint); }
.event-body h2 { margin: 7px 0 11px; font-size: clamp(1.8rem, 3vw, 2.8rem); line-height: .93; letter-spacing: -.055em; }
.event-flavor { min-height: 44px; color: #aab4b0; font-size: .78rem; line-height: 1.5; }
.event-readout { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 13px 0 18px; }
.bigbar { height: 14px; border: 1px solid #65716e; background: #071011; }
.bigbar i { display: block; width: var(--value); height: 100%; background: var(--yellow); transition: width .15s linear; }
.timer { min-width: 50px; color: var(--yellow); font: 700 1.2rem var(--display); text-align: right; }
.requirements { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.requirement { padding: 5px 7px; border: 1px solid #697572; color: #9ca9a5; font-size: .56rem; letter-spacing: .07em; text-transform: uppercase; }
.requirement.covered { border-color: var(--mint); background: rgba(48,183,169,.12); color: var(--mint); }
.requirement.complication { border-color: var(--red); color: #ff7a70; }
.event-actions { display: grid; gap: 8px; margin-top: auto; }
.choice-btn { border: 1px solid #687470; background: #263333; padding: 11px 12px; cursor: pointer; font-size: .68rem; text-align: left; }
.choice-btn strong { display: block; margin-bottom: 3px; color: var(--paper); font: 700 .76rem var(--display); }
.choice-btn span { color: #98a39f; }
.choice-btn:hover { border-color: var(--yellow); }
.complication-card { margin: 5px 0 15px; border-left: 5px solid var(--red); background: #302423; padding: 10px 12px; }
.complication-card strong { display: block; color: #ff8278; font: 700 .75rem var(--display); }
.complication-card span { color: #bdaba6; font-size: .62rem; }
.event-tip { margin: auto 0 0; color: #7f8d88; font-size: .59rem; line-height: 1.45; }

.crew-deck { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 10px; margin-top: 14px; }
.crew-card { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 11px; min-width: 0; border: 1px solid #4d5a57; background: var(--ink-soft); padding: 8px; cursor: pointer; text-align: left; transition: border-color .12s, transform .12s; }
.crew-card:hover { border-color: var(--paper); }
.crew-card.selected { border-color: var(--yellow); transform: translateY(-3px); box-shadow: 0 3px 0 var(--yellow); }
.crew-card.injured { border-color: var(--red); }
.crew-card .avatar { width: 52px; height: 58px; }
.crew-name { display: block; overflow: hidden; font: 700 .84rem var(--display); text-overflow: ellipsis; white-space: nowrap; }
.crew-role { display: block; margin: 3px 0 7px; color: #899691; font-size: .56rem; letter-spacing: .08em; text-transform: uppercase; }
.healthbar { width: 100%; height: 4px; background: #081011; }
.healthbar i { display: block; width: var(--health); height: 100%; background: var(--health-color, var(--mint)); }
.skill-pip { display: grid; width: 31px; height: 31px; place-items: center; border: 1px solid #53605d; color: var(--yellow); font: 700 .78rem var(--display); }
.crew-station { grid-column: 2 / 4; margin-top: -4px; color: #b4beb9; font-size: .54rem; letter-spacing: .06em; text-transform: uppercase; }
.mission-controls { display: flex; flex-direction: column; justify-content: center; gap: 7px; padding-left: 4px; }

.log-strip { display: flex; gap: 10px; min-height: 36px; margin-top: 10px; color: #89958f; font-size: .58rem; line-height: 1.4; }
.log-strip strong { flex: 0 0 auto; color: var(--mint); letter-spacing: .1em; }

.dock-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 20px; }
.result-card { border: var(--line); background: var(--paper); color: var(--ink); box-shadow: var(--shadow); padding: clamp(24px, 5vw, 54px); }
.result-stamp { display: inline-block; margin-bottom: 20px; border: 4px solid var(--mint-dark); padding: 8px 13px; color: var(--mint-dark); font: 800 1rem var(--display); letter-spacing: .12em; transform: rotate(-3deg); }
.result-stamp.failed { border-color: var(--rust); color: var(--rust); }
.result-card h1 { margin-bottom: 12px; font-size: clamp(2.7rem, 6vw, 5.7rem); line-height: .9; letter-spacing: -.06em; }
.result-card > p { max-width: 650px; color: #65685e; line-height: 1.55; }
.result-ledger { display: grid; grid-template-columns: repeat(3,1fr); margin: 30px 0; border: var(--line); }
.ledger-cell { padding: 15px; border-right: var(--line); }
.ledger-cell:last-child { border: 0; }
.ledger-cell small { display: block; color: #75776d; font-size: .58rem; letter-spacing: .08em; text-transform: uppercase; }
.ledger-cell strong { display: block; margin-top: 5px; font: 800 1.4rem var(--display); }
.result-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.upgrade-bay { border: 1px solid #56625f; background: var(--ink-soft); padding: 18px; }
.upgrade-bay h2 { margin-bottom: 5px; }
.upgrade-bay > p { color: #8b9792; font-size: .68rem; line-height: 1.5; }
.upgrade-list { display: grid; gap: 9px; margin-top: 18px; }
.upgrade { border: 1px solid #52605d; background: #222e2f; padding: 12px; }
.upgrade.owned { opacity: .55; }
.upgrade h3 { margin-bottom: 5px; font-size: .84rem; }
.upgrade p { min-height: 31px; margin-bottom: 10px; color: #8f9c97; font-size: .6rem; line-height: 1.4; }
.upgrade-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.upgrade-price { color: var(--yellow); font-size: .68rem; font-weight: 700; }
.buy-btn { border: 1px solid var(--mint); background: transparent; color: var(--mint); padding: 6px 9px; cursor: pointer; font-size: .58rem; text-transform: uppercase; }
.buy-btn:disabled { border-color: #5c6663; color: #737d79; cursor: not-allowed; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; max-width: min(90vw, 520px); transform: translate(-50%, 30px); border: var(--line); background: var(--yellow); color: var(--ink); padding: 11px 16px; box-shadow: 4px 4px 0 #000; font-size: .7rem; font-weight: 700; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading, .fatal { display: grid; min-height: 75vh; place-items: center; text-align: center; }
.loading strong { animation: blink .8s steps(2,end) infinite; letter-spacing: .14em; }
@keyframes blink { 50% { opacity: .25; } }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .hero-copy { border-right: 0; border-bottom: var(--line); }
  .hero-art { min-height: 350px; }
  .contract-layout, .dock-grid { grid-template-columns: minmax(0, 1fr); }
  .side-file { order: -1; }
  .mini-crew { grid-template-columns: repeat(3,1fr); }
  .account-line { margin-top: 12px; }
  .mission-layout { grid-template-columns: 1fr; }
  .event-panel { min-height: 390px; }
  .crew-deck { grid-template-columns: repeat(3,1fr); }
  .mission-controls { grid-column: 1 / -1; flex-direction: row; }
}

@media (max-width: 720px) {
  .app-shell { padding: 10px 10px 28px; }
  .topbar, .screen { width: calc(100% - 12px); }
  .topbar { min-height: 48px; margin-bottom: 10px; }
  .brand { font-size: 1rem; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-mark::before { width: 13px; height: 4px; left: 6px; top: 6px; box-shadow: 0 10px var(--ink); }
  .brand-mark::after { width: 4px; height: 14px; left: 12px; top: 5px; }
  .hero { min-height: calc(100vh - 88px); box-shadow: 5px 5px 0 #050808; }
  .hero-copy { padding: 34px 24px; }
  .hero h1 { font-size: clamp(4.2rem, 23vw, 7rem); }
  .hero-art { min-height: 275px; padding-top: 26px; }
  .page-head { display: block; margin: 22px 0 18px; }
  .page-head h1 { max-width: 100%; font-size: clamp(2rem, 9.5vw, 3rem); overflow-wrap: anywhere; }
  .page-head p:last-child { margin-top: 14px; }
  .contract-grid { min-width: 0; grid-template-columns: minmax(0, 1fr); }
  .side-file { min-width: 0; }
  .contract-card { min-height: 360px; }
  .mini-crew { grid-template-columns: 1fr; }
  .mission-top { grid-template-columns: 1fr; }
  .resources { grid-template-columns: repeat(5, minmax(65px,1fr)); overflow-x: auto; }
  .resource { padding: 8px; }
  .route-label { display: none; }
  .ship-head small { display: none; }
  .stations { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .station { min-height: 178px; border-right: var(--line) !important; border-bottom: var(--line) !important; }
  .station:nth-child(2n) { border-right: 0 !important; }
  .station:nth-child(n+5) { border-bottom: 0 !important; }
  .crew-deck { grid-template-columns: 1fr; }
  .crew-card { grid-template-columns: 48px 1fr auto; }
  .crew-card .avatar { width: 44px; height: 49px; }
  .result-ledger { grid-template-columns: 1fr; }
  .ledger-cell { border-right: 0; border-bottom: var(--line); }
  .ledger-cell:last-child { border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Turn-based rebuild */
.crew-figure { display: block; width: 100%; height: 100%; overflow: visible; }
.crew-figure .shadow { fill: rgba(16,22,23,.22); }
.crew-figure .eyes, .crew-figure .mouth, .crew-figure .panel { fill: var(--ink); }
.crew-figure .accent { fill: var(--yellow); }
.crew-figure .visor { fill: var(--blue); stroke: var(--ink); stroke-width: 3px; }
.crew-figure .line { fill: none; stroke: var(--ink); stroke-width: 4px; }

.hero-art.generated { padding: 40px 18px 0; }
.hero-generated { display: flex; width: min(100%, 500px); height: 82%; align-items: end; justify-content: center; gap: clamp(2px, 1vw, 12px); }
.hero-generated > span { display: block; width: 31%; height: 100%; transform: translateY(calc(var(--i) * 5px)); }
.hero-generated .crew-figure { filter: drop-shadow(9px 9px 0 rgba(16,22,23,.15)); }

.roster-file h3 { margin-bottom: 4px; }
.roster-hint { margin: 0 0 14px; color: #8e9a95; font-size: .62rem; line-height: 1.45; }
.roster-list { display: grid; gap: 7px; }
.roster-crew { position: relative; display: grid; grid-template-columns: 42px 1fr; min-width: 0; min-height: 61px; border: 1px solid #50605c; background: #202d2e; }
.roster-crew.active { border-color: var(--mint); background: #193433; }
.roster-crew > .crew-figure { width: 42px; height: 58px; align-self: end; background: var(--paper-2); }
.roster-main { display: grid; grid-template-columns: 1fr auto; align-content: center; min-width: 0; border: 0; background: transparent; padding: 8px 26px 8px 9px; cursor: pointer; text-align: left; }
.roster-main strong { overflow: hidden; font: 700 .75rem var(--display); text-overflow: ellipsis; white-space: nowrap; }
.roster-main span { grid-column: 1 / -1; margin-top: 3px; color: #91a09b; font-size: .53rem; text-transform: uppercase; }
.roster-main em { color: var(--mint); font-size: .5rem; font-style: normal; letter-spacing: .08em; }
.release-btn { position: absolute; top: 2px; right: 2px; border: 0; background: transparent; color: #84918d; cursor: pointer; font-size: 1rem; }
.contract-card:disabled { opacity: .58; cursor: not-allowed; }
.contract-card:disabled:hover { transform: none; box-shadow: var(--shadow); }

.staged-layout { grid-template-columns: minmax(640px, 1.55fr) minmax(315px, .65fr); }
.staged-stations { min-height: 590px; }
.staged-station { min-height: 294px; padding: 12px; isolation: isolate; }
.staged-station::after { content: ""; position: absolute; z-index: -1; inset: 0; border: 0 solid transparent; pointer-events: none; }
.staged-station.critical::after { border-width: 6px; border-color: var(--red); animation: danger-frame 1.05s steps(2,end) infinite; }
.staged-station.warning { background: rgba(240,215,91,.18); }
.staged-station.warning::after { border-width: 4px; border-color: #c69d26; }
@keyframes danger-frame { 50% { border-width: 10px; border-color: #ff8a80; } }
.staged-station .station-icon { width: 30px; height: 30px; margin: 5px 0 2px; opacity: .75; }
.staged-station h3 { font-size: .95rem; }
.room-role { display: block; max-width: 62%; margin-top: 2px; color: var(--mint-dark); font-size: .48rem; font-weight: 700; line-height: 1.3; text-transform: uppercase; }
.critical .room-role { color: #7b2a26; }
.room-ok { color: #65756f; font-size: .5rem; font-weight: 700; letter-spacing: .08em; }
.room-condition { position: relative; z-index: 2; display: flex; width: 56%; min-height: 83px; flex-direction: column; margin-top: 8px; border-top: 1px solid #8f9184; padding-top: 8px; pointer-events: none; }
.room-condition strong { font: 800 .68rem var(--display); letter-spacing: .03em; text-transform: uppercase; }
.critical .room-condition strong { color: #b52620; }
.room-condition > span:not(.hazard-pips) { margin-top: 3px; color: #5d625b; font-size: .55rem; line-height: 1.35; }
.hazard-pips { display: flex; gap: 3px; margin-top: 8px; }
.hazard-pips i { width: 11px; height: 5px; border: 1px solid #777c73; background: transparent; }
.hazard-pips i.live { border-color: var(--red); background: var(--red); }
.room-floor { position: absolute; z-index: 0; right: 8px; bottom: 12px; width: 42%; height: 4px; background: rgba(16,22,23,.28); }
.room-crew-group { position: absolute; z-index: 4; right: 7px; bottom: 13px; display: flex; width: 43%; height: 145px; align-items: end; justify-content: flex-end; gap: 1px; pointer-events: none; }
.standing-crew { position: relative; right: auto; bottom: auto; width: 82px; height: 134px; border: 0; background: transparent; padding: 0 0 18px; cursor: grab; pointer-events: auto; }
.room-crew-group.count-2 .standing-crew { width: 61px; height: 113px; }
.room-crew-group.count-3 .standing-crew { width: 45px; height: 95px; }
.standing-crew:active { cursor: grabbing; }
.standing-crew.selected { outline: 3px solid var(--yellow); outline-offset: 2px; background: rgba(240,215,91,.16); }
.standing-crew .crew-figure.working { transform-origin: 50% 100%; animation: working var(--work-speed, 2.3s) ease-in-out infinite; animation-delay: var(--work-delay); }
@keyframes working { 0%, 100% { transform: rotate(-1deg) translateY(0); } 50% { transform: rotate(1.5deg) translateY(-2px); } }
.room-crew-name { position: absolute; right: 0; bottom: 9px; left: 0; overflow: hidden; color: var(--ink); font-size: .43rem; font-weight: 800; text-align: center; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.room-health { position: absolute; right: 3px; bottom: 2px; left: 3px; height: 5px; border: 1px solid var(--ink); background: var(--ink); }
.room-health i { display: block; width: var(--health); height: 100%; background: var(--mint-dark); }
.room-health.low i { background: var(--red); }
.empty-room { position: absolute; right: 12px; bottom: 25px; width: 58px; color: #777c73; font-size: .5rem; line-height: 1.3; text-align: center; }

.situation-panel { min-height: 636px; }
.situation-panel .event-body { padding: 24px; }
.situation-panel h2 { font-size: clamp(2rem, 3.2vw, 3.35rem); }
.setup-panel { border-color: var(--blue); }
.plain-steps { margin: 18px 0 24px; padding-left: 22px; color: #aeb8b4; font-size: .68rem; line-height: 1.6; }
.launch-btn, .action-btn { width: 100%; margin-top: auto; }
.general-status { border-left: 5px solid var(--red); background: #302423; padding: 12px; color: #e7d5ce; font-size: .75rem; line-height: 1.5; }
.situation-count { display: grid; gap: 4px; margin: 14px 0 12px; }
.situation-count strong { color: var(--yellow); font: 700 .9rem var(--display); }
.situation-count span { color: #8d9995; font-size: .58rem; line-height: 1.4; }
.outcome-ledger { display: grid; grid-template-columns: 1fr 1fr; margin: 24px 0; border: 1px solid #586561; }
.outcome-ledger span { padding: 12px; color: #98a49f; font-size: .65rem; }
.outcome-ledger span + span { border-left: 1px solid #586561; }
.outcome-ledger strong { display: block; margin-top: 4px; color: var(--paper); font: 800 1.35rem var(--display); }
.recovery-panel { border-color: var(--blue); }
.transit-duties { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 18px 0 24px; }
.transit-duties span { border: 1px solid #50605c; background: #233132; padding: 8px; color: #98a7a1; font-size: .56rem; line-height: 1.35; }
.transit-duties b { display: block; margin-bottom: 2px; color: var(--blue); font: 700 .62rem var(--display); }
.recovery-report { display: grid; gap: 7px; margin: 18px 0 24px; padding: 0; list-style: none; }
.recovery-report li { border-left: 4px solid var(--mint); background: #213433; padding: 9px; color: #b9c6c1; font-size: .62rem; line-height: 1.4; }

.staged-crew { grid-template-columns: repeat(3, minmax(0,1fr)); }
.simple-card { grid-template-columns: 52px 1fr auto; }
.simple-card > .crew-figure { width: 48px; height: 72px; align-self: end; background: var(--paper-2); }

.mission-overlay, .guide-overlay { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(5,10,11,.82); backdrop-filter: blur(4px); }
.briefing-card { width: min(680px, 100%); border: var(--line); background: var(--paper); color: var(--ink); padding: clamp(26px, 5vw, 55px); box-shadow: 10px 10px 0 #050808; animation: briefing-in .28s ease both; }
@keyframes briefing-in { from { opacity: 0; transform: translateY(12px) rotate(-.3deg); } }
.briefing-card h2 { margin-bottom: 16px; font-size: clamp(2.3rem, 6vw, 5rem); line-height: .94; letter-spacing: -.055em; }
.briefing-card > p:not(.eyebrow) { color: #575d56; line-height: 1.6; }
.briefing-facts { display: flex; gap: 8px; margin: 25px 0; }
.briefing-facts span { border: 1px solid var(--ink); padding: 7px 9px; font-size: .62rem; font-weight: 700; text-transform: uppercase; }
.briefing-actions { display: flex; justify-content: flex-end; gap: 10px; }
.report-card h2 { font-size: clamp(2rem, 5vw, 4rem); }
.report-card ul { display: grid; gap: 7px; margin: 20px 0 26px; padding: 0; list-style: none; }
.report-card li { border-left: 5px solid var(--mint-dark); background: #d3ddc9; padding: 9px 11px; font-size: .68rem; line-height: 1.4; }
.report-card li.bad { border-color: var(--red); background: #e7c8ba; }

.transit-overlay { overflow: hidden; background: #071011; }
.transit-copy { position: relative; z-index: 2; display: grid; gap: 4px; text-align: center; animation: transit-copy 1.2s ease both; }
.transit-copy span, .transit-copy small { color: var(--mint); font-size: .65rem; font-weight: 700; letter-spacing: .22em; }
.transit-copy strong { font: 800 clamp(3rem, 10vw, 8rem)/1 var(--display); letter-spacing: -.06em; }
@keyframes transit-copy { 0% { opacity: 0; transform: scale(.85); } 35%, 75% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.04); } }
.star-streaks { position: absolute; inset: 0; perspective: 300px; }
.star-streaks i { position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; background: white; transform: rotate(calc(var(--r, 1) * 20deg)) translateX(20px); animation: streak .75s linear infinite; }
.star-streaks i:nth-child(2n) { --r: 4; animation-delay: -.2s; }
.star-streaks i:nth-child(3n) { --r: 7; animation-delay: -.55s; }
.star-streaks i:nth-child(4n) { --r: 10; animation-delay: -.35s; }
.star-streaks i:nth-child(5n) { --r: 13; animation-delay: -.65s; }
.star-streaks i:nth-child(7n) { --r: 16; animation-delay: -.1s; }
@keyframes streak { from { transform: rotate(calc(var(--r, 1) * 20deg)) translateX(20px) scaleX(1); opacity: 0; } 25% { opacity: 1; } to { transform: rotate(calc(var(--r, 1) * 20deg)) translateX(75vw) scaleX(18); opacity: 0; } }

.resource-hit { position: relative; z-index: 3; animation: indicator-hit .18s linear 5; background: rgba(227,79,66,.24); }
.resource-hit .microbar i { background: var(--red) !important; }
@keyframes indicator-hit { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.guide-overlay { z-index: 80; overflow-y: auto; align-items: start; padding-top: max(24px, 6vh); }
.guide-card { width: min(930px, 100%); border: var(--line); background: var(--paper); color: var(--ink); box-shadow: 10px 10px 0 #000; }
.guide-card header { display: flex; align-items: start; justify-content: space-between; gap: 20px; border-bottom: var(--line); padding: 22px; }
.guide-card header h2 { margin: 0; font-size: clamp(1.7rem, 4vw, 3.3rem); letter-spacing: -.04em; }
.guide-card header .icon-btn { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.guide-grid { display: grid; grid-template-columns: repeat(3,1fr); }
.guide-grid article { min-height: 190px; border-right: var(--line); border-bottom: var(--line); padding: 20px; }
.guide-grid article:nth-child(3n) { border-right: 0; }
.guide-grid article:nth-child(n+4) { border-bottom: 0; }
.guide-grid h3 { margin: 8px 0; font-size: 1rem; }
.guide-grid p { color: #62665e; font-size: .65rem; line-height: 1.55; }
.guide-no { color: var(--mint-dark); font-weight: 800; }
.red-key { color: var(--red); }
.room-guide { padding: 20px; }
.room-guide h3 { margin-bottom: 12px; }
.room-guide > div { display: grid; grid-template-columns: repeat(3,1fr); border: var(--line); }
.room-guide span { padding: 10px; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); color: #62665e; font-size: .58rem; }
.room-guide span:nth-child(3n) { border-right: 0; }
.room-guide span:nth-child(n+4) { border-bottom: 0; }
.room-guide b { display: block; margin-bottom: 3px; color: var(--ink); font: 700 .68rem var(--display); }

.candidate-list { display: grid; gap: 8px; margin: 16px 0 24px; }
.candidate { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; border: 1px solid #53615e; background: #222f30; padding: 7px; }
.candidate > .crew-figure { width: 46px; height: 64px; background: var(--paper-2); }
.candidate h3 { margin: 0 0 4px; font-size: .78rem; }
.candidate p { min-height: 0; margin: 0 0 4px; font-size: .54rem; text-transform: uppercase; }
.candidate span { color: var(--yellow); font-size: .58rem; }
.dock-subhead { margin-top: 24px; border-top: 1px solid #53615e; padding-top: 18px; }
.dock-roster { display: grid; gap: 6px; }
.dock-crew { position: relative; display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 8px; min-height: 52px; border: 1px solid #4f5e5a; background: #202c2d; padding: 4px 25px 4px 4px; }
.dock-crew > .crew-figure { width: 36px; height: 46px; background: var(--paper-2); }
.dock-crew strong { display: block; font: 700 .66rem var(--display); }
.dock-crew span { color: #8e9b96; font-size: .5rem; text-transform: uppercase; }
.dock-crew em { border: 1px solid #5f6d69; padding: 3px 5px; color: #85918d; font-size: .46rem; font-style: normal; letter-spacing: .07em; }
.dock-crew em.active { border-color: var(--mint); color: var(--mint); }
.roster-note { margin: 8px 0 0; color: #7f8c87; font-size: .55rem; line-height: 1.4; }

@media (max-width: 1100px) {
  .staged-layout { grid-template-columns: 1fr; }
  .situation-panel { min-height: 410px; }
}

@media (max-width: 720px) {
  .top-actions { gap: 4px; }
  .top-actions button { padding: 7px; font-size: .55rem; }
  .brand small { display: none; }
  .hero-generated { height: 88%; }
  .staged-stations { min-height: 0; }
  .staged-station { min-height: 260px; }
  .room-crew-group { width: 48%; height: 116px; }
  .standing-crew { width: 58px; height: 104px; }
  .room-crew-group.count-2 .standing-crew { width: 45px; height: 91px; }
  .room-crew-group.count-3 .standing-crew { width: 34px; height: 77px; }
  .room-condition { width: 52%; }
  .staged-crew { grid-template-columns: 1fr; }
  .situation-panel { min-height: 480px; }
  .briefing-actions { flex-direction: column-reverse; }
  .briefing-actions button { width: 100%; }
  .guide-grid { grid-template-columns: 1fr; }
  .guide-grid article { min-height: 0; border-right: 0; border-bottom: var(--line) !important; }
  .guide-grid article:last-child { border-bottom: 0 !important; }
  .room-guide > div { grid-template-columns: 1fr; }
  .room-guide span { border-right: 0; border-bottom: 1px solid var(--ink) !important; }
  .room-guide span:last-child { border-bottom: 0 !important; }
}
