@font-face { font-family: "Black Ops One"; src: url("public/assets/BlackOpsOne-Regular.282a825b5f29.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("public/assets/BarlowCondensed-Medium.262bd143292c.ttf") format("truetype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("public/assets/BarlowCondensed-Bold.e476562ec9c1.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
:root {
  color-scheme: dark;
  --charcoal: #152c35; --ink: #10232b; --ivory: #eee0b9;
  --teal: #275761; --jade: #4e8685;
  --muted: #b8ccca; --amber: #eda649; --line: #49636a; --danger: #ffad92;
  --safe-top: max(8px, env(safe-area-inset-top));
  --safe-bottom: max(8px, env(safe-area-inset-bottom));
  font: 500 18px/1.4 "Barlow Condensed", "Arial Narrow", sans-serif;
  background: var(--charcoal); color: var(--ivory);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; height: 100vh; height: 100dvh; padding: var(--safe-top) max(8px, env(safe-area-inset-right)) var(--safe-bottom) max(8px, env(safe-area-inset-left)); display: grid; place-items: center; overflow: hidden; }
button, input, select { font: inherit; }
button, select, summary { cursor: pointer; }
button { min-height: 44px; min-width: 44px; border-radius: 2px; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .42; cursor: default; }
button, select, input, summary { touch-action: manipulation; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: square; stroke-linejoin: round; }
kbd { font: 700 12px/1 "Barlow Condensed", sans-serif; border: 1px solid #777b6d; border-bottom-width: 2px; padding: 3px 5px; border-radius: 2px; white-space: nowrap; }
h1, h2, p, dl { margin: 0; }
button, select { transition: background-color .12s, color .12s, border-color .12s; }
#shell { --chrome-height: 100px; width: min(1536px, 100%, calc((100dvh - var(--safe-top) - var(--safe-bottom) - var(--chrome-height)) * 16 / 9)); display: grid; gap: 6px; min-width: 0; }
.toolbar, .control-strip { height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toolbar-title { display: flex; align-items: baseline; gap: 14px; white-space: nowrap; }
.toolbar-title strong { font-size: 18px; font-weight: 700; letter-spacing: .02em; }
.toolbar-title > span { color: var(--muted); font-size: 14px; }
.toolbar-actions { display: flex; align-items: center; gap: 2px; }
.icon-button, .quiet-button, .text-button { border: 1px solid transparent; background: transparent; color: var(--muted); }
.icon-button { width: 44px; padding: 11px; display: grid; place-items: center; flex: 0 0 44px; }
.quiet-button { display: flex; gap: 7px; align-items: center; padding: 8px 10px; }
.text-button { padding: 8px 12px; }
button:not(:disabled):hover { color: var(--ivory); }
.icon-button:not(:disabled):hover, .quiet-button:not(:disabled):hover, .text-button:not(:disabled):hover { background: #ffffff0d; border-color: var(--line); }
.sound-slash { display: none; }
.sound-button[aria-pressed="true"] { color: var(--amber); }
.sound-button[aria-pressed="true"] .sound-waves { display: none; }
.sound-button[aria-pressed="true"] .sound-slash { display: block; }

#stage { position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--ink); isolation: isolate; box-shadow: 0 0 0 1px var(--line); }
#stage-surface { position: absolute; inset: 0; overflow: hidden; isolation: isolate; container: battlefield / inline-size; background: var(--charcoal); }
.scene-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: left bottom; image-rendering: pixelated; pointer-events: none; user-select: none; }
#game { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; touch-action: none; }
#game canvas { display: block !important; width: 100% !important; height: 100% !important; max-width: 100%; max-height: 100%; margin: 0 !important; object-fit: contain; image-rendering: crisp-edges; image-rendering: pixelated; }
#game:focus-visible { outline-offset: -3px; }
.screen { position: absolute; inset: 0; z-index: 20; }
.title-screen { display: flex; align-items: center; background: linear-gradient(90deg, #10232bf2 0%, #152c35cf 30%, #152c3530 57%, transparent 76%); }
.title-layout { width: min(43%, 480px); margin-left: 6%; padding-block: 24px; }
.field-badge { display: inline-flex; align-items: center; gap: clamp(10px, 1.15cqw, 16px); font-size: clamp(11px, 1.15cqw, 16px); font-weight: 700; }
.field-badge > span { color: var(--ivory); border-left: 1px solid #f4efdf66; padding: 5px 0 5px clamp(10px, 1.15cqw, 16px); letter-spacing: .09em; text-transform: uppercase; font-size: .85em; line-height: 1.1; white-space: nowrap; }
.aws-logo { display: block; flex: 0 0 auto; width: clamp(42px, 4.3cqw, 60px); height: auto; aspect-ratio: 109 / 64; object-fit: contain; image-rendering: auto; }
h1 { font: 400 clamp(40px, 6.8cqw, 98px)/.94 "Black Ops One", Impact, sans-serif; text-transform: uppercase; letter-spacing: -.035em; margin: 20px 0 14px; }
.operation-name { font-weight: 700; font-size: clamp(14px, 1.65cqw, 23px); letter-spacing: .13em; text-transform: uppercase; color: var(--amber); }
.briefing { max-width: 33ch; margin-top: 18px; color: var(--ivory); font-size: clamp(16px, 1.55cqw, 22px); line-height: 1.4; text-wrap: pretty; }
.briefing strong { color: var(--amber); font-weight: 700; }
.title-controls { max-width: 350px; margin-top: 24px; }
.first-controls { font-size: 16px; color: var(--ivory); margin-bottom: 16px; }
.portrait-advice, .portrait-play-note { display: none; }
.difficulty-control { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 10px; margin-bottom: 13px; }
.difficulty-control > label { color: var(--muted); font-size: 15px; }
.difficulty-control select { min-height: 44px; min-width: 125px; padding: 5px 30px 5px 12px; border: 1px solid var(--line); border-radius: 2px; background: var(--ink); color: var(--ivory); }
#difficulty-note { grid-column: 1 / -1; color: var(--muted); font-size: 14px; padding-top: 6px; }
.primary-button, .secondary-button { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 18px; width: 100%; font-weight: 700; font-size: 19px; }
.primary-button { background: var(--amber); color: var(--ink); border: 1px solid var(--amber); }
.primary-button:not(:disabled):hover { background: #f8bd6c; color: var(--ink); }
.primary-button:active { transform: translateY(1px); }
.primary-button kbd { color: inherit; border: 0; font-size: 20px; padding: 0; opacity: .75; }
.primary-button .primary-key { flex-shrink: 0; }
#shell[data-ui-input-mode="gamepad"] .primary-key { font-size: 12px; letter-spacing: 0; opacity: 1; }
#shell.gamepad-navigation :focus { outline: 2px solid var(--amber); outline-offset: 3px; }
#shell.gamepad-navigation .toggle-setting input:focus + .switch { outline: 2px solid var(--amber); outline-offset: 4px; }
.secondary-button { justify-content: center; background: var(--teal); color: var(--ivory); border: 1px solid var(--jade); font-size: 18px; }
.secondary-button:not(:disabled):hover { background: #356b74; }
.menu-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.menu-actions .text-button { padding-inline: 0; border: 0; border-radius: 0; }
.menu-actions .text-button:not(:disabled):hover { background: transparent; text-decoration: underline; text-underline-offset: 4px; }

/* HUD occupies the sky band. No bottom panels across the ground or actors. */
.hud { --status-inner: clamp(170px, 18cqw, 240px); position: absolute; inset: 0; z-index: 5; pointer-events: none; font-size: clamp(14px, 1.3cqw, 18px); font-variant-numeric: tabular-nums; }
.hud-top { position: absolute; top: 16px; left: 16px; right: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.player-status { display: flex; gap: 9px; align-items: center; background: #10232bf0; padding: 8px 12px; border-left: 3px solid var(--jade); }
.player-mark { display: none; }
.health-status { width: var(--status-inner); }
.health-heading { display: flex; align-items: baseline; gap: 6px; line-height: 1; margin-bottom: 8px; }
.health-heading > span:first-child { color: var(--muted); }
.health-heading > strong { font-weight: 700; }
.health-pips { display: flex; align-items: center; gap: 4px; height: 6px; }
.health-pips i { display: block; flex: 1; min-width: 1px; height: 6px; background: var(--ivory); }
.health-pips i.empty { background: #4a636b; }
.health-pips[data-low="true"] i:not(.empty) { background: var(--danger); border-color: #ffcfbe; }
.reserve-label { display: block; margin-left: auto; font-size: .9em; color: var(--muted); }
.reserve-label strong { margin-left: 4px; }
.score-status { text-align: right; display: flex; gap: 10px; align-items: baseline; background: #10232bf0; padding: 8px 12px; }
.score-status > span { font-size: .8em; }
.score-status strong { font-size: 1.35em; font-variant-numeric: tabular-nums; letter-spacing: .07em; line-height: 1; }
.hud-equipment { position: absolute; top: 74px; left: 16px; display: flex; gap: 16px; align-items: center; font-size: 15px; background: #10232be8; padding: 6px 10px; }
.hud-equipment strong { margin-left: 4px; }
.weapon-status { color: var(--amber); font-weight: 700; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lambda-status { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ivory); border-bottom: 2px solid var(--jade); }
.lambda-status[data-ending="true"] { color: var(--amber); border-bottom-color: var(--amber); }
.replay-status { position: absolute; top: 108px; right: 16px; display: flex; align-items: center; gap: 14px; padding: 5px 10px; font-size: 15px; line-height: 1.2; background: #10232bf0; border-left: 2px solid var(--jade); }
.replay-status strong { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.replay-status[data-state="missed"] strong { color: var(--amber); }
#shield-status[data-ready="true"] strong { color: var(--amber); }
.objective-status { position: absolute; right: 16px; top: 66px; max-width: 42%; display: grid; grid-template-columns: auto minmax(0,1fr); column-gap: 8px; align-items: center; font-size: 15px; line-height: 1.2; background: #10232be8; padding: 8px 10px; }
.hud:has(.boss-status:not([hidden])) .objective-status { display: none; }
.objective-service { color: var(--ivory); background: var(--teal); padding: 3px 5px; font-size: .85em; font-weight: 700; line-height: 1; letter-spacing: .035em; }
.objective-service[data-service="MAINFRAME"] { color: var(--ivory); border-color: #f2b64a80; }
.weapon-status[data-service="lambda"] { text-decoration: underline; text-underline-offset: 3px; }
#hud-objective { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
progress, meter { display: block; width: 100%; height: 5px; appearance: none; border: 0; background: #101a13e6; border-radius: 0; overflow: hidden; }
progress::-webkit-progress-bar { background: #101a13e6; }
progress::-webkit-progress-value { background: var(--amber); }
progress::-moz-progress-bar { background: var(--amber); }
meter::-webkit-meter-bar { background: #101a13e6; border: 0; border-radius: 0; }
meter::-webkit-meter-optimum-value { background: var(--amber); }
meter::-moz-meter-bar { background: var(--amber); }
#mission-progress { grid-column: 2; margin-top: 6px; height: 3px; box-shadow: 0 1px 1px #0008; }
.vehicle-status { position: absolute; left: 16px; top: 16px; display: grid; grid-template-columns: 1fr auto auto; gap: 6px 8px; width: calc(var(--status-inner) + 27px); padding: 8px 12px; border-left: 3px solid var(--amber); background: #10232bf0; font-size: inherit; line-height: 1; }
.vehicle-exit { grid-column: 2; font-size: 12px; color: var(--muted); align-self: center; white-space: nowrap; }
.vehicle-status meter { grid-row: 2; grid-column: 1 / -1; }
.vehicle-status strong { grid-row: 1; grid-column: 3; }
.vehicle-status meter { height: 6px; }
.vehicle-status[data-low="true"] strong { color: var(--danger); }
.vehicle-status[data-low="true"] meter::-webkit-meter-optimum-value { background: var(--danger); }
.vehicle-status[data-low="true"] meter::-moz-meter-bar { background: var(--danger); }
.vehicle-status[data-hit="true"] { box-shadow: inset 0 0 0 1px var(--danger); }
.hud[data-vehicle="true"] .player-status { margin-top: 48px; padding-block: 4px; border-color: transparent; font-size: 14px; }
.hud[data-vehicle="true"] .health-heading { margin-bottom: 0; }
.hud[data-vehicle="true"] .health-pips { display: none; }
.hud[data-vehicle="true"] .hud-equipment { top: 90px; }
.boss-status { position: absolute; top: 16px; left: 36%; width: 28%; font-size: 15px; padding: 8px 12px; background: #10232bf0; }
.boss-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; line-height: 1.1; }
.boss-status strong { color: var(--ivory); font-size: max(14px, 1.05em); letter-spacing: .065em; white-space: nowrap; }
#boss-phase { color: var(--muted); font-size: max(11px, .8em); white-space: nowrap; }
#boss-subtitle { display: block; margin-top: 3px; font-size: clamp(11px, 1.05cqw, 13px); line-height: 1.15; letter-spacing: .055em; color: var(--ivory); }
.boss-status progress { height: 6px; margin-top: 4px; box-shadow: 0 0 0 1px #07100bb3; }
.boss-status progress::-webkit-progress-value { background: var(--amber); }
.boss-status progress::-moz-progress-bar { background: var(--amber); }
.boss-tip { display: block; margin-top: 6px; color: var(--ivory); font-size: 15px; line-height: 18px; }
.boss-tip[data-urgent="true"] { color: #ffd498; border-left: 2px solid #ee956e; padding-left: 6px; font-weight: 700; }
.boss-status[data-shielded="true"] #boss-phase { color: var(--amber); }
.boss-status[data-shielded="true"] .boss-tip { white-space: pre-line; }
.boss-status[data-shielded="true"] progress::-webkit-progress-value { background: repeating-linear-gradient(135deg, #efc888 0 4px, #836446 4px 8px); }
.boss-status[data-shielded="true"] progress::-moz-progress-bar { background: repeating-linear-gradient(135deg, #efc888 0 4px, #836446 4px 8px); }
.stage-tools { position: absolute; top: 6px; right: 6px; z-index: 24; display: none; gap: 2px; }
.stage-tools .icon-button { background: #10232be8; color: var(--ivory); }
.stage-tools[inert] { visibility: hidden; }
.toolbar[inert], .control-strip[inert] { opacity: .45; }
#stage[data-view="paused"] .hud { visibility: hidden; }
#stage:not([data-view="playing"]) .stage-tools [data-action="pause"] { display: none; }

.veil-screen { display: grid; place-items: center; background: #10232bcf; padding: 24px; overflow: auto; }
.menu-panel { width: min(370px, 100%); text-align: left; margin: auto; }
.panel-eyebrow { color: var(--amber); font-size: 14px; letter-spacing: .08em; }
h2 { font-weight: 700; font-size: clamp(26px, 3.5cqw, 44px); line-height: 1.05; }
.menu-panel h2 { margin: 7px 0 8px; }
.panel-description { color: var(--muted); font-size: 18px; line-height: 1.4; }
.pause-panel > .primary-button { margin-top: 24px; }
.pause-panel > .secondary-button { margin-top: 12px; }
.result-panel { width: min(430px, 100%); }
.result-score { display: grid; gap: 2px; margin: 20px 0 14px; }
.result-score > span { color: var(--muted); font-size: 15px; }
.result-score > strong { color: var(--amber); font-size: clamp(32px, 5cqw, 58px); font-weight: 700; letter-spacing: .07em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.result-score b { color: var(--ivory); margin-left: 6px; font-weight: 500; }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0 22px; }
.result-stats dt { color: var(--muted); font-size: 14px; }
.result-stats dd { margin: 2px 0 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-panel > .text-button { margin-top: 6px; }
.dialog-screen { display: grid; place-items: center; padding: clamp(8px, 3cqw, 36px); background: #10232bcc; z-index: 30; }
.document-panel { width: min(590px, 100%); max-height: 100%; min-height: 0; display: flex; flex-direction: column; background: var(--charcoal); border: 1px solid var(--line); box-shadow: 0 12px 48px #0005; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 22px 14px; flex-shrink: 0; border-bottom: 1px solid var(--line); }
.panel-header .panel-eyebrow { font-size: 12px; margin-bottom: 5px; }
.panel-header h2 { font-size: 30px; }
.panel-header .icon-button { color: var(--ivory); }
.panel-scroll { overflow-y: auto; overscroll-behavior: contain; padding: 16px 22px; min-height: 0; scrollbar-width: thin; scrollbar-color: #90957e #202920; }
.panel-scroll:focus-visible { outline-offset: -3px; }
.manual-brief, .manual-note, .credits p { font-size: 16px; line-height: 1.4; color: var(--muted); }
.mission-route { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 16px; list-style: none; padding: 0; margin: 16px 0 12px; }
.mission-route li { position: relative; min-width: 0; border-top: 2px solid var(--amber); padding-top: 6px; }
.mission-route li:not(:last-child)::after { content: "›"; position: absolute; right: -12px; top: 8px; color: var(--muted); }
.mission-route strong { display: block; font-size: clamp(16px, 2.5cqw, 21px); line-height: 1.1; color: var(--amber); }
.mission-route span { display: block; font-size: 14px; line-height: 1.25; margin-top: 3px; color: var(--ivory); }
.mission-route [data-service="MAINFRAME"] { border-color: var(--ivory); }
.mission-route [data-service="MAINFRAME"] strong { color: var(--ivory); }
.service-kit { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.service-kit > div { border-left: 2px solid var(--amber); background: #f4efdf05; padding: 8px 10px; min-width: 0; }
.service-kit dt { color: var(--ivory); font-size: 17px; }
.service-kit dt strong { color: var(--amber); }
.service-kit dd { color: var(--muted); font-size: 14px; line-height: 1.35; margin: 4px 0 0; }
.unit-notes { border-block: 1px solid var(--line); padding: 12px 0; margin-bottom: 16px; }
.unit-notes h3 { color: var(--ivory); font-size: 16px; font-weight: 700; margin: 0 0 8px; }
.unit-notes p { color: var(--muted); font-size: 14px; line-height: 1.4; margin-top: 8px; }
.unit-notes strong { color: var(--ivory); }
.unit-notes .kiro-name { color: #dbc8ed; }
.unit-notes .peccy-name { color: var(--amber); }
.manual-pad, .manual-touch { display: none; font-size: 16px; line-height: 1.4; color: var(--muted); margin: 16px 0; }
#shell[data-ui-input-mode="gamepad"] .manual-pad, #shell[data-ui-input-mode="touch"] .manual-touch { display: block; }
#shell[data-ui-input-mode="gamepad"] .manual-controls, #shell[data-ui-input-mode="touch"] .manual-controls { display: none; }
.manual-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; margin: 20px 0; }
.manual-controls > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.manual-controls dt { font-size: 16px; }
.manual-controls dd { margin: 0; white-space: nowrap; color: var(--muted); font-size: 12px; }
.manual-controls kbd { display: inline-block; color: var(--ivory); font-size: 13px; min-width: 19px; text-align: center; }
.credits { margin-top: 14px; border-top: 1px solid var(--line); }
.credits summary { min-height: 44px; padding: 12px 0; color: var(--ivory); }
.credits p { font-size: 14px; margin-bottom: 10px; }
.license-notices { border-top: 1px solid var(--line); }
.license-copy h4 { margin: 16px 0 8px; font-size: 15px; }
.license-copy pre { margin: 0 0 20px; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 monospace; color: var(--muted); }
.panel-footer { flex-shrink: 0; padding: 12px 22px; border-top: 1px solid var(--line); }
.panel-footer > button { font-size: 17px; min-height: 44px; padding-block: 8px; }
.settings-panel { width: min(420px, 100%); }
.volume-setting > label { display: flex; justify-content: space-between; font-size: 18px; }
#volume-value { color: var(--amber); font-variant-numeric: tabular-nums; }
#setting-volume { width: 100%; min-height: 44px; margin: 0; accent-color: var(--amber); cursor: pointer; }
.toggle-setting { position: relative; min-height: 66px; padding: 10px 0; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; font-size: 18px; }
.toggle-setting small { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.toggle-setting input { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; margin: 0; opacity: 0; cursor: pointer; }
.switch { position: relative; width: 40px; height: 22px; border: 1px solid #b3b8a5; background: #0b100e; border-radius: 12px; flex-shrink: 0; pointer-events: none; }
.switch::before { content: ""; position: absolute; width: 14px; height: 14px; top: 3px; left: 3px; background: var(--muted); border-radius: 50%; }
.toggle-setting input:checked + .switch { background: var(--amber); border-color: var(--amber); }
.toggle-setting input:checked + .switch::before { transform: translateX(18px); background: var(--ink); }
.toggle-setting input:focus-visible + .switch { outline: 2px solid var(--amber); outline-offset: 4px; }
.settings-note { font-size: 14px; color: var(--muted); margin-top: 12px; }
#settings-save-note[data-saved="false"] { color: var(--amber); }
.keyboard-settings { border-top: 1px solid var(--line); margin-top: 2px; }
.keyboard-settings > summary { padding: 14px 0; min-height: 48px; font-weight: 700; font-size: 18px; }
.binding-instructions, .binding-status { font-size: 14px; line-height: 1.35; color: var(--muted); }
.binding-instructions { margin-bottom: 14px; }
.binding-column-labels, .binding-row { display: grid; grid-template-columns: minmax(75px,1fr) 68px 68px; gap: 6px; align-items: center; }
.binding-column-labels { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.binding-column-labels span:not(:first-child) { text-align: center; }
.binding-row { border-top: 1px solid #49636a66; padding: 4px 0; font-size: 16px; }
.binding-key { min-width: 0; min-height: 44px; width: 68px; padding: 6px 3px; background: var(--ink); color: var(--ivory); border: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.binding-key:hover { border-color: var(--amber); }
.binding-key[aria-pressed="true"] { background: var(--amber); color: var(--ink); border-color: var(--amber); }
.binding-status { min-height: 3.1em; margin-top: 10px; color: var(--ivory); }
.reset-keys { padding-left: 0; color: var(--amber); }
.manual-controls [data-control-help="move"] dd { white-space: normal; max-width: 11em; text-align: right; }
.mission-toast { position: absolute; top: 142px; left: 16px; z-index: 40; max-width: min(60%, 360px); padding: 9px 14px; border-left: 3px solid var(--amber); background: #10232bf5; pointer-events: none; }
.mission-toast strong { display: block; color: var(--ivory); font-size: clamp(14px, 1.65cqw, 20px); }
.mission-toast span { display: block; color: var(--muted); font-size: clamp(13px, 1.35cqw, 16px); }
#stage:not([data-view="playing"]) .mission-toast { top: auto; bottom: 10px; }
.interaction-prompt { position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%); z-index: 7; max-width: 65%; padding: 6px 12px; background: #10232bf5; border: 1px solid var(--jade); color: var(--ivory); font-size: clamp(14px, 1.6cqw, 20px); text-align: center; pointer-events: none; }
.mission-coach { position: absolute; left: 16px; top: 142px; display: flex; align-items: center; width: min(390px, 48%); padding: 8px 8px 8px 12px; background: #10232be8; border-left: 2px solid var(--jade); z-index: 8; }
.mission-coach strong { font-size: 16px; font-weight: 700; }
.mission-coach p { font-size: 15px; color: var(--muted); line-height: 1.3; margin-top: 3px; }
.mission-coach .icon-button { align-self: flex-start; }
.coach-compact { display: none; }
.hud:has(.vehicle-status:not([hidden])) ~ :is(.mission-coach, .mission-toast) { margin-top: 32px; }
.confirm-panel { width: min(430px, 100%); }
.confirm-panel h2 { font-size: 30px; margin: 10px 0 12px; }
.confirm-panel .panel-scroll { padding: 24px; }
.confirm-actions { display: grid; gap: 10px; }
.boot-status { position: absolute; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: var(--charcoal); }
.boot-panel { width: min(380px, 100%); }
.boot-panel h2 { font-size: 32px; line-height: 1.1; margin: 10px 0 16px; }
.boot-panel > p:not(.panel-eyebrow) { font-size: 18px; line-height: 1.4; color: var(--muted); }
.boot-panel .primary-button { margin-top: 24px; }

.control-strip { color: var(--muted); font-size: 14px; container: controls / inline-size; }
.keyboard-hints { display: flex; align-items: center; flex-wrap: nowrap; gap: clamp(10px, 1.5vw, 20px); }
.keyboard-hints > span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.keyboard-hints kbd { font-size: 11px; color: var(--ivory); border-color: #606555; padding: 3px 4px; }
.control-strip > .text-button { padding-inline: 8px; white-space: nowrap; }
.control-strip > .text-button > span { display: inline-grid; place-items: center; border: 1px solid #727866; width: 17px; height: 17px; margin-left: 5px; border-radius: 50%; font-size: 12px; }
.touch-hint { display: none; font-size: 13px; }
.gamepad-hint { display: none; font-size: 13px; }
#shell[data-ui-input-mode="keyboard"] .keyboard-hints { display: flex; }
#shell[data-ui-input-mode="gamepad"] .keyboard-hints, #shell[data-ui-input-mode="touch"] .keyboard-hints { display: none; }
#shell[data-ui-input-mode="keyboard"] .touch-hint, #shell[data-ui-input-mode="gamepad"] .touch-hint { display: none; }
#shell[data-ui-input-mode="touch"] .touch-hint, #shell[data-ui-input-mode="gamepad"] .gamepad-hint { display: block; }
#shell[data-ui-input-mode="keyboard"] .touch-controls, #shell[data-ui-input-mode="gamepad"] .touch-controls { display: none; }
#shell[data-ui-input-mode="keyboard"] .interaction-prompt, #shell[data-ui-input-mode="gamepad"] .interaction-prompt { bottom: 9%; }
@container controls (max-width: 850px) {
  .keyboard-hints > .optional-hint { display: none; }
  .keyboard-hints { gap: 12px; }
}
.touch-controls { position: absolute; left: 12px; right: 12px; bottom: 10px; z-index: 10; display: none; justify-content: space-between; align-items: flex-end; pointer-events: none; }
.touch-controls button { min-width: 44px; min-height: 44px; padding: 4px; border: 1px solid #89a8aa; background: #152c35e8; color: var(--ivory); font-size: 16px; font-weight: 700; touch-action: none; pointer-events: auto; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.touch-controls button.is-down { background: var(--amber); color: var(--ink); border-color: #ffe2a0; }
.touch-movement { display: grid; grid-template: repeat(2, 44px) / repeat(3, 44px); gap: 4px; }
.touch-up { grid-column: 2; grid-row: 1; line-height: .8; }
.touch-up span { display: block; font-size: 11px; margin-top: 4px; }
.touch-left { grid-column: 1; grid-row: 2; }
.touch-crouch { grid-column: 2; grid-row: 2; }
.touch-right { grid-column: 3; grid-row: 2; }
.touch-actions { display: grid; grid-template: repeat(2, 44px) / repeat(3, 52px); gap: 4px; }
.touch-actions button { font-size: 14px; }
.touch-jump { grid-column: 1; grid-row: 2; }
.touch-fire { grid-column: 2 / 4; grid-row: 2; border-color: var(--amber) !important; background: #593e20ed !important; font-size: 19px !important; }
.touch-fire.is-down { background: var(--amber) !important; }
.force-touch .touch-controls { display: flex; }
.force-touch .keyboard-hints { display: none; }
.force-touch .touch-hint { display: block; }
.force-touch #stage[data-view="playing"] .interaction-prompt { bottom: 110px; }

/* Black bars belong to the fullscreen root, never to the scene-aligned UI. */
#stage:fullscreen, #stage.is-fullscreen { width: 100vw; width: 100dvw; height: 100vh; height: 100dvh; aspect-ratio: auto; box-shadow: none; background: #080b09; }
#stage:fullscreen #stage-surface, #stage.is-fullscreen #stage-surface { inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(calc(100dvw - env(safe-area-inset-left) - env(safe-area-inset-right)), calc((100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 16 / 9)); aspect-ratio: 16 / 9; }
#stage:fullscreen .stage-tools, #stage.is-fullscreen .stage-tools { display: flex; }
#stage:fullscreen .score-status, #stage.is-fullscreen .score-status { margin-right: 138px; }
.noscript-note, .load-error { position: fixed; inset: auto 12px 12px; padding: 12px; background: var(--ink); text-align: center; z-index: 50; }
@media (pointer: coarse) {
  .touch-controls { display: flex; }
  .keyboard-hints { display: none; }
  .touch-hint { display: block; }
  #stage[data-view="playing"] .interaction-prompt { bottom: 110px; }
}
@media (max-width: 800px) {
  .toolbar-title > span, .optional-hint { display: none !important; }
  .toolbar-title { gap: 0; }
  .keyboard-hints { gap: 12px; }
}
@media (max-width: 450px) {
  .toolbar-title strong { font-size: 15px; }
  .toolbar-actions .quiet-button > span { display: none; }
  .toolbar, .control-strip { gap: 6px; }
  .keyboard-hints > span { font-size: 12px; gap: 3px; }
  .keyboard-hints { gap: 7px; }
  .touch-hint { max-width: 23ch; line-height: 1.2; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #shell { --chrome-height: 0px; gap: 0; }
  .toolbar, .control-strip { display: none; }
  .stage-tools { display: flex; }
  .score-status { display: none; }
}
@container battlefield (max-width: 950px) {
  .title-layout { width: 44%; margin-left: 5%; padding-block: 10px; }
  h1 { margin-top: 10px; margin-bottom: 8px; font-size: 7.1cqw; }
  .briefing { margin-top: 10px; font-size: 15px; }
  .title-controls { margin-top: 12px; max-width: 270px; }
  .difficulty-control { margin-bottom: 8px; }
  .primary-button { padding: 9px 14px; font-size: 18px; }
  .menu-actions { margin-top: 4px; }
  .hud-top { top: 10px; left: 10px; right: 10px; }
  .hud-equipment { top: 64px; left: 10px; gap: 12px; }
  .objective-status { top: 60px; right: 10px; }
  .vehicle-status { top: 10px; left: 10px; }
  .hud[data-vehicle="true"] .hud-equipment { top: 84px; }
  .mission-coach, .mission-toast { top: 132px; left: 10px; }
  .result-score { margin: 12px 0; }
  .result-stats { margin: 12px 0 16px; }
}
@container battlefield (max-width: 680px) {
  .title-screen { background: linear-gradient(90deg, #10232be8, #152c35b8 65%, #152c3570); }
  .title-layout { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 20px; width: calc(100% - 48px); margin: 0 24px; padding: 8px 0; }
  .title-copy { min-width: 0; }
  h1 { font-size: 8cqw; margin: 10px 0; }
  .operation-name { font-size: 15px; letter-spacing: .075em; }
  .briefing { font-size: 16px; max-width: 28ch; line-height: 1.3; }
  .title-controls { margin-top: 0; }
  .difficulty-control { column-gap: 6px; }
  .difficulty-control select { min-width: 106px; }
  #difficulty-note { font-size: 14px; }
  .first-controls { font-size: 15px; margin-bottom: 10px; }
  .hud-top { top: 8px; left: 8px; right: 8px; }
  .score-status { display: none; }
  .player-status { padding: 7px 9px; }
  .hud-equipment { top: 55px; left: 8px; font-size: 14px; gap: 10px; padding: 5px 8px; }
  .objective-status { right: 8px; top: 60px; max-width: 44%; font-size: 14px; }
  .vehicle-status { top: 8px; left: 8px; padding: 7px 9px; width: calc(var(--status-inner) + 21px); font-size: 14px; }
  .hud[data-vehicle="true"] .player-status { margin-top: 42px; }
  .hud[data-vehicle="true"] .hud-equipment { top: 73px; }
  .boss-status { top: 8px; left: 34%; width: 30%; font-size: 13px; }
  .boss-status strong { font-size: 14px; }
  .boss-status #boss-subtitle { font-size: 11px; }
  .mission-coach { width: min(360px, 60%); top: 112px; }
  .mission-toast { top: 112px; max-width: 62%; }
  .panel-header { padding: 10px 14px; }
  .panel-header h2 { font-size: 25px; }
  .panel-header .panel-eyebrow { display: none; }
  .panel-scroll { padding: 12px 14px; }
  .panel-footer { padding: 8px 14px; }
  .manual-controls { gap: 10px 20px; }
  .manual-controls dt, .manual-brief, .manual-note { font-size: 16px; }
  .result-panel { display: grid; grid-template-columns: 1fr 1fr; align-items: center; column-gap: 24px; width: min(550px, 100%); }
  .result-panel .panel-eyebrow, .result-panel h2, .result-panel .panel-description { grid-column: 1; }
  .result-panel .panel-eyebrow { align-self: end; }
  .result-panel h2 { margin: 4px 0; }
  .result-panel .panel-description { font-size: 14px; align-self: start; }
  .result-score { grid-column: 2; grid-row: 1 / 4; margin: 0; }
  .result-stats { grid-column: 1 / -1; margin: 12px 0; }
  .result-stats dd { font-size: 19px; }
  .result-panel .primary-button { grid-column: 2; grid-row: 5; }
  .result-panel > .text-button { grid-column: 1; grid-row: 5; margin: 0; }
  .pause-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; align-items: center; width: min(490px, 100%); }
  .pause-panel .panel-eyebrow, .pause-panel h2, .pause-panel .panel-description { grid-column: 1; margin: 0; }
  .pause-panel .panel-eyebrow { align-self: end; }
  .pause-panel .panel-description { font-size: 15px; align-self: start; }
  .pause-panel > .primary-button { grid-column: 2; grid-row: 1 / 3; margin: 0; }
  .pause-panel > .secondary-button { grid-column: 2; grid-row: 3; margin: 0; }
  .pause-panel .menu-actions { grid-column: 1 / -1; justify-content: center; gap: 24px; }
}
@container battlefield (max-width: 450px) {
  .title-layout { gap: 12px; margin-inline: 12px; width: calc(100% - 24px); }
  .field-badge { font-size: 12px; gap: 10px; }
  .field-badge > span { padding-left: 10px; letter-spacing: .025em; }
  h1 { font-size: 8.5cqw; margin: 8px 0; }
  .operation-name { font-size: 12px; letter-spacing: .055em; }
  .briefing { font-size: 16px; line-height: 1.4; margin-top: 8px; }
  .difficulty-control { grid-template-columns: 1fr; gap: 0; margin-bottom: 7px; }
  .difficulty-control > label { font-size: 15px; margin-bottom: 2px; }
  .difficulty-control select { width: 100%; font-size: 15px; }
  #difficulty-note { font-size: 14px; }
  .primary-button { padding: 10px 14px; font-size: 18px; }
  .menu-actions { gap: 4px; }
  .menu-actions .text-button { font-size: 16px; }
  .stage-tools { top: 3px; right: 3px; gap: 0; }
  #stage.is-fullscreen[data-view="title"] .title-layout { padding-block: 0; }
  #stage.is-fullscreen[data-view="title"] .title-controls { margin-top: 44px; }
  #stage.is-fullscreen[data-view="title"] .difficulty-control > label { display: none; }
  .touch-controls { left: 6px; right: 6px; bottom: 6px; }
  .touch-movement { gap: 2px; }
  .touch-actions { grid-template-columns: repeat(3, 44px); gap: 2px; }
  .touch-actions button { font-size: 12px; }
  .interaction-prompt { max-width: 70%; padding: 3px 7px; font-size: 12px; }
  .mission-toast { padding: 6px 9px; max-width: 90%; }
  .manual-controls { grid-template-columns: 1fr; }
  .veil-screen { padding: 10px; }
  .pause-panel { gap: 6px 12px; }
  .pause-panel h2 { font-size: 25px; }
  .pause-panel .secondary-button { font-size: 15px; padding-inline: 6px; }
  .result-panel { column-gap: 10px; }
  .result-panel h2 { font-size: 24px; }
  .result-panel .panel-description { font-size: 16px; }
  .result-stats { gap: 5px; margin: 8px 0; }
  .result-stats dt { font-size: 12px; }
  .result-stats dd { font-size: 17px; }
}
/* Portrait is a deliberate console layout: status, unobstructed 16:9 world,
   contextual guidance, then controls. The game and its coordinates are untouched. */
@media (orientation: portrait) and (max-width: 800px) {
  body { display: block; height: auto; min-height: 100dvh; overflow: auto; }
  #shell { width: 100%; max-width: 100%; gap: 6px; margin-inline: auto; }
  #stage, #stage.is-fullscreen, #stage:fullscreen { width: 100%; height: max(620px, calc(100dvh - 116px)); aspect-ratio: auto; }
  #stage-surface, #stage.is-fullscreen #stage-surface, #stage:fullscreen #stage-surface { inset: 0; width: 100%; height: 100%; margin-inline: auto; aspect-ratio: auto; transform: none; }
  #stage.is-fullscreen, #stage:fullscreen { height: 100dvh; }
  #game { inset: 104px 0 auto; height: 56.25cqw; }
  .scene-backdrop { top: 104px; height: 56.25cqw; }
  #stage[data-view="title"] #game, #stage[data-view="title"] .scene-backdrop { top: 0; }
  .title-screen { align-items: flex-start; overflow-y: auto; background: linear-gradient(180deg, #10232b10 0, #152c3599 105px, var(--charcoal) 200px); }
  .title-layout { display: block; width: calc(100% - 40px); margin: 120px 20px 24px; padding: 0; }
  .field-badge { font-size: 13px; }
  h1 { font-size: clamp(48px, 12cqw, 72px); margin: 12px 0; line-height: .95; }
  .operation-name { font-size: 16px; }
  .briefing { max-width: 40ch; font-size: 18px; margin-top: 14px; }
  .title-controls { margin-top: 20px; max-width: none; }
  .first-controls { font-size: 16px; margin-bottom: 12px; }
  .difficulty-control { grid-template-columns: 1fr auto; gap: 0 10px; margin-bottom: 12px; }
  .difficulty-control select { font-size: 17px; min-width: 130px; }
  #difficulty-note { font-size: 14px; padding-top: 6px; }
  .title-controls .primary-button { min-height: 48px; }
  .portrait-advice { display: block; color: var(--muted); font-size: 15px; line-height: 1.35; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
  .hud { inset: 0 0 auto; height: 104px; background: var(--ink); }
  .hud-top { top: 10px; left: 10px; right: 10px; }
  .player-status { border: 0; padding: 0; background: transparent; }
  .health-status { width: 172px; }
  .health-heading { margin-bottom: 6px; }
  .hud-equipment { top: 44px; left: 10px; right: 10px; padding: 0; background: transparent; gap: 14px; font-size: 15px; }
  .objective-status { top: 73px; left: 10px; right: 10px; max-width: none; padding: 0; background: transparent; font-size: 14px; }
  #mission-progress { display: none; }
  .score-status { display: flex; background: transparent; padding: 0; gap: 6px; }
  .score-status strong { font-size: 18px; }
  .score-status > span { font-size: 13px; }
  .hud:has(.vehicle-status:not([hidden])) .score-status { display: none; }
  .vehicle-status { top: 10px; left: 10px; right: auto; width: 172px; padding: 0; border: 0; background: transparent; font-size: 16px; }
  .hud[data-vehicle="true"] .player-status { position: absolute; right: 0; margin: 0; padding: 0; }
  .hud[data-vehicle="true"] .health-status { width: 126px; }
  .hud[data-vehicle="true"] .health-heading { flex-wrap: wrap; gap: 3px 6px; }
  .hud[data-vehicle="true"] .reserve-label { flex-basis: 100%; margin: 0; font-size: 12px; }
  .hud[data-vehicle="true"] .hud-equipment { top: 44px; }
  .boss-status { top: 69px; left: 10px; right: 10px; width: auto; padding: 0; background: transparent; }
  .boss-status #boss-subtitle { display: none; }
  .boss-status progress { height: 4px; margin-top: 4px; }
  .mission-coach, .mission-toast, #stage .interaction-prompt { top: calc(104px + 56.25cqw + 10px); bottom: auto; left: 10px; right: 10px; width: auto; max-width: none; transform: none; font-size: 15px; margin: 0; }
  .mission-coach, .mission-toast { padding: 6px 8px 6px 12px; background: transparent; }
  .mission-coach { display: block; min-height: 66px; }
  .mission-coach .coach-details > strong { display: block; padding-right: 38px; }
  .mission-coach .icon-button { position: absolute; right: 0; top: 0; }
  .mission-coach p { font-size: 15px; }
  .hud:has(.vehicle-status:not([hidden])) ~ :is(.mission-coach, .mission-toast) { margin-top: 0; }
  #stage .interaction-prompt { padding: 10px; text-align: left; }
  #shell #stage .interaction-prompt { bottom: auto; }
  #stage:has(.interaction-prompt:not([hidden])) .mission-toast { display: none; }
  #stage:not([data-view="playing"]) .mission-toast { top: auto; bottom: 12px; background: var(--ink); }
  .touch-controls { left: 12px; right: 12px; top: auto; bottom: 24px; gap: 12px; }
  .touch-movement { grid-template: repeat(2, 52px) / repeat(3, minmax(44px, 1fr)); gap: 5px; }
  .touch-actions { grid-template: repeat(2, 52px) / repeat(3, minmax(44px, 1fr)); gap: 5px; }
  .touch-movement, .touch-actions { flex: 1; min-width: 0; max-width: 248px; }
  .touch-actions button { font-size: 14px; }
  .touch-controls button { background: var(--teal); }
  .portrait-play-note { position: absolute; bottom: 150px; left: 12px; right: 12px; text-align: center; font-size: 15px; color: var(--muted); }
  #stage[data-view="playing"] .portrait-play-note { display: block; }
  .veil-screen { padding: 24px; }
  .pause-panel, .result-panel { display: block; width: min(400px, 100%); }
  .pause-panel h2, .result-panel h2 { font-size: 36px; margin: 10px 0 14px; }
  .pause-panel .panel-description, .result-panel .panel-description { font-size: 18px; }
  .pause-panel > .primary-button { margin-top: 28px; }
  .pause-panel > .secondary-button { margin-top: 12px; font-size: 18px; }
  .pause-panel .menu-actions { justify-content: space-between; margin-top: 12px; }
  .result-score { margin: 24px 0 20px; }
  .result-score > strong { font-size: 52px; }
  .result-stats { margin: 24px 0; gap: 10px; }
  .result-stats dt { font-size: 16px; }
  .result-stats dd { font-size: 24px; }
  .result-panel > .text-button { margin-top: 10px; }
  .dialog-screen { padding: 12px; }
  .panel-header { padding: 14px 16px; }
  .panel-scroll { padding: 16px; }
  .panel-header h2 { font-size: 30px; }
  .manual-controls { grid-template-columns: 1fr; }
  .stage-tools { display: none; }
  #stage.is-fullscreen .stage-tools, #stage:fullscreen .stage-tools { display: flex; }
  #stage.is-fullscreen .hud-top, #stage:fullscreen .hud-top { right: 148px; }
  #stage.is-fullscreen .score-status, #stage:fullscreen .score-status { display: none; }
}
@media (orientation: portrait) and (max-width: 800px) and (max-height: 740px) {
  /* Keep title dialogs inside the viewport, including their return action. */
  #stage[data-view="title"]:not(.is-fullscreen):not(:fullscreen):has(.dialog-screen:not([hidden])) { height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 100px); }
  #stage[data-view="playing"], #stage[data-view="paused"], #stage[data-view="result"] { height: max(490px, calc(100dvh - 66px)); }
  #shell:has(#stage:not([data-view="title"])) .control-strip { display: none; }
  .title-layout { margin-top: 24px; }
  .title-screen { background: #152c35e8; }
  .title-layout h1 { font-size: 44px; }
  .title-layout .briefing { font-size: 16px; }
  .title-controls { margin-top: 14px; }
  .touch-controls { bottom: 12px; }
  .touch-movement, .touch-actions { grid-template-rows: repeat(2, 48px); }
  .portrait-play-note { display: none !important; }
  #stage.is-fullscreen, #stage:fullscreen { height: 100dvh; }
}
@media (max-width: 359px) and (orientation: portrait) {
  .touch-controls { left: 6px; right: 6px; gap: 6px; }
  .touch-movement, .touch-actions { gap: 2px; }
  .touch-actions button { font-size: 12px; }
  .hud-equipment { gap: 8px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .primary-button:active { transform: none; }
}
html.reduced-motion *, html.reduced-motion *::before, html.reduced-motion *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
html.reduced-motion .primary-button:active { transform: none; }

/* Results keep the advertised retry cost beside its action. Details can scroll
   on short screens while keyboard/controller focus still reaches every item. */
.result-panel { display: flex; flex-direction: column; align-items: stretch; gap: 0; width: min(680px, 100%); max-height: 100%; min-height: 0; background: #10232bef; border-top: 2px solid var(--jade); }
.result-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px 24px; padding: 24px; min-height: 0; text-align: left; }
.result-heading, .result-ledger { min-width: 0; }
.result-heading .panel-eyebrow { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 0; letter-spacing: .04em; font-size: 14px; }
#result-difficulty { color: var(--muted); border-left: 1px solid var(--line); padding-left: 12px; }
.result-heading h2 { font-size: 34px; line-height: 1.05; margin: 10px 0 14px; }
.result-heading .panel-description { font-size: 17px; line-height: 1.4; }
.result-ledger .result-score { display: grid; margin: 0; gap: 3px; }
.result-ledger .result-score > strong { font-size: 48px; }
.result-ledger .result-score > span { font-size: 15px; }
.result-delta { margin-top: 8px; font-size: 15px; color: var(--muted); }
.result-delta[data-record="true"] { color: var(--amber); }
.result-breakdown { display: grid; gap: 4px; font-size: 16px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.result-breakdown > div { display: flex; justify-content: space-between; gap: 10px; }
.result-breakdown dt { color: var(--muted); }
.result-breakdown dd { margin: 0; font-variant-numeric: tabular-nums; }
.result-content .result-stats { grid-column: 1 / -1; margin: 0; padding-top: 14px; border-top: 1px solid var(--line); gap: 12px; }
.result-content .result-stats dt { font-size: 15px; }
.result-content .result-stats dd { font-size: 23px; }
.result-target { grid-column: 1 / -1; font-size: 17px; line-height: 1.3; color: var(--ivory); border-left: 2px solid var(--jade); padding-left: 10px; }
.result-replay { grid-column: 1 / -1; padding: 8px 10px; border-left: 2px solid var(--amber); background: #27576140; font-size: 16px; line-height: 1.3; }
.result-replay[data-state="met"] { border-left-color: var(--jade); }
.result-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); flex-shrink: 0; }
.result-actions .primary-button { grid-column: 1; grid-row: auto; margin: 0; font-size: 18px; }
.result-actions .text-button { grid-column: 2; grid-row: auto; margin: 0; font-size: 16px; padding-inline: 8px; }
.retry-cost { grid-column: 1 / -1; font-size: 16px; line-height: 1.35; color: var(--ivory); white-space: pre-line; margin: 0 0 2px; }
@container battlefield (max-width: 680px) {
  .result-content { padding: 14px; gap: 14px 18px; }
  .result-heading h2 { font-size: 28px; margin: 8px 0 10px; }
  .result-heading .panel-description { font-size: 16px; }
  .result-ledger .result-score > strong { font-size: 38px; letter-spacing: .03em; }
  .result-breakdown { font-size: 15px; margin-top: 8px; padding-top: 8px; }
  .result-actions { padding: 10px 14px; gap: 8px; }
  .result-content .result-stats { padding-top: 10px; }
  .result-content .result-stats dd { font-size: 20px; }
  .result-target { font-size: 16px; }
}
@media (orientation: portrait) and (min-height: 741px) and (max-width: 800px) {
  .result-content { grid-template-columns: 1fr; gap: 18px; }
  .result-heading h2 { font-size: 32px; }
  .result-ledger .result-score > strong { font-size: 46px; }
}
@media (orientation: portrait) and (max-height: 740px) and (max-width: 450px) {
  .result-content { gap: 12px; padding: 12px; }
  .result-heading h2 { font-size: 25px; }
  .result-heading .panel-eyebrow { font-size: 13px; gap: 4px; }
  #result-difficulty { padding-left: 0; border-left: 0; width: 100%; }
  .result-ledger .result-score > strong { font-size: 32px; }
  .result-breakdown { font-size: 14px; gap: 3px; }
  .result-actions { padding: 10px; }
  .result-actions .primary-button { padding-inline: 10px; font-size: 17px; }
  .retry-cost { font-size: 15px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  #result-screen { padding: 12px 18px; }
  .hud { --status-inner: min(170px, 24cqw); }
  .health-status { width: var(--status-inner); }
  /* A short bearing/action card uses the sky beside the equipment. Keep the
     original canvas size and the actor/gantry area clear. */
  .mission-coach {
    left: auto; right: 8px; top: 52px; width: calc(100% - 352px);
    padding: 4px 6px 4px 8px; align-items: flex-start; gap: 4px;
  }
  .mission-coach .coach-details { display: none; }
  .coach-compact { display: block; flex: 1; min-width: 0; }
  .mission-coach strong { display: block; font-size: 14px; line-height: 16px; }
  .mission-coach p { font-size: 14px; line-height: 16px; margin-top: 2px; white-space: pre-line; }
  .mission-coach .icon-button { flex: 0 0 44px; }
  .hud:has(.vehicle-status:not([hidden])) ~ .mission-coach { margin-top: 0; }
  #stage[data-compact-coach="true"] .objective-status { display: none; }
  .boss-status { padding-block: 3px; left: 34%; width: 36%; }
  .boss-status progress { height: 5px; margin-top: 3px; }
  .boss-tip { margin-top: 3px; font-size: 13px; line-height: 14px; white-space: nowrap; }
  .boss-status #boss-subtitle { display: none; }
  .hud:has(.boss-status:not([hidden])) ~ .mission-toast {
    left: auto; right: 8px; top: 52px; max-width: calc(100% - 352px);
    margin-top: 0; padding: 6px 8px;
  }
  .hud:has(.boss-status:not([hidden])) ~ .mission-toast :is(strong, span) { font-size: 14px; line-height: 16px; }
  .replay-status { top: 120px; right: 8px; }
  .hud:has(.boss-status:not([hidden])) .replay-status {
    top: 56px; padding: 4px 8px; gap: 8px; font-size: 13px; line-height: 14px;
  }
}

/* Boss cues occupy the left side of the arena. Keep the reusable defense
   instructions in the upper-right sky, including desktop fit scaling. */
@media (orientation: landscape) and (min-height: 521px), (min-width: 801px) and (min-height: 521px) {
  .hud:has(.boss-status:not([hidden])) ~ .mission-coach {
    left: auto; right: 16px; top: 76px; width: min(350px, 36%);
    margin-top: 0; padding: 4px 6px 4px 8px; align-items: flex-start; gap: 4px;
  }
  .hud:has(.boss-status:not([hidden])) ~ .mission-coach .coach-details { display: none; }
  .hud:has(.boss-status:not([hidden])) ~ .mission-coach .coach-compact { display: block; flex: 1; min-width: 0; }
  .hud:has(.boss-status:not([hidden])) ~ .mission-coach strong { display: block; font-size: 14px; line-height: 16px; }
  .hud:has(.boss-status:not([hidden])) ~ .mission-coach p { font-size: 14px; line-height: 16px; margin-top: 2px; white-space: pre-line; }
  .hud:has(.boss-status:not([hidden])) ~ .mission-coach .icon-button { flex: 0 0 44px; }
  .hud:has(.boss-status:not([hidden])) ~ .mission-toast {
    left: auto; right: 16px; top: 76px; max-width: min(350px, 36%);
    margin-top: 0; padding: 6px 8px;
  }
  .hud:has(.boss-status:not([hidden])) ~ .mission-toast :is(strong, span) { font-size: 14px; line-height: 16px; }
}

/* Keep optional run feedback in the portrait HUD, above the full battlefield. */
@media (orientation: portrait) and (max-width: 800px) {
  .hud-equipment { gap: 8px; font-size: 14px; white-space: nowrap; }
  .hud-equipment strong { margin-left: 1px; }
  .replay-status { top: 102px; left: 10px; right: 10px; padding: 4px 0; border: 0; border-top: 1px solid var(--line); justify-content: space-between; gap: 6px; font-size: 14px; }
  #stage:has(#hud-replay:not([hidden])) .hud { height: 130px; }
  #stage:not([data-view="title"]):has(#hud-replay:not([hidden])) :is(#game, .scene-backdrop) { top: 130px; }
  #stage:has(#hud-replay:not([hidden])) :is(.mission-coach, .mission-toast, .interaction-prompt) { top: calc(130px + 56.25cqw + 10px); }
}
@media (orientation: portrait) and (max-width: 359px) {
  .hud[data-vehicle="true"] .health-status { width: 108px; }
}
@media (orientation: landscape) and (max-width: 600px) {
  .vehicle-service { display: none; }
}

/* Entry and scores use the same field-console palette as the mission. */
.title-screen { overflow-y: auto; align-items: safe center; }
.title-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .8fr); align-items: center; gap: 10%; width: 88%; max-width: 1200px; margin: auto 6%; padding-block: 24px; }
.title-controls { width: 100%; max-width: 370px; margin: 0 0 0 auto; padding: 22px; background: #10232bf2; border: 1px solid var(--line); border-top: 3px solid var(--amber); box-shadow: 0 8px 24px #07181c40; }
.entry-eyebrow { color: var(--amber); font-size: 14px; letter-spacing: .07em; text-transform: uppercase; font-weight: 700; margin-bottom: 16px; }
.player-entry { display: grid; gap: 6px; margin-bottom: 18px; }
.player-entry label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-weight: 700; }
.player-entry label > span { font-size: 13px; font-weight: 500; color: var(--muted); }
.player-entry input { width: 100%; min-width: 0; min-height: 46px; padding: 8px 12px; border: 1px solid #718b90; border-radius: 2px; color: var(--ivory); background: #091c24; font-size: 19px; }
.player-entry input::placeholder { color: #acbdbc; opacity: 1; }
.player-entry input[aria-invalid="true"] { border-color: var(--danger); }
#player-name-note, #player-name-error { font-size: 14px; line-height: 1.3; }
#player-name-note { color: var(--muted); }
#player-name-error { color: var(--danger); }
.title-controls .difficulty-control { grid-template-columns: minmax(0, 1fr) auto; margin-bottom: 16px; }
.title-controls .difficulty-control select { min-width: 170px; }
.title-controls .first-controls { margin: 12px 0 0; font-size: 14px; line-height: 1.3; color: var(--muted); }
.leaderboard-button { margin-top: 8px; justify-content: space-between; }
.result-player { margin-top: 12px; font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.result-multiplier { color: var(--amber); font-size: 15px; margin-top: 5px; }
.result-ranking { color: var(--muted); font-size: 15px; margin-top: 6px; }
.result-actions > .primary-button, .result-links { grid-column: 1 / -1; }
.result-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 12px; }
.result-links .text-button { flex: 1; padding-inline: 4px; }
.result-links .secondary-button { flex: 2; width: auto; min-height: 44px; padding: 8px 14px; font-size: 18px; }
.leaderboard-panel { width: min(740px, 100%); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.leaderboard-toolbar { display: flex; align-items: center; flex-shrink: 0; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.leaderboard-toolbar label { font-size: 15px; color: var(--muted); }
.leaderboard-toolbar select { min-height: 44px; border: 1px solid var(--line); background: var(--ink); color: var(--ivory); padding: 6px 12px; border-radius: 2px; }
#leaderboard-count { margin-left: auto; color: var(--muted); font-size: 15px; white-space: nowrap; }
.leaderboard-scroll { padding: 0; min-height: 44px; }
.leaderboard-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
.leaderboard-table th { position: sticky; top: 0; z-index: 1; background: #1b333c; font-weight: 500; color: var(--muted); font-size: 14px; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.leaderboard-table th:first-child { width: 12%; }
.leaderboard-table th:nth-child(2) { width: 40%; }
.leaderboard-table th:nth-child(3) { width: 23%; }
.leaderboard-table th:last-child { width: 25%; text-align: right; }
.leaderboard-table td { border-bottom: 1px solid #49636a70; padding: 12px; font-size: 17px; vertical-align: middle; overflow-wrap: anywhere; }
.leaderboard-table td:first-child { color: var(--muted); }
.leaderboard-table td:last-child { text-align: right; font-weight: 700; font-size: 21px; }
.leaderboard-table td strong { display: block; font-weight: 700; }
.leaderboard-table td small { display: block; font-size: 13px; line-height: 1.3; color: var(--muted); margin-top: 3px; }
.leaderboard-table td[data-mode="hard"] { color: var(--amber); }
.leaderboard-table tr:first-child td:first-child { color: var(--amber); font-weight: 700; }
.leaderboard-table tr[data-current="true"] { background: #eda64912; box-shadow: inset 3px 0 var(--amber); }
.leaderboard-empty { padding: 32px 22px; font-size: 17px; color: var(--muted); text-align: center; }
.leaderboard-empty strong { display: block; color: var(--ivory); margin-bottom: 8px; font-size: 24px; }
.leaderboard-footer { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; column-gap: 16px; }
.leaderboard-footer p { grid-column: 1; font-size: 14px; line-height: 1.35; color: var(--muted); }
#leaderboard-storage { margin-top: 6px; }
#leaderboard-storage[data-saved="false"] { color: var(--amber); }
.leaderboard-footer button { grid-column: 2; grid-row: 1 / span 2; margin: 0; width: auto; }
#pause-context { white-space: pre-line; overflow-wrap: anywhere; }
@container battlefield (max-width: 950px) {
  .title-layout { grid-template-columns: minmax(0, 1fr) minmax(260px, .9fr); width: 92%; gap: 5%; margin-inline: 4%; padding-block: 14px; }
  .title-controls { padding: 14px; }
  .entry-eyebrow { margin-bottom: 10px; }
  .player-entry { margin-bottom: 12px; }
}
@container battlefield (max-width: 680px) {
  .title-layout { grid-template-columns: minmax(0, 1fr) minmax(250px, 1fr); gap: 16px; margin-inline: 14px; width: calc(100% - 28px); align-items: start; }
  .title-copy { padding-top: 12px; }
  .title-controls { padding: 12px; }
  .title-controls .difficulty-control { grid-template-columns: 1fr; gap: 4px; margin-bottom: 10px; }
  .title-controls .difficulty-control select { width: 100%; font-size: 17px; }
  .leaderboard-toolbar { padding: 8px 12px; gap: 8px; }
  .leaderboard-footer { padding: 10px 12px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .title-layout { padding-block: 16px; }
  .title-controls .first-controls { display: none; }
  .entry-eyebrow { display: none; }
  .title-copy .briefing { font-size: 15px; }
  .title-controls { margin-top: 0; }
  .leaderboard-footer p { font-size: 13px; }
}
@media (orientation: portrait) and (max-width: 800px) {
  .title-layout { display: block; width: calc(100% - 32px); margin: 100px 16px 20px; padding: 0; }
  .title-controls { max-width: none; margin: 20px 0 0; padding: 18px; }
  .title-controls .difficulty-control { grid-template-columns: minmax(0,1fr) auto; }
  .title-controls .difficulty-control select { width: auto; }
  .leaderboard-table th, .leaderboard-table td { padding-inline: 8px; }
  .leaderboard-table td { font-size: 15px; }
  .leaderboard-table td:last-child { font-size: 18px; }
  .leaderboard-table td small { font-size: 12px; }
  .leaderboard-empty { padding-inline: 16px; }
  .result-links { gap: 0; }
}
@media (orientation: portrait) and (max-width: 800px) and (max-height: 740px) {
  .title-layout { margin-top: 16px; }
  .title-controls { margin-top: 16px; }
}
@media (orientation: portrait) and (max-width: 359px) {
  .title-controls { padding: 12px; }
  .title-controls .difficulty-control { grid-template-columns: 1fr; }
  .title-controls .difficulty-control select { width: 100%; }
  .leaderboard-toolbar label { display: none; }
  .leaderboard-table th:first-child { width: 11%; }
  .leaderboard-table th:nth-child(2) { width: 37%; }
  .leaderboard-table th:nth-child(3) { width: 25%; }
  .leaderboard-table th:last-child { width: 27%; }
}

/* Shared-keyboard co-op. Solo selectors and HUD geometry remain independent. */
:root { --p1: #ffb260; --p2: #78dce8; }
.p1-color, [data-player="0"] { --player-color: var(--p1); }
.p2-color, [data-player="1"] { --player-color: var(--p2); }
.p1-color { color: var(--p1); }
.p2-color { color: var(--p2); }
.player-count-control { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.player-count-control label { font-weight: 700; }
.player-count-control select { min-height: 44px; min-width: 170px; padding: 6px 10px; background: var(--ink); color: var(--ivory); border: 1px solid var(--line); border-radius: 2px; }
.party-note { color: var(--muted); font-size: 14px; line-height: 1.3; margin: 6px 0 16px; }
.player-entry label > .name-label { font: inherit; color: inherit; }
#shell[data-player-count="2"] #player-one-label { color: var(--p1); }
#player-two-entry .name-label { color: var(--p2); }
#player-two-name-error { color: var(--danger); font-size: 14px; line-height: 1.3; }
.co-op-start-help { padding: 10px 0; margin-bottom: 12px; border-block: 1px solid var(--line); font-size: 14px; line-height: 1.35; }
.co-op-start-help p + p { margin-top: 7px; }
.co-op-start-help p:last-child { color: var(--muted); }
.co-op-start-help :is(.p1-color, .p2-color) { font-weight: 700; margin-right: 4px; }
.co-op-manual { margin: 14px 0 20px; }
.co-op-manual h3 { font-size: 22px; margin: 0 0 8px; }
.co-op-manual p { color: var(--muted); font-size: 16px; line-height: 1.4; }
.co-op-control-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.co-op-control-card { border-top: 3px solid var(--player-color); padding: 10px; background: var(--ink); min-width: 0; }
.co-op-control-card h4 { color: var(--player-color); margin: 0 0 10px; font-size: 17px; }
.co-op-control-card dl { display: grid; gap: 12px; }
.co-op-control-card dt { color: var(--muted); font-size: 14px; margin-bottom: 5px; }
.co-op-control-card dd { margin: 0; font-size: 12px; white-space: nowrap; }
#shell[data-player-count="2"] :is(.manual-controls, .manual-pad, .manual-touch, .keyboard-hints, .touch-hint, .gamepad-hint, .portrait-advice, .portrait-play-note) { display: none; }
#shell[data-player-count="2"] #touch-controls { display: none; }
.co-op-quick-controls { font-size: 14px; line-height: 1.3; }
.co-op-quick-controls > span { margin-left: 10px; }
.co-op-quick-controls > span:first-child { margin-left: 0; }
.co-op-quick-controls > span:last-child { color: var(--muted); }
.result-player > span { display: block; }
.leaderboard-toolbar { flex-wrap: wrap; }
.leaderboard-toolbar > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.leaderboard-toolbar select { min-width: 0; max-width: 100%; }

/* Natural grid rows separate both actor cards, shared status and live guidance.
   Long names truncate inside cards, while full names remain in their titles. */
#shell[data-player-count="2"] #stage-surface { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: max-content max-content 1fr; align-content: start; }
.hud[data-player-count="2"] { position: relative; inset: auto; height: auto; min-width: 0; grid-row: 1; grid-column: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: auto auto; align-items: start; align-content: start; gap: 4px 8px; padding: 8px; font-size: 14px; }
.hud[data-player-count="2"] .co-op-hud { display: contents; }
.co-op-player { min-width: 0; padding: 7px 9px; border-top: 3px solid var(--player-color); background: #10232bf5; grid-row: 1 / span 2; }
#co-op-player-0 { grid-column: 1; }
#co-op-player-1 { grid-column: 3; }
.co-op-heading { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 2px 6px; font-size: 15px; line-height: 18px; }
.co-op-mark { color: var(--player-color); font-weight: 700; }
.co-op-heading > strong { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.co-op-state { grid-column: 1 / -1; color: var(--player-color); font-size: 12px; line-height: 14px; }
.co-op-state:empty { display: none; }
.co-op-health-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 6px; font-size: 13px; line-height: 16px; margin-top: 4px; }
.co-op-health-row span { white-space: nowrap; color: var(--muted); }
.co-op-health-row strong { color: var(--ivory); }
.co-op-player meter { height: 4px; margin: 4px 0 5px; }
.co-op-player meter::-webkit-meter-optimum-value { background: var(--player-color); }
.co-op-player meter::-moz-meter-bar { background: var(--player-color); }
.co-op-player[data-low="true"] meter::-webkit-meter-optimum-value { background: var(--danger); }
.co-op-player[data-low="true"] meter::-moz-meter-bar { background: var(--danger); }
.co-op-player[data-out="true"] { border-top-style: dashed; }
.co-op-player[data-out="true"] .co-op-equipment, .co-op-player[data-dead="true"] .co-op-equipment { opacity: .65; }
.co-op-equipment { display: flex; flex-wrap: wrap; gap: 2px 9px; font-size: 13px; line-height: 16px; }
.co-op-equipment > span { overflow-wrap: anywhere; }
.co-op-equipment > span:first-child { color: var(--player-color); font-weight: 700; }
.hud[data-player-count="2"] :is(.player-status, .hud-equipment, .vehicle-status) { display: none; }
.hud[data-player-count="2"] :is(.hud-top, .objective-status, .boss-status) { position: static; inset: auto; width: auto; max-width: none; min-width: 0; margin: 0; grid-column: 2; }
.hud[data-player-count="2"] .hud-top { grid-row: 1; display: block; }
.hud[data-player-count="2"] .score-status { display: flex; justify-content: space-between; flex-wrap: wrap; margin: 0; padding: 5px 8px; gap: 2px 6px; text-align: left; }
/* Outrank solo fullscreen tool clearance and solo rover score suppression. */
#shell[data-player-count="2"] #stage .score-status { display: flex; margin: 0; min-width: 0; }
.hud[data-player-count="2"] .score-status strong { font-size: 18px; overflow-wrap: anywhere; min-width: 0; letter-spacing: .03em; }
.co-op-keyboard-note { display: block; padding: 3px 8px; color: var(--muted); background: #10232bf5; font-size: 12px; line-height: 14px; }
.hud[data-player-count="2"] .objective-status { grid-row: 2; padding: 6px 8px; font-size: 14px; }
.hud[data-player-count="2"] #hud-objective { white-space: normal; }
.hud[data-player-count="2"] .boss-status { grid-row: 2; padding: 5px 8px; font-size: 13px; }
.hud[data-player-count="2"] #boss-subtitle { display: none; }
.hud[data-player-count="2"] .boss-tip { font-size: 13px; line-height: 16px; white-space: pre-line; overflow-wrap: anywhere; }
.hud[data-player-count="2"] .replay-status { position: static; inset: auto; grid-column: 2; grid-row: 3; min-width: 0; margin: 0; padding: 5px 8px; flex-wrap: wrap; gap: 2px 6px; font-size: 13px; line-height: 16px; }
.hud[data-player-count="2"] .replay-status strong { white-space: normal; }
#shell[data-player-count="2"] #stage[data-view="playing"] :is(.mission-coach, .mission-toast, .interaction-prompt) { position: relative; inset: auto; transform: none; grid-column: 1; grid-row: 2; align-self: start; justify-self: start; width: auto; max-width: min(500px, calc(100% - 16px)); margin: 2px 8px 0; padding: 5px 8px; background: #10232bf5; }
#shell[data-player-count="2"] #stage[data-view="playing"] .interaction-prompt { justify-self: center; text-align: center; }
#shell[data-player-count="2"] .mission-coach .coach-details { display: none; }
#shell[data-player-count="2"] .mission-coach .coach-compact { display: block; flex: 1; min-width: 0; }
#shell[data-player-count="2"] .mission-coach :is(strong, p) { font-size: 14px; line-height: 16px; white-space: pre-line; }
#shell[data-player-count="2"] .stage-tools { top: auto; bottom: 6px; }

@container battlefield (max-width: 680px) {
  .co-op-control-cards { grid-template-columns: 1fr; }
  .co-op-control-card dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .co-op-player { padding: 5px 6px; }
  .co-op-heading { font-size: 13px; }
  .co-op-equipment { font-size: 12px; gap: 2px 6px; }
  .co-op-quick-controls > span:last-child { display: none; }
  .leaderboard-toolbar > div { flex: 1; flex-direction: column; align-items: stretch; gap: 3px; }
  .leaderboard-toolbar select { padding-inline: 6px; font-size: 16px; }
  #leaderboard-count { flex-basis: 100%; text-align: right; font-size: 13px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  #shell[data-player-count="2"] .title-copy { align-self: start; }
  #shell[data-player-count="2"] .title-controls { padding-block: 10px; }
  .hud[data-player-count="2"] { gap: 3px 6px; padding: 6px; }
  .hud[data-player-count="2"] .boss-heading { flex-wrap: wrap; gap: 0 6px; }
  #shell[data-player-count="2"] .mission-coach { max-width: calc(100% - 160px); }
}
@media (orientation: portrait) and (max-width: 800px) {
  /* Co-op status is an intrinsic-height band above the unchanged 16:9 world.
     Guidance has its own row below it; no absolute HUD offsets to collide. */
  #shell[data-player-count="2"] #stage-surface { grid-template-rows: max-content 56.25cqw 1fr; }
  .hud[data-player-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto auto; background: var(--ink); }
  .hud[data-player-count="2"] .co-op-player { grid-row: 1; }
  #co-op-player-1 { grid-column: 2; }
  .hud[data-player-count="2"] .hud-top { grid-column: 1; grid-row: 2; }
  .hud[data-player-count="2"] .objective-status { grid-column: 2; grid-row: 2; }
  .hud[data-player-count="2"] .boss-status { grid-column: 1 / -1; grid-row: 3; }
  .hud[data-player-count="2"] .replay-status { grid-column: 1 / -1; grid-row: 4; }
  #shell[data-player-count="2"] #stage .hud { height: auto; }
  .hud[data-player-count="2"] .score-status { display: flex; margin: 0; }
  #shell[data-player-count="2"] #stage:not([data-view="title"]) #game { position: relative; inset: auto; grid-column: 1; grid-row: 2; height: 56.25cqw; width: 100%; }
  #shell[data-player-count="2"] #stage:not([data-view="title"]) .scene-backdrop { display: none; }
  #shell[data-player-count="2"] #stage[data-view="playing"] :is(.mission-coach, .mission-toast, .interaction-prompt) { grid-row: 3; max-width: calc(100% - 16px); justify-self: stretch; }
  #shell[data-player-count="2"] .mission-coach .coach-details { display: block; }
  #shell[data-player-count="2"] .mission-coach .coach-compact { display: none; }
  #shell[data-player-count="2"] #stage.is-fullscreen .hud-top, #shell[data-player-count="2"] #stage:fullscreen .hud-top { right: auto; }
  .co-op-control-card dl { grid-template-columns: 1fr; }
}

/* Compact quiz cards keep the paused battlefield visible. The body can scroll
   on short viewports while Skip / Continue remains reachable. */
.toolkit-screen { display: grid; place-items: center; padding: clamp(8px, 2cqw, 20px); background: #10232b9c; z-index: 45; }
.toolkit-panel { width: min(540px, 100%); min-width: 0; min-height: 0; max-height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--charcoal); border: 1px solid var(--line); border-top: 3px solid var(--amber); box-shadow: 0 12px 36px #06131888; }
.toolkit-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); min-width: 0; }
.toolkit-header h2 { font-size: 24px; line-height: 1.1; }
.toolkit-collector { min-width: 0; text-align: right; max-width: 48%; font-size: 15px; line-height: 1.2; }
#toolkit-player { display: block; color: var(--player-color); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#toolkit-pause { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.toolkit-content { display: block; min-height: 0; padding: 16px 18px; overflow-wrap: break-word; }
.toolkit-reward { display: flex; align-items: baseline; gap: 10px; border-left: 2px solid var(--amber); padding-left: 8px; margin-bottom: 12px; }
.toolkit-reward-label { color: var(--muted); font-size: 14px; }
#toolkit-reward-detail { font-size: 18px; color: var(--amber); line-height: 1.2; }
.toolkit-question-area { min-width: 0; }
#toolkit-question { font-size: 26px; line-height: 1.2; margin: 0 0 12px; font-weight: 700; }
/* Reading anchors keep programmatic focus; only interactive choices need a ring. */
#toolkit-screen #toolkit-title:focus, #toolkit-screen #toolkit-question:focus, #toolkit-screen #toolkit-outcome:focus { outline: none; }
.toolkit-placeholder-line { display: block; width: 76%; height: 18px; margin: 7px 0 19px; background: #b8ccca18; border-radius: 2px; }
.toolkit-placeholder-answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.toolkit-placeholder-answers > span { height: 48px; border: 1px solid #49636a80; background: #10232b80; border-radius: 2px; }
.toolkit-answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.toolkit-answer { display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: center; gap: 3px 8px; min-width: 0; min-height: 48px; width: 100%; padding: 10px; color: var(--ivory); background: var(--ink); border: 1px solid var(--line); text-align: left; font-size: 21px; font-weight: 700; line-height: 1.15; }
.toolkit-letter { color: var(--muted); font-size: 13px; border: 1px solid var(--line); text-align: center; padding-block: 1px; }
.toolkit-answer:not(:disabled):hover { border-color: var(--amber); background: #25434a; }
.toolkit-answer-result { grid-column: 2; font-size: 13px; font-weight: 700; }
.toolkit-answer-result:empty { display: none; }
.toolkit-answer:disabled { opacity: 1; cursor: default; }
.toolkit-answer[data-result="correct"] { border-color: var(--jade); background: #234b4c; }
.toolkit-answer[data-result="wrong"] { border-color: var(--danger); }
.toolkit-answer[data-result="wrong"] .toolkit-answer-result { color: var(--danger); }
.toolkit-result { padding-block: 8px; }
#toolkit-outcome { font-size: 28px; line-height: 1.2; margin: 0 0 6px; }
.toolkit-screen[data-outcome="correct"] #toolkit-outcome { color: #bcebd1; }
.toolkit-screen[data-outcome="wrong"] #toolkit-outcome { color: var(--danger); }
#toolkit-correct-answer { color: var(--ivory); font-weight: 700; margin-bottom: 8px; font-size: 21px; line-height: 1.2; }
#toolkit-explanation { color: var(--muted); font-size: 18px; line-height: 1.3; }
.toolkit-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; padding: 10px 18px; border-top: 1px solid var(--line); }
.toolkit-footer > button { grid-column: 2; grid-row: 1 / span 2; width: auto; min-width: 100px; padding: 9px 14px; font-size: 18px; }
#toolkit-skip { background: transparent; border-color: var(--line); color: var(--muted); }
#toolkit-skip:hover { border-color: var(--amber); color: var(--ivory); }
#toolkit-input-note, #toolkit-action-status { grid-column: 1; font-size: 14px; color: var(--muted); line-height: 1.3; }
#toolkit-action-status[data-state="error"] { color: var(--danger); }
#toolkit-action-status[data-state="loading"]::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -2px; border: 2px solid var(--line); border-top-color: var(--muted); border-radius: 50%; animation: toolkit-wait .9s linear infinite; }
@keyframes toolkit-wait { to { transform: rotate(360deg); } }
.toolkit-manual { border-block: 1px solid var(--line); margin: 16px 0; padding: 12px 0; }
.toolkit-manual h3 { margin: 0 0 8px; font-size: 18px; }
.toolkit-manual p { color: var(--muted); font-size: 15px; line-height: 1.4; }
.toolkit-manual p + p { margin-top: 8px; }
@container battlefield (max-width: 560px) {
  .toolkit-header { padding: 10px 12px; }
  .toolkit-header h2 { font-size: 22px; }
  .toolkit-content { padding: 12px; }
  #toolkit-question { font-size: 22px; }
  .toolkit-answer { font-size: 19px; }
  .toolkit-footer { padding: 8px 12px; gap: 6px 10px; }
  .toolkit-footer > button { min-width: 90px; padding-inline: 10px; font-size: 17px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .toolkit-screen { padding: 6px; }
  .toolkit-header, .toolkit-footer { padding-block: 7px; }
  .toolkit-content { padding-block: 10px; }
  .toolkit-collector { font-size: 14px; }
}

/* A single clear stakes line for the three mandatory boss defenses. */
.toolkit-reward .toolkit-stakes { flex-basis: 100%; margin: 4px 0 0; color: #ffc48b; font-size: 17px; line-height: 1.3; }
.toolkit-screen[data-kind="boss"] .toolkit-panel { border-top-color: #8cddd5; }

.toolkit-screen[data-kind="boss"] .toolkit-reward { flex-wrap: wrap; row-gap: 0; border-left-color: #8cddd5; }

/* Hosted setup extends the scrollable title card; offline geometry is unchanged. */
#shell[data-hosted="true"] .title-layout { align-items: start; }
#shell[data-hosted="true"] .title-controls { max-width: 410px; }
#shell[data-hosted="true"] .control-strip > .text-button { flex-shrink: 0; }
#shell[data-hosted="true"] .co-op-quick-controls { min-width: 0; }
.online-mode-entry { display: grid; gap: 6px; margin-bottom: 16px; }
.online-mode-entry > label { font-weight: 700; }
.online-mode-entry select { width: 100%; min-width: 0; min-height: 44px; padding: 7px 10px; border: 1px solid var(--amber); border-radius: 2px; background: var(--ink); color: var(--ivory); }
.online-mode-entry p, #participant-code-note, .online-recovery p { color: var(--muted); font-size: 15px; line-height: 1.35; }
.online-event-fields { border-top: 1px solid var(--line); padding-top: 12px; margin-bottom: 16px; }
#participant-code-note { margin-bottom: 12px; }
.online-event-fields .player-entry { margin-bottom: 12px; }
.online-event-fields .player-entry input { font-family: monospace; font-size: 16px; }
.online-recovery { border-left: 2px solid var(--amber); padding-left: 10px; margin: 12px 0; }
.online-recovery button { margin-top: 8px; width: 100%; }
.online-recovery .discard-result-note { margin-top: 14px; }
.online-recovery .discard-result { color: var(--danger); border-color: var(--line); }
.online-status { color: var(--amber); font-size: 16px; line-height: 1.35; margin: 10px 0; overflow-wrap: anywhere; }
#result-save-retry { grid-column: 1 / -1; width: 100%; min-height: 44px; margin: 0; }
#leaderboard-refresh { margin-left: auto; border-color: var(--line); flex-shrink: 0; }
.toolkit-remote-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.toolkit-remote-actions button { flex: 1 1 auto; min-height: 44px; margin: 0; padding: 8px 12px; font-size: 17px; }
.toolkit-answer[data-pending="true"] { border-color: var(--amber); background: #eda6490c; }
#toolkit-action-status { overflow-wrap: anywhere; }
@container battlefield (max-width: 560px) {
  #shell[data-hosted="true"] .title-controls { max-width: none; }
  #shell[data-hosted="true"] .leaderboard-toolbar label { display: block; }
}

/* Launch screen: the illustration and setup own separate columns.
   These rules are scoped to the title so the playable viewport stays 16:9. */
#shell:has(#stage[data-view="title"]) { width: min(1480px, 100%); }
#shell:has(#stage[data-view="title"]) > .control-strip { display: none; }
#stage[data-view="title"] {
  --launch-panel: clamp(360px, 34%, 448px);
  height: min(840px, calc(100dvh - var(--safe-top) - var(--safe-bottom) - 56px));
  aspect-ratio: auto;
}
#stage[data-view="title"] #stage-surface { inset: 0; width: 100%; height: 100%; transform: none; display: block; }
#stage[data-view="title"] :is(#game, .scene-backdrop) {
  position: absolute; inset: 0 var(--launch-panel) 0 0;
  width: auto; height: 100%; max-height: none; transform: none;
}
#stage[data-view="title"] .scene-backdrop { width: calc(100% - var(--launch-panel)); object-position: center; }
#stage[data-view="title"] #game canvas { object-fit: cover; object-position: center; }
#shell #title-screen { display: block; overflow: hidden; background: none; padding: 0; scroll-padding-block: 16px 136px; }
#shell #title-screen .title-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--launch-panel);
  align-items: stretch; gap: 0; width: 100%; height: 100%; max-width: none; margin: 0; padding: 0;
}
#shell #title-screen .title-copy {
  position: relative; align-self: stretch; min-width: 0; padding: clamp(24px, 3cqw, 44px);
  background: linear-gradient(180deg, #10232bd9, #10232b80 32%, transparent 65%, #10232ba8);
}
#title-screen .field-badge { font-size: 14px; gap: 14px; }
#title-screen .aws-logo { width: 52px; }
#title-screen .field-badge > span { padding-left: 14px; letter-spacing: .09em; }
#title-screen h1 {
  font-size: clamp(58px, min(6.8cqw, 12vh), 98px); line-height: .96;
  margin: 22px 0 14px; letter-spacing: -.04em;
}
#title-screen h1 span { display: block; }
#title-screen .operation-name { font-size: clamp(16px, 1.5cqw, 20px); letter-spacing: .15em; }
#title-screen .briefing { margin-top: 12px; font-size: clamp(17px, 1.6cqw, 21px); max-width: 32ch; line-height: 1.35; }
#title-screen .title-scene-caption { position: absolute; bottom: 26px; left: clamp(24px, 3cqw, 44px); right: 24px; }
#title-screen .first-controls { margin: 0; color: var(--ivory); font-size: 16px; line-height: 1.4; }
#title-screen .co-op-start-help { margin: 0; padding: 0; border: 0; font-size: 16px; line-height: 1.5; }
#title-screen .co-op-start-help p { color: var(--ivory); margin: 0; }
#title-screen .co-op-start-help :is(.p1-color, .p2-color) { display: inline-block; min-width: 24px; }
#shell[data-player-count="2"] #title-screen .first-controls { display: none; }
#shell #title-screen .title-controls {
  display: flex; flex-direction: column; justify-content: safe center; gap: 18px;
  width: 100%; max-width: none; min-height: 0; margin: 0; padding: 32px;
  background: #10232b; border: 0; border-left: 1px solid var(--line); box-shadow: none;
  overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; scroll-padding-block: 16px 136px;
}
#title-screen .setup-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: 0 0 auto; }
#title-screen .setup-heading h2 { font-size: 32px; line-height: 1.1; font-weight: 700; letter-spacing: -.015em; }
#title-screen .setup-fields { display: grid; gap: 18px; min-height: 0; flex: 0 0 auto; }
#title-screen .setup-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
#shell[data-hosted="false"] #title-screen .setup-options { grid-template-columns: 1fr; }
#title-screen :is(.online-mode-entry, .player-count-control) { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 0; }
#title-screen :is(.player-entry, .online-mode-entry, .player-count-control) > label { font-size: 17px; font-weight: 500; line-height: 1.2; color: var(--muted); }
#title-screen :is(select, .player-entry input) {
  width: 100%; min-width: 0; min-height: 46px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 3px; background: #18313a;
  color: var(--ivory); font-size: 18px; line-height: 1.25;
}
#title-screen select { padding-right: 6px; }
#title-screen :is(select, input):hover:not(:disabled) { border-color: #8da5a5; }
#title-screen .player-entry input { background: #0b1d25; }
#title-screen .player-entry input[aria-invalid="true"] { border-color: var(--danger); }
#title-screen .setup-names, #title-screen .online-event-fields { display: grid; grid-template-columns: 1fr; gap: 6px 14px; }
#shell[data-player-count="2"] #title-screen .setup-names { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#title-screen .player-entry { min-width: 0; display: grid; align-content: start; gap: 6px; margin: 0; }
#title-screen :is(#player-name-note, #participant-code-note) { grid-column: 1 / -1; margin: 0; font-size: 14px; line-height: 1.3; color: var(--muted); }
#title-screen :is(#player-name-error, #player-two-name-error) { font-size: 14px; line-height: 1.3; color: var(--danger); }
#shell #title-screen .difficulty-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; margin: 0; }
#shell #title-screen .difficulty-control label { display: block; font-size: 17px; color: var(--muted); }
#shell #title-screen .difficulty-control select { width: auto; min-width: 176px; }
#title-screen #difficulty-note { padding-top: 6px; font-size: 14px; line-height: 1.3; }
#title-screen .online-event-fields { border: 0; padding: 0; margin: 0; }
#title-screen .online-event-fields input { font-family: "Barlow Condensed", sans-serif; font-size: 18px; }
#title-screen .online-status, #title-screen .online-recovery { margin: 0; }
#title-screen .setup-actions {
  position: sticky; bottom: -32px; z-index: 1; flex: 0 0 auto;
  margin-top: 2px; padding: 8px 0 0; background: var(--ink);
}
#title-screen #start-button { min-height: 52px; font-size: 20px; padding: 12px 16px; }
#title-screen .menu-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: space-between; margin-top: 8px; }
#title-screen .menu-actions .text-button { width: auto; margin: 0; min-height: 44px; padding: 8px 0; font-size: 16px; font-weight: 500; }
#title-screen .leaderboard-button { display: flex; align-items: center; gap: 7px; color: var(--ivory); }
#title-screen .leaderboard-button span { color: var(--amber); }
#stage.is-fullscreen[data-view="title"], #stage:fullscreen[data-view="title"] { width: 100%; height: 100dvh; }
@media (max-height: 780px) {
  #shell #title-screen .title-controls { padding: 24px; gap: 14px; }
  #title-screen .setup-fields { gap: 14px; }
  #title-screen .setup-heading h2 { font-size: 30px; }
  #title-screen .setup-actions { bottom: -24px; }
}
@media (max-height: 660px) and (orientation: landscape) {
  #shell #title-screen .title-controls { padding: 16px 24px; gap: 12px; justify-content: safe center; }
  #title-screen .setup-fields { gap: 10px; }
  #title-screen .setup-heading h2 { font-size: 26px; }
  #title-screen .setup-actions { bottom: -16px; }
  #title-screen :is(select, .player-entry input) { min-height: 44px; padding-block: 8px; }
  #title-screen .title-scene-caption { bottom: 18px; }
  #title-screen .briefing { margin-top: 8px; font-size: 16px; }
  #title-screen h1 { margin-block: 12px 10px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  #stage[data-view="title"] { height: calc(100dvh - var(--safe-top) - var(--safe-bottom)); --launch-panel: max(360px, 47%); }
  #shell #title-screen .title-copy { padding: 20px; }
  #title-screen .title-scene-caption { left: 20px; right: 12px; }
  #title-screen :is(.first-controls, .co-op-start-help) { font-size: 14px; }
  #title-screen .briefing { display: none; }
  #stage[data-view="title"] .stage-tools { display: none; }
}
@media (max-width: 760px) and (orientation: portrait) {
  #stage[data-view="title"]:not(.is-fullscreen):not(:fullscreen) { height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 56px); }
  #shell #title-screen { overflow-y: auto; }
  #shell #title-screen .title-layout { display: flex; flex-direction: column; height: auto; min-height: 100%; }
  #shell #title-screen .title-copy { flex: 0 0 210px; padding: 22px 24px; background: linear-gradient(90deg, #10232bd9, #10232b50); }
  #stage[data-view="title"] :is(#game, .scene-backdrop) { inset: 0 0 auto; width: 100%; height: 210px; }
  #stage[data-view="title"] #game canvas { object-position: center 62%; }
  #title-screen .aws-logo { width: 36px; }
  #title-screen .field-badge { font-size: 12px; }
  #title-screen h1 { font-size: clamp(40px, 10cqw, 64px); margin-block: 16px 8px; }
  #title-screen h1 span { display: inline; }
  #title-screen .operation-name { font-size: 14px; }
  #title-screen .briefing, #title-screen .title-scene-caption { display: none; }
  #shell #title-screen .title-controls { flex: 1 0 auto; overflow: visible; padding: 22px 24px 14px; gap: 18px; border: 0; border-top: 1px solid var(--line); }
  #title-screen .setup-fields { gap: 16px; }
  #title-screen .setup-heading h2 { font-size: 28px; }
  #title-screen .setup-actions { position: sticky; bottom: -14px; margin-top: auto; }
}
@media (max-width: 760px) and (orientation: portrait) and (max-height: 740px) {
  #shell #title-screen .title-copy { flex-basis: 156px; padding-block: 16px; }
  #stage[data-view="title"] :is(#game, .scene-backdrop) { height: 156px; }
  #title-screen h1 { margin-block: 12px 6px; }
}
@media (prefers-reduced-motion: no-preference) {
  #title-screen:not([hidden]) .title-copy, #title-screen:not([hidden]) .title-controls { animation: launch-reveal .35s ease-out both; }
  @keyframes launch-reveal { from { opacity: 0; } to { opacity: 1; } }
}
