/* TTDD Mono: JetBrains Mono cut down and renamed (tools/fonts/build_ttdd_mono.py), under the
   SIL Open Font License (fonts/OFL.txt, credited on the Credits page). Every character is one
   cell wide, so the board lines up the same on every device. The pages preload this file;
   the file name carries the font's version, so change it here, in the build script and in
   the pages' preload links together. */
@font-face { font-family: 'TTDD Mono'; src: url('fonts/ttdd-mono-v1.woff2') format('woff2'); font-weight: 400 700; font-style: normal; font-display: swap; }
:root { color-scheme: dark; font-family: 'TTDD Mono', ui-monospace, 'Cascadia Code', Consolas, monospace; color: #dce5dc; background: #111916; --line: #354339; --muted: #a6b5a8; --accent: #d8e89f; --dim: #5c6b5e; }
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button { border: 1px solid var(--accent); background: var(--accent); color: #172017; border-radius: 5px; padding: .65rem .85rem; min-height: 44px; cursor: pointer; white-space: nowrap; }
button.quiet { background: transparent; color: #dce5dc; border-color: var(--line); }
/* Hover styles are in the (hover: hover) block at the end, so a tap never leaves one stuck. */
button:active:not(:disabled) { filter: brightness(.9); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app-shell { max-width: 1180px; margin: auto; height: var(--viewport-height, 100dvh); position: relative; top: var(--viewport-top, 0); display: flex; flex-direction: column; padding: 0 24px; }
.app-shell.welcome-mode { width:100%; max-width:none; padding:0; overflow-y:auto; background:#101713; }
.welcome-mode > .game-body { flex:1 0 auto; min-height:100%; overflow:visible; padding:0; }
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 0 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.masthead-title { display: flex; align-items: center; gap: 12px; }
.masthead-logo { flex-shrink: 0; border-radius: 8px; }
.masthead-actions { display: flex; gap: 8px; }
.eyebrow { font-size: 10px; letter-spacing: .18em; color: var(--muted); margin: 0 0 7px; }
h1 { font-size: clamp(18px, 3.8vw, 28px); font-weight: 500; letter-spacing: -.05em; margin: 0; }
.sun { color: var(--accent); }
.statusbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 12px 0; font-size: 12px; }
/* Status bar: the run group and the Hull group on the left (the Hull drops to its own row
   when there is no room), Help on the right. */
.sb-info { display: flex; flex-wrap: wrap; align-items: center; column-gap: 14px; row-gap: 6px; min-width: 0; clip-path: inset(-8px -8px -8px 0); }
/* The Hull group's "·" hangs into the gap before it: on the run group's line it separates the
   two, and when the Hull wraps to a line of its own it falls past the left edge, clipped. */
.sb-hull { margin-left: -11px; }
.sb-group { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.sb-group .leave-run, .sb-group .hull-repair { margin-left: 2px; }
.sb-menu { position: relative; flex-shrink: 0; }
.sb-menu-toggle { display: none; }
.statusbar-actions { display: flex; gap: 8px; }
.statusbar-actions button { min-height: 0; padding: 0 8px; line-height: 1.5; }
/* Below desktop width: Help folds into a Menu that drops down from the top
   right; a click outside it closes it (.sb-menu-scrim). */
.sb-site { display: none; }
.sb-leave { display: none; }
@media (max-width: 600px) { .sb-site { display: inline-block; } }
@media (max-width: 949.98px) {
    .statusbar { flex-wrap: nowrap; align-items: flex-start; }   /* the Menu stays top right */
    .sb-menu-toggle { display: inline-flex; align-items: center; min-height: 30px; padding: 0 10px; font-size: 12px; }
    .sb-menu-toggle.active { border-color: var(--accent); color: var(--accent); }
    .statusbar-actions { display: none; position: absolute; top: calc(100% + 4px); right: 0; z-index: 41; flex-direction: column; gap: 4px; min-width: 150px;
        padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: #151f19; box-shadow: 0 8px 24px #000c; }
    .statusbar-actions.open { display: flex; }
    .statusbar-actions button { width: 100%; min-height: 36px; padding: 0 12px; text-align: left; }
    .sb-menu-scrim { position: fixed; inset: 0; z-index: 40; }
}
/* Up to 600px: row 1, the run group and the Menu; row 2, full width, the Hull (no separator);
   then the acting note. */
@media (max-width: 600px) {
    .statusbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; row-gap: 6px; }
    .sb-info { display: contents; }
    .sb-run { grid-column: 1; grid-row: 1; }
    .sb-menu { grid-column: 2; grid-row: 1; }
    .sb-hull { grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap; white-space: normal; margin-left: 0; }
    .sb-hull .hull-repair { white-space: nowrap; }
    .statusbar .acting-note { grid-column: 1 / -1; }
    .sb-sep { display: none; }
}
.game-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 16px; }
.state-panel, .history-panel { border: 1px solid var(--line); border-radius: 7px; min-width: 0; }
.state-panel { padding: 16px; background: #151f19; }
h2 { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; margin: 0; color: var(--accent); }
.text-block { font: inherit; font-size: 13px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; tab-size: 4; }
.history-panel { position: fixed; top: var(--viewport-top, 0); width: min(760px, calc(100% - 24px)); max-height: calc(var(--viewport-height, 100dvh) - 32px); margin: 16px auto 0; padding: 0; color: #dce5dc; background: #151f19; box-shadow: 0 16px 60px #0009; }
.history-panel[open] { display: flex; flex-direction: column; }
.history-panel::backdrop { background: #070d0ab3; }
.history-toggle { min-height: 30px; padding: .3rem .55rem; font-size: 11px; }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; flex-shrink: 0; }
.history-heading span { color: var(--muted); margin-left: 8px; }
.history-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 0 16px 12px; }
.history-entry { padding: 10px 0; border-top: 1px solid var(--line); }
.command-echo { color: var(--accent); font-size: 13px; margin: 0 0 5px; overflow-wrap: anywhere; }
.welcome { font-size: 13px; color: var(--muted); line-height: 1.6; }
.input-row { display: flex; align-items: center; gap: 8px; }
.input-row > span { color: var(--accent); }
input { background: #1c2820; color: #f0f5ea; border: 1px solid #52604c; border-radius: 4px; min-width: 0; width: 100%; font-size: 16px; padding: 11px; }
/* Checkboxes and radios are not text fields: undo the size and padding above. */
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; margin: 0; border: none; flex-shrink: 0; accent-color: var(--accent); }
.tutorial-hint { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.tutorial-hint p { margin: 2px 0 0; color: var(--muted); }
.tutorial-hint strong { color: var(--accent); }
.tutorial-badge { flex-shrink: 0; background: var(--accent); color: #172017; font-size: 11px; font-weight: bold; padding: 1px 6px; border-radius: 3px; margin-top: 2px; }
/* Tutorial tip: topic label, dismiss, optional Why? and a compact Minimal mode. */
.tutorial-content { flex: 1; min-width: 0; }
.tutorial-title { margin: 0; color: inherit; }
.tutorial-topic { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.tutorial-hint .tutorial-dismiss { min-height: 32px; min-width: 32px; padding: 0 8px; border-color: transparent; color: var(--muted); flex-shrink: 0; }
.tutorial-hint .tutorial-dismiss:focus-visible { border-color: var(--line); color: #dce5dc; }
.tutorial-why { margin-top: 4px; }
.tutorial-why summary { cursor: pointer; color: var(--accent); font-size: 12px; width: fit-content; }
.tutorial-why p { max-height: 6em; overflow-y: auto; }
.tutorial-hint.recovery strong { color: #f0d878; }
.tutorial-hint.minimal { padding-top: 6px; font-size: 12px; }
/* Battle-end / restore recap, above the board and before the detailed log. */
.recap { border-color: var(--accent); }
.recap-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.recap h2 { margin: 0; color: var(--accent); font-size: 12px; }
.recap ul { margin: 6px 0 0; padding-left: 20px; }
.lose-lesson { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--accent); }
.lose-lesson p { margin: 4px 0 0; }
.first-win { margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--accent); }
.first-win p { margin: 4px 0 0; }
.recap button { min-height: 32px; padding: 0 10px; }
.recap-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
/* Restore buttons are filled with the accent, so their detail needs a dark tone (6.2:1 on the accent). */
.restore-detail { color: #455438; font-weight: normal; }
/* New game under them (App's NewGameChoice): past a wide "or start over" divider, outlined in
   red since it replaces the saved run; its first press turns it solid red, asking to confirm. */
.leave-or { display: flex; align-items: center; gap: 10px; flex-basis: 100%; margin: 18px 0 6px !important; color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.leave-or::before, .leave-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.leave-note { margin-top: 4px !important; color: var(--muted); }
/* The return's confirmation box: what the return discards, then Return and Cancel. */
.confirm-box { flex-basis: 100%; padding: 8px 10px; border: 1px solid var(--accent); border-radius: 6px; background: #17221b; text-align: left; }
.confirm-box p { margin: 0 0 8px; line-height: 1.45; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.new-game-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; flex-basis: 100%; }
.recap-dialog .recap-actions .new-game-row { justify-content: flex-end; }
/* The tutorial tips checkbox: its own line under New game's row (a full line in a flex parent too). */
.replay-row { display: flex; flex-basis: 100%; }
.recap-dialog .recap-actions .replay-row { justify-content: flex-end; }
.replay-row .replay-choice { margin: 4px 0 0; }
button.new-game { background: transparent; border-color: var(--enemy-line); color: var(--enemy); }
button.new-game.confirm { background: var(--enemy-line); border-color: var(--enemy-line); color: #fff; }
.help-tabs { display: flex; gap: 6px; padding: 0 16px 8px; }
.help-tabs button { min-height: 36px; padding: 0 12px; }
.help-tabs button.active { border-color: var(--accent); color: var(--accent); }
.guidance { border: 1px solid var(--line); border-radius: 5px; margin: 14px 0 4px; padding: 8px 12px; font-size: 13px; }
.guidance legend { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.guidance-options { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 8px; }
.guidance-options label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.guidance-note { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }
.replay-choice { display: flex; align-items: center; gap: 8px; width: fit-content; margin: 8px 0 4px; font-size: 13px; cursor: pointer; }
.tutorial-hint kbd { font: inherit; color: var(--accent); background: #1c2a22; border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; }
.latest-message { font-size: 12px; line-height: 1.5; max-height: 3em; overflow: auto; overflow-wrap: anywhere; margin-bottom: 8px; }
.latest-message:empty { display: none; }
.notice, .outcome { border: 1px solid #b6a875; padding: 12px; font-size: 13px; line-height: 1.6; margin: 0 0 12px; overflow: auto; flex-shrink: 0; max-height: 35dvh; }
.notice button { margin: 6px 6px 0 0; }
.notice p { margin: 0; }
.loading { padding: 40px 24px; line-height: 2; color: var(--accent); }
.cyan, .darkcyan { color: #80dce5; }
.blue { color: #eaf3ff; background-color: #1d3a5c; border-radius: 3px; padding: 0 2px; }
.green, .darkgreen { color: #b3e991; }
.yellow { color: #f5dc8b; }
.darkgray { color: #4d5c51; }
.red { color: #ffa49a; }
.darkblue { color: #4f6b85; }
.darkyellow { color: #a38230; }
.darkred { color: #944440; }
/* Newly added / touched items: background lights up green, then fades out. Keep the duration in step with HighlightMs in App.razor. */
.white { animation: lit-fade 2s ease-out forwards; border-radius: 3px; }
/* Craftable blueprints stay blue; a new craftable one flashes green first, then settles to blue. */
.magenta { color: #6cb8ff; }
.darkmagenta { animation: lit-fade-craftable 2s ease-out forwards; border-radius: 3px; }
@keyframes lit-fade {
    0%, 30% { background-color: #2f7a2a; }
    100% { background-color: transparent; }
}
@keyframes lit-fade-craftable {
    0%, 30% { background-color: #2f7a2a; color: #dce5dc; }
    100% { background-color: transparent; color: #6cb8ff; }
}
@media (prefers-reduced-motion: reduce) { .white { animation: none; background-color: #2f7a2a; } .darkmagenta { animation: none; background-color: #2f7a2a; color: #6cb8ff; } }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 18px; background: #512d26; z-index: 10; }
a { color: var(--accent); }
@media (max-width: 600px) { .app-shell { padding: 0 12px; } .masthead { padding: 12px 0; } .masthead-logo { width: 28px; height: 28px; } .eyebrow { font-size: 9px; } .masthead-actions button { padding: .5rem; font-size: 12px; } .state-panel { padding: 10px; } .text-block { font-size: 12px; } .statusbar { font-size: 11px; padding: 10px 0; } .input-row { gap: 6px; } .input-row button { padding: .65rem; font-size: 13px; } .dock-note { font-size: 9px; } }
@media (max-height: 500px) { .masthead { padding: 6px 0; } .eyebrow { display: none; } .statusbar { padding: 5px 0; } }

.modal-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: #070d0ab3; }
.modal-dialog { width: min(480px, 100%); max-height: 100%; overflow: auto; padding: 24px; border: 1px solid var(--accent); border-radius: 7px; background: #151f19; box-shadow: 0 16px 60px #0009; line-height: 1.6; text-align: center; }
.modal-dialog h2 { margin: 0 0 12px; color: var(--accent); font-size: 20px; }
.modal-dialog p { margin: 0 0 12px; }
.modal-dialog.win-dialog { width: min(500px, 100%); }
/* A battle's outcome (App's recap pop-up): the summary, a loss's lesson, then its actions. */
.modal-dialog.recap-dialog { width: min(580px, 100%); text-align: left; }
.recap-dialog:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.recap-dialog .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.recap-dialog .dialog-head h2 { margin: 0; }
.recap-dialog.lost h2, .recap-dialog.runlost h2 { color: var(--enemy); }
.recap-dialog ul { margin: 0 0 12px; padding-left: 20px; }
.recap-dialog .recap-actions { justify-content: flex-end; margin-top: 14px; }
/* A won recap can run long (cards, blueprints): Next stays on screen at the dialog's foot. */
.recap-dialog.won .recap-actions { position: sticky; bottom: -24px; margin-bottom: -24px; padding: 10px 0 14px; border-top: 1px solid var(--line); background: #151f19; }
/* A blueprint the battle's end granted: its Workbench card, read-only, under the recap. */
.recap-grants { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 8px; }
.recap-grant-msg { margin: 0; color: var(--warn); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.recap-grant-body { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: center; }
.recap-grant-body:not(:has(> .hb-art)) { grid-template-columns: minmax(0, 1fr); }
.recap-grant .h-lines { color: #dce5dc; }
.recap-grant .h-lines + .h-lines { color: var(--muted); }
.recap-dialog .recap-actions > p, .recap-dialog .recap-actions > label { flex-basis: 100%; margin: 0; }
.recap-dialog .recap-actions button { min-height: 36px; padding: 0 14px; }

/* The battle result's level-up cards (LevelUpList), in the won recap and the docked result.
   Gold while a card has points to assign, green once it has none; a card that rose this battle
   comes in with a flash. */
.levelup { margin: 0 0 14px; text-align: left; }
.insp-result .levelup { margin: 0 0 12px; }
.levelup-banner { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; margin-bottom: 10px; padding: 8px 12px; border: 1px solid var(--gold-dim); border-radius: 6px; background: linear-gradient(90deg, rgb(227 194 84 / .2), rgb(227 194 84 / .03)); }
.levelup-banner h3 { margin: 0; color: var(--gold); font-size: 16px; letter-spacing: .14em; text-transform: uppercase; }
.levelup-star { display: inline-block; animation: levelup-star 1s ease-out .15s backwards; }
.levelup-tally { margin: 0 !important; color: var(--warn); font-size: 12px; }
.levelup-tally.done { color: var(--comp); }
.levelup .levelup-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.levelup-card { position: relative; overflow: hidden; display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--well); transition: border-color .25s ease; animation: levelup-rise .4s ease-out calc(var(--i) * 90ms) backwards; }
.levelup-card.pending { border-color: var(--gold-dim); }
.levelup-card.done { border-color: var(--comp-line); }
.levelup-card.rose::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 30%, rgb(255 236 170 / .4) 50%, transparent 70%); translate: -100% 0; animation: levelup-sheen .9s ease-out calc(var(--i) * 90ms + .35s) 1; }
.levelup-card.rose.pending { animation: levelup-rise .4s ease-out calc(var(--i) * 90ms) backwards, levelup-glow .7s ease-out calc(var(--i) * 90ms + .35s) 2; }
.levelup-art { display: block; align-self: start; height: 72px; border-radius: 5px; background-color: #0b110d; background-position: center; background-repeat: no-repeat; background-size: contain; }
.levelup-body { min-width: 0; }
.levelup-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 8px; }
.levelup-name { min-width: 0; color: var(--comp); font-size: 14px; font-weight: 700; }
.levelup-rank { display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; font-size: 12px; }
.levelup-rank strong { color: var(--gold); font-size: 15px; }
.levelup-from { color: var(--muted); }
.levelup-arrow { color: var(--gold-dim); }
.levelup .levelup-stats { display: flex; flex-wrap: wrap; gap: 2px 10px; margin: 4px 0; padding: 0; list-style: none; font-size: 12px; }
.levelup-stats li { display: inline-flex; align-items: center; gap: 3px; }
.levelup-stats .ic { color: var(--muted); }
.levelup-reward { margin: 2px 0 !important; color: var(--act); font-size: 12px; }
.levelup-out, .levelup-kept { margin: 2px 0 0 !important; color: var(--muted); font-size: 11px; }
.levelup-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.levelup-chip { padding: 1px 7px; border: 1px solid; border-radius: 999px; font-size: 11px; white-space: nowrap; }
.levelup-chip.stat { border-color: var(--gold-dim); background: rgb(227 194 84 / .12); color: var(--warn); }
.levelup-chip.skill { border-color: #2f7f88; background: rgb(128 220 229 / .1); color: var(--act); }
.levelup-done { color: var(--comp); font-size: 12px; font-weight: 700; }
.levelup .levelup-assign { min-height: 30px; margin-left: auto; padding: 0 12px; border-color: var(--gold); background: var(--gold); color: #1d1a0c; font-weight: 700; }
.insp-result .levelup .levelup-cards { grid-template-columns: minmax(0, 1fr); }
.insp-result .levelup-card { grid-template-columns: 52px minmax(0, 1fr); gap: 8px; padding: 8px; }
.insp-result .levelup-art { height: 52px; }
@keyframes levelup-rise { from { opacity: 0; translate: 0 10px; } }
@keyframes levelup-sheen { to { translate: 100% 0; } }
@keyframes levelup-glow { 40% { box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgb(227 194 84 / .55); } }
@keyframes levelup-star { 0% { opacity: 0; scale: .2; rotate: -120deg; } 60% { opacity: 1; scale: 1.5; } }
@media (prefers-reduced-motion: reduce) {
    .levelup-star, .levelup-card, .levelup-card.rose.pending, .levelup-card.rose::after { animation: none; }
    .levelup-card { transition: none; }
}

/* One companion's growth (GrowthDialog), over the battle result. */
/* The Test dialog (localhost only). */
.modal-dialog.test-dialog { width: min(620px, 100%); text-align: left; }
.test-dialog p { font-size: 13px; }
.test-stages { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-bottom: 12px; }
.test-stages fieldset { margin: 0; padding: 6px 10px 8px; border: 1px solid var(--line); border-radius: 6px; }
.test-stages legend { padding: 0 4px; font-size: 12px; color: var(--muted); }
.test-stages label { display: block; }
.test-units { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 14px; }
.test-unit { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.test-unit-name { width: 90px; white-space: nowrap; }
.modal-dialog.growth-dialog { width: min(600px, 100%); text-align: left; }
.growth-dialog:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.growth-dialog .dialog-head h2 { flex: 1; min-width: 0; font-size: 18px; }
/* The growth dialog's header: the picture beside the name, level, XP, kit and skill points. */
.growth-dialog .growth-head { position: static; justify-content: flex-start; align-items: stretch; margin-bottom: 10px; }
.growth-summary { flex: 1; min-width: 0; }
.growth-summary h2 { margin: 0 0 6px; font-size: 18px; text-align: left; }
.growth-summary p:last-child { margin-bottom: 0; }
.growth-head .dialog-close { align-self: flex-start; }
.growth-art { position: relative; flex: none; width: 128px; min-height: 128px; border: 1px solid var(--gold-dim); border-radius: 5px; background: var(--art) center / contain no-repeat, linear-gradient(#26301c, #0b110d); }
.growth-level { display: block; color: var(--gold); font-size: 13px; letter-spacing: .08em; }
.growth-meter { height: 6px; margin: 0 0 10px; border-radius: 3px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.growth-meter::before { content: ""; display: block; width: var(--left); height: 100%; background: var(--gold); transition: width .15s ease; }
.growth-dialog p { margin: 0 0 6px; font-size: 13px; }
.growth-xp { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.growth-xp progress { flex: 1 1 8rem; height: 8px; accent-color: var(--accent); }
.growth-kit { color: var(--muted); }
.growth-reward { color: var(--warn); }
.growth-note { color: var(--muted); font-size: 12px !important; }
.growth-tabs { display: flex; gap: 6px; margin: 12px 0 10px; border-bottom: 1px solid var(--line); }
.growth-tabs button { min-height: 32px; padding: 0 12px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; margin-bottom: -1px; }
.growth-tabs button.active { border-color: var(--accent) var(--accent) #151f19; color: var(--accent); }
.growth-points strong { color: var(--warn); font-size: 16px; }
.growth-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.growth-table th, .growth-table td { padding: 4px 6px; text-align: right; white-space: nowrap; }
.growth-table th:first-child { text-align: left; }
.growth-table tbody th .ic { color: var(--muted); }
.growth-table thead th { color: var(--muted); font-size: 11px; font-weight: 400; letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.growth-table tbody tr + tr { border-top: 1px dashed var(--line); }
.growth-table tr.planned td:nth-child(3), .growth-table tr.planned td:nth-child(4) { color: var(--comp); font-weight: 700; }
.growth-steps { display: flex; justify-content: flex-end; gap: 4px; }
.growth-steps button { min-height: 32px; min-width: 32px; padding: 0; font-size: 16px; }
.growth-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 14px; }
.growth-actions button { min-height: 36px; padding: 0 14px; }
.growth-confirm { flex-basis: 100%; margin: 0 !important; color: var(--warn); text-align: right; }
.skill-confirm { margin: 8px 0 0 !important; color: var(--warn); text-align: left; }
/* The Skills tab (GrowthDialog): the AAC's chip on top, a column per branch under it, each
   skill a node coloured by Core's state for it, and the selected skill's details below. */
.skill-chip { display: flex; align-items: center; justify-content: center; gap: 8px; width: fit-content; margin: 4px auto 0; padding: 6px 14px; border: 1px solid #fff; border-radius: 6px; background: var(--well); color: #fff; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.skill-chip-core { font-size: 18px; line-height: 1; }
.skill-tree { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.skill-branch h3 { margin: 0 0 6px; color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; text-align: center; }
/* A branch is an outline: no gap between rows, so each row's guides join up into the tree's lines. */
.skill-row { display: flex; align-items: stretch; padding-bottom: 4px; }
.skill-guide { flex: none; width: 12px; margin-bottom: -4px; position: relative; }
.skill-guide.line::before, .skill-guide.tee::before, .skill-guide.corner::before { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; border-left: 1px solid var(--line); }
.skill-guide.corner::before { bottom: 50%; }
.skill-guide.tee::after, .skill-guide.corner::after { content: ""; position: absolute; left: 5px; right: 0; top: 50%; margin-top: -2px; border-top: 1px solid var(--line); }
.skill-node { flex: 1 1 0; min-width: 0; min-height: 40px; padding: 4px 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; white-space: normal; text-align: left; background: transparent; color: #dce5dc; border-color: var(--line); }
.skill-name { font-size: 12px; font-weight: 700; }
.skill-meta { font-size: 10px; color: var(--muted); letter-spacing: .04em; }
.skill-node.s-active { border-color: var(--comp); background: var(--comp-bg); }
.skill-node.s-active .skill-meta { color: var(--comp); }
.skill-node.s-learnable { border-color: var(--accent); }
.skill-node.s-learnable .skill-meta { color: var(--accent); }
.skill-node.s-inactive .skill-meta { color: var(--warn); }
.skill-node.s-replaced, .skill-node.s-needsparent { opacity: .6; }
.skill-node.s-planned { border-style: dashed; opacity: .6; }
.skill-node.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.skill-detail { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--well); }
.skill-detail-text { flex: 1; min-width: 0; }
.skill-learn { flex: none; min-height: 36px; padding: 0 14px; }
.skill-learned { flex: none; display: grid; place-items: center; width: 36px; height: 36px; color: #fff; font-size: 28px; }
.skill-tree-view:focus { outline: none; }
/* A dialog showing the tree doesn't scroll: the branches do, between the header above and the
   details and buttons below, under their branch names. A screen too short to leave them room
   scrolls the whole dialog as before. */
@media (min-height: 561px) {
    .modal-dialog.skill-dialog { display: flex; flex-direction: column; overflow: hidden; }
    .skill-dialog > *, .skill-dialog .skill-tree-view > * { flex: none; }
    .skill-dialog > .skill-tree-view { flex: 0 1 auto; display: flex; flex-direction: column; min-height: 0; }
    .skill-dialog .skill-tree-view > .skill-tree { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 4px 4px; }
    .skill-dialog .skill-branch h3 { position: sticky; top: -10px; z-index: 1; margin-top: -10px; padding: 10px 0 6px; margin-bottom: 0; background: #151f19; }
    .skill-dialog .skill-node { scroll-margin: 36px 0 4px; }
}
.skill-detail ul { margin: 4px 0; padding-left: 18px; font-size: 13px; }
/* The inspector's Skills section (UnitInspector): its head with the tree's button, then each
   learned skill — working, inactive (with why) or replaced (dimmed). */
.hi-box-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hi-box-row .hi-box-head { margin-bottom: 0; }
.hi-box-row button { min-height: 28px; padding: 0 10px; font-size: 11px; }
.hi-skill-list { margin: 6px 0 0; padding: 0; list-style: none; font-size: 12px; }
.hi-skill { display: flex; flex-wrap: wrap; gap: 2px 8px; padding: 3px 0; }
.hi-skill + .hi-skill { border-top: 1px dashed var(--line); }
.hi-skill-name { font-weight: 700; }
.hi-skill-state { color: var(--muted); }
.hi-skill.s-active .hi-skill-name, .hi-skill.s-active .hi-skill-state { color: var(--comp); }
.hi-skill.s-inactive .hi-skill-state { color: var(--warn); }
.hi-skill.s-replaced { opacity: .55; }
/* A phone: the cost and cap columns go, so the table fits without scrolling sideways. */
@media (max-width: 520px) {
    .growth-art { width: 84px; min-height: 84px; }
    .growth-table th:nth-child(5), .growth-table td:nth-child(5), .growth-table th:nth-child(6), .growth-table td:nth-child(6) { display: none; }
}

/* Reusable email-subscribe form: the welcome hero, the in-game modal, and the win dialog all embed it. */
.subscribe-form label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; text-align: left; }
.subscribe-form .input-row { gap: 8px; }
.subscribe-form .input-row input { flex: 1; min-width: 0; }
.subscribe-form form { margin: 0 0 12px; }
.subscribe-consent { padding-top:6px; margin: 6px 0 0; color: var(--muted); font-size: 11px; text-align: left; }
.subscribe-error { color: #e8a0a0; font-size: 13px; margin: 6px 0 0; text-align: left; }
.subscribe-thanks { color: var(--accent); margin: 0; }
/* Trap field: off-screen rather than display:none, which some bots detect and skip. */
.dialog-head { position: sticky; top: -24px; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: -24px -24px 12px; padding: 24px 24px 0; background: #151f19; }
.dialog-head h2 { margin: 0; text-align: left; }
.dialog-close { flex-shrink: 0; width: 44px; margin: -8px -10px 0 0; padding: 0; font-size: 28px; line-height: 1; border-color: transparent; }
.feedback-form label:not(.replay-choice) { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 13px; text-align: left; }
.feedback-form textarea { display: block; width: 100%; min-height: 110px; max-height: 40vh; resize: vertical; background: #1c2820; color: #f0f5ea; border: 1px solid #52604c; border-radius: 4px; font: inherit; font-size: 16px; padding: 11px; box-sizing: border-box; }
.feedback-form .replay-choice { align-items: flex-start; width: auto; text-align: left; line-height: 1.4; }
.feedback-form .replay-choice input { margin-top: 3px; }
.feedback-count { margin: 4px 0 0; color: var(--muted); font-size: 11px; text-align: right; }
.feedback-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; text-align: left; }
.feedback-details { margin: 0 0 4px 24px; color: var(--muted); font-size: 12px; text-align: left; }
.feedback-details summary { cursor: pointer; }
.feedback-details p { margin: 6px 0 0; }
.feedback-send { margin: 12px 8px 12px 0; }
.subscribe-trap { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* Welcome gate: the terminal panel's first screen, not a separate landing page. */
.hero { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 40px 24px; text-align: center; line-height: 1.65; }
.hero p { margin: 0; max-width: 62ch; }
.hero-pitch { font-size: 18px; color: var(--accent); }
.hero-type { display: inline-block; vertical-align: bottom; overflow: hidden; white-space: nowrap; width: calc(var(--chars) * 1ch); animation: type-on 1.8s steps(var(--chars), end) .2s both; }
.hero-cursor { color: var(--accent); animation: cursor-blink 1s steps(1) infinite; }
.hero-hook { font-size: 14px; }
.hero-premise { font-size: 13px; color: var(--muted); }
.hero-mobile { display: none; font-size: 12px; color: #f5dc8b; border: 1px dashed #b6a875; border-radius: 5px; padding: 8px 12px; }
.hero-start { font-size: 18px; letter-spacing: .08em; padding: .9rem 2.6rem; min-height: 56px; margin-top: 6px; box-shadow: 0 0 28px #d8e89f33; }
.hero-start::before { content: '> '; }
/* Auto margins above the pitch and the footer split the spare height: the content stays centred, the links sit at the bottom. */
.hero > :first-child { margin-top: auto; }
.hero-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; font-size: 12px; margin-top: auto; padding-top: 18px; width: 100%; }
.hero-links a { display: inline-block; padding: 3px 0; }
.hero-soon { color: var(--muted); }
.hero-journal { max-width: 460px; font-size: 12px; color: var(--muted); }
.hero-journal label { color: var(--text); white-space: nowrap; }
.hero-subscribe { width: 100%; max-width: 360px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 13px; }
@keyframes type-on { from { width: 0; } }
@keyframes cursor-blink { 50% { opacity: 0; } }
/* A wrapped line would clip mid-type, so narrow screens get the text at once. */
@media (max-width: 820px) { .hero-type { width: auto; white-space: normal; display: inline; animation: none; } }
@media (max-width: 600px), (pointer: coarse) { .hero-mobile { display: block; } }
@media (max-width: 600px) { .hero { padding: 24px 12px; gap: 14px; } .hero-pitch { font-size: 16px; } .hero-start { width: 100%; max-width: 320px; } }
@media (prefers-reduced-motion: reduce) { .hero-type { animation: none; } .hero-cursor { animation: none; } }
/* Scene art (welcome-scene-v2.webp, 1370 x 1148), cropped per screen size: the frame has the crop's
   shape, and the image is sized and shifted so the crop fills it. --crop-w, -x and -y are the crop's
   width and left/top edge in the master's pixels; margins in % are of the frame's width, so the shift
   scales with it. Desktop: 2.4:1, full width, y 175-745, at most 28% of the window's height. */
.hero-art { --crop-w: 1370; --crop-x: 0; --crop-y: 175; width: 100%; max-width: min(640px, 67.2dvh); aspect-ratio: 2.4; overflow: hidden; flex-shrink: 0; border: 1px solid var(--line); border-radius: 7px; background: #081b50; }
.hero-art img { display: block; height: auto; width: calc(1370 / var(--crop-w) * 100%); margin-left: calc(var(--crop-x) / var(--crop-w) * -100%); margin-top: calc(var(--crop-y) / var(--crop-w) * -100%); }
/* Tablet: 2:1, full width, y 150-835 (adds the robots' heads and more ground). */
@media (max-width: 949.98px) { .hero-art { --crop-y: 150; max-width: min(560px, 56dvh); aspect-ratio: 2; } }
/* Phone: 3:2, x 185-1185, y 160-827 (the ship and AACs, tentacle tips at the edges), the column's full width. */
@media (max-width: 600px) { .hero-art { --crop-w: 1000; --crop-x: 185; --crop-y: 160; max-width: none; aspect-ratio: 1.5; } }

/* Hull-defense welcome screen. Characters stay as separate transparent game assets so the crew
   reads clearly at wide and tablet widths without baking the layout into a single image. */
.welcome-landing { --wl-ink:#f5f7f0; --wl-muted:#d1d6cb; --wl-line:#ffffff38; --wl-lime:#d3ed73; position:relative; isolation:isolate; display:flex; flex-direction:column; width:100%; min-height:var(--viewport-height,100dvh); margin:0; padding:20px clamp(22px,5.4vw,78px) 22px; overflow:hidden; box-sizing:border-box; color:var(--wl-ink); background:#101713; }
.welcome-backdrop { position:absolute; z-index:-1; inset:0; background:linear-gradient(90deg,#0a110df2 0%,#0a110de8 28%,#101713aa 53%,#1017131a 100%),linear-gradient(0deg,#0a110df2 0%,transparent 45%,#0a110d55 100%),url('../art/hero.png') center 43% / cover no-repeat; transform:scale(1.015); }
.welcome-topline { display:flex; align-items:center; justify-content:space-between; gap:20px; color:#e0e4d9; font-size:10px; padding-bottom:12px; border-bottom:1px solid #ffffff25; }.welcome-topline a { color:inherit; text-decoration:none; }.welcome-brand { display:flex; align-items:center; gap:10px; }.welcome-brand img { border-radius:9px; }.welcome-brand > span { display:flex; flex-direction:column; gap:3px; }.welcome-brand small { color:#d1d6cb; font-size:8px; letter-spacing:.1em; }.welcome-brand strong { font-size:17px; font-weight:600; letter-spacing:-.05em; }.welcome-brand .sun { color:var(--wl-lime); }.welcome-topline nav { display:flex; gap:22px; margin-left:auto; }.welcome-topline nav a { font-size:10px; }
.welcome-hero-grid { display:grid; grid-template-columns:minmax(310px,.85fr) minmax(0,1.15fr); align-items:center; gap:12px; flex:1; min-height:clamp(380px,59vh,620px); }
.welcome-copy { z-index:1; padding:28px 0; max-width:580px; }.welcome-copy h1 { margin:0 0 22px; font-size:clamp(50px,7vw,94px); line-height:.88; letter-spacing:-.065em; font-weight:750; }.welcome-copy h1 em { color:var(--wl-lime); font-style:normal; }
.welcome-copy .hero-pitch { color:#f5f7f0; font-size:18px; text-align:left; margin:0 0 10px; }.welcome-copy .hero-hook { font-size:14px; text-align:left; margin:0; color:var(--wl-muted); }.welcome-copy .hero-premise { color:var(--wl-muted); font-size:13px; text-align:left; margin:0; }
.welcome-landing .hero-start { display:block; width:min(260px,100%); margin:25px 0 12px; text-align:center; padding:13px 20px; min-height:52px; color:#1b2412; background:var(--wl-lime); border:0; box-shadow:0 8px 30px #0003; font-weight:700; text-transform:none; letter-spacing:.02em; }.welcome-landing .hero-start:hover:not(:disabled) { background:#e4f99d; transform:translateY(-1px); }.welcome-landing .hero-start::before { content:none; }.welcome-landing .hero-start span { display:none; }
.welcome-lower { display:none; }
.welcome-landing .welcome-copy .hero-journal { width:min(430px,100%); margin:8px 0 0; text-align:left; color:#e0e4d9; font-size:10px; line-height:1.45; }.welcome-copy .hero-journal label { display:block; margin-bottom:4px; }.welcome-copy .hero-journal input { accent-color:var(--wl-lime); }
.welcome-landing .welcome-copy .hero-subscribe { width:min(430px,100%); max-width:none; margin:10px 0 0; padding-top:8px; border-top:1px solid #ffffff25; text-align:left; }.welcome-copy .hero-subscribe .subscribe-form label { text-align:left; }.welcome-landing .hero-links { padding-top:6px; margin-top:6px; }
@media (max-width:900px) { .welcome-landing { min-height:calc(100dvh - 100px); }.welcome-hero-grid { grid-template-columns:minmax(260px,.9fr) minmax(0,1.1fr); min-height:430px; }.welcome-backdrop { background-position:58% center; } }
@media (max-width:680px) { .welcome-landing { min-height:var(--viewport-height,100dvh); padding:15px 17px 18px; }.welcome-topline { font-size:8px; letter-spacing:.08em; }.welcome-brand img { width:32px; height:32px; }.welcome-brand small { font-size:7px; }.welcome-brand strong { font-size:14px; }.welcome-topline nav { gap:12px; margin-left:14px; }.welcome-protocol { display:none; }.welcome-hero-grid { display:flex; flex-direction:column; align-items:stretch; gap:0; padding-top:5px; }.welcome-copy { padding:16px 0 22px; }.welcome-copy h1 { font-size:clamp(48px,13vw,74px); }.welcome-backdrop { background-position:62% center; background-image:linear-gradient(90deg,#0a110dcf 0%,#0a110d85 55%,#10171330 100%),linear-gradient(0deg,#0a110df2 0%,transparent 55%,#0a110d44 100%),url('../art/hero.png'); }.welcome-lower { grid-template-columns:1fr; }.welcome-promise { padding:9px 6px; border-right:0; border-bottom:1px solid #ffffff38; flex-direction:row; align-items:center; gap:14px; }.welcome-promise span { min-width:94px; }.welcome-landing .hero-start { max-width:none; }.welcome-landing .hero-journal { font-size:11px; }.welcome-landing .hero-journal label { white-space:normal; } }

/* Story, Privacy and Credits pages: normal scrolling pages, not the fixed-height game shell. */
.story-page { max-width: 760px; margin: auto; padding: 0 24px 40px; }
.story-home { color: inherit; text-decoration: none; }
.story-back { display: inline-block; padding: 6px 0; font-size: 12px; white-space: nowrap; }
.story { margin-top: 20px; padding: 24px; line-height: 1.75; font-size: 14px; }
.story h3 { font-size: 13px; font-weight: 500; color: var(--accent); margin: 24px 0 6px; }
.story p { margin: 0 0 12px; }
.story-logline { color: var(--muted); font-style: italic; margin-top: 12px !important; }
.story-cta { margin-top: 28px !important; text-align: center; font-size: 16px; }
.story-cta a, .story-subscribe a { display: inline-block; padding: 4px 0; }
.story-subscribe { text-align: center; font-size: 13px; color: var(--muted); }
@media (max-width: 600px) { .story-page { padding: 0 12px 24px; } .story { padding: 16px; font-size: 13px; } }
.info-page { --wl-ink:#f5f7f0; --wl-muted:#d1d6cb; --wl-lime:#d3ed73; position:relative; isolation:isolate; width:min(1440px,100%); min-height:var(--viewport-height,100dvh); margin:auto; padding:20px clamp(22px,5.4vw,78px) 40px; color:var(--wl-ink); background:#101713; }
.info-page .welcome-backdrop { position:fixed; z-index:-1; inset:0; background:linear-gradient(90deg,#0a110de8 0%,#0a110db8 48%,#10171394 100%),linear-gradient(0deg,#0a110de8 0%,transparent 70%),url('../art/hero.png') center 43% / cover no-repeat; }
.info-page .content-page-header { margin-bottom:clamp(24px,6vh,64px); }
.content-page-back { color:#f5f7f0; text-decoration:none; padding:8px 12px; border:1px solid #ffffff50; border-radius:4px; font-size:12px; }
.content-page-back:hover { border-color:var(--wl-lime); color:var(--wl-lime); }
.info-page .story { max-width:860px; margin:0 auto; padding:clamp(20px,4vw,36px); border:1px solid #ffffff38; background:#101713d9; backdrop-filter:blur(8px); color:var(--wl-ink); }
.info-page .story h2 { color:var(--wl-lime); }
.info-page .story h3 { color:#dce8bf; }
.info-page .story-logline,.info-page .story-subscribe { color:#c1c9bc; }
@media (max-width:600px) { .info-page { padding:15px 14px 24px; }.info-page .content-page-header { margin-bottom:24px; }.info-page .welcome-brand small { max-width:250px; }.info-page .story { padding:16px; font-size:13px; } }

/* Build note under the title in the header. */
.build-note { display: inline-block; margin: 8px 0 0; padding: 3px 8px; font-size: 11px; color: var(--accent); background: #2a3b24; border: 1px solid #4a5f3c; border-radius: 4px; }
@media (max-width: 600px) { .build-note { font-size: 10px; } }
@media (max-height: 500px) { .build-note { display: none; } }
/* Layout breakpoints, kept in step everywhere (header, status bar, Hangar, cards):
     width  ≤ 600 phone · 601–949 tablet · ≥ 950 desktop
     height < 650 too short for the Hangar's two rows · < 880 short (short cards, one-line tip,
            the Icon key behind a button) · ≥ 1250 tall (the full header, desktop width only)
   The Hangar's two-row layout needs desktop width and ≥ 650 tall; anything else uses tabs.
   A touch screen (pointer: coarse) has taller controls: it always uses the short cards, keeps
   the short screen's one-line tip and Icon key button up to 1000 tall, and needs ≥ 840 tall
   for two rows. browser.js repeats the two-row and short-screen queries; keep them in step.
   Every switch reads the window's own size, never the space left over, so none feeds another.
   A compact header, one line high, everywhere except a tall desktop window: the eyebrow goes,
   the title and logo shrink, the build note sits beside the title and the buttons get
   smaller, so the game area keeps the height. */
@media (max-width: 949.98px), (max-height: 1249.98px) {
    .masthead { padding: 8px 0; }
    .masthead-title { gap: 10px; }
    .masthead-title > div { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 10px; }
    .masthead .eyebrow { display: none; }
    .masthead h1 { font-size: clamp(16px, 2.6vw, 20px); }
    .masthead-logo { width: 26px; height: 26px; border-radius: 6px; }
    .masthead .build-note { margin: 0; padding: 1px 6px; font-size: 10px; }
    .masthead-actions { gap: 6px; }
    .masthead-actions button { min-height: 32px; padding: .3rem .7rem; font-size: 12px; }
}

/* ── Board screens: Deployment, Battle and the battle's end ──────────────────────────────
   The board is centred in the panel as pointy-topped hexes on a grid of half-hex columns
   (BoardModel.cs places them: a row drawn half a hex in starts one half-column later, and each
   hex is a third taller than its row, so the rows interlock and every hex touches its six
   neighbours). The Hull is one block over its footprint, clipped to its hexes. Under
   the board: the icon key and the replay controls; in Battle the key row's Lost button opens
   the lost list in a pop-up. In Deployment the companions to place queue on the Hull.
   The board screen fills the game area: everything under the board takes the height it
   needs and the board takes the rest, scrolling inside itself (the page does not scroll).
   Tunable values — change them together (and with browser.js's board section):
     board width cap ............ 1920px (.app-shell.board-mode)
     screen class ............... picked by browser.js from the board area's width (large from
                                  1200px, medium from 700px, small below) → .size-* classes
     hex size (fixed) ........... width × row pitch: large 112×75 · medium 96×64 · small 72×48
                                  (--cw, --chh); each hex is 4/3 of the pitch tall (112×100)
     tile text .................. large 12px · medium 10.5px · small 9.5px (--tile-font)
     tile tiers (tile's inner width; about 14px less than the cell)
                                  Compact under 66px (small): order, id, HP, attack,
                                  armor; Full from 66px (large, medium): adds name, move,
                                  range, pattern and type
     board height ............... what the game area leaves after the key row; at least
                                  120px; the board scrolls inside it
     enlarged tile .............. large 260px, medium 220px wide over its neighbours; small:
                                  a sheet at the bottom of the board instead
     mini map ................... large 180px and medium 150px, floating top right (large open
                                  by default, medium closed); small: a bar above the board with
                                  the map (110px tall, closed by default) under it; hidden
                                  when the whole board fits
     edge markers ............... enemies out of view, by side, with a count
     lost this battle ........... a pop-up from its button in the key row: the lost
                                  companions as crossed-out hexes, then the enemy tally */
:root { --comp: #b3e991; --comp-bg: #15241a; --comp-line: #3d6a38; --enemy: #ff8577; --enemy-bg: #230f0d; --enemy-line: #e0483a; --act: #80dce5; --reach-fill: #1f6680; --warn: #f5dc8b; --spot: #ff5fd2; --glitch: #c9a2f0; --well: #131d17;
    --gold: #e3c254; --gold-dim: #a48d3c; --foe-reach: #4e1c17; --move-w: 3px; --move-hover: 8px; }
.app-shell.board-mode { max-width: 1920px; }
.game-body { container: game / inline-size; }
/* The board screens fill the game area as a column; only the board grows. If the screen is
   too short even for the board's minimum, the game area scrolls as a fallback. */
.board-body { display: flex; flex-direction: column; }
.state-panel.board-mode { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.state-panel.board-mode > .recap { flex-shrink: 0; margin: 0; }
.board-screen { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.board-screen > :not(.board-main) { flex-shrink: 0; }
/* The screen classes: one fixed tile size each (browser.js picks the class). */
.size-large { --cw: 112px; --chh: 75px; --tile-font: 12px; --exp-w: 260px; }
.size-medium { --cw: 96px; --chh: 64px; --tile-font: 10.5px; --exp-w: 220px; }
.size-small { --cw: 72px; --chh: 48px; --tile-font: 9.5px; --move-w: 2px; --move-hover: 6px; }
/* The board's row: the frame, and on a large or medium screen the inspector docked on its
   right (as in the Hangar). It takes the height the key row leaves. The frame holds the mini
   map and the view: the board itself and its edge markers. */
.board-main { position: relative; flex: 1 1 0; min-height: 160px; display: flex; gap: 10px; }
.board-frame { position: relative; flex: 1 1 0; min-width: 0; min-height: 160px; display: flex; flex-direction: column; }
.board-view { position: relative; flex: 1 1 0; min-height: 120px; display: flex; }
.board-screen kbd, .panel-note kbd { font: inherit; color: var(--accent); background: #1c2a22; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

/* The board's background lightens toward the top as the night goes on (--dawn, 0 to 1). */
/* The board pans by dragging (browser.js) as well as by scrolling; nothing on it is text to select. */
.battlefield { flex: 1 1 0; min-width: 0; overflow: auto; cursor: grab; user-select: none; -webkit-user-select: none; overscroll-behavior: contain; touch-action: pan-x pan-y; padding: 4px; border-radius: 6px;
    background: linear-gradient(to bottom, rgb(245 220 139 / calc(var(--dawn, 0) * .18)), transparent 45%), #0e1612; }
.battlefield.dragging, .battlefield.dragging .tile { cursor: grabbing; }
/* Room above the top row for its units' pictures and the panels over their heads (.t-art, .t-label). */
.board-sizer { width: calc(var(--half-cols) * var(--cw) / 2); margin: 0 auto; padding-top: calc(var(--chh) * .6); }
/* The board (.board) carries its ground in two layers under its hexes, bottom up:
     ground (::before) ... art/battle/ground.png, a seamless 512px tile of
                           cracked slate bedrock seen from above, repeated from the board's
                           top-left corner, under the Hull too;
     depth (::after) ..... night darkening the ground toward the far edge, where enemies spawn,
                           and the dawn's light (--dawn) coming in from there (--depth-far is
                           how dark the far edge is).
   Both are out of the grid's flow (absolute) and behind its cells (z-index -1 inside the board,
   which is its own stacking context), and fade into the battlefield at the sides and the top. */
.board { position: relative; z-index: 0; --depth-far: .78;
    --edge-fade: linear-gradient(to right, transparent, #000 4% 96%, transparent), linear-gradient(to bottom, transparent, #000 8%); }
.board::before, .board::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    -webkit-mask-image: var(--edge-fade); -webkit-mask-composite: source-in; mask-image: var(--edge-fade); mask-composite: intersect; }
.board::before { background: url("art/battle/ground.png") 0 0 / 512px 512px repeat; }
.board::after { background:
    linear-gradient(to bottom, rgb(245 220 139 / calc(var(--dawn, 0) * .16)), transparent 45%),
    linear-gradient(to bottom, rgb(8 12 10 / var(--depth-far)), rgb(8 12 10 / calc(var(--depth-far) * .45)) 45%, rgb(8 12 10 / .08) 85%, transparent); }
/* A hex is two half-columns wide (--cw) and --chh is the row pitch: fixed for the screen class.
   The hex itself is a third taller than its row (4/3 --chh): pointy-topped, its top and bottom
   points reach into the rows above and below, between their hexes. The last row's points hang
   below the grid, so the board keeps that third of a row under it. */
.board { display: grid; grid-template-columns: repeat(var(--half-cols), calc(var(--cw) / 2)); grid-auto-rows: var(--chh); padding-bottom: calc(var(--chh) / 3); }
.board > :is(.cell, .hull) { align-self: start; }
.board > .cell { height: calc(var(--chh) * 4 / 3); }
/* Only a hex takes a click, never the corners of its box (where the neighbouring rows' hexes
   are): the cells' boxes and the tiles let clicks through, and what takes them is clipped to
   the hex (a move's button, a tile's ground, the Hull's plating), or is the acting unit's strip. */
.board > .cell, .tile, .hull { pointer-events: none; }
.board > .cell > :is(.slot-button, .t-dock), .tile::before, .hull-shape { pointer-events: auto; }

/* A hex: an empty well with a centre dot, or a unit's tile. Each cell is a size container,
   so its tile can show as much as fits. */
.cell { position: relative; container: cell / inline-size; padding: 2px; min-width: 0; }
/* A hex's ground: a box clipped to a hexagon (--hex). A clipped border or box shadow would keep
   only the two straight sides, so its edge is drawn inside it by gradients: one strip down each
   side and one diagonal band in each corner, each --hex-w wide at right angles to its edge.
   Rules set --hex-fill (the ground), --hex-edge (the edge's colour) and --hex-w; --hex-art adds
   up to two more layers over the fill (a tile's stripes and highlight). The cells' ground is
   their ::before; a unit's is its tile's ::before; a move destination's hover edge is its button's. */
:root { --hex: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
:is(.cell.empty, .cell.spot-reach, .rm-self-cell)::before { content: ""; position: absolute; inset: 2px; }
:is(.cell.empty, .cell.spot-reach, .rm-self-cell)::before, .tile::before, .slot-button {
    clip-path: var(--hex); background-color: var(--hex-fill, transparent); background-repeat: no-repeat;
    background-image:
        linear-gradient(to top left, transparent calc(50% - var(--hex-w, 1px)), var(--hex-edge, transparent) 0 50%, transparent 0),
        linear-gradient(to top right, transparent calc(50% - var(--hex-w, 1px)), var(--hex-edge, transparent) 0 50%, transparent 0),
        linear-gradient(to bottom left, transparent calc(50% - var(--hex-w, 1px)), var(--hex-edge, transparent) 0 50%, transparent 0),
        linear-gradient(to bottom right, transparent calc(50% - var(--hex-w, 1px)), var(--hex-edge, transparent) 0 50%, transparent 0),
        linear-gradient(to right, var(--hex-edge, transparent) var(--hex-w, 1px), transparent 0),
        linear-gradient(to left, var(--hex-edge, transparent) var(--hex-w, 1px), transparent 0),
        var(--hex-art, none);
    background-size: 50% 25%, 50% 25%, 50% 25%, 50% 25%, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
    background-position: 0 0, 100% 0, 0 100%, 100% 100%, 0 0, 0 0, 0 0, 0 0; }
/* A hex's ground (--cell-bg): none on the board (Deployment and Battle alike), where the
   board's own background shows and only the faint grid, reach, moves and units mark the hexes;
   a well elsewhere (the inspector's reach map outside the board). */
.board-screen { --cell-bg: transparent; }
.cell.empty::before { --hex-fill: var(--cell-bg, var(--well)); transition: background-color .14s ease; }
.cell.empty::after { content: ""; position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px; border-radius: 50%; background: #2c3b31; }
/* Two layers that can overlap: what the acting unit can reach is a bright blue fill (no
   outline, --reach-fill, strong enough to lead over the gold);
   where it can move is a gold border drawn inside the hex (--move-w), which grows further
   inward under the pointer or focus (--move-hover), so it never spills onto a neighbour. A hex
   it can both move to and reach shows both. Deployment's free slots use the same gold border,
   with their number. */
.cell.in-range::before { --hex-fill: var(--reach-fill); --hex-edge: transparent; }
.cell.slot-cell::before { --hex-fill: transparent; --hex-edge: var(--gold); --hex-w: var(--move-w); }
.cell.slot-cell.in-range::before { --hex-fill: var(--reach-fill); --hex-edge: var(--gold); --hex-w: var(--move-w); }
.cell.slot-cell::after { display: none; }
.slot { position: absolute; inset: 0; display: grid; place-items: center; color: var(--warn); font-size: clamp(10px, 20cqw, 17px); font-weight: 700; }
/* A free slot or move destination is a button over the hex, clipped to it so only the hex
   takes the click (the points of the rows above and below reach into its box). */
.slot-button { width: 100%; height: 100%; min-height: 0; padding: 0; border: 0; border-radius: 0; font: inherit; font-size: clamp(10px, 20cqw, 17px); font-weight: 700; color: var(--warn); cursor: pointer;
    transition: background-color .14s ease; }
.slot-button:hover, .slot-button:focus-visible { --hex-fill: rgb(227 194 84 / .12); --hex-edge: var(--gold); --hex-w: var(--move-hover); outline: none; filter: none; }
@media (prefers-reduced-motion: reduce) { .slot-button, .cell.empty::before { transition: none; } }
.in-range .slot { color: var(--act); }
/* A selected unit that isn't acting (Board's Spotlight): its moves and reach, in its side's
   colours, in place of the acting companion's. A companion's moves are a dimmer gold (it can't
   move now); an enemy's are red, and so is its reach. */
.cell.spot-reach::before { --hex-fill: var(--reach-fill); }
.cell.spot-reach.foe::before { --hex-fill: var(--foe-reach); }
.cell.spot-move::before { --hex-fill: transparent; --hex-edge: var(--gold-dim); --hex-w: var(--move-w); }
.cell.spot-move.foe::before { --hex-edge: var(--enemy-line); }
.cell.spot-move.spot-reach::before { --hex-fill: var(--reach-fill); }
.cell.spot-move.spot-reach.foe::before { --hex-fill: var(--foe-reach); }
.cell.spot-move::after { display: none; }
/* The board (Deployment and Battle): softer marks on the bare ground, so the units lead. A
   move (or a free deploy slot) is a faint gold fill and a gold dot at the hex's centre, its
   full border only under the pointer or focus (.slot-button:hover); reach is a slightly
   see-through blue. A selected unit's moves are the same in dim gold, an enemy's in red. */
.board-screen {
    --move-fill: rgb(227 194 84 / .1); --move-edge: rgb(227 194 84 / .3); --reach-soft: rgb(31 102 128 / .7);
}
/* The grid: every hex, and the ground under every unit, faintly outlined (--grid-line, the
   weakest line on the board, under the move edge); no centre dots, so a dot means a move. */
.board-screen { --grid-line: rgb(255 255 255 / .05); }
.board-screen .cell.empty::before { --hex-edge: var(--grid-line); --hex-w: 1px; }
.board-screen .cell.empty:not(.slot-cell, .spot-move, .fx-trail)::after { display: none; }
.board-screen .cell.in-range::before { --hex-fill: var(--reach-soft); }
.board-screen .cell.slot-cell::before { --hex-fill: var(--move-fill); --hex-edge: var(--move-edge); --hex-w: 1px; }
.board-screen .cell.slot-cell.in-range::before { --hex-fill: var(--reach-soft); --hex-edge: var(--move-edge); --hex-w: 1px; }
.board-screen .cell:is(.slot-cell, .spot-move)::after { display: block; z-index: 1; width: 6px; height: 6px; margin: -3px; pointer-events: none;
    background: var(--gold); box-shadow: 0 0 6px rgb(227 194 84 / .6); }
.board-screen .cell.spot-move::before { --hex-fill: rgb(227 194 84 / .06); --hex-edge: rgb(164 141 60 / .35); --hex-w: 1px; }
.board-screen .cell.spot-move.foe::before { --hex-fill: rgb(224 72 58 / .1); --hex-edge: rgb(224 72 58 / .35); --hex-w: 1px; }
.board-screen .cell.spot-move.spot-reach::before { --hex-fill: var(--reach-soft); }
.board-screen .cell.spot-move.spot-reach.foe::before { --hex-fill: var(--foe-reach); }
.board-screen .cell.spot-reach::before { --hex-fill: var(--reach-soft); }
.board-screen .cell.spot-reach.foe::before { --hex-fill: var(--foe-reach); }
.board-screen .cell.spot-move::after { background: var(--gold-dim); box-shadow: none; }
.board-screen .cell.spot-move.foe::after { background: var(--enemy-line); }

/* A unit's tile, filling its cell and a size container itself: the unit standing on its hex (no
   card, no shadow) with a small panel over its head (.t-label), in its side's colour. The
   border shows only while waiting. Its ground (--ground) carries the acting unit's marks:
   blue in its reach, red where its attack would hit, green where its repair would heal. A
   fill alone marks a hex something happens to; a fill with an inset edge (--hl and the box
   shadow) marks the unit itself: white for the unit the inspector shows (selected, or in
   Battle the acting unit when nothing is), red for the enemy acting now. The acting
   companion has no mark of its own: its Attack and End turn strip sits under it. Text is in
   --tf, fixed per screen class. */
.tile { position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 1; width: calc(100% - 4px); height: calc(100% - 4px);
    container: tile / inline-size; --tf: var(--tile-font, 11px); font-size: var(--tf); --hl: none; --stripes: none;
    --hex-edge: transparent; --hex-w: 1px; color: #dce5dc; line-height: 1.05; cursor: pointer; user-select: none; }
/* Its hex: the ground, the stripes and highlight over it, and its edge (the hex ground rule above). */
.tile::before { content: ""; position: absolute; inset: 0; --hex-fill: var(--ground, var(--cell-bg, var(--well))); --hex-art: var(--stripes), var(--hl); }
.board-screen .tile { --hex-edge: var(--grid-line); }
.tile.waiting { --hex-edge: var(--line-c); }
/* A unit's hex in the acting unit's reach is blue like an empty one, so the reach has no gaps;
   one its attack would hit now is red (an enemy in reach it can't hit, a flyer, stays blue),
   one its repair would heal green; both stronger while Attack (or Repair) is aimed. With
   another unit selected, the hexes of units in its reach take its reach colour. */
.board-screen .cell.in-range .tile { --ground: var(--reach-soft); }
.board-screen .cell.spot-reach .tile { --ground: var(--reach-soft); }
.board-screen .cell.spot-reach.foe .tile { --ground: var(--foe-reach); }
/* The action mode (Attack or Repair pressed): the current facing's area shaded stronger; an
   enemy the attack reaches orange, an ally the repair reaches green, each with a mark (the
   attack or repair icon, so the colour never stands alone); under the pointer (or the first tap
   on a touch screen) the units the click would hit red, those it would repair dark green, each
   with a thicker edge and its HP change. */
.board-screen.act-mode .cell.in-range::before { --hex-fill: rgb(40 140 176 / .8); --hex-edge: rgb(128 220 229 / .5); --hex-w: 1px; }
.board-screen.act-mode .cell.in-range .tile { --ground: rgb(40 140 176 / .8); }
.board-screen.act-mode .cell .tile.act-foe { --ground: rgb(255 158 44 / .5); --hex-edge: rgb(255 158 44); --hex-w: 2px; }
.board-screen.act-mode .cell .tile.act-hit { --ground: rgb(232 48 38 / .72); --hex-edge: #ff6a5a; --hex-w: 3px; }
.board-screen.act-mode .cell .tile.act-ally { --ground: rgb(63 191 74 / .45); --hex-edge: rgb(63 191 74); --hex-w: 2px; }
.board-screen.act-mode .cell .tile.act-mend { --ground: rgb(14 96 34 / .85); --hex-edge: #a6f0aa; --hex-w: 3px; }
.tile .t-mark { position: absolute; left: 50%; bottom: 8%; z-index: 2; translate: -50% 0; display: grid; place-items: center;
    width: 1.7em; height: 1.7em; border-radius: 50%; border: 1px solid #0008; pointer-events: none; }
.tile .t-mark .ic { width: 1.1em; height: 1.1em; }
.tile.act-foe .t-mark { background: rgb(255 158 44); color: #2a1600; }
.tile.act-hit .t-mark { background: #ff5a4a; color: #fff; }
.tile.act-ally .t-mark { background: rgb(63 191 74); color: #0d1a0f; }
.tile.act-mend .t-mark { background: #0e6022; color: #fff; }
/* A consumable from the ⋯ menu waiting for whom to use it on: the units it can help, lit green. */
.board-screen .cell .tile.item-target { --ground: rgb(63 191 74 / .55); }
.tile.acting { z-index: 3; }
.tile.selected { z-index: 4; --hl: linear-gradient(rgb(255 255 255 / .12), rgb(255 255 255 / .12)); --hex-edge: rgb(255 255 255 / .5); --hex-w: 1.5px; }
.tile:focus-visible { outline: none; --hex-edge: var(--accent); --hex-w: 2px; }
/* The picture stands where the hex's lower sides end (the bottom of its row, 22% up the tile)
   and is 89% of the tile tall (with the hex a third taller than its row, as tall as the old
   3:2 tile's 119%), so it rises 11% above the hex's top point, over the hexes
   behind it: tiles share one z-index and the board lists rows top first, so a unit lower on
   the screen stands in front. It never takes a click (the hex behind it does), and it is at
   most a little wider than its tile (105cqw), so a wide sprite doesn't cover its neighbours.
   Every sheet is framed alike (the figure as large as its square frame allows, feet on its
   bottom edge), so the frame is the box's height; mirrored for the left-facing directions.
   Scaled smoothly: the board's art is not held to a pixel grid. The
   img shows one square frame of its unit's sheet (--frame-x). Over it, the same size, .t-tint
   is a colour masked by that frame, so a replay's flash covers the figure only. */
.t-art { position: absolute; left: 0; right: 0; bottom: 22%; height: 89%; pointer-events: none; }
.t-sprite { aspect-ratio: 1; object-fit: cover; object-position: var(--frame-x, 50%) 0; }
.t-sprite, .t-tint { position: absolute; left: 50%; bottom: 0; height: min(100%, 105cqw); width: auto; max-width: none; translate: -50% 0; }
.t-sprite.mirror, .t-tint.mirror { scale: -1 1; }
.t-tint { display: none; aspect-ratio: 1; -webkit-mask-size: 300% 100%; mask-size: 300% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: var(--frame-x, 50%) 0; mask-position: var(--frame-x, 50%) 0; }
/* A tile in the lost tray: the picture stays inside the tile. */
.tile.lost .t-art { inset: 3px; height: auto; overflow: hidden; clip-path: var(--hex); }
.tile.done .t-sprite { filter: saturate(.55) brightness(.8); }   /* acted this turn */
.tile.companion { --line-c: var(--comp-line); --tint: var(--comp); }
.tile.enemy { --line-c: var(--enemy-line); --tint: var(--enemy); }
.tile.acting { scale: 1.05; }
.tile.enemy.acting { --hl: linear-gradient(rgb(255 90 74 / .15), rgb(255 90 74 / .15)); --hex-edge: rgb(255 90 74 / .8); --hex-w: 2px; }
.tile.stunned { --stripes: repeating-linear-gradient(135deg, transparent 0 5px, rgb(245 220 139 / .12) 5px 10px); }

/* Over the unit's head, at one height on every unit (the top of the picture's box), a small
   panel like the action strip: the action order (► when acting) at the left, and beside it in
   two rows the heart and HP (red when low) with the id after them, then a thin HP bar and the
   status badges. It takes no clicks: the hex behind it does. A unit lower on the screen draws
   its panel over the feet of those above it; nothing covers a panel but the acting or
   selected unit's. On small tiles the id shows only on the hovered or selected unit. */
.t-label { position: absolute; left: 50%; bottom: calc(111% + 3px); translate: -50% 0; z-index: 2; display: flex; align-items: center; gap: 3px;
    padding: 2px 5px 2px 2px; border: 1px solid var(--line-c); border-radius: 7px; background: rgb(11 16 13 / .82); box-shadow: 0 2px 6px #000a;
    white-space: nowrap; pointer-events: none; }
.t-label:not(:has(.t-order, .t-acting, .t-kill)) { padding-left: 5px; }   /* no order badge (Deployment): the HP and bar keep off the edge */
.t-rows { display: flex; flex-direction: column; gap: 2px; }
.t-meter { display: flex; align-items: center; gap: 3px; }
.t-id { margin-left: .4em; font-size: .85em; opacity: .75; }
.size-small .tile:not(:hover, :focus-visible, .selected) .t-id { display: none; }
/* The lost tray has no room above its tiles: the panel sits inside, at the top. */
.tile.lost .t-label { bottom: auto; top: 8%; }
.t-order, .t-acting { display: inline-grid; place-items: center; min-width: 1.6em; height: 1.6em; padding: 0 .2em;
    border-radius: 999px; font-size: .9em; font-weight: 700; background: var(--tint); color: #111916; box-shadow: 0 1px 2px #000; }
.t-acting { background: var(--act); }
.tile.enemy .t-acting { background: #ff8a7a; }
.tile.done .t-order { background: #0b110d; color: var(--tint); box-shadow: inset 0 0 0 1px var(--tint), 0 1px 2px #000; }
.t-id, .t-num { color: var(--tint); font-weight: 700; text-shadow: 0 1px 2px #000, 0 0 2px #000; }
.t-hp { display: inline-flex; align-items: center; gap: 2px; }
.t-hp > .ic { width: .9em; height: .9em; color: var(--tint); filter: drop-shadow(0 1px 1px #000); }
.tile.low :is(.t-num, .t-hp > .ic) { color: #e0625a; }
/* The HP bar: thin, at least the same width on every unit, so the fill is the share of max HP; the pending
   attack's loss (pale) or repair's gain (green) pulses on it. */
.t-bar { position: relative; flex: 1; min-width: 3.2em; height: 3px; border-radius: 2px; background: #2a332d; overflow: hidden; }
.t-bar > span:first-child { display: block; height: 100%; background: var(--tint); }
.tile.low .t-bar > span:first-child { background: #e0625a; }
.t-delta { position: absolute; top: 0; height: 100%; animation: delta-pulse 1.2s ease-in-out infinite; }
.t-delta.damage, .t-delta.lethal { background: #ffd0c8; }
.t-delta.heal { background: #7fe07a; }
@keyframes delta-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .t-delta { animation: none; } }
.ic { width: 1.05em; height: 1.05em; flex-shrink: 0; vertical-align: -.15em; }
.t-badges { display: flex; gap: 2px; }
.t-badge { display: inline-flex; align-items: center; gap: 1px; padding: 0 .2em; border-radius: 3px; font-size: .75em; line-height: 1.2; font-weight: 700; }
/* Boosts are green, apart from the warm troubles: a shield (ringed, its amount per hit) and
   Fortress (solid, its turns left). */
.t-badge.boost { background: #1d3d27; color: #9ef0a8; box-shadow: 0 0 0 1px #4fae5e; }
.t-badge.boost.fort { background: #9ef0a8; color: #111916; box-shadow: none; }
.t-badge.stun { background: var(--warn); color: #111916; }
.t-badge.cool { background: #213645; color: var(--act); }
.t-badge.bleed { background: #5a2626; color: #ffb4a8; }
.t-badge.glitch { background: #4b2f63; color: var(--glitch); font-size: .85em; box-shadow: 0 0 0 1px var(--glitch); }   /* ringed: a glitch is lasting damage worth spotting */
/* What the active unit's attack or repair would leave this unit at, after its HP: "40→5",
   "60→80", or the kill icon when it would destroy it. */
.t-change { flex-shrink: 0; display: inline-flex; align-items: center; font-weight: 700; text-shadow: 0 1px 2px #000, 0 0 2px #000; }
.t-change.damage { color: #ff8a7a; }
.t-change.lethal { color: #ff3b2f; }
.t-change.heal { color: #7fe07a; }
.t-change .ic { width: 1.1em; height: 1.1em; }
/* A small board: only the result (→100; its colour says damage or repair), so a preview keeps
   the label as narrow as the tile and neighbours' labels don't run into each other. */
.size-small .t-hp:has(> .t-change) > :is(.t-num, .ic) { display: none; }
/* A kill: the skull in place of the action-order badge (as large), white on a red disc with a
   white ring, so it reads on a red-lit tile. It holds still (no pulse).
   The HP beside it reads 0, in the kill's red. */
.t-num.lethal { color: #ff3b2f; }
.t-kill { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; flex: none; border-radius: 50%; background: #e8302a; color: #fff;
    box-shadow: 0 0 0 1px #fff, 0 1px 3px #000; }
.t-kill .ic { width: 1em; height: 1em; }

/* With a mouse on a large or medium board (Board.TileActions), the acting companion's own
   controls sit just under its tile (.t-dock; over it on the board's last two rows, .flip):
   the strip, Turn (↻, which turns a step a press and opens the six facings in a grid under it,
   FacingCompass), Attack as an icon, Repair (a repair weapon's) as an icon, More (⋯, which opens the
   unit's reactors and consumables in a menu under it, .t-more-menu; greyed out with none), then
   after a gap End turn in words and the accent colour, as the turn's last step. */
.t-dock { position: absolute; top: calc(100% + 3px); left: 50%; translate: -50% 0; z-index: 7; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.t-dock.flip { top: auto; bottom: calc(100% + var(--chh) * .35); flex-direction: column-reverse; }
/* In the board's first and last columns, lined up with the tile's outer side, not centred, so
   the board's edge doesn't cut off the strip, the facings or the menu. */
.t-dock.at-left { left: 0; translate: 0 0; align-items: flex-start; }
.t-dock.at-right { left: auto; right: 0; translate: 0 0; align-items: flex-end; }
.t-strip { display: flex; align-items: center; gap: 2px; padding: 2px;
    border: 1px solid var(--act); border-radius: 6px; background: #0b100d; box-shadow: 0 4px 12px #000c; }
.t-compass { padding: 6px 8px; border: 1px solid var(--act); border-radius: 8px; background: #0b100d; box-shadow: 0 4px 12px #000c; }
.t-compass[hidden] { display: none; }
.t-compass .facing-compass { --fc: 26px; }
.t-more-menu, .ab-more { padding: 4px; border: 1px solid var(--act); border-radius: 8px; background: #0b100d; box-shadow: 0 4px 12px #000c; }
.t-more-menu[hidden], .ab-more[hidden] { display: none; }
.more-menu { display: flex; flex-direction: column; gap: 2px; min-width: 150px; }
.more-menu button { justify-content: flex-start; min-height: 26px; padding: 3px 8px; color: var(--act); font-size: 12px; text-align: left; white-space: nowrap; }
.more-menu button:disabled { opacity: .45; cursor: not-allowed; }
.t-strip .t-more.active, .ab-more-toggle.active, .action-bar .ab-more-toggle.active { background: var(--act); color: #0b1a1c; }   /* dark text on cyan, over the bar's cyan "active" text */
.t-strip button { position: relative; display: grid; place-items: center; width: 22px; height: 22px; min-height: 0; padding: 0;
    border: 1px solid #2f6c74; border-radius: 4px; background: #12343a; color: var(--act); font-size: 13px; font-weight: 700; line-height: 1; }
/* Turn: solid cyan, as Attack is, open or not; dark once disabled. */
.t-strip .t-turn { margin-right: 4px; border-color: var(--act); background: var(--act); color: #111916; font-size: 15px; }
.t-strip .t-turn:disabled { border-color: #2f6c74; background: rgb(18 52 58); color: var(--act); }
.t-strip .tc-act { background: var(--act); border-color: var(--act); color: #111916; }
.t-strip .tc-act .ic { width: 14px; height: 14px; color: currentColor; }
/* Attack (or Repair) once used: dark, as Turn and More are when disabled. */
.t-strip .tc-act:disabled { border-color: #2f6c74; background: rgb(18 52 58); color: var(--act); }
.t-strip button:disabled { opacity: .4; cursor: not-allowed; }
.t-strip .ab-end { width: auto; min-width: 38px; margin-left: 6px; padding: 0 6px; border-color: var(--accent); border-radius: 11px;
    background: var(--accent); color: #172017; font-size: 10.5px; white-space: nowrap; }
.t-strip .ab-end.glow { box-shadow: 0 0 0 2px #0b100d, 0 0 10px rgb(216 232 159 / .7); }   /* nothing left to do: end */
.t-strip .ab-end.confirm { background: #b04a40; border-color: #b04a40; color: #fff; }
.size-medium .t-strip button:not(.ab-end) { width: 20px; height: 20px; }

/* The acting companion's commands without the strip (a finger or a small board): in the
   action bar, the facings in a pop-up over it behind Facing (FacingCompass). */
.turn-commands { display: flex; align-items: center; gap: 12px; }
.tc-buttons { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; min-width: 0; }
.tc-buttons button { min-height: 32px; padding: .3rem .75rem; font-size: 12px; }
.tc-buttons button, .action-bar .tc-act { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tc-buttons button .ic, .tc-act { border-color: var(--act); background: var(--act); color: #111916; font-weight: 700; }
.tc-act .ic { color: currentColor; }
/* Aiming on a finger or a small board (the action mode, or whom a consumable is for): the
   button that opened it, alone in the bar and pressed (a white ring inside its own colour); a
   press again cancels, as A, S, Esc or a tap on anything but a lit unit do. */
.action-bar button.choosing { box-shadow: inset 0 0 0 2px #fff; }
.tc-act:disabled { opacity: .4; cursor: not-allowed; }
/* Repair: a repair weapon's secondary, beside Attack, solid green as the repair previews are.
   Greyed while it cools down, with the turns left beside its icon in the strip. */
.tc-repair { --heal: rgb(63 191 74); border-color: var(--heal); background: var(--heal); color: #0d1a0f; font-weight: 700; }
.tc-repair .ic { color: currentColor; }
.tc-repair:disabled { opacity: .4; cursor: not-allowed; }
.action-bar .tc-repair { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.t-strip .tc-repair .ic { width: 14px; height: 14px; }
.t-strip .tc-repair:disabled { border-color: #2f6c45; background: rgb(18 58 30); color: var(--heal); }
.t-strip .tc-repair.cooling { width: auto; grid-auto-flow: column; gap: 2px; padding: 0 4px; }
.t-strip .tc-repair .tc-count { font-size: 10px; }

/* The six facings as a hex around the unit: ↖ ↗ / ← (unit) → / ↙ ↘. The one it faces now is
   outlined (a marker). Each is coloured by what the unit could do facing that way
   (FacingCompass): filled orange (attack), green (repair), split orange and green, top-left to
   bottom-right (both), with that icon (atk, rep, or the crossed atkrep) in its outer corner: a
   press turns there and opens the action mode. Plain (neither): a press only turns. Locked (it
   attacked after moving): closed, Turn disabled. */
.facing-compass { --fc: 30px; --atk: rgb(255 158 44); --heal: rgb(63 191 74);
    display: grid; grid-template-columns: repeat(4, var(--fc)); grid-template-rows: repeat(3, var(--fc));
    gap: 2px; flex-shrink: 0; }
.facing-compass [hidden] { display: none !important; }   /* the keys' turn-only twins */
.fc-dir, .action-bar .fc-dir { position: relative; display: grid; place-items: center; width: var(--fc); height: var(--fc); min-height: 0; padding: 0;
    border: 1px solid #2f6c74; border-radius: 6px; background: #12343a; color: var(--act); font-size: 15px; font-weight: 700; line-height: 1; }
.fc-dir.now { border: 2px solid var(--act); background: #0b1a1c; color: #fff; cursor: default; }
.fc-dir.reach-atk { border-color: var(--atk); background: var(--atk); color: #2a1600; }
.fc-dir.reach-rep { border-color: var(--heal); background: var(--heal); color: #0d1a0f; }
.fc-dir.reach-both { border-color: var(--atk) var(--heal) var(--heal) var(--atk);
    background: linear-gradient(135deg, var(--atk) 50%, var(--heal) 50%); color: #111916; }
/* The facing it has, coloured too: a press only opens the mode. A white ring inside its edge. */
.fc-dir.now[data-reach] { border-width: 2px; cursor: pointer; box-shadow: inset 0 0 0 2px #fff; }
.fc-dir:disabled { opacity: .4; cursor: not-allowed; }
.fc-dir.now:disabled { opacity: .7; }
/* A coloured facing's icon, small in its outer corner, so the arrow keeps the middle. */
.fc-dir .fc-badge { position: absolute; display: grid; width: 44%; height: 44%; pointer-events: none; }
.fc-dir .fc-badge .ic { width: 100%; height: 100%; color: currentColor; }
.fc-badge.tl { top: 1px; left: 1px; }
.fc-badge.tr { top: 1px; right: 1px; }
.fc-badge.bl { bottom: 1px; left: 1px; }
.fc-badge.br { bottom: 1px; right: 1px; }
/* Beside the icon, the arrow a little smaller and nudged to the opposite corner, so they don't overlap. */
.fc-dir[data-reach] .fc-arrow { --nudge: calc(var(--fc) * .14); font-size: calc(var(--fc) * .46); }
.fc-dir:has(.fc-badge.tl) .fc-arrow { translate: var(--nudge) var(--nudge); }
.fc-dir:has(.fc-badge.tr) .fc-arrow { translate: calc(var(--nudge) * -1) var(--nudge); }
.fc-dir:has(.fc-badge.bl) .fc-arrow { translate: var(--nudge) calc(var(--nudge) * -1); }
.fc-dir:has(.fc-badge.br) .fc-arrow { translate: calc(var(--nudge) * -1) calc(var(--nudge) * -1); }
/* The combined button pressed, alone in the action bar while aiming (Board.PickToggle). */
.tc-both { border-color: rgb(255 158 44) rgb(63 191 74) rgb(63 191 74) rgb(255 158 44);
    background: linear-gradient(135deg, rgb(255 158 44) 50%, rgb(63 191 74) 50%); color: #111916; font-weight: 700; }
.action-bar .tc-both { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tc-both .ic { color: currentColor; }

/* Without the strip (a finger or a small board): the six facings take the action bar's button
   row while open (Board hides the buttons), in one row clockwise from ↗ as the keys 1–6 go,
   then × to close, so they never cover the board. Each as tall as the bar's buttons, narrower
   when the row is short of room. */
.ab-compass { display: flex; flex: 1 1 auto; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; margin-left: auto; }
.size-small .ab-compass { flex-basis: 100%; }
.ab-compass[hidden] { display: none; }
.ab-compass .facing-compass { --fc: var(--ab-btn); display: flex; flex: 0 1 auto; gap: 4px; min-width: 0; }
.action-bar .ab-compass .fc-dir { flex: 0 1 var(--fc); width: var(--fc); min-width: 0; grid-column: auto !important; grid-row: auto !important; }
.ab-compass :is([data-face="2"], [data-face-act="2"]) { order: 1; }
.ab-compass :is([data-face="1"], [data-face-act="1"]) { order: 2; }
.ab-compass :is([data-face="0"], [data-face-act="0"]) { order: 3; }
.ab-compass :is([data-face="5"], [data-face-act="5"]) { order: 4; }
.ab-compass :is([data-face="4"], [data-face-act="4"]) { order: 5; }
.ab-compass :is([data-face="3"], [data-face-act="3"]) { order: 6; }
.action-bar .ab-compass-close { flex: none; width: var(--ab-btn); padding: 0; font-size: 22px; line-height: 1; }
/* The action bar's ⋯ menu: over the bar, like the facings. */
.ab-more { position: absolute; right: 10px; bottom: calc(100% + 6px); z-index: 25; }

/* A facing hovered in the compass: the enemies it would line up, outlined. */
.cell.preview-target .tile { --hex-edge: var(--enemy-line); --hex-w: 2px; }

/* The action bar above the board: the acting companion's state and the buttons for its turn
   (or Start / Next). Every button runs the typed command (Board.razor). */
/* One fixed height whatever it holds (buttons on your turn, a line of text during the enemy
   turn, short or long status), so the board under it never shifts while a replay plays: the
   status is one line, cut short with an ellipsis (its full text is its title), and the
   buttons never wrap. Small screens: the status on its own line above the buttons, both rows
   always reserved. --ab-btn is the button height (bigger for a finger, below). */
.action-bar { position: relative; --ab-btn: 32px; flex-wrap: nowrap; min-height: calc(var(--ab-btn) + 14px); }
.size-small .action-bar { --ab-btn: 40px; flex-wrap: wrap; align-content: flex-start; min-height: calc(var(--ab-btn) + 34px + 20px); }
.size-small .action-bar .ab-status { flex: 1 0 100%; }
/* A small board: the commands share the row's width (tighter padding, so four fit a phone). */
.size-small .ab-buttons { flex: 1 1 100%; justify-content: flex-end; gap: 4px; min-width: 0; }
.size-small .action-bar .ab-buttons > button { flex: 0 1 auto; min-width: 0; padding: 0 6px; }
.action-bar { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 6px 10px;
    border: 1px solid var(--line); border-radius: 6px; background: var(--well); font-size: 12px; line-height: 1.4; }
.ab-status { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
.ab-status b { color: var(--act); }
/* No room for the docked inspector: the unit's name and an ⓘ, one button opening the details
   over the board (as a Hangar card's name does). Framed on hover, focus and while open. */
.ab-status { display: flex; align-items: center; }
/* What follows the name: cut short with an ellipsis (its full text is the status's title); the
   name and its ⓘ keep their width (at most three quarters of the line). */
.ab-rest { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* A small board with no commands (Deployment, the enemy turn, the battle's end), or aiming
   (only Cancel in the row): the line wraps, up to two lines. */
.size-small .action-bar:not(:has(.ab-buttons:not([hidden]), .ab-compass:not([hidden]))) .ab-rest,
.size-small .action-bar:has(.choosing) .ab-rest {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; white-space: normal; }
.ab-name { display: contents; }
.action-bar .ab-namebar { display: inline-flex; flex: 0 0 auto; max-width: 75%; align-items: center; gap: 6px; min-width: 0; min-height: 28px; margin-right: 6px; padding: 0 6px;
    border: 1px solid transparent; border-radius: 4px; background: transparent; color: inherit; font: inherit; }
.ab-namebar b { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.action-bar .ab-namebar:is(:hover, :focus-visible, .active) { border-color: #52604c; color: inherit; }
.ab-info { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid #52604c; border-radius: 50%; background: #101915;
    color: var(--act); font-size: 11px; font-weight: 700; font-style: italic; line-height: 1; }
.ab-status b.ab-foe { color: var(--enemy); }
.ab-buttons { display: flex; flex-wrap: nowrap; flex-shrink: 0; gap: 6px; margin-left: auto; }
.ab-buttons[hidden] { display: none; }   /* the facings in their place (.ab-compass) */
.action-bar button { min-height: var(--ab-btn); padding: .3rem .75rem; font-size: 12px; }
.action-bar button.active { border-color: var(--act); color: var(--act); }
.ab-end.glow { box-shadow: 0 0 0 2px var(--accent), 0 0 12px rgb(216 232 159 / .55); }   /* nothing left to do: end */
.ab-end.confirm { background: #b04a40; border-color: #b04a40; color: #fff; }


@keyframes chip-armed { 50% { filter: brightness(1.3); } }

/* The mini map: the whole battlefield, the view as a frame, click to jump there (browser.js).
   Large and medium: floating in the board's top-right corner, faded while the pointer is on the
   board elsewhere. Small: a bar above the board (the Map button and what is out of view), the
   map under it. Hidden when the whole board fits. */
/* --sbw / --sbh: the board's scrollbar width and height (browser.js), kept clear of. */
.minimap { position: absolute; top: 8px; right: calc(var(--sbw, 0px) + 10px); z-index: 20; display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
    user-select: none; -webkit-user-select: none; }   /* a drag on the map must never select the Map button's text */
.edge-mark { user-select: none; -webkit-user-select: none; }
.map-bar { display: flex; align-items: center; gap: 10px; }
.map-toggle { background: rgb(21 31 25 / .92); }
.size-small .map-toggle { padding: .3rem .75rem; font-size: 12px; }   /* the action bar's button text size */
.offscreen-summary { display: none; }
.minimap-svg { display: block; width: 180px; height: auto; background: rgb(14 22 18 / .92); border: 1px solid var(--line); border-radius: 5px; cursor: grab; transition: opacity .15s; }
.size-medium .minimap-svg { width: 150px; }
.minimap-svg { touch-action: none; -webkit-tap-highlight-color: transparent; }   /* a finger drags the view frame rather than scrolling the page */
.minimap-svg.dragging { cursor: grabbing; }
.board-screen[data-fits="1"] .minimap { display: none; }
.size-small .minimap { position: static; align-items: stretch; margin-bottom: 6px; }
.size-small .offscreen-summary { display: inline; font-size: 12px; color: var(--enemy); }
.size-small .minimap-svg { width: 100%; height: 110px; }
.map-bg { fill: #121b16; }
.map-hull { fill: #24323e; stroke: #4f6b85; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.map-hull.damaged { fill: #2d2716; stroke: #a38230; }
.map-hull.critical { fill: #331a17; stroke: #b04a40; }
.map-unit.companion { fill: var(--comp); }
.map-unit.enemy { fill: var(--enemy); }
.map-unit.acting { fill: var(--act); }
.map-unit.target { stroke: #fff; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.map-view { fill: rgb(216 232 159 / .08); stroke: var(--accent); stroke-width: 1.5px; vector-effect: non-scaling-stroke; pointer-events: none; }

/* Edge markers: enemies out of view on a side, with a count; a click scrolls to the nearest. */
.edge-mark { position: absolute; z-index: 15; display: inline-flex; align-items: center; gap: 4px; min-height: 0; padding: 2px 8px;
    border: 1px solid var(--enemy-line); border-radius: 12px; background: rgb(35 15 13 / .92); color: var(--enemy); font-size: 12px; font-weight: 700; }
.edge-mark[hidden] { display: none; }
.edge-mark.up { top: 6px; left: 50%; translate: -50% 0; }
.edge-mark.down { bottom: calc(var(--sbh, 0px) + 6px); left: 50%; translate: -50% 0; }
.edge-mark.left { left: 6px; top: 50%; translate: 0 -50%; }
.edge-mark.right { right: calc(var(--sbw, 0px) + 6px); top: 50%; translate: 0 -50%; }
.size-small .edge-mark { padding: 6px 12px; font-size: 13px; }   /* finger-sized */

/* The selected unit's details (UnitInspector). With room (a window at least 1100px wide):
   docked on the board's right, 320px (browser.js dockWidth counts it with the gap), scrolling
   inside itself. Without: the name's ⓘ opens them over the whole game panel, as the Hangar's
   details (the panel is the positioned box meanwhile: the board screen and board give up
   their own positioning, and everything they place is under the details); the × stays at
   the top as they scroll. */
.insp-dock { position: relative; flex: 0 0 320px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px 14px;
    background: #101915; border: 1px solid var(--line); border-radius: 6px; }
.state-panel.board-mode:has(.insp-overlay) { position: relative; overflow: hidden; }
.state-panel.board-mode:has(.insp-overlay) :is(.board-screen, .board-main) { position: static; }
.insp-overlay { position: absolute; inset: 0; z-index: 30; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px 14px; background: #101915; }
.insp-close { position: absolute; top: 6px; right: 8px; z-index: 2; display: grid; place-items: center; width: 30px; height: 30px; min-height: 0; padding: 0; font-size: 18px; line-height: 1; }
/* Its ×: the dialogs' (a 28px × in a 44px quiet button), beside the name, whose row is as tall. */
.insp-overlay .insp-close { top: 0; right: 0; width: 44px; height: 44px; font-size: 28px; }
.insp-overlay .hi-head { min-height: 44px; padding-right: 48px; }
@media (pointer: coarse) { .insp-close { width: 44px; height: 44px; top: 2px; right: 2px; } .insp-overlay .hi-head { padding-right: 48px; } }

/* The Hull: one block over its footprint, in four layers over the board's ground, bottom up
   (no fill: the ground shows inside its edge):
     edge (.hull-edge) . the outline of its hexes in the condition's colour (--hull-line), an
                         SVG stretched over the block (HullBlock.EdgePoints, in percent) with a
                         stroke that keeps its width however it is stretched;
     ship (.hull-art) .. art/battle/hull.png, the crashed ship, whole and unclipped (clipped to
                         the hexes it would be cut into zigzags), with no outline: as large as
                         fits the block a little taller than it (it rises 12% into the row
                         above, as a unit's picture rises over its hex), on the block's bottom,
                         fading out at its foot so it sits sunk in the hexes;
     shape (.hull-shape) the footprint again: transparent; it takes the clicks (in Deployment,
                         Start battle), shows the gold wash under the pointer there and flashes
                         red on a hit;
     name and HP ....... in the top row's right-hand hex (HullBlock.TopRightHex places the box),
                         in Deployment and Battle alike: the text alone in the condition's
                         colour, no plate and no fill, with a dark shadow so it reads over the
                         ship.
   Units on the hexes around it draw over the ship. */
.hull { position: relative; z-index: 0; }
.hull-edge { position: absolute; left: 2px; top: 2px; width: calc(100% - 4px); height: calc(100% - 4px); overflow: visible; pointer-events: none; }
.hull-edge polygon { fill: none; stroke: var(--hull-line); stroke-width: 1.5px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.hull-art { position: absolute; inset: -12% 0 0; pointer-events: none;
    background: url("art/battle/hull.png") 50% 100% / contain no-repeat;
    -webkit-mask-image: linear-gradient(to top, transparent, #000 14%); mask-image: linear-gradient(to top, transparent, #000 14%); }
.hull.sound { --hull-line: #4f6b85; --hull-text: #b7cde0; }
.hull.damaged { --hull-line: #a38230; --hull-text: #f5dc8b; }
.hull.critical { --hull-line: #b04a40; --hull-text: #ffa49a; }
/* The small board's Hull strip, under the board: icon, HP and a bar in the condition's colour;
   red while a hit plays (the replay's frame). The board's own label (off the screen's edge
   there) is hidden. */
.hull-strip.sound { --hull-line: #4f6b85; --hull-text: #b7cde0; }
.hull-strip.damaged { --hull-line: #a38230; --hull-text: #f5dc8b; }
.hull-strip.critical { --hull-line: #b04a40; --hull-text: #ffa49a; }
.hull-strip { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px;
    background: var(--well); color: var(--hull-text); font-size: 12px; line-height: 1; }
.hull-icon { flex: none; width: 18px; height: 14px; }
.hull-strip-label { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; }
.hull-strip-hp { font-variant-numeric: tabular-nums; }
.hull-strip-hp b { font-size: 14px; }
.hull-strip-bar { flex: 1; height: 6px; overflow: hidden; border-radius: 3px; background: #060a08; }
.hull-strip-bar > span { display: block; height: 100%; background: var(--hull-line); transition: width .3s; }
.hull-strip.hit { border-color: var(--enemy-line); color: var(--enemy); animation: hull-strip-hit .6s ease-out; }
.hull-strip.hit .hull-strip-bar > span { background: var(--enemy-line); }
@keyframes hull-strip-hit { 0%, 40% { background: rgb(192 57 43 / .5); } 100% { background: var(--well); } }
@media (prefers-reduced-motion: reduce) { .hull-strip.hit { animation: none; } }
.size-small .hull-id { display: none; }
.hull-shape { position: absolute; inset: 2px; clip-path: var(--hull-clip); container-type: inline-size; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: transparent; color: var(--hull-text); }
.hull-id { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; white-space: nowrap;
    text-shadow: 0 0 3px #000, 0 1px 2px #000; }
.hull-label { font-size: clamp(9px, 1.7cqw, 13px); letter-spacing: .2em; padding-left: .2em; }
.hull-hp { font-size: clamp(11px, 2.2cqw, 16px); font-weight: 700; line-height: 1; }
.hull-hp small { font-size: .7em; font-weight: 400; opacity: .75; }

/* Battle replay (BattleReplay.cs): one class per lit cell, for as long as its frame shows.
   The page skips the replay under prefers-reduced-motion, so these never animate for those visitors.
   fx-actor and fx-spawn draw nothing of their own: the actor has its acting marks, and
   browser.js follows fx-actor to keep it in view. */
/* A hit, repair or glitch tints the unit's figure (.t-tint, under its numbers). A hit a skill
   changed flashes twice: a short red, then a longer orange for a bonus hit (fx-bonus) or green for
   a reduced one (fx-block). The .45s and .7s here match BattleReplay.HitMs and SkillFlashMs. */
.cell:is(.fx-hit, .fx-heal, .fx-glitch, .fx-bonus, .fx-block) .t-tint { display: block; }
.cell.fx-hit .t-tint { animation: fx-hit .45s ease-out forwards; }
.cell.fx-hit .tile { --line-c: #ff5a4a; }
.cell.fx-bonus .t-tint { animation: fx-bonus .7s ease-out forwards; }
.cell.fx-bonus .tile { --line-c: #ff9a2e; }
.cell.fx-block .t-tint { animation: fx-block .7s ease-out forwards; }
.cell.fx-block .tile { --line-c: #7fe07a; }
/* The jerk (ReplayFrame.Jolts): a hit that did damage snaps the unit's figure (.t-art, not its
   panel or numbers) away from the attacker in 50ms and back by 160ms; a skill's extra is a
   smaller, quicker one. jd0-jd5 is the direction on screen, as HexCoord numbers them
   (0 ↘, 1 →, 2 ↗, 3 ↖, 4 ←, 5 ↙); the distance is a share of the tile's width. */
.cell.jd0 { --jx: .5;  --jy: .87; }
.cell.jd1 { --jx: 1;   --jy: 0; }
.cell.jd2 { --jx: .5;  --jy: -.87; }
.cell.jd3 { --jx: -.5; --jy: -.87; }
.cell.jd4 { --jx: -1;  --jy: 0; }
.cell.jd5 { --jx: -.5; --jy: .87; }
.cell.jolt .t-art { --jd: 8cqw; animation: jolt .16s both; }
.cell.jolt-small .t-art { --jd: 4cqw; animation: jolt .13s both; }
@keyframes jolt {
    0%   { translate: 0 0; animation-timing-function: ease-out; }
    31%  { translate: calc(var(--jx) * var(--jd)) calc(var(--jy) * var(--jd)); animation-timing-function: ease-in-out; }
    100% { translate: 0 0; } }
/* The numbers (.fx-pop, ReplayPop): every hit's damage in red (grey 0 when it did nothing), a
   repair's HP in green, a skill's amount after the hit's. None fades in: a number whose unit
   jerks (.late) is hidden for the 50ms the snap takes and then shows at once, full size, at its
   furthest point; any other shows at once as its frame starts. So Fast, which cuts the flashes
   short, still shows every one. A plain hit's number rises and fades at the end of its flash; a
   hit a skill changed (lead) holds to 170ms, then rises a pill's height as it fades, gone by
   320ms, so the skill's number, coming in where it started at 300ms, is clear of it. Over the Hull they sit over the hex the hit landed on (.hull-pops, a layer after the cells). */
.cell:has(> .fx-pops) { z-index: 6; }   /* the numbers stay over the neighbours' art */
.fx-pops { position: absolute; left: 50%; top: 12%; width: 0; height: 0; z-index: 5; pointer-events: none; }
.fx-pop { position: absolute; left: 0; top: 0; translate: -50% 0; display: inline-flex; align-items: center; gap: 2px; white-space: nowrap;
    padding: 0 .4em; border: 1px solid currentColor; border-radius: 7px; background: rgb(11 16 13 / .9); box-shadow: 0 2px 6px #000a;
    font-size: calc(var(--tile-font, 12px) * 1.25); font-weight: 700; color: #ff8a7a; scale: 1.3; animation: pop-hit .45s both; }
.fx-pop.late { animation: pop-wait .05s, pop-hit .45s both; }
.fx-pop.lead { animation: pop-lead .32s both; }
.fx-pop.lead.late { animation: pop-wait .05s, pop-lead .32s both; }
.fx-pop.zero { color: #a9b4ad; }
.fx-pop.heal { color: #7fe07a; }
.fx-pop:is(.bonus, .restore) { scale: 1.4; animation: none; }
.fx-pop:is(.bonus, .restore).late { animation: pop-wait .05s; }
.fx-pop.bonus { color: #ffb056; }
.fx-pop.restore { color: #7fe07a; }
.hull-pops { position: relative; z-index: 7; pointer-events: none; }
.hull-pops > .fx-pops { position: absolute; width: auto; height: auto; }   /* placed over the hit hex by HullBlock.PopHex */
.hull-pops .fx-pop { left: 50%; top: -.6em; }
@keyframes pop-wait { 0%, 100% { visibility: hidden; } }
@keyframes pop-hit { 0%, 75% { opacity: 1; translate: -50% 0; animation-timing-function: ease-out; } 100% { opacity: 0; translate: -50% -.8em; } }
@keyframes pop-lead { 0%, 53% { opacity: 1; translate: -50% 0; animation-timing-function: ease-in-out; } 100% { opacity: 0; translate: -50% -1.7em; } }
.cell.fx-heal .t-tint { background: rgb(63 191 74 / .55); }
.cell.fx-glitch .t-tint { background: rgb(150 90 210 / .6); }
.cell.fx-trail::before { --hex-fill: #1f2a22; }
.cell.fx-trail::after { width: 8px; height: 8px; margin: -4px; background: #6f8274; }
.cell.fx-down::before { --hex-fill: #4a1a16; }
.hull.fx-hull .hull-shape { animation: hull-hit .45s ease-out forwards; }
@keyframes fx-hit { 0%, 40% { background-color: rgb(220 57 43 / .7); } 100% { background-color: rgb(120 31 26 / .35); } }
@keyframes fx-bonus { 0%, 75% { background-color: rgb(255 140 30 / .8); } 100% { background-color: rgb(150 80 20 / .35); } }
@keyframes fx-block { 0%, 75% { background-color: rgb(63 191 74 / .75); } 100% { background-color: rgb(30 100 40 / .35); } }
@keyframes hull-hit { 0%, 40% { box-shadow: inset 0 0 0 999px rgb(192 57 43 / .75); } 100% { box-shadow: inset 0 0 0 999px rgb(90 31 26 / .35); } }

/* The key row: the icon key left, the replay controls right; the buttons drop below when narrow. */
.board-legend { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 16px; }
.board-key { flex: 1 1 14em; min-width: 0; font-size: 12px; color: var(--muted); }
.board-key summary { width: fit-content; cursor: pointer; }
.key-list { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 0; padding: 0; list-style: none; }
.key-list li { display: inline-flex; align-items: center; gap: 6px; }
.key-list .ic { color: var(--accent); }
/* The small board's key: the ? beside Map opens it over the whole game panel (as the Hangar's
   details do), one meaning a line, the heading and × staying at the top as it scrolls. */
/* Its button: a small round ? at the right end of the bar over the board (beside Map), a
   finger's size to press (the ::before), quiet since it is reference, not a command. */
.board-key-open { position: relative; flex: none; display: grid; place-items: center; width: 30px; height: 30px; min-height: 0; margin-left: auto; padding: 0;
    border-radius: 50%; color: var(--act); font-size: 14px; font-weight: 700; line-height: 1; }
.board-key-open::before { content: ""; position: absolute; inset: -7px; }
/* The board fits whole (no map): the bar stays on a small board for the ?, without Map. */
.board-screen.size-small[data-fits="1"] .minimap { display: flex; }
.board-screen.size-small[data-fits="1"] .minimap > :not(.map-bar), .board-screen.size-small[data-fits="1"] .map-toggle { display: none; }
/* Nothing left in the key row (a small board in Deployment): no row. */
.board-legend:not(:has(button, summary)) { display: none; }
/* The key's panel: over the game panel's box (browser.js --panel-*), as the phone's dialogs. */
.modal-overlay:has(> .key-dialog) { position: fixed; inset: auto; top: var(--panel-top, 0px); left: var(--panel-left, 0px); width: var(--panel-width, 100vw); height: var(--panel-height, 100dvh);
    z-index: 30; padding: 0; background: none; }
.modal-dialog.key-dialog { width: 100%; height: 100%; max-height: none; padding: 20px 16px 16px;
    border: 0; border-radius: 0; box-shadow: none; text-align: left; font-size: 13px; line-height: 1.45; color: var(--muted); }
.key-dialog .dialog-head { top: -20px; margin: -20px -16px 8px; padding: 20px 16px 0; }
.key-dialog .key-list { flex-direction: column; flex-wrap: nowrap; gap: 0; margin: 0; }
.key-dialog .key-list li { display: block; padding: 7px 0; }
.key-dialog .key-list li > :is(.key-sample, .t-badge, .ic) { margin-right: 6px; vertical-align: middle; }
.key-dialog .key-list li + li { border-top: 1px dashed var(--line); }
.key-sample { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 3px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.key-sample.order { border-radius: 999px; background: var(--comp); color: #111916; }
.key-sample.bar { display: inline-block; vertical-align: middle; min-width: 0; width: 2.4em; height: 4px; padding: 0; border: 0; border-radius: 2px; background: #060a08; overflow: hidden; }
.key-sample.bar > span { display: block; width: 65%; height: 100%; background: var(--comp); }
.key-sample.acting { border-radius: 999px; background: var(--act); color: #111916; }
.key-sample.slot { color: var(--warn); background: transparent; box-shadow: inset 0 0 0 2px var(--gold); }
.key-sample.foe-range { width: 22px; background: var(--foe-reach); box-shadow: inset 0 0 0 2px var(--enemy-line); }
.key-sample.selected { width: 22px; background: linear-gradient(rgb(255 255 255 / .12), rgb(255 255 255 / .12)), var(--comp-bg); box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / .5); }
.key-sample.slot { width: 22px; }
.key-sample.range { width: 22px; background: var(--reach-fill); }
.key-sample.move { position: relative; width: 22px; background: rgb(227 194 84 / .1); box-shadow: inset 0 0 0 1px rgb(227 194 84 / .3); }
.key-sample.move::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.key-sample.change { color: #ff8a7a; }
.key-sample.change.heal { color: #7fe07a; }
.key-sample.act { background: var(--act); color: #111916; }
.key-sample.turn { border: 1px solid #2f6c74; background: #12343a; color: var(--act); font-size: 13px; }
.key-sample:is(.act-foe, .act-hit, .act-ally, .act-mend, .fc-both) { gap: 2px; width: auto; }
.key-sample.fc-both { background: linear-gradient(135deg, rgb(255 158 44) 50%, rgb(63 191 74) 50%); color: #111916; }
.key-sample.act-foe { background: rgb(255 158 44); color: #2a1600; }
.key-sample.act-hit { background: #ff5a4a; color: #fff; }
.key-sample.act-ally { background: rgb(63 191 74); color: #0d1a0f; }
.key-sample.act-mend { background: #0e6022; color: #fff; }
.legend-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-left: auto; }
/* The key row's buttons (Icon key, Replay, Skip replay, Lost this battle) in the action bar's
   button text size. */
.legend-actions button { padding: .3rem .75rem; font-size: 12px; }
/* A small board: the key row's buttons (Replay, Skip replay, Lost this battle) are secondary:
   small, quiet chips at the row's right end, as wide as their labels, still a finger's height
   to press (the ::before), wrapping to a second row only if they can't share one. */
.size-small .board-legend { justify-content: flex-end; }
.size-small .legend-actions { flex-wrap: wrap; gap: 6px; }
.size-small .legend-actions button { position: relative; flex: none; min-height: 28px; height: 28px; margin: 0; padding: 0 10px;
    border-color: var(--line); border-radius: 14px; color: var(--muted); font-size: 11px; line-height: 1; white-space: nowrap; }
.size-small .legend-actions button::before { content: ""; position: absolute; inset: -8px 0; }
/* Compact buttons on wider screens; full-size touch targets on phones. */
@container game (min-width: 600px) { button.compact { min-height: 28px; padding: .2rem .5rem; font-size: 11px; } }

.panel-heading { margin: 0 0 4px; font-size: 13px; font-weight: 400; line-height: 1.65; }
.panel-note { margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

/* Deployment: any companion still waiting to be placed (normally none: Core puts the sortie in
   front of the Hull), lined up on the Hull's bottom row (Board's queue) and centred on it, their
   hexes edged in a dimmer green; pressing one selects it. The Hull's label moves to its top so
   the queue doesn't cover it. */
.queue-cell { z-index: 1; }
.tile.waiting { --line-c: #5d7a58; }
.queue-more { z-index: 2; place-self: center end; margin-right: -6px; padding: 1px 6px; border-radius: 9px; background: var(--comp); color: #111916; font-size: 11px; font-weight: 700; }
/* Deployment: the Hull is the Start battle button, its label in the middle of the Hull. Once no
   companion waits (.ready) it lights up: a gold edge, and a gold wash over the ship under
   the pointer or focus; a press starts turn 1. Until then the label is faded and a press does nothing. */
.hull-start { font-size: clamp(13px, 2.6cqw, 22px); font-weight: 700; letter-spacing: .06em; white-space: nowrap; color: var(--warn); opacity: .45;
    text-shadow: 0 0 4px #000, 0 1px 3px #000, 0 0 10px #000; }
.hull.start:focus-visible { outline: none; }
.hull.start.ready { --hull-line: var(--gold); cursor: pointer; }
.hull.start.ready .hull-start { opacity: 1; }
.hull.start.ready .hull-shape { cursor: pointer; transition: background-color .14s ease; }
.hull.start.ready:hover .hull-shape, .hull.start.ready:focus-visible .hull-shape { background-color: rgb(227 194 84 / .2); }
@media (prefers-reduced-motion: reduce) { .hull.start.ready .hull-shape { transition: none; } }
.tray-cell { width: 84px; aspect-ratio: 112 / 100; }
/* A lost companion in the pop-up: bigger than a board tile, so the Full tier (name, move,
   range, pattern and type) fits with room to read; two to a row on a phone. */
.lost-slot .tray-cell { width: min(160px, calc((100vw - 96px) / 2)); --tile-font: 13px; }

/* Battle: the companions lost this battle, a pop-up of crossed-out slots. */
.lost-dialog { width: min(720px, 100%); text-align: left; }
.lost-tiles { display: flex; flex-wrap: wrap; gap: 10px 8px; padding-top: 6px; }
.lost-slot { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 0; flex-shrink: 0; }
.lost-slot figcaption { font-size: 11px; color: var(--muted); }
.tile.lost { filter: grayscale(.6); opacity: .8; }   /* dimmed and crossed out, still readable */
.tile.lost::after { content: ""; position: absolute; inset: 0; pointer-events: none; clip-path: var(--hex);
    background: linear-gradient(to top right, transparent calc(50% - 1px), #b04a40 50%, transparent calc(50% + 1px)),
                linear-gradient(to top left, transparent calc(50% - 1px), #b04a40 50%, transparent calc(50% + 1px)); }

/* Status bar: how far the night has gone, and who acts. */
.dawn-meter { display: inline-block; width: 64px; height: 6px; margin: 0 4px; vertical-align: middle; border-radius: 3px; background: #1c2820; overflow: hidden; }
.dawn-meter > span { display: block; width: calc(var(--dawn, 0) * 100%); height: 100%; background: linear-gradient(90deg, #4f6b85, var(--warn)); }
.acting-note { color: var(--act); }

/* The Hangar's lists: each line is indented with padding,
   not spaces, so a long line wraps under its own text: the line starts --ind characters in,
   and every wrapped line starts at --hang. */
.list-row { display: flex; flex-wrap: wrap; column-gap: 2ch; }
.list-col { flex: 1 1 24ch; min-width: 0; }
.list-col:first-child { flex: 0 0 150px; } /* the OE column */
/* Side by side, the Stockpile and Tools columns are flush left; a wrapped line returns under its text. */
.list-col:not(:first-child) .side-line { padding-left: calc((var(--hang) - var(--ind, 0)) * 1ch); text-indent: calc((var(--ind, 0) - var(--hang)) * 1ch); }
/* Tall screens have the height to stack OE, Stockpile and Tools again, indented as in the other lists. */
@media (min-height: 1060px) {
  .list-row { display: block; }
  .list-col + .list-col { margin-top: 1.65em; }
  .list-col:not(:first-child) .side-line { padding-left: calc(var(--hang) * 1ch); text-indent: calc((var(--ind, 0) - var(--hang)) * 1ch); }
}
.side-line { --hang: 5; min-height: 1.65em; padding-left: calc(var(--hang) * 1ch); text-indent: calc((var(--ind, 0) - var(--hang)) * 1ch); }
.side-line > span { text-indent: 0; }

/* Minimal tip: one line; the title expands the full text in place. */
.tutorial-more summary { cursor: pointer; list-style-position: outside; }
.tutorial-more p { margin: 4px 0 0; color: var(--muted); max-height: 8em; overflow-y: auto; }

/* ── The Hangar's cards (HangarScreen.razor) ─────────────────────────────────────────────
   The state panel holds the whole Hangar at its natural height and scrolls it vertically;
   nothing inside scrolls on its own, and nothing is wider than the panel, so there is never
   a horizontal scroll. The Workbench's cards sit in a grid whose rows are all as tall as
   the tallest card. Below 760px of game area the bay, the Workbench and Tonight become tabs. Each card's top edge is its kind's
   colour (--k): companion green, weapon orange, reactor cyan, utility violet, tool gold. */
/* Repair Hull, beside the Hull HP in the status bar while in the Hangar. */
/* Leave run, beside Repair Hull (or the Hull HP outside the Hangar): the same small size. */
.leave-run { min-height: 0; margin-left: 4px; padding: 1px 8px; font-size: 11px; line-height: 1.5; vertical-align: baseline; }
.hull-repair { min-height: 0; margin-left: 4px; padding: 1px 8px; font-size: 11px; line-height: 1.5; vertical-align: baseline; }
.state-panel.hangar-mode { padding: 10px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.hangar { --k: var(--muted); min-width: 0; display: flex; flex-direction: column; gap: 10px; font-size: 12px; line-height: 1.4; }
.hangar h3 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: .06em; text-transform: uppercase; color: #eef4e8; font-weight: 700; }
.h-count { color: var(--accent); }
.h-sub { margin: 10px 0 6px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.h-sub:first-child { margin-top: 0; }
.h-eyebrow { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
/* The docked inspector after a battle (Board's BattleResult). */
.insp-result h2 { margin: 4px 0 10px; font-size: 18px; color: var(--comp); }
.insp-result h2.lost { color: var(--enemy); }
.insp-result dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0 0 12px; font-size: 12px; }
.insp-result dt { color: var(--muted); }
.insp-result dd { margin: 0; }
.h-note, .h-small { color: var(--muted); font-size: 11px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.h-empty { color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; padding: 10px; margin: 0; font-size: 12px; }

/* The HUD panel: the Hull, OE and the sortie as framed readouts with Position squad at the
   end, then the materials, then tonight's known threat. */
.h-top { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.h-hud { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; }
.h-stat { display: flex; align-items: center; gap: 4px 10px; min-height: 40px; padding: 4px 10px; border: 1px solid #2c3a31; border-radius: 4px; background: #0d1511; box-shadow: inset 0 1px 0 rgb(255 255 255 / .03); }
.h-stat-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.h-stat-num { color: #eef4e8; font-size: 18px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.h-stat-num small { color: var(--muted); font-size: 12px; font-weight: 400; }
.h-hull { flex-wrap: wrap; }
.h-hull .hull-repair { margin-left: 0; }
.h-meter { display: block; width: 80px; height: 8px; overflow: hidden; border-radius: 2px; background: #1f2a22; box-shadow: inset 0 0 0 1px #35493e; }
.h-meter > span { display: block; height: 100%; background: linear-gradient(90deg, #6fa65c, var(--comp)); }
.h-meter.low > span { background: linear-gradient(90deg, #b8483c, var(--enemy)); }
.h-pips { display: flex; gap: 3px; }
.h-pips i { width: 13px; height: 13px; transform: rotate(45deg) scale(.78); border: 2px solid #52604c; border-radius: 2px; }
.h-pips i.on { background: var(--warn); border-color: var(--warn); }
.h-delta { color: var(--warn); font-weight: 700; }
.h-top-actions { display: flex; align-items: stretch; gap: 8px; margin-left: auto; }
.h-autodeal { align-self: center; white-space: nowrap; }
.deal-auto { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; cursor: pointer; }
.deal-auto input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.h-launch { min-height: 40px; padding: 0 20px; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.h-tabs { display: none; }
.h-insp-close { display: none; }   /* the tabs layout's full-panel details show it */

/* A panel: a dark plate with a hairline frame and lime corner brackets (background layers, so
   they stay put on the inspector, which scrolls inside itself). */
:root { --panel-line: #2c3a31; --panel-corner: linear-gradient(rgb(216 232 159 / .6), rgb(216 232 159 / .6)); }
.h-top, .h-bay, .h-bench, .h-insp { padding: 10px 12px; border: 1px solid var(--panel-line); border-radius: 4px; box-shadow: inset 0 1px 0 rgb(255 255 255 / .04), 0 2px 10px rgb(0 0 0 / .25);
    background: var(--panel-corner) top left / 14px 2px no-repeat, var(--panel-corner) top left / 2px 14px no-repeat,
        var(--panel-corner) top right / 14px 2px no-repeat, var(--panel-corner) top right / 2px 14px no-repeat,
        var(--panel-corner) bottom left / 14px 2px no-repeat, var(--panel-corner) bottom left / 2px 14px no-repeat,
        var(--panel-corner) bottom right / 14px 2px no-repeat, var(--panel-corner) bottom right / 2px 14px no-repeat,
        linear-gradient(180deg, #16211b, #111a15); }
.h-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.h-bay { flex-shrink: 0; display: flex; flex-direction: column; }
.h-mechs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--hc-w)), 1fr)); gap: 8px; padding: 2px; }
.h-mechs > .hc { width: auto; }
.h-lower { min-width: 0; display: flex; flex-direction: column; }
.h-bench { min-width: 0; display: flex; flex-direction: column; }
.h-scroll { min-width: 0; padding: 2px 2px 6px; }
.h-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
/* Every Workbench card the same height, whatever its kind, so rows line up and paging is even;
   anything longer is cut off at the bottom (the inspector shows it all). */
:root { --wb-h: 166px; }
@media (pointer: coarse) { :root { --wb-h: 182px; } }   /* 44px buttons */
:root { --wb-compact: 106px; }   /* a compact Workbench card (two-row layout, fine pointer only) */
.h-cards .h-card { height: var(--wb-h); overflow: hidden; }

/* A card: its kind's colour on top, then its label, name, lines and actions. */
.h-card { position: relative; min-width: 0; display: flex; flex-direction: column; gap: 5px; padding: 8px 9px; border: 1px solid var(--line); border-top: 3px solid var(--k); border-radius: 7px; background: #151f19; }
.h-card.fresh { border-color: var(--warn); border-top-color: var(--k); box-shadow: inset 0 0 0 1px var(--warn); }
.hc, .k-companion { --k: var(--comp); }
.k-weapon { --k: #f0ae74; }
.k-reactor { --k: #7fcbdc; }
.k-utility { --k: #c3b2f2; }
.k-tool { --k: var(--warn); }
.k-resource { --k: var(--muted); }
.h-lbl { padding: 0 4px; border: 1px solid #3d4b40; border-radius: 3px; color: var(--muted); font-size: 10px; font-weight: 400; }
.h-kind { color: var(--k); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; }
.h-new { padding: 0 5px; border-radius: 3px; background: var(--warn); color: #142018; font-size: 9.5px; font-weight: 700; }

/* What the last action brought (a dealt material or blueprint, a crafted part, a changed
   companion) flashes: a gold glow pulses out from it three times, then it keeps its gold
   outline until the highlight fades (PlaySession, about two seconds). Its NEW / +N badge
   pulses with it. Reduced motion keeps only the outline. */
@keyframes h-flash {
    0%   { box-shadow: 0 0 0 0 rgb(240 216 120 / .95), inset 0 0 0 2px var(--warn); filter: brightness(1.45); }
    70%  { box-shadow: 0 0 0 10px rgb(240 216 120 / 0), inset 0 0 0 2px var(--warn); filter: brightness(1); }
    100% { box-shadow: 0 0 0 0 rgb(240 216 120 / 0), inset 0 0 0 1px var(--warn); filter: brightness(1); }
}
@keyframes h-badge { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.35); } }
.h-card.fresh, .h-chip.fresh { animation: h-flash .75s ease-out 3; }
.fresh .h-new, .h-chip.fresh .h-plus { display: inline-block; animation: h-badge .75s ease-out 3; }
@media (prefers-reduced-motion: reduce) {
    .h-card.fresh, .h-chip.fresh, .fresh .h-new, .h-chip.fresh .h-plus { animation: none; }
}
.h-name { font-size: 13px; font-weight: 700; line-height: 1.2; }
.h-lines { display: flex; flex-direction: column; color: var(--muted); font-size: 11px; line-height: 1.35; }
.h-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; }
.h-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.h-stats span { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.h-stats .ic { color: var(--muted); }

/* A companion, compact: stats, its slots as chips, glitches, deploy. */
/* The companion card's height (--hc-h): fixed, so a row of them pages evenly; shorter on a
   short screen and taller under a finger (44px slot rows). */
:root { --hc-h: 260px; --hc-w: 250px; }
@media (max-height: 879.98px), (pointer: coarse) { :root { --hc-w: 220px; } }   /* four companions fit one row from 1366 wide */
@media (max-height: 879.98px) { :root { --hc-h: 175px; } }
@media (pointer: coarse) { :root { --hc-h: 222px; } }   /* always the short layout, with 44px slots */
.hc { width: var(--hc-w); max-width: 100%; height: var(--hc-h); gap: 4px;
    background: radial-gradient(ellipse at 100% 0%, rgb(179 233 145 / .12), transparent 55%), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='42' viewBox='0 0 24 42'%3E%3Cpath d='M12 0 24 7v14L12 28 0 21V7zM12 28v14' fill='none' stroke='%23b3e991' stroke-opacity='.07' stroke-width='1'/%3E%3C/svg%3E") 0 0 / 24px 42px, var(--comp-bg); }   /* armour-plate hex mesh */
/* The tile is one selection button: name and sortie badge, the service bay with the companion
   standing in it (one scene, .hc-scene), its weapon line (--wpn) and the stat strip (--strip) over the bottom. Selected is a cyan
   outline with a "Selected" tab in its corner; the sortie is the badge: the two are independent. */
.hc { padding: 0; }
.hc-select { width: 100%; height: 100%; min-height: 0; display: flex; flex-direction: column; gap: 4px; padding: 10px 7px 6px; border: 0; border-radius: 6px;
    background: transparent; color: inherit; font: inherit; text-align: left; white-space: normal; cursor: pointer; }
.hc.deployed { border-color: var(--comp-line); border-top-color: var(--k); }
/* Selected: inside the card (the pager clips anything outside), and over every other card state
   (craftable, just dealt), so the inspected card is always the cyan one. */
.h-card.selected, .h-card.selected.fresh, .hb.ready.selected, .hb.fresh.selected { border-color: var(--act); border-top-color: var(--act); box-shadow: inset 0 0 0 2px var(--act); }
/* Selected's tab: part of the cyan frame, flush in the card's top-left corner (the header is
   pushed down 4px on every tile to clear it, so selecting never moves anything). */
.hc-selected { position: absolute; top: 0; left: 0; z-index: 3; height: 13px; padding: 0 7px 0 6px; border-radius: 5px 0 5px 0; background: var(--act); color: #102020;
    font-size: 9px; font-weight: 700; line-height: 13px; letter-spacing: .08em; text-transform: uppercase; pointer-events: none; }
.hc-head { display: flex; align-items: center; gap: 6px; min-width: 0; flex-shrink: 0; }
.hc-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; font-weight: 700; }
.hc-tag { margin-left: auto; flex: none; padding: 0 5px; border: 1px solid #52604c; border-radius: 3px; color: var(--muted); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; }
.hc-tag.on { border-color: var(--comp); background: var(--comp); color: #142018; font-weight: 700; }
/* The tile's sortie button, top right beside its name: Add to sortie (lime) or Remove from sortie
   (outlined), the game's ordinary compact buttons, a little taller. The name gives way to it. */
/* The header row is as tall as the button (--hc-btn) plus a little room, and the button sits
   centred in it (the tile's 10px top padding + 2px), so it never reaches down into the art. */
.hc { --hc-btn: 26px; }
.hc-head { padding-right: 140px; min-height: calc(var(--hc-btn) + 4px); }
.hc .hc-sortie { position: absolute; top: 12px; right: 6px; z-index: 3; min-height: var(--hc-btn); height: var(--hc-btn); padding: 0 .55rem; font-size: 11px; line-height: 1.4; }
.hc .hc-sortie.quiet { background: #18231c; }
@media (pointer: coarse) {
    .hc { --hc-btn: 36px; }
    .hc .hc-sortie { right: 3px; }
    .hc .hc-sortie::before { content: ""; position: absolute; inset: -4px; }
    .hc-head { padding-right: 150px; }
}
.hc-art { --strip: 36px; --wpn: 22px; position: relative; display: block; flex: 1; min-height: 0; overflow: hidden; border-radius: 4px; background: #09130f; }
/* The scene fills the art: the bay picture (--bay) as its background and the companion (--art)
   over it in its ::before, the two the same size and aligned, so the companion's picture is
   drawn to sit in the bay. A missing profile shows one square frame of the battle sheet
   instead (.framed, --frame-x), centred at full height. The inspector's portrait draws the
   same scene. */
.hc-scene { position: absolute; inset: 0; background: var(--bay) center / cover no-repeat; }
.hc-scene::before { content: ""; position: absolute; inset: 0; background: var(--art, none) center / cover no-repeat; }
.hc-scene.framed::before { left: 50%; right: auto; width: auto; aspect-ratio: 1; translate: -50% 0; background-size: 300% 100%; background-position: var(--frame-x, 0%) 0; }
.hc-scene.mirror::before { scale: -1 1; }
/* The companion's level, in the art's top-left corner, panelled like the weapon line. */
.hc-lv { position: absolute; top: 4px; left: 4px; z-index: 2; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: rgb(8 21 16 / .94);
    color: #dce5dc; font-size: 11px; font-weight: 700; line-height: 18px; white-space: nowrap; }
/* The fitted weapon, a small gap over the stat strip and panelled like it: its type icon in the
   weapon colour, then its name; .none when the slot is empty. */
.hc-tags { position: absolute; left: 4px; right: 4px; bottom: calc(var(--strip) + 5px); z-index: 2; display: flex; gap: 3px; }
/* A fitted reactor: a blue dot on a tag panelled like the weapon's, left of it (named in its title and the tile's label). */
.hc-rea { flex: none; display: flex; align-items: center; justify-content: center; width: calc(var(--wpn) - 2px); height: calc(var(--wpn) - 2px); box-sizing: border-box;
    border: 1px solid var(--line); border-radius: 4px; background: rgb(8 21 16 / .94); }
.hc-rea::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #4aa8ff; }
.hc-wpn { min-width: 0; height: calc(var(--wpn) - 2px); box-sizing: border-box;
    display: flex; align-items: center; gap: 5px; padding: 0 8px 0 6px; border: 1px solid var(--line); border-radius: 4px; background: rgb(8 21 16 / .94);
    color: #dce5dc; font-size: 11px; font-weight: 700; }
.hc-wpn .ic { width: 13px; height: 13px; color: #f0ae74; }
.hc-wpn-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hc-wpn.none { color: var(--muted); font-weight: 400; }
/* Short tiles leave the art too low for the weapon line: the weapon is its icon alone in the corner (named in its title and the
   tile's label); no weapon, no chip. */
@media (max-height: 879.98px) and (pointer: fine) {
    .hc-wpn { width: var(--wpn); padding: 0; justify-content: center; }
    .hc-wpn-name { display: none; }
    .hc-wpn.none { display: none; }
    .hc-wpn.hc-fit, .hc-wpn.hc-nofit { width: auto; padding: 0 8px; justify-content: flex-start; }
    .hc-wpn.hc-fit .hc-wpn-name, .hc-wpn.hc-nofit .hc-wpn-name { display: block; }
}
.hc-strip { z-index: 2; }
.hc-strip { position: absolute; left: 4px; right: 4px; bottom: 4px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 2px 0;
    border: 1px solid var(--line); border-radius: 4px; background: rgb(8 21 16 / .94); }
.hc-strip > span { min-width: 0; display: flex; flex-direction: column; align-items: center; border-right: 1px solid #35493e; line-height: 1.15; }
.hc-strip > span:last-child { border-right: 0; }
.hc-strip small { color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.hc-strip b { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Equip mode: a stat the fit changes shows its new value, green going up and red going down,
   with an arrow before its label so the colour is never the only sign; cyan when it changes
   without a direction (attack turning to repair). */
.hc-strip > .up { --chg: var(--comp); }
.hc-strip > .down { --chg: var(--enemy); }
.hc-strip > .changed { --chg: var(--act); }
.hc-strip > [class] { background: color-mix(in srgb, var(--chg) 14%, transparent); }
.hc-strip > [class] b, .hc-strip small i { color: var(--chg); }
.hc-strip small i { margin-right: 1px; font-size: 9px; font-style: normal; }
.hc-role { flex-shrink: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 11px; }
.hc-warn { color: var(--glitch); }
/* The tile's Revive and Fix button, in the middle of a knocked-out or glitched companion's tile,
   over its art: filled in the glitch colour and larger than the tile's other buttons; greyed while
   the stock can't pay. "Knocked out" or "1 glitch" is its small top-left line, the action centred
   under it. Lowered a little, to the
   middle of the art left between the level chip and the stat strip on a short tile. */
.hc .hc-revive { position: absolute; top: calc(50% + 10px); left: 50%; translate: -50% -50%; z-index: 3; display: flex; flex-direction: column; justify-content: center; gap: 1px;
    min-width: 100px; min-height: 44px; height: 44px; padding: 0 .5rem; white-space: nowrap; font-size: 14px; line-height: 1.2;
    border-color: var(--glitch); background: var(--glitch); color: #1d1428; font-weight: 700; }
.hc .hc-revive.off { border-color: #3a473d; background: #1a231d; color: #7f8f82; font-weight: 400; }
.hc-revive-note { align-self: flex-start; font-size: 10px; font-weight: 400; }
@media (pointer: coarse) { .hc .hc-revive::before { content: ""; position: absolute; inset: -5px; } }
/* The stage panel, above the known threat: the stage and battle number, then the rounds in a row
   that wraps on a phone. ▶ marks the round Position squad launches, ✓ a cleared one, 🔒 a last
   round the goal still holds back, its note saying what the goal still needs. */
.h-stage { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--panel-line); }
.h-stage-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.h-stage-head .h-threat-title { color: var(--accent); }
.h-stage-of { color: var(--muted); font-size: 11px; }
.h-stage-battle { margin-left: auto; color: var(--muted); font-size: 12px; }
.h-rounds { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0; padding: 0; list-style: none; font-size: 12px; }
.h-round { display: flex; align-items: baseline; gap: 5px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); }
.h-round-mark { width: 1.2em; text-align: center; }
.h-round-note { color: var(--dim); font-size: 11px; }
.h-round.cleared .h-round-mark { color: var(--accent); }
.h-round.launch { border-color: var(--accent); color: #dce5dc; background: color-mix(in srgb, var(--accent) 10%, transparent); font-weight: 700; }
.h-round.launch .h-round-mark { color: var(--accent); }
.h-round.launch .h-round-note { color: var(--muted); font-weight: 400; }
.h-round.locked { border-style: dashed; border-color: var(--gold-dim, #a48d3c); }
.h-round.locked .h-round-note { color: var(--gold, #e3c254); font-size: 12px; overflow-wrap: anywhere; }
/* The plan line under the HUD: the stage with its rounds, then the threats, one line while the
   width allows (each part wraps whole first, then within itself). Tonight's threat names the
   battle, so the stage doesn't repeat it. */
.h-plan { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; padding-top: 8px; border-top: 1px solid var(--panel-line); }
/* Its parts sit in .h-plan-body, which lays them out as the plan's own children; a phone folds
   them behind the summary toggle (see "Tabs Hangar"), which is hidden everywhere else. */
.h-plan-body { display: contents; }
.h-plan-toggle { display: none; }
.h-plan-body > .h-stage, .h-plan-body > .h-threat { padding-top: 0; border-top: 0; }
.h-plan-body > .h-stage { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.h-plan .h-stage-battle { margin-left: 0; }
.h-plan-body:has(> .h-threat:not(.h-revealed)) .h-stage-battle { display: none; }
.h-plan .h-round { padding: 1px 8px; }
/* Equip mode: the companions that can take the item lit (a lime outline; the weapon line says
   what pressing does, the strip what it changes); the rest dimmed, the weapon line saying why not.
   On entering Equip mode the lit ones flash three times, then keep the steady glow. */
@keyframes equip-flash {
    0%, 100% { box-shadow: inset 0 0 0 2px var(--accent), 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent); filter: brightness(1); }
    40%      { box-shadow: inset 0 0 0 3px var(--accent), 0 0 26px 6px color-mix(in srgb, var(--accent) 85%, transparent); filter: brightness(1.4); }
}
.hc.equip-target { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent), 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent); animation: equip-flash .6s ease-in-out 3; }
@media (prefers-reduced-motion: reduce) { .hc.equip-target { animation: none; } }
.hc.equip-target .hc-select { cursor: copy; }
.hc.equip-off { opacity: .45; }
.hc.equip-off .hc-select:disabled { opacity: 1; cursor: not-allowed; }
.hc-fit { color: var(--accent); font-weight: 700; }
.hc-nofit { color: var(--muted); }
/* The swap dialog: equipping onto a full slot asks first; with several utilities fitted, one
   row per utility to pick from. */
.swap-dialog { text-align: left; }
.swap-options { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; }
.swap-option { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; white-space: normal; background: transparent; color: #dce5dc; border-color: var(--line); }
.swap-option small { color: var(--muted); }
.swap-option.on { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.swap-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
/* What a swap changes, one line each: the OE first, highlighted, then the stats and skills. */
ul.swap-changes { list-style: none; margin: 0 0 12px; padding: 0; }
.swap-changes { display: flex; flex-direction: column; gap: 2px; }
.swap-changes .swap-oe { width: fit-content; margin-bottom: 2px; padding: 0 8px; border: 1px solid var(--accent); border-radius: 4px; background: #1c2a22; color: var(--accent); font-weight: 600; }

/* A blueprint, on blueprint paper: what it makes, its cost as pips (filled = in stock), its tool. */
.hb { border-color: #2e4250; border-top-color: var(--k); background-color: #132029;
    background-image: linear-gradient(#ffffff08 1px, transparent 1px), linear-gradient(90deg, #ffffff08 1px, transparent 1px); background-size: 12px 12px; }
.hb.ready { border-color: #7d955c; border-top-color: var(--k); box-shadow: 0 0 0 1px var(--accent); }
.hb.fresh { border-color: var(--warn); border-top-color: var(--k); }
/* Equip mode at the Workbench: the card being equipped outlined like the lit companions, every
   other card dimmed (its Equip… still switches to that item); Craft is disabled meanwhile. */
.h-card.hb.equip-src { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.h-card.equip-dim { opacity: .45; }
.hb-top { display: flex; align-items: center; gap: 5px; }
.hb-tier { margin-left: auto; color: var(--muted); font-size: 10px; }
.hb-req { display: flex; align-items: center; gap: 5px; }
.hb-req.ok { color: var(--accent); }
.hb-req.short { color: var(--enemy); }
.hb-rn { flex: 0 0 auto; max-width: 11ch; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hb-pips { display: flex; flex: 1; gap: 2px; }
.hb-pips i { width: 8px; height: 8px; border: 1.5px solid currentColor; border-radius: 50%; }
.hb-pips i.have { background: currentColor; }
.hb .h-foot { justify-content: space-between; }
/* A tool, on brushed workshop steel with a gold hazard strip along the bottom. */
.ht { padding-bottom: 14px; background:
    repeating-linear-gradient(-45deg, rgb(245 220 139 / .22) 0 5px, transparent 5px 10px) bottom / 100% 6px no-repeat,
    radial-gradient(ellipse at 0% 0%, rgb(245 220 139 / .10), transparent 60%),
    repeating-linear-gradient(0deg, #ffffff06 0 1px, transparent 1px 3px), #1b1d15; }


/* Materials: a HUD readout like the Hull's, its chips inside the frame. */
.h-res { flex-wrap: wrap; gap: 4px 6px; }
.h-res .h-stat-label { margin-right: 4px; }
.h-res .h-chip { padding: 1px 8px; }
.h-threat-title { margin-right: 4px; color: var(--muted); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }
.h-chip { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 4px; background: #1c2820; font-size: 12px; }
.h-chip b { font-size: 14px; font-variant-numeric: tabular-nums; }
.h-chip.fresh { border-color: var(--warn); background: #2a2a18; }
.h-plus { color: var(--warn); font-size: 10px; font-weight: 700; }
.h-filters { display: flex; flex-wrap: wrap; gap: 5px; }
.h-filter { min-height: 0; padding: 1px 9px; border-color: #52604c; border-radius: 999px; background: transparent; color: #dce5dc; font-size: 11px; }
.h-filter.on { border-color: var(--accent); background: var(--accent); color: #142018; font-weight: 700; }

/* The top band's second line: tonight's known threat, one chip per enemy kind. */
.h-threat { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding-top: 8px; border-top: 1px solid var(--panel-line); }
.h-threat .h-threat-title { color: var(--enemy); }
.h-threat-chip { min-height: 0; padding: 2px 10px; border: 1px solid #5a2e29; border-radius: 999px; background: var(--enemy-bg); color: #f6c2b8; font-size: 11px; }
.h-threat-chip b { color: var(--enemy); }
.h-threat-chip { display: inline-flex; align-items: center; gap: 5px; }
/* The enemy's small picture before its name: its profile, or its sheet's front frame (.framed). */
.h-threat-icon { width: 18px; height: 18px; object-fit: contain; flex: none; }
.h-threat-icon.framed { object-fit: cover; object-position: var(--frame-x, 0%) 0; }
.h-threat-chip.on { border-color: var(--act); box-shadow: 0 0 0 1px var(--act); }
/* Keyboard only: shown when focused. */
.h-skip:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }

/* The two columns: the paged rows on the left, the inspector on the right. */
.h-main { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(280px, 25vw, 380px); gap: 12px; align-items: start; }
.h-left { min-width: 0; display: flex; flex-direction: column; gap: 8px; }

/* A Workbench card: one selection button in two columns, the name over a large picture on
   the left and the facts on the right (kind, quantity, stats, then ✓ or ! with what it
   lacks), and the action row across the bottom, its buttons sharing the width; every action
   row lines up at the bottom. A card without a picture gives its facts the whole width. */
.hb-select { width: 100%; min-height: 0; display: grid; grid-template-columns: 96px minmax(0, 1fr); grid-template-rows: auto 1fr;
    grid-template-areas: "name info" "art info"; align-items: start; gap: 4px 10px; padding: 0; border: 0;
    background: transparent; color: inherit; font: inherit; text-align: left; white-space: normal; cursor: pointer; }
.hb-select > * { min-width: 0; }
.hb-select > .h-name { grid-area: name; display: block; }
.hb-select > .hb-art { grid-area: art; align-self: center; }
.hb-select > .hb-info { grid-area: info; }
.hb-select:not(:has(> .hb-art)) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "info"; }
.hb-info { display: flex; flex-direction: column; gap: 3px; font-size: 11px; line-height: 1.35; }
.hb-q { color: var(--k); font-size: 10.5px; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hb-q > span { display: block; overflow: hidden; text-overflow: ellipsis; }   /* Available and Equipped, one line each */
.hb-art { display: block; width: 100%; height: 84px; object-fit: contain; border-radius: 4px; }
.hb-status { display: flex; align-items: flex-start; gap: 6px; margin-top: 2px; color: var(--enemy); font-weight: 700; }
.hb-status.ok { color: var(--accent); }
.hb-ico { flex: none; display: grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--enemy); color: #1a0d0b; font-size: 10px; line-height: 1; }
.hb-status.ok .hb-ico { background: var(--accent); color: #142018; }
.hb-why { min-width: 0; display: flex; flex-direction: column; }
.h-cards .hb-info .h-lines { display: flex; flex-direction: column; overflow: visible; white-space: normal; color: #dce5dc; }   /* wraps in its column */
.h-cards .hb-info .h-lines > span:not(:last-child)::after { content: none; }
.h-cards .h-foot { gap: 8px; }
.h-cards .h-foot button { flex: 1; }
/* A blueprint drawing is on solid black: lighten blends the black into the card behind it. */
.hb-art.plan, .hi-art.plan { mix-blend-mode: lighten; }
.hb-reason { margin: 0; min-height: 2.7em; color: var(--enemy); font-size: 11px; line-height: 1.35; }
.hb-reason.ok { color: var(--accent); }
/* A panel's own action, at the top right of its header (Deal on the Workbench, All to sortie
   on the bay): a pixel icon on a dark tile and two lines, what it does over the OE before and
   after. The tabs layout keeps it beside the panel's title (see "Tabs Hangar"). */
.h-cta { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.h-cta-btn { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 3px 14px 3px 4px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.h-cta-btn img { width: 40px; height: 32px; padding: 2px; border-radius: 3px; background: #142018; }
.h-cta-btn.off img { filter: grayscale(.6) brightness(.75); }
.h-cta-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.h-cta-text small { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: none; font-variant-numeric: tabular-nums; }

/* The inspector: the selection's facts, then the actions that spend something. */
.h-insp { position: sticky; top: 0; max-height: calc(100dvh - 160px); overflow-y: auto; overscroll-behavior: contain; }
.h-insp:focus-visible { outline: 2px solid var(--act); }
.hi { container: hi / inline-size; display: flex; flex-direction: column; gap: 8px; font-size: 12px; line-height: 1.45; }
.hi p { margin: 0; }
.hi h3 { font-size: 18px; }
.hi h4 { margin: 6px 0 0; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.hi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hi-portrait { position: relative; aspect-ratio: 4 / 3; max-height: 170px; overflow: hidden; border-radius: 6px; background: #09130f; }
/* In sortie or Reserve: over the portrait's top right corner. The copy beside the name is for
   screen readers, and shows when a short screen drops the portrait. */
.hi-portrait .hc-tag { position: absolute; top: 6px; right: 6px; }
.hi-portrait .hc-tag:not(.on) { background: rgb(14 22 18 / .85); }
/* A unit off the Hangar's bay (an enemy on the scout report): its profile on a patch of open
   ground. A profile is drawn whole, fitted and standing on the bottom; a unit with no profile
   shows its sheet's front frame (.framed). */
.hi-portrait.field { background: radial-gradient(ellipse 52% 14% at 50% 86%, #000c, transparent 70%), linear-gradient(#18241d, #0b110d); }
.hi-enemy .hi-portrait.field { background: radial-gradient(ellipse 52% 14% at 50% 86%, #000c, transparent 70%), linear-gradient(#2a1512, #0f0807); }
.unit-sprite { position: absolute; left: 50%; bottom: 10px; height: calc(100% - 20px); width: 92%; translate: -50% 0; object-fit: contain; object-position: center; }
.unit-sprite.mirror { scale: -1 1; }
/* The board's inspector (Deployment and Battle): the picture alone, no background. */
.hi-portrait.plain { background: transparent; }
/* One square frame of a battle sheet, standing in for a missing profile (here or in the bay). */
.unit-sprite.framed { width: auto; max-width: none; aspect-ratio: 1; object-fit: cover; object-position: var(--frame-x, 0%) 0; }
.hi-facing { position: absolute; bottom: 6px; right: 6px; padding: 1px 6px; border-radius: 4px; background: rgb(14 22 18 / .85); font-size: 11px; color: #dce5dc; }   /* backed: it can sit on the bay picture */
.hc-tag.act { border-color: var(--act); background: var(--act); color: #0b1a1c; font-weight: 700; }
.hc-tag.foe { border-color: var(--enemy-line); color: var(--enemy); }
.hi-portrait .hc-tag.act { background: var(--act); }
.hi-enemy .hi-hp progress { accent-color: var(--enemy); }
.hi-after { color: #ff8a7a; }
.hi-after.heal { color: #7fe07a; }
.hi-facts { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }
/* The board's status line, under the unit's name in the docked inspector. */
.hi-status { margin: -2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.hi-status button { margin-left: 4px; vertical-align: baseline; }
.link-button { min-height: 0; padding: 0; border: 0; background: none; color: var(--act); font: inherit; text-decoration: underline; cursor: pointer; }
.hi-facts .warn { color: var(--warn); }
.hi-head-tag { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.hi-hp { display: flex; flex-direction: column; gap: 3px; }
.hi-hp progress { width: 100%; height: 10px; accent-color: var(--comp); }
.hi-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0; }
.hi-stats > div { min-width: 0; padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; }
.hi-stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }   /* a companion: attack, armor and move in one row */
.hi-stats .wide { grid-column: 1 / -1; }
.hi-stats dt { color: var(--muted); font-size: 10.5px; }
.hi-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.hi-slot, .hi-option { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 4px; }
.hi-slot.glitch { border-color: #6a3c36; background: #2a1a17; color: #f6c2b8; }
.hi-option { border-color: #2e4250; background: #132029; }
.hi-k { flex: none; width: 7ch; color: var(--muted); font-size: 11px; }
.hi-part { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
/* The equipment slots in two columns (UnitInspector): the weapon's block on the left (kind,
   picture, name), the reactor's and the utilities' on the right, the utilities taking the rest
   of the height. At least 125px; it grows with more utilities. Each block is topped in its
   kind's colour (k-weapon, …); an empty one is dashed, an empty weapon's picture faint. */
.hi-loadout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; min-height: 125px; }
.hi-loadout.solo { grid-template-columns: minmax(0, 1fr); }
.hi-loadout-col { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.hi-sock { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 5px 7px; border: 1px solid #2b3a31; border-top: 2px solid var(--k); border-radius: 4px; background: #131d17; }
.hi-sock.empty { border-style: dashed; border-top-style: dashed; background: transparent; }
.hi-sock.wide, .hi-sock.grow { flex: 1; }
.hi-sock.wide { align-items: center; text-align: center; }
.hi-sock-k { align-self: stretch; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
.hi-sock-name { font-weight: 700; overflow-wrap: anywhere; }
.hi-sock-name.dim { color: var(--dim); font-weight: 400; }
.hi-sock-art { flex: 1; width: 100%; min-height: 64px; max-height: 92px; object-fit: contain; }
.hi-sock.empty .hi-sock-art { opacity: .2; }
.hi-part small { color: var(--muted); font-size: 11px; }
.hi-part.dim { color: var(--dim); }
.hi-choose { flex: 1; min-width: 0; min-height: 0; display: flex; justify-content: space-between; padding: 3px 8px; border: 1px dashed var(--line);
    background: transparent; color: var(--muted); font-size: 11px; text-align: left; }
.hi-choose.on { border-style: solid; border-color: var(--act); color: var(--act); }
.hi-choices, .hi-recipients { display: flex; flex-direction: column; gap: 6px; }
.hi-choices { margin-left: 12px; }
.hi-art { display: block; width: 100%; max-height: 120px; object-fit: contain; border-radius: 6px; }
.hi-lines { margin: 0; padding-left: 16px; }
/* The recipe in the inspector: one row per material (its dots, then held/needed) and the tool. */
.hi-reqs { display: flex; flex-direction: column; gap: 4px; }
/* The companions carrying an item, after its requirements. */
.hi-equipped { display: flex; flex-direction: column; gap: 4px; }
.hi-carriers { display: flex; flex-wrap: wrap; gap: 4px; }
.hi-reqs .hb-rn { min-width: 14ch; max-width: none; }
.hi-reqs .hb-pips i { width: 9px; height: 9px; }
.hi-reqs .ok { color: var(--accent); }
.hi-reqs .short { color: var(--enemy); }
.hi-foot { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.hi-foot > button { width: 100%; }
.hi-enemy h3 { color: var(--enemy); }
/* What a weapon does besides its numbers (a stun), under its reach map or its slot. */
.hi-effect { margin: 0; color: var(--warn); font-size: 11px; line-height: 1.4; }
/* Who a strike lands on (all, the nearest, the one picked), under the reach map. */
.hi-hits { margin: 0; font-size: 11px; line-height: 1.4; text-align: center; }
.hi-part .hi-effect { color: var(--warn); }
/* The reach map: the board's own cells (.cell, .slot-cell for a move, .in-range for the
   reach) on the board's half-column grid, small enough to fit the inspector. */
.hi-reach { display: flex; flex-direction: column; gap: 6px; }
/* The combat panel: the stat row and the reach map in one framed block; the map loses its
   own frame and sits on the panel. */
.hi-combat { gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: #0e1612; }
.hi-combat .hi-stats > div { border-color: #2b3a31; background: #131d17; }
.hi-combat .hi-stats dt { display: flex; align-items: center; gap: 5px; }
.hi-combat .reach-map { padding: 2px 0; border: 0; background: transparent; }
.hi-combat .reach-legend { margin: 0; justify-content: center; text-align: center; }
.hi-combat > .h-note { font-size: 10.5px; }
.hi-combat .hi-box-head, .hi-box .hi-box-head { margin: 0 -8px; padding: 0 8px 6px; border-bottom: 1px solid var(--line); }
/* The top: the portrait, and beside it when the inspector is wide enough (else under it) the
   vitals panel: HP and its bar, then attack, armor, move and range in a 2×2 grid, each an icon
   beside its label over its number. Without a portrait the panel takes the whole row. */
.hi-top { display: flex; flex-direction: column; gap: 8px; }
.hi-vitals { display: flex; flex-direction: column; justify-content: space-between; gap: 8px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: #0e1612; }
.hi-vitals .hi-hp { gap: 4px; }
.hi-hp-line { display: flex; align-items: baseline; gap: 14px; }
.hi-hp-line > span { color: var(--muted); }
.hi-hp-line > b { font-size: 16px; font-variant-numeric: tabular-nums; }
.hi-vitals .hi-hp progress { height: 9px; accent-color: var(--gold); }
.hi-enemy .hi-vitals .hi-hp progress { accent-color: var(--enemy); }
.hi-vitals .hi-after { font-size: 11px; }
.hi-xp { display: flex; flex-direction: column; gap: 3px; }
.hi-xp .hi-hp-line > b { font-size: 13px; }
.hi-xp progress { width: 100%; height: 5px; accent-color: var(--comp); }
.hi-quad { gap: 6px; }
.hi-quad > div { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; align-items: center; padding: 6px 8px; border-color: #2b3a31; background: #131d17; }
.hi-quad dt { display: contents; }
.hi-quad dt .ic { grid-row: 1 / 3; width: 16px; height: 16px; color: currentColor; }
.hi-quad dt > span { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10.5px; }
.hi-quad dd { grid-column: 2; font-size: 15px; line-height: 1.2; }
.hi-quad .k-reach .ic { color: #5fb8d6; }   /* the reach map's colours: teal reach, gold move */
.hi-quad .k-move .ic { color: var(--gold); }
.hi-enemy .hi-quad .k-reach .ic { color: var(--enemy); }
@container hi (min-width: 330px) {
    .hi-top { flex-direction: row; align-items: stretch; }
    .hi-top > .hi-portrait { flex: 0 0 44%; aspect-ratio: auto; min-height: 150px; max-height: none; }
    .hi-top > .hi-vitals { flex: 1; }
    .hi-top .hi-quad > div { column-gap: 6px; padding: 5px 6px; }
}
/* Equipment slots and additional info: framed like the combat panel, a heading across the top. */
.hi-box { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: #0e1612; }
.hi-box .hi-slot:not(.glitch) { border-color: #2b3a31; background: #131d17; }
/* As on the board, each hex is a third taller than its row: the rows are 3 parts each and a
   last 1-part row keeps room for the bottom row's points. */
.reach-map { display: grid; grid-template-columns: repeat(var(--half), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(0, 3fr)) minmax(0, 1fr);
    width: min(100%, calc(var(--half) * 20px)); aspect-ratio: calc(var(--half) * 20) / calc(var(--rows) * 27 + 9); margin: 0 auto;
    padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: #0e1612; }
.reach-map .cell { align-self: start; height: calc(100% * 4 / 3); padding: 1px; }
.reach-map .cell::before { inset: 1px; }
.reach-map .cell::after { width: 2px; height: 2px; margin: -1px; }
.reach-map .rm-self-cell::before { --hex-fill: var(--comp-bg); --hex-edge: var(--comp); --hex-w: 1px; }
.hi-enemy .reach-map .rm-self-cell::before { --hex-fill: var(--enemy-bg); --hex-edge: var(--enemy); }
.hi-enemy .reach-map .cell.in-range::before { --hex-fill: var(--foe-reach); }
.hi-enemy .rm-self { color: var(--enemy); }
.rm-self { position: absolute; inset: 0; display: grid; place-items: center; color: var(--comp); font-size: 13px; font-weight: 700; line-height: 1; }
.hi-enemy .rm-self { color: var(--enemy); }
.reach-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; }
.reach-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.hi-stats .rm-key { width: 12px; height: 10px; }
.rm-key { display: inline-block; width: 16px; height: 12px; border-radius: 3px; }
.rm-key.move { background: transparent; box-shadow: inset 0 0 0 2px var(--gold); }
.hi-enemy .rm-key.reach { background: var(--foe-reach); }
.reach-map { --move-w: 2px; }   /* the map's hexes are small: a thinner move border */
.rm-key.reach { background: var(--reach-fill); }
.he-count { flex: none; padding: 0 6px; border-radius: 999px; background: var(--enemy); color: #230f0d; font-size: 10px; font-weight: 700; }

/* A game screen (.board-mode: the Hangar or the board): one header row, the logo and title,
   then the status bar (App.StatusBar) with Help, and a Menu holding Welcome, Feedback and
   Subscribe (and Test and Log on a local host) at every width. Below desktop width the status
   bar's own rules fold Help into the Menu too; on a phone the title is left to the
   logo (still read by screen readers). */
.sb-quick { display: none; }
.sb-run-actions { display: contents; }
.app-shell.board-mode .masthead { padding: 8px 0; gap: 8px 18px; }
.app-shell.board-mode .masthead .eyebrow, .app-shell.board-mode .build-note { display: none; }
.app-shell.board-mode .masthead-title { flex: none; gap: 10px; }
.app-shell.board-mode .masthead h1 { font-size: 17px; white-space: nowrap; }
.app-shell.board-mode .masthead-logo { width: 26px; height: 26px; border-radius: 6px; }
.app-shell.board-mode .masthead .statusbar { flex: 1; min-width: 0; padding: 0; }
.app-shell.board-mode .sb-site { display: inline-block; }
@media (min-width: 950px) {
    .app-shell.board-mode .sb-menu { display: flex; align-items: center; gap: 8px; }
    .app-shell.board-mode .sb-quick { display: flex; gap: 8px; }
    .app-shell.board-mode .sb-quick button { min-height: 0; padding: 0 8px; line-height: 1.5; }
    .app-shell.board-mode .sb-quick button.active { border-color: var(--accent); color: var(--accent); }
    .app-shell.board-mode .sb-menu-toggle { display: inline-flex; align-items: center; min-height: 0; padding: 0 8px; font-size: 12px; line-height: 1.5; }
    .app-shell.board-mode .sb-menu-toggle.active { border-color: var(--accent); color: var(--accent); }
    .app-shell.board-mode .sb-run-actions { display: none; }
    .app-shell.board-mode .statusbar-actions { display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 41; flex-direction: column; gap: 4px; min-width: 150px;
        padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: #151f19; box-shadow: 0 8px 24px #000c; }
    .app-shell.board-mode .statusbar-actions.open { display: flex; }
    .app-shell.board-mode .statusbar-actions button { width: 100%; min-height: 36px; padding: 0 12px; text-align: left; }
    .app-shell.board-mode .sb-menu-scrim { position: fixed; inset: 0; z-index: 40; }
}
@media (max-width: 600px) {
    .app-shell.board-mode .masthead h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ── Hangar layouts (breakpoints: see the compact header above) ─────────────────────────────
   browser.js picks the layout and sets it as data-hangar on <html>: "rows" for a desktop-width
   window at least 650px tall (840px on a touch screen) whose Workbench keeps a row of cards
   under the HUD and the bay, else "tabs" (also before browser.js has run). Both blocks sit in
   :where() so they keep the specificity they had as media queries.
   Tabs: one layout for everything that isn't the two rows (a phone, a tablet, a short
   window), built for a phone. This block is what makes it tabs: the bay and the Workbench one
   at a time, and the details, which a card's details bar (its number, name and ⓘ) opens,
   covering the whole game panel, the dock hidden meanwhile, the × kept at the top as the
   details scroll. The game panel itself doesn't scroll: the Hangar scrolls inside it, so the
   details and the dock ("Tabs Hangar") are placed against the panel and stay put. (A fixed
   box would be placed against the window: .game-body's container query doesn't contain it.)
   The rest is "Tabs Hangar" below. */
:where(:root:not([data-hangar="rows"])) {
    .h-tabs { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; }
    .h-tab { display: flex; flex-direction: column; align-items: center; gap: 0; }
    .h-tab small { color: var(--warn); font-size: 10px; font-weight: 400; }
    .hangar:not([data-tab="bay"]) .h-bay { display: none; }
    .hangar:not([data-tab="bench"]) .h-lower { display: none; }
    .hangar:not([data-details="open"]) .h-insp { display: none; }
    .h-main, .h-left, .h-row1 { display: contents; }
    .h-lower { display: flex; flex-direction: column; }
    .state-panel.hangar-mode { position: relative; padding: 0; overflow: hidden; }
    .state-panel.hangar-mode > .hangar { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
    .h-insp { position: absolute; inset: 0; z-index: 30; width: auto; max-height: none; overflow-y: auto; overscroll-behavior: contain;
        border: 0; border-radius: 0; background-color: #101915; box-shadow: none; }
    .hangar[data-details="open"] :is(.h-tabs, .h-top-actions) { display: none; }
    /* The ×: drawn as the dialogs' × (.dialog-close: a 28px × in a 44px quiet button). The name's
       row is as tall as the × beside it, so the × never covers the HP box under the name. */
    button.h-insp-close { display: grid; top: 0; right: 0; width: 44px; height: 44px; font-size: 28px; }
    .h-insp .hi-head { min-height: 44px; padding-right: 48px; }
}
/* The details' ×: a zero-height bar that sticks to the top, the button hanging from it. */
.h-insp-bar, .insp-bar { position: sticky; top: 0; z-index: 4; height: 0; }
/* Two rows, no scrolling (data-hangar="rows", see above).
   Row 1 is the bay and Tonight side by side: Tonight as wide as its cards (at most 40%), the
   bay the rest; one card row high, or two when the bay's companions overflow one and the
   window still leaves the Workbench a row. Row 2, the Workbench, shows the chosen category in
   as many rows of cards as the height allows. Every area pages sideways
   (browser.js, .pager): its track fills column by column and hides the columns past its
   width; ◀/▶ just inside its edges show how many cards are hidden each way. */
.pager { position: relative; min-width: 0; }
.pager-arrow { display: none; }
:where(:root[data-hangar="rows"]) {
    .hangar-body { overflow: hidden; padding-bottom: 10px; }
    .state-panel.hangar-mode { overflow: hidden; }
    .state-panel.hangar-mode > .hangar { flex: 1; min-height: 0; }
    .hangar { gap: 8px; }
    /* The inspector column runs the full height of both rows and scrolls inside itself. */
    .h-main { flex: 1; min-height: 0; align-items: stretch; }
    .h-left { min-height: 0; }
    .h-insp { position: relative; max-height: none; min-height: 0; }
    .h-row1 { flex-shrink: 0; display: flex; gap: 16px; min-width: 0; }
    .h-row1 > .h-bay { flex: 1 1 0; min-width: 0; }
    .h-head { margin-bottom: 6px; }
    .h-lower { flex: 1; min-height: 0; }
    .h-bench { flex: 1; min-height: 0; }
    .h-scroll.pager-fit { flex: 1; min-height: 0; padding: 0; overflow: hidden; }
    /* A track: --rows rows of cards (browser.js), filled column by column. */
    .pager-track { position: relative; overflow: hidden; padding: 2px; display: grid; grid-auto-flow: column;
        grid-template-rows: repeat(var(--rows, 1), var(--row-h, auto)); grid-template-columns: none; gap: 8px; justify-content: start; align-content: start; }
    .h-mechs.pager-track { --col-min: var(--hc-w); --row-h: var(--hc-h); grid-auto-columns: var(--col-w, var(--col-min)); }
    .h-cards.pager-track { --col-min: 250px; grid-auto-columns: var(--col-w, var(--col-min)); }
    /* Two rows that need no paging fill row by row (browser.js sets --cols), the first row full. */
    .pager-track[data-flow="row"] { grid-auto-flow: row; grid-template-columns: repeat(var(--cols), var(--col-w, var(--col-min))); }
    .pager-track > .hc { width: auto; }
    /* The Workbench's smaller cards: the item's lines on one line (the full text is its title). */
    .h-cards .h-card { gap: 3px; padding: 6px 7px; }
    /* A card fills its row (browser.js stretches the rows into the Workbench's height; measured
       at its own height), and its picture takes the height it gains. */
    .h-cards.pager-track:not([data-measuring]) > .h-card { height: auto; }
    /* Compact cards (browser.js sets [data-compact] when they show more of the library than
       the tall ones): the picture down the card's whole height, as wide as that height makes a
       portrait card (--art-w, at most 88px; 14px is the card's padding and border), and beside
       it the name, one line each of kind, stats and status (no stock line), then a shorter
       action row. The picture stays in the selection button, so it still selects, but is placed
       against the card, because the action row is outside that button. Anything longer is cut;
       the inspector shows it all. */
    .h-cards.pager-track[data-compact][data-measuring] > .h-card { height: var(--wb-compact); }
    .h-cards.pager-track[data-compact] > .h-card { --art-w: clamp(56px, calc((var(--row-h) - 14px) * .67), 88px); gap: 3px; padding: 5px 7px; }
    .h-cards.pager-track[data-compact] > .h-card:has(> .hb-select > .hb-art) { padding-left: calc(15px + var(--art-w)); }
    .h-cards.pager-track[data-compact] .hb-select { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
        grid-template-areas: "name" "info"; gap: 2px; }
    .h-cards.pager-track[data-compact] .hb-select > .hb-art { position: absolute; top: 5px; left: 7px; width: var(--art-w); height: calc(100% - 10px); min-height: 0; max-height: none; }
    .h-cards.pager-track[data-compact] .hb-info { gap: 1px; overflow: hidden; font-size: 10.5px; }
    .h-cards.pager-track[data-compact] .hb-info .h-lines { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .h-cards.pager-track[data-compact] .hb-info .h-lines > span:not(:last-child)::after { content: " · "; }
    .h-cards.pager-track[data-compact] .hb-q { display: none; }   /* Available and Equipped: in the inspector, and on Equip's state */
    .h-cards.pager-track[data-compact] .hb-select { overflow: hidden; }
    .h-cards.pager-track[data-compact] .hb-status { margin-top: 0; }
    .h-cards.pager-track[data-compact] .hb-why { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .h-cards.pager-track[data-compact] .hb-why > * { display: inline-flex; margin-right: 8px; }
    .h-cards.pager-track[data-compact] .h-foot button { min-height: 26px; height: 26px; padding: 0 .5rem; }
    .h-cards.pager-track .hb-select { flex: 1; min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
    .h-cards.pager-track .hb-select > .hb-art { height: 100%; min-height: 84px; max-height: 150px; }
    .h-cards .hb-top { min-width: 0; }
    .h-cards .h-kind { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .h-cards .h-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
    .h-cards .h-lines { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .h-cards .h-lines > span:not(:last-child)::after { content: " · "; }
    /* ◀/▶: a slim tab in the gutter beside the track, as tall as it (browser.js places them). */
    .pager-arrow:not([hidden]) { display: flex; position: absolute; z-index: 4; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 24px;
        min-height: 0; padding: 0; border: 1px solid #3d4b40; border-radius: 4px; background: #121b16; color: var(--accent); font-size: 11px; font-weight: 700; }
    .pager-arrow.prev { left: 0; top: 0; }
    .pager-arrow.next { right: 0; top: 0; }
}
/* A short window, or any touch screen: shorter cards (with --hc-h), in either layout. */
@media (max-height: 879.98px), (pointer: coarse) {
    /* The two-row Hangar's inspector column drops its portrait first, so its facts keep the
       height. The tabs layout's details fill the panel and scroll, so they keep it (as the
       board's inspector does). */
    :root[data-hangar="rows"] .hangar .hi-portrait { display: none; }
    :root[data-hangar="rows"] .hangar .hi-head-tag { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
    /* Workbench: tighter, and the item's lines run together on two lines instead of three. */
    .h-cards .h-card { gap: 3px; padding: 6px 8px; }
    .h-cards .h-lines { display: block; }
    .h-cards .h-lines > span:not(:last-child)::after { content: " · "; }
}

/* ── Tabs Hangar (the tabs layout, the same on a phone, a tablet or a short window) ──────────
   Built for a phone. The parts that stay on screen are kept short, so the cards get the height:
     HUD .............. two rows: the Hull with Repair Hull, then OE (no pips) and the
                        materials as one row that scrolls sideways
     plan line ........ one summary line (StageText.PlanSummary); its toggle opens the stage's
                        rounds and the threats in place
     section header ... the title and its action (Deal, All to sortie) on one line, the filters
                        one row that scrolls sideways; it sticks to the top as the cards scroll
     dock ............. the Bay and Workbench tabs and Position squad along the bottom, within
                        thumb reach; Auto deal ✓ a chip just above it
     cards ............ as many to a row as fit at 300px (one on a phone); a Workbench card
                        compact (its picture down the left); its number, name and ⓘ, one button,
                        open its details over the whole game panel
     dialogs .......... the swap and deal dialogs are sheets along the bottom, buttons stacked */
.h-info, .h-namebar { display: none; }
:where(:root:not([data-hangar="rows"])) {
    .state-panel.hangar-mode > .hangar { gap: 8px; padding: 6px 6px 90px; }   /* the bottom: the dock's height, so the last card clears it */
    .h-top, .h-bay, .h-bench { padding: 8px; }

    .h-hud { gap: 6px; }
    .h-stat { flex: 1 1 auto; min-height: 36px; gap: 4px 8px; padding: 2px 8px; }
    .h-stat-num { font-size: 16px; }
    .h-hull { flex: 1 0 100%; flex-wrap: nowrap; }
    /* No room for the meter beside Repair Hull: the number alone, red when the meter would be. */
    .h-hull .h-meter { display: none; }
    .h-hull:has(.h-meter.low) .h-stat-num { color: var(--enemy); }
    .h-hull .hull-repair { flex: 0 1 auto; min-width: 0; margin-left: auto; white-space: normal; line-height: 1.2; text-align: center; }
    .h-oe { flex: none; }
    .h-oe .h-pips { display: none; }
    .h-res { flex: 1 1 0; min-width: 0; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
    .h-res::-webkit-scrollbar { display: none; }
    .h-res .h-stat-label { display: none; }   /* the group's label still names it */
    .h-res .h-chip, .h-res .h-note { flex: none; white-space: nowrap; }

    .h-plan { display: block; padding-top: 4px; }
    .h-plan-toggle { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: #dce5dc;
        font-size: 12px; text-align: left; }
    .h-plan-summary { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .h-plan-caret { flex: none; color: var(--accent); }
    .h-plan:not(.open) > .h-plan-body { display: none; }
    .h-plan.open > .h-plan-body { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 4px 0 4px; }
    /* The threats, known and revealed, one row each that scrolls sideways, as the materials do. */
    .h-plan-body > .h-threat { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
    .h-plan-body > .h-threat::-webkit-scrollbar { display: none; }
    .h-plan-body > .h-threat > * { flex: none; white-space: nowrap; }

    .hangar h3 { font-size: 15px; }
    .h-head { position: sticky; top: 0; z-index: 5; flex-wrap: wrap; gap: 6px 8px; margin: -8px -8px 8px; padding: 8px 8px 6px;
        border-radius: 4px 4px 0 0; background: #141e18; box-shadow: 0 6px 8px -6px #000c; }
    .h-head > h3 { order: 0; flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .h-head > .h-cta { order: 1; flex: none; margin-left: auto; }
    .h-head > .h-filters { order: 2; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
    .h-head > .h-filters::-webkit-scrollbar { display: none; }
    .h-filter { flex: none; white-space: nowrap; }
    .h-cta-btn { min-height: 44px; padding: 2px 10px 2px 3px; font-size: 12px; }
    .h-cta-btn img { width: 34px; height: 28px; }

    /* The dock: the tab row on the left, Position squad on the right, along the bottom of the
       game panel (placed against it, see the tabs layout), the cards scrolling under both; 10px
       in from the sides and 12px up from the bottom (more above a home indicator). */
    .h-tabs, .h-top-actions { position: absolute; bottom: 0; z-index: 20; margin: 0; padding: 14px 0 calc(12px + env(safe-area-inset-bottom));
        border: 0; background: linear-gradient(to bottom, transparent, #111916 14px); }
    .h-tabs { left: 0; width: 52%; gap: 6px; padding-left: 10px; padding-right: 3px; }
    .h-tabs .h-tab { justify-content: center; min-height: 48px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 6px; background: #151f19; color: #dce5dc; font-size: 12px; }
    .h-tabs .h-tab.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, #151f19); color: var(--accent); }
    .h-top-actions { left: 52%; right: 0; display: flex; gap: 6px; padding-left: 3px; padding-right: 10px; }
    .h-top-actions .h-launch { flex: 1; min-height: 48px; padding: 0 8px; font-size: 12px; letter-spacing: .04em; line-height: 1.2; white-space: normal; }
    .h-top-actions .h-autodeal { position: absolute; right: 10px; bottom: calc(100% - 10px); background: #111916; }

    .h-mechs, .h-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; }
    .hc { width: auto; }
    /* Brought into view (browser.js) clear of the sticky header above and the dock below. */
    .h-card { scroll-margin: 104px 0 96px; }
    /* A compact Workbench card: the picture down the card's left side, beside it the name and
       one line each of kind, stats and status, then the action row (the inspector has it all).
       At least 140px, taller when its lines need it, so the action row never covers them. */
    .h-cards .h-card { --art-w: 72px; height: auto; min-height: 140px; gap: 3px; padding: 6px 8px; }
    .h-cards .h-card:has(> .hb-select > .hb-art) { padding-left: calc(16px + var(--art-w)); }
    .h-cards .hb-select { flex: 1; min-height: 0; overflow: hidden; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
        grid-template-areas: "name" "info"; gap: 2px; }
    .h-cards .hb-select > .hb-art { position: absolute; top: 6px; left: 8px; width: var(--art-w); height: calc(100% - 12px); }
    .h-cards .h-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .h-cards .hb-info { gap: 1px; overflow: hidden; }
    .h-cards .hb-q { display: none; }   /* Available and Equipped: in the inspector, and on Equip's state */
    .h-cards .hb-info .h-lines { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .h-cards .hb-info .h-lines > span:not(:last-child)::after { content: " · "; }
    .h-cards .hb-status { margin-top: 0; }
    .h-cards .hb-why { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .h-cards .hb-why > * { display: inline-flex; margin-right: 8px; }

    /* The details bar: the card's number and name with ⓘ after them, one button as wide as
       they are, that opens the details (its own frame on hover and focus). The name inside the
       card's selection button is hidden from sight but kept for screen readers; the bar is
       named "Details of …". On a companion the bar lies over the tile's own header, which keeps
       its place (see-through); on a Workbench card it is the card's first line. */
    .h-namebar { display: flex; align-items: center; gap: 6px; width: fit-content; max-width: 100%; min-width: 0; min-height: 30px; margin-left: -5px; padding: 0 4px;
        border: 1px solid transparent; border-radius: 6px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
    .h-namebar:focus-visible { border-color: var(--act); outline: none; }
    @media (hover: hover) { .h-namebar:hover { border-color: #52604c; background: rgb(255 255 255 / .04); } }
    .h-namebar-name { display: block; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .h-cards .h-namebar-name { font-size: 13px; font-weight: 700; }
    .hc .h-namebar-name { display: flex; align-items: center; gap: 6px; }
    .h-namebar-name > .hc-name { min-width: 0; }
    .h-info { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid #52604c; border-radius: 50%; background: #101915;
        color: var(--act); font-size: 12px; font-weight: 700; font-style: italic; line-height: 1; }
    .hc .h-namebar { position: absolute; top: 12px; left: 12px; z-index: 3; max-width: calc(100% - 160px); height: var(--hc-btn); min-height: 0; }
    .hc .hc-head > * { opacity: 0; }
    .h-cards .hb-select > .h-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

    .modal-overlay:has(> .swap-dialog) { align-items: flex-end; padding: 0; }
    .modal-dialog.swap-dialog { width: 100%; max-height: 85%; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); border-bottom: 0; border-radius: 10px 10px 0 0; }
    .swap-dialog .dialog-head { top: -20px; margin: -20px -16px 12px; padding: 20px 16px 0; }
    .swap-actions { flex-direction: column-reverse; }
    .swap-actions button { width: 100%; min-height: 48px; }
    .deal-auto { min-height: 44px; }
}

/* ── Touch and pointer ────────────────────────────────────────────────────────────────────
   Every action works by mouse, by finger and by typing. Sizes follow the pointer, not the
   screen width: a tablet is wide but still driven by a finger.
     touch target ........ 44px at least under (pointer: coarse); where a card's fixed layout
                           can't grow that far, an invisible ::before widens the hit area
     hover ............... only under (hover: hover), so a tap never leaves a hover stuck
     double-tap zoom ..... off on controls (touch-action: manipulation), so "tap again" and
                           "press twice" never zoom the page */

/* Notched phones: keep the shell clear of the notch, on its side (left, right) and upright
   (top: the page is drawn under the status bar, viewport-fit=cover). */
.app-shell { padding-top: env(safe-area-inset-top, 0px); padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
@media (max-width: 600px) { .app-shell { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); } }

button, summary, label, [role="button"], .tile { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.battlefield, .hangar { -webkit-touch-callout: none; }

/* The guide strip under the status bar: the last result (or why a pressed control is greyed
   out) and the tutorial tip. It replaces the command dock. */
.guide { flex-shrink: 0; margin: 0 0 10px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #151f19; max-height: 34dvh; overflow-y: auto; }
.guide .latest-message { margin: 0; max-height: none; }
.guide .latest-message.blocked { color: var(--warn); }
.guide .latest-message:empty + .tutorial-hint { margin-top: 0; padding-top: 0; border-top: 0; }
.tutorial-hint .tutorial-show { flex-shrink: 0; align-self: center; }
/* The board screens' strip: one fixed height (a message line and a tip line, both always
   reserved), so nothing in it moves the board. Each line is cut with an ellipsis; the message's
   full text is its title and in the Log, the tip's in its expanded form. Opening the tip is the
   one time it grows, on request. --g-row is the tip line's height (its buttons). */
.guide.fixed { --g-row: 32px; height: calc(var(--g-row) + 12px); overflow: hidden; font-size: 12px; padding: 5px 10px; }
.guide.fixed:has(details[open]) { height: auto; max-height: 34dvh; overflow-y: auto; }
.guide.fixed .tutorial-hint { height: var(--g-row); margin: 0; padding: 0; border: 0; align-items: center; }
.guide.fixed .tutorial-hint .tutorial-badge { margin-top: 0; }
.guide.fixed .tutorial-hint button { min-height: 0; height: var(--g-row); padding-block: 0; }
.guide.fixed:has(details[open]) .tutorial-hint { height: auto; align-items: flex-start; }
.guide.fixed .tutorial-more:not([open]) summary { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* A refusal on the one-line strip (the Hangar on a short screen): one line, the rest in its title. */
.guide.fixed .latest-message { height: var(--g-row); line-height: var(--g-row); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* A full tip's text: two lines; a click shows the rest (App._tipOpen), so the strip keeps a
   predictable height. */
.tutorial-body { cursor: pointer; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.tutorial-body.open { display: block; cursor: default; }
/* A strip holding a tip wears --spot, the hue of the dashed ring on the control the tip is about,
   so the tip and its target read as one. A refusal alone keeps the plain strip; a recovery tip
   keeps its yellow title. */
.guide:has(.tutorial-hint) { border-color: rgb(255 95 210 / .5); border-left: 3px solid var(--spot); background: linear-gradient(90deg, rgb(255 95 210 / .16), rgb(255 95 210 / .04) 45%), #151f19; }
.guide .tutorial-badge { background: var(--spot); color: #2b0a22; }
.guide .tutorial-topic { color: #d9a3c9; }
.guide .tutorial-hint strong { color: #ffc4ee; }
.guide .tutorial-hint.recovery strong { color: #f0d878; }
.guide .tutorial-hint .tutorial-show { border-color: var(--spot); color: var(--spot); }

/* Read by screen readers, not shown. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.statusbar-actions button.active { border-color: var(--accent); color: var(--accent); }

/* A control Core would refuse: dimmed, but pressing it says why (the guide strip). */
button.off { cursor: help; border-color: #3a473d; background: #1a231d; color: #7f8f82; }
button.quiet.off { border-color: #2f3b33; background: transparent; color: #6f7f72; }
/* The control the tip on screen is about. --spot is a hue nothing else on screen uses, so it
   stands apart from the pale accent of borders and buttons. A flashing dashed outline, still
   under reduced motion; Show me pulses it harder. */
@keyframes tip-flash { 0%, 100% { outline-color: var(--spot); } 50% { outline-color: transparent; } }
.tip-target { outline: 2px dashed var(--spot); outline-offset: 2px; animation: tip-flash 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .tip-target { animation: none; } }
/* Show me: the control a tip is about pulses for a moment, a dark gap between it and the ring. */
@keyframes spotlit { 0%, 100% { box-shadow: 0 0 0 3px #111916, 0 0 0 3px rgb(255 95 210 / 0); } 30%, 70% { box-shadow: 0 0 0 3px #111916, 0 0 0 7px rgb(255 95 210 / .9), 0 0 22px 6px rgb(255 95 210 / .55); } }
.spotlit { position: relative; z-index: 30; animation: spotlit .8s ease-in-out 3; outline: 3px solid var(--spot); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .spotlit { animation: none; box-shadow: 0 0 0 3px #111916, 0 0 0 7px rgb(255 95 210 / .9); } }
/* A free hex's button is clipped to the hex, which cuts off any outline or box shadow, so its
   marks are drawn inside it: the hex's own edge and fill, and for Show me a pulsing fill. */
@keyframes tip-flash-hex { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
.slot-button.tip-target { --hex-fill: rgb(255 95 210 / .2); --hex-edge: var(--spot); --hex-w: 3px; outline: none; animation: tip-flash-hex 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .slot-button.tip-target { animation: none; } }
@keyframes spotlit-hex { 0%, 100% { background-color: rgb(255 95 210 / .15); } 30%, 70% { background-color: rgb(255 95 210 / .7); } }
.slot-button.spotlit { --hex-edge: var(--spot); --hex-w: 4px; outline: none; box-shadow: none; animation: spotlit-hex .8s ease-in-out 3; }
@media (prefers-reduced-motion: reduce) { .slot-button.spotlit { --hex-fill: rgb(255 95 210 / .5); animation: none; box-shadow: none; } }

/* Board tile size: − Auto + in the key row. */

/* Battle: an armed touch control asks for its second tap. */
.action-bar button.armed { animation: chip-armed .8s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .action-bar button.armed { animation: none; } }


@media (hover: hover) {
    :where(button:not(:disabled)):hover { filter: brightness(1.1); }   /* low specificity: the rules below override it */
    .tutorial-hint .tutorial-dismiss:hover { border-color: var(--line); color: #dce5dc; }
    /* A filter on a card's button would cut its blueprint picture off from the card behind it
       (lighten would then show the drawing's black), so only the facts brighten. */
    .hb-select:hover:not(:disabled) { filter: none; }
    .hb-select:hover:not(:disabled) > :not(.hb-art) { filter: brightness(1.1); }
    /* The card under the pointer: a lighter face and a cyan outline (selected keeps its own). */
    .h-card:not(.selected):has(> .hb-select:hover:not(:disabled)) { border-color: rgb(128 220 229 / .7); border-top-color: var(--k); background-color: #1e3340; box-shadow: 0 0 0 1px rgb(128 220 229 / .45); }
    .t-strip button:not(.tc-act):not(.tc-repair):not(.t-turn):not(.ab-end):not([aria-expanded="true"]):hover:not(:disabled) { border-color: var(--act); background: rgb(128 220 229 / .45); color: #fff; filter: none; }
    .fc-dir:not(.now):not([data-reach]):hover:not(:disabled) { border-color: var(--act); background: rgb(128 220 229 / .3); color: #fff; filter: none; }
    .fc-dir[data-reach]:hover:not(:disabled) { filter: brightness(1.2); }
    .board-frame:hover .minimap-svg:not(:hover) { opacity: .45; }
    .minimap-svg:active { cursor: grabbing; }
    button.new-game:not(.confirm):hover:not(:disabled) { background: var(--enemy-bg); }
}


@media (pointer: coarse) {
    /* Buttons the layout made small, back to a finger's size. */
    .board-screen .action-bar { --ab-btn: 44px; }
    .facing-compass { --fc: 44px; }
    .tc-buttons button { min-height: 44px; }
    button.compact, .recap button, .help-tabs button, .h-tab, .h-filter, .h-threat-chip, .hi-choose,
    .statusbar-actions button, .hull-repair, .leave-run, .tutorial-hint .tutorial-dismiss, .app-shell.board-mode .sb-quick button, .app-shell.board-mode .sb-menu-toggle { min-height: 44px; }
    .statusbar-actions button, .hull-repair, .leave-run { padding: 0 12px; }
    .masthead-actions button { min-height: 44px; }   /* the compact header's buttons stay finger-sized */
    .h-filter { padding: 0 14px; font-size: 12px; }
    .tutorial-hint .tutorial-show { min-height: 44px; }
    .guide.fixed { --g-row: 44px; }
    .tutorial-hint .tutorial-dismiss { min-width: 44px; }
    .board-key summary, .tutorial-why summary, .tutorial-more summary, .feedback-details summary { padding: 10px 0; }

    /* The edge markers. */
    .edge-mark, .size-small .edge-mark { min-height: 44px; padding: 0 14px; font-size: 13px; }
}

/* ── Phone (up to 640px wide) ──────────────────────────────────────────────────────────────
   One rule for what opens over the game: every dialog, the Leave this run panel (and the run's
   end) cover the game panel's box (browser.js --panel-*), as the Hangar's and
   the board's details do; with no game panel (the welcome page), the whole screen. Headings a
   size smaller, so they keep to one line. */
@media (max-width: 640px) {
    .modal-overlay, .app-shell > .leave-panel {
        position: fixed; top: var(--panel-top, 0px); left: var(--panel-left, 0px); width: var(--panel-width, 100vw); height: var(--panel-height, 100dvh); margin: 0; }
    .modal-overlay { z-index: 50; display: flex; padding: 0; background: none; }
    .modal-overlay > .modal-dialog { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 16px; overflow-y: auto;
        border: 1px solid var(--line); border-radius: 7px; box-shadow: none; }
    .modal-overlay .dialog-head { top: -16px; margin: -16px -16px 12px; padding: 16px 16px 0; }
    .modal-dialog h2, .history-heading h2 { font-size: 16px; letter-spacing: .04em; }
    .history-panel { top: var(--panel-top, 0px); left: var(--panel-left, 0px); width: var(--panel-width, 100vw); height: var(--panel-height, 100dvh);
        max-width: none; max-height: none; margin: 0; box-shadow: none; }
    .history-panel::backdrop { background: transparent; }
    .app-shell > .leave-panel { z-index: 35; max-height: none; overflow-y: auto; padding: 16px; border: 1px solid var(--accent);
        border-radius: 7px; background: #151f19; font-size: 13px; }
    .leave-panel button { white-space: normal; text-align: center; }

    /* The tip: two lines, without its topic label, so it can be read without opening it. */
    .guide.fixed .tutorial-more:not([open]) summary { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
        overflow: hidden; white-space: normal; line-height: 1.3; }
    .guide.fixed .tutorial-more:not([open]) summary .tutorial-topic { display: none; }
    .guide.fixed .latest-message { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
        height: auto; max-height: var(--g-row); white-space: normal; line-height: 1.3; }

    /* The status bar keeps one line: Leave run moves into the Menu, and the Hull is under the
       board (the Hangar has it in its HUD). */
    .sb-group .leave-run { display: none; }
    .sb-leave { display: block; }
    .app-shell.board-mode .sb-hull { display: none; }

    /* A compact companion card: the bay picture on the left half, the stats beside it in two
       rows and the weapon under them. */
    :where(:root:not([data-hangar="rows"])) {
        .hc { height: 172px; }
        .hc-art > .hc-scene { right: auto; width: 48%; }   /* the card's only: the details' portrait keeps its whole box */
        .hc-strip { top: 4px; bottom: auto; left: calc(48% + 6px); grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 3px; }
        .hc-strip > span:nth-child(3) { border-right: 0; }
        .hc-tags { left: calc(48% + 6px); bottom: 4px; }
        .hc .hc-revive { left: 24%; min-width: 0; max-width: 46%; white-space: normal; }
    }
}

/* Finger-sized: the welcome page's links and the checkboxes; the Test dialog's pickers. */
@media (pointer: coarse) {
    .welcome-topline nav a, .hero-links a { display: inline-block; padding: 12px 4px; }
    input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
    .test-dialog select { min-height: 44px; }
}

/* A phone held sideways (browser.js watchRotate sets :root[data-rotate]): the game screens'
   cover asks for the phone upright, over everything, dialogs included. */
.rotate-cover { display: none; }
:root[data-rotate] .rotate-cover { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; padding: 16px; background: #101915; text-align: center; }
:root[data-rotate] body { overflow: hidden; }
.rotate-icon { width: 64px; height: 64px; margin-bottom: 6px; fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
}
.rotate-title { margin: 0; font-size: 16px; color: #dce5dc; }
.rotate-text { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.rotate-cover button { min-height: 36px; padding: 0 14px; font-size: 12px; color: var(--muted); }
