@media screen {
  .game-ui {
    --game-ink: #e6efef;
    --game-gold: #ffcc83;
    --game-deep: #081219;
    color: var(--game-ink);
    background: linear-gradient(90deg, #080f16f2, #0a171dd8 66%, #102029b8),
      url("../assets/intro-facility.jpg") 64% center / cover fixed no-repeat, var(--game-deep);
  }
  .game-ui :is(.masthead, .manual-masthead) {
    color: var(--game-ink);
    background: #0a141bf2;
    border-bottom: 1px solid #a87b485c;
  }
  .game-ui .masthead { gap: .35rem 1rem; flex-wrap: wrap; }
  .game-nav { display: flex; flex-wrap: wrap; gap: .15rem .35rem; }
  .game-nav a {
    display: block; padding: .4rem .55rem; color: var(--game-ink); text-decoration: none;
    border-left: 2px solid transparent; font: 650 .78rem/1.35 Consolas, monospace;
  }
  .game-nav a:hover, .game-nav a:focus-visible, .game-nav a[aria-current="page"] {
    color: var(--game-gold); border-left-color: var(--game-gold); background: #ffcb7419;
  }
  .game-nav a:focus-visible, .game-ui a.button:focus-visible { outline: 2px solid var(--game-gold); outline-offset: 2px; }
  .game-ui h1 { font-family: "Segoe UI", system-ui, sans-serif; font-weight: 900; text-transform: uppercase; }
  .game-ui .brand strong, .game-ui .eyebrow, .game-ui .handbook-mark { color: var(--game-gold); }
  .game-ui :is(.setup, .telemetry, .system, .override, .power-panel, .module) {
    background: linear-gradient(150deg, #162832f5, #102029f7);
  }
  .game-ui :is(.button, .print-tools button), body.game-manual > button {
    border-left: 3px solid #83949b; font-family: Consolas, monospace; font-weight: 700;
  }
  .game-ui :is(.button.primary, .print-tools button), body.game-manual > button {
    color: var(--game-gold); background: #ffcb741b; border-color: #c59154; border-left-color: var(--game-gold);
  }
  .game-ui :is(.button.primary:hover:not(:disabled), .print-tools button:hover) { background: #ffcb7433; }
  .audio-mixer { position: relative; }
  .audio-mixer summary {
    padding: .64rem .75rem;
    border: 1px solid #4c646e;
    border-left: 3px solid #83949b;
    border-radius: 4px;
    background: #1e313a;
    color: #e6efef;
    font: 700 .78rem/1.3 Consolas, monospace;
    cursor: pointer;
  }
  .audio-mixer summary:hover, .audio-mixer[open] summary { background: #304750; }
  .audio-mixer-controls {
    position: absolute;
    bottom: calc(100% + .45rem);
    right: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: auto minmax(5.5rem, 10rem) 3ch;
    align-items: center;
    gap: .65rem;
    width: min(17rem, calc(100vw - 2rem));
    padding: .8rem;
    background: #11242e;
    border: 1px solid #64818a;
    border-radius: 5px;
    box-shadow: 0 6px 18px #0008;
    color: #e6efef;
    font: 700 .78rem/1.3 Consolas, monospace;
  }
  .audio-mixer-controls input { min-width: 0; width: 100%; accent-color: #9deccd; }
  .audio-mixer-controls output { color: #aaf4ce; }
  @media (max-width: 600px) {
    .preferences { position: relative; }
    .audio-mixer { position: static; }
    .audio-mixer-controls { width: min(15rem, calc(100vw - 2rem)); }
  }
  .game-ui .welcome-links .menu-item { border: 0; border-left: 3px solid transparent; }
  .game-ui .welcome-links :is(.menu-start, .menu-item:hover, .menu-item:focus-visible) { border-left-color: var(--game-gold); }
  .crew-indicator { display: inline-block; margin-inline-start: .65rem; color: #baf2df; letter-spacing: .035em; }
  .crew-indicator b { color: #738e92; }
  .personnel-screen { border-top: 3px solid #d5a76a; }
  #screen[data-view="control"] .personnel-shift .screen-heading.with-oscar { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
  .personnel-shift .screen-heading h1 { font-size: clamp(2rem, 3.4vw, 2.8rem); }
  .personnel-screen .oscar { width: min(100%, 30rem); }
  .crew-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
  .crew-card, .personnel-clocks { padding: .9rem 1rem; background: linear-gradient(150deg, #1d343a, #101f29); }
  .crew-card h2 { margin: .25rem 0 .5rem; color: #baf2df; }
  .crew-previous { color: #c5d3d5; font-size: .82em; }
  .crew-exchange { display: inline-block; color: #f1bd7e; animation: shift-exchange 720ms ease-out both; }
  @keyframes shift-exchange { from { opacity: .5; transform: translateX(-.4rem); } to { opacity: 1; transform: none; } }
  @media (prefers-reduced-motion: reduce) { .crew-exchange { animation: none; } }
  .personnel-clocks { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin-top: .8rem; }
  .personnel-clocks strong { color: #f7ce96; font: 700 1.12rem var(--mono); }
  #crew-clock-state { color: #c5e4dc; font-size: .8rem; }
  .personnel-note { margin-top: .6rem; color: var(--amber); }
  .crew-report { margin-top: 1rem; color: #dceae7; }
  .crew-report h2 { margin-bottom: .25rem; font-size: 1rem; }
  @media (max-width: 520px) {
    .crew-cards { grid-template-columns: 1fr; }
    .crew-indicator { display: block; margin-inline-start: 0; }
  }
  @media (max-width: 740px) {
    #screen[data-view="control"] .personnel-shift .screen-heading.with-oscar { grid-template-columns: minmax(0, 1fr); }
  }
  .manual-masthead { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding: .65rem max(1rem, calc((100% - 1190px) / 2)); }
  .manual-masthead strong { font: 800 .95rem Consolas, monospace; color: var(--game-gold); letter-spacing: .09em; }
  .game-manual .manual-page, .game-manual main:not(.shell) { color: var(--game-ink); background: #12212af2; }
  .game-manual .manual-page { border-top-color: var(--game-gold); }
  .game-manual .handbook-mascots { color: #181818; background: #f3eee1; border: 1px solid var(--game-gold); }
  .game-manual th, .game-manual td { border-color: #76858c; }
  .game-manual :is(.year, .handbook-diagram) { border-color: #84959b; }
  .game-manual .print-tools button, body.game-manual > button { border-radius: 4px; }
}

@media print {
  .manual-masthead { display: none; }
}

@media screen {
  #screen[data-view="control"] { isolation: isolate; }
  body:has(#screen[data-view="control"]) > :is(.masthead, .console-footer) {
    position: relative;
    z-index: 1;
  }
  .room-environment { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
  .room-background, .room-light, .room-foreground { position: absolute; inset: 0; }
  .room-background {
    background: linear-gradient(180deg, #080f1550 8%, #0a141b40 32%, #07101892 100%),
      url("../assets/control-room/facility.webp") center 35% / cover no-repeat, #0b171c;
  }
  .room-light {
    background: radial-gradient(ellipse at 8% 9%, #de742858, transparent 34%),
      radial-gradient(ellipse at 89% 11%, #df923746, transparent 33%);
    opacity: .64;
    transition: opacity 650ms ease;
  }
  .room-environment[data-room-state="paused"] .room-light { opacity: .19; }
  .room-environment[data-room-state="ready"] .room-light {
    background: radial-gradient(ellipse at 88% 14%, #72ddac62, transparent 42%);
    opacity: .72;
  }
  .room-environment[data-room-state="active"] .room-light::after {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(ellipse at 8% 12%, #ce702b75, transparent 28%),
      radial-gradient(ellipse at 92% 10%, #d65c4069, transparent 25%);
    opacity: calc((1 - var(--time-reserve, 1)) * .85);
    transition: opacity 450ms ease;
  }
  #screen[data-urgency="critical"] .room-environment[data-room-state="active"] .room-light { opacity: .92; }
  #screen[data-urgency="warning"] .system:is([data-status="Fault detected"], [data-status="In repair"]) .light { color: #ffd08a; box-shadow: 0 0 6px #ffd08a55; }
  #screen[data-urgency="critical"] .system:is([data-status="Fault detected"], [data-status="In repair"]) .light { color: #ffb19c; box-shadow: 0 0 6px #ffb19c70; }
  #screen[data-urgency="critical"] .schematic-node[data-status="Fault"] { color: #ffb19c; }
  .system .light, .schematic-node { transition: color 280ms ease, box-shadow 280ms ease; }

  .emergency-timer {
    --timer-ink: #aef5d5;
    position: relative; min-width: 0; padding: .30rem .48rem; gap: .18rem;
    border: 1px solid #778487; border-radius: 6px;
    background: linear-gradient(165deg, #445357, #243439 48%, #162328);
    box-shadow: inset 0 1px #ffffff38, inset 0 -2px #0a1418, 0 2px #050a0c;
    transition: border-color 280ms ease;
  }
  .emergency-timer::after {
    content: ""; position: absolute; inset: .18rem .18rem auto auto; width: 3px; height: 3px; border-radius: 50%;
    background: #16242a; box-shadow: 0 0 0 1px #7a898a; pointer-events: none;
  }
  .timer-nameplate { display: flex; align-items: center; justify-content: space-between; gap: .28rem; }
  .timer-nameplate .eyebrow { font-size: .65rem; color: #d9e5e3; }
  .timer-lamps { display: inline-flex; gap: .24rem; padding-right: .14rem; }
  .timer-lamps i {
    width: 6px; height: 6px; border-radius: 50%; background: #10191c; border: 1px solid #7a898a;
    transition: background-color 220ms ease, box-shadow 220ms ease;
  }
  .emergency-timer[data-urgency="normal"] [data-lamp="normal"],
  .emergency-timer[data-urgency="warning"] [data-lamp="warning"],
  .emergency-timer[data-urgency="critical"] [data-lamp="critical"] { background: var(--timer-ink); box-shadow: 0 0 5px var(--timer-ink); }
  .emergency-timer[data-urgency="warning"] { --timer-ink: #ffd08a; border-color: #b8894e; }
  .emergency-timer[data-urgency="critical"] { --timer-ink: #ffb19c; border-color: #ce8c7b; }
  .timer-display {
    display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center;
    gap: .4rem; min-width: 0; padding: .27rem .43rem;
    background: #061316; border: 1px solid #647676; border-radius: 3px;
    box-shadow: inset 0 2px 6px #000a;
  }
  .emergency-timer #clock {
    color: var(--timer-ink); font: 750 clamp(1.4rem, 2.55vw, 2.4rem)/.98 var(--mono);
    font-variant-numeric: tabular-nums; letter-spacing: .02em; white-space: nowrap;
  }
  .emergency-timer[data-timed="false"] #clock { font-size: clamp(1rem, 2vw, 1.7rem); }
  .emergency-timer .clock-status { min-height: .85rem; color: var(--timer-ink); }
  .emergency-timer[data-paused="true"] .clock-status { color: #d8e8e5; }
  .timer-reserve { height: 3px; overflow: hidden; background: #0b171d; border-radius: 2px; }
  .timer-reserve span { display: block; width: 100%; height: 100%; background: var(--timer-ink); transform: scaleX(var(--time-reserve, 1)); transform-origin: left; transition: transform 220ms linear; }
  .emergency-timer[data-timed="false"] .timer-reserve { visibility: hidden; }
  @media (max-width: 1050px) {
    .timer-display { grid-template-columns: minmax(0, 1fr); gap: .12rem; }
  }
  @media (max-width: 360px) {
    .emergency-timer #clock { font-size: 1.3rem; }
    .timer-nameplate .eyebrow { letter-spacing: 0; }
    .timer-lamps { gap: .14rem; }
  }
  .room-foreground {
    inset: auto 0 0;
    height: clamp(52px, 11vh, 132px);
    background: url("../assets/control-room/workstation-rail.svg") center bottom / 100% 100% no-repeat;
  }
  #screen[data-view="control"] > .screen-heading h1 { text-shadow: 0 2px 12px #061215; }
  #screen[data-view="control"] .system {
    grid-template-rows: auto minmax(64px, 1fr) auto auto;
    gap: .22rem;
    padding: .5rem .65rem;
    background: linear-gradient(180deg, #1c3139f5 0 23px, #09141bd4 24px 70%, #152932fb 71%);
    border-radius: 5px 5px 12px 12px;
    border-bottom-width: 3px;
    box-shadow: inset 0 2px #ffffff19, 0 4px 0 #060d10;
    transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
  }
  #screen[data-view="control"] .system:not(:disabled):hover { transform: translateY(-2px); box-shadow: inset 0 2px #ffffff20, 0 5px 8px #0007; }
  #screen[data-view="control"] .system:not(:disabled):active { transform: translateY(2px); box-shadow: inset 0 2px 4px #0007; }
  .station-assignment { color: #d0e0e4; text-transform: uppercase; font-size: .93em; }
  .system:is([data-status="In repair"], [data-status="Under repair"]) .system-status { color: var(--amber); }
  #screen[data-view="control"] .system[data-status="Restored"]:disabled { color: var(--game-ink); }
  #screen[data-view="control"] .system[data-current-fault] {
    border-color: #e5b276;
    box-shadow: inset 0 0 22px #c9802e28, 0 0 0 1px #e5b27648;
  }
  .system[data-fault-arrived] .system-status .light { animation: fault-arrival 850ms ease-out both; }
  .dynamic-dispatch {
    display: flex; align-items: center; gap: .55rem; margin: .45rem 0 .65rem;
    padding: .3rem .55rem; background: #13242d; color: #f5d19d; font: 700 .8rem/1.35 var(--mono);
  }
  .dynamic-dispatch[data-dispatch="scanning"] { color: #c5e4e9; }
  .dynamic-dispatch[data-dispatch="ready"] { color: var(--mint); }
  #screen:has(.dynamic-dispatch) .telemetry { margin-bottom: .15rem; }
  #screen:has(.dynamic-dispatch) .preferences { margin-top: .6rem; }
  #screen:has(.dynamic-dispatch) .system .station-art { --station-height: clamp(64px, 10.6vh, 109px); }
  .dispatch-icon { color: inherit; border: 1px solid currentColor; min-width: 1.15rem; text-align: center; border-radius: 3px; }
  [data-dispatch="scanning"] .dispatch-icon { animation: diagnostic-scan 1.8s ease-in-out infinite alternate; }
  [data-dispatch="fault"][data-dispatch-new="true"] .dispatch-icon { animation: fault-arrival 850ms ease-out both; }
  #screen[data-machine-paused="true"] .dispatch-icon, [data-machine-hidden="true"] .dispatch-icon { animation-play-state: paused; }
  #screen:has([data-fault-arrived]) .room-light { animation: fault-room-light 950ms ease-out; }
  @keyframes fault-arrival { from { opacity: .55; transform: scale(.86); } 42% { opacity: 1; transform: scale(1.16); } to { opacity: 1; transform: none; } }
  @keyframes diagnostic-scan { from { opacity: .55; } to { opacity: 1; } }
  @keyframes fault-room-light { from { filter: brightness(1.3); } to { filter: none; } }
  #screen[data-view="control"] .telemetry, #screen[data-view="control"] .override {
    background: linear-gradient(150deg, #132630f2, #102029fa);
  }
  .override-schematic { align-content: start; padding: .6rem; gap: .35rem; }
  .override-schematic h2 { font-size: 1.16rem; }
  .override-code { color: var(--amber); font: .65rem var(--mono); white-space: nowrap; }
  .override-schematic > p { font-size: .85rem; }
  .facility-schematic {
    box-sizing: border-box; width: 100%; max-width: 320px; margin: 0 auto;
    padding: .4rem; border: 1px solid #577681; border-radius: 4px; background: #091920;
  }
  .facility-schematic figcaption {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: .2rem .4rem;
    color: #e2f0ed; font: .73rem var(--mono);
  }
  .facility-schematic figcaption span { color: var(--mint); }
  .facility-schematic svg { display: block; width: 100%; height: auto; margin: .35rem auto .15rem; }
  .schematic-link { fill: none; stroke: #52696e; stroke-width: 1.3; }
  [data-sector-link][data-status="Restored"] .schematic-link { stroke: var(--mint); stroke-width: 1.8; }
  .schematic-node { color: #a8c0c7; }
  .schematic-node[data-status="Fault"] { color: var(--amber); }
  .schematic-node[data-status="Restored"] { color: var(--mint); }
  .schematic-node rect { fill: #12252c; stroke: currentColor; stroke-width: .7; }
  .schematic-node[data-active="true"] rect { stroke-width: 2; stroke: white; }
  .schematic-node circle, .schematic-node text { fill: currentColor; }
  .schematic-node text { font: 11px var(--mono); }
  .schematic-node .schematic-code { font-weight: bold; }
  .schematic-node[data-status="Unassigned"] .schematic-status { font-size: 8px; }
  .schematic-core { color: #a8c0c7; }
  .schematic-core[data-ready="true"] { color: var(--mint); }
  .schematic-core-ring, .schematic-core path { fill: #12252c; stroke: currentColor; stroke-width: 1.3; }
  .schematic-core-light { fill: currentColor; }
  .schematic-caption { color: #e2f0ed; font: .73rem var(--mono); }
  .schematic-pulse { fill: none; stroke: #e1fff2; stroke-width: 2.6; stroke-dasharray: .17 .83; opacity: 0; animation: network-pulse 750ms ease-out; }
  .schematic-core[data-activating="true"] .schematic-core-ring { animation: core-wake 650ms 500ms ease-out; }
  @keyframes network-pulse {
    from { stroke-dashoffset: .17; opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    to { stroke-dashoffset: -1; opacity: 0; }
  }
  @keyframes core-wake { 40% { stroke-width: 4; fill: #31574b; } }
  .module-schematic { margin-top: .7rem; padding: .45rem .65rem; }
  .module-schematic summary { cursor: pointer; color: var(--amber); font: .82rem var(--mono); }
  .module-schematic .facility-schematic { margin: .55rem 0 0; }
  @media (max-width: 620px) {
    .room-background { background-position: center, 54% center; }
    .room-foreground { background-size: auto 100%; }
  }
}
