:root {
    --bg: #07090c;
    --surface: #10141a;
    --surface-2: #161b23;
    --line: #253041;
    --text: #e7ecf2;
    --muted: #8a97a8;
    --cyan: #4fd1ff;
    --cyan-dim: #1f6f8a;
    --amber: #ffb02e;
    --good: #59d98e;
    --bad: #ff5a6a;
    --radius: 6px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --mono: "Cascadia Mono", "Consolas", ui-monospace, monospace;
    color-scheme: dark;
}

* { box-sizing: border-box; }
#app { min-height: 100%; display: grid; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
button, input, select { font: inherit; color: inherit; }
img { display: block; }

button {
    background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 6px 12px; cursor: pointer; transition: background .15s, border-color .15s;
}
button:hover:not(:disabled) { border-color: var(--cyan-dim); background: #1b2330; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
button.primary { background: #0d4a60; border-color: #1690ba; color: #eafaff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #12607c; border-color: var(--cyan); }
button.danger { border-color: #8a2c36; }
button.primary.danger { background: #6b1d26; border-color: #b33242; }
button.primary.danger:hover:not(:disabled) { background: #85242f; border-color: var(--bad); }
button.big { padding: 10px 16px; font-size: 16px; width: 100%; }
button.ghost { background: transparent; }
select { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 6px; }

.kicker { font: 600 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); margin: 0 0 8px; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; text-align: center; }
.fatal { padding: 40px; text-align: center; color: var(--bad); }

/* ------------------------------------------------------------ setup */

.setup {
    min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
    /* The board in use (--menu-board, set by app.js setBoardArt), darkened. */
    background: linear-gradient(rgba(7, 9, 12, .78), rgba(7, 9, 12, .92)), var(--menu-board, url("../../assets/board/board-own-small.webp")) center / cover;
}
.setup-card {
    width: min(560px, 100%); background: #10141a; border: 1px solid var(--line);
    border-radius: 10px; padding: 28px; box-shadow: 0 20px 60px #000a;
    position: relative; overflow: hidden; isolation: isolate;
}
/* The menu scene drifts behind the card's content (sprites.js, menuScene),
   darkened at the top so the text reads. */
.menu-scene {
    --ps: 1; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    /* The sky fades into the card instead of starting with a hard edge. */
    -webkit-mask-image: linear-gradient(to top, #000 calc(var(--h, 324) * .62px), transparent calc(var(--h, 324) * 1px));
    mask-image: linear-gradient(to top, #000 calc(var(--h, 324) * .62px), transparent calc(var(--h, 324) * 1px));
}
.menu-scene .px-layer:first-child { animation: none; }
.menu-scene::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(rgba(16, 20, 26, .9) 0%, rgba(16, 20, 26, .7) 55%, rgba(16, 20, 26, .45) 75%, rgba(16, 20, 26, .15) 100%);
}
.title { font: 800 34px/1.05 var(--font); letter-spacing: .02em; text-transform: uppercase; margin: 0 0 12px; color: #fff; }
.lede { color: #c4ccd6; margin: 0 0 20px; }
/* The start screen's heading: the text, and the USPF badge on its right at 2x its pixels. */
.setup-head { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: start; }
.uspf-badge { width: 112px; height: 144px; image-rendering: pixelated; filter: drop-shadow(0 0 8px rgba(78, 195, 255, .35)); }
@media (max-width: 520px) { .uspf-badge { width: 56px; height: 72px; } .setup-head { gap: 12px; } }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font: 600 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.color-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.color-opt {
    display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
    border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; background: var(--surface-2);
}
.color-opt input { position: absolute; opacity: 0; pointer-events: none; }
.color-opt:has(input:checked) { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.color-opt:has(input:focus-visible) { outline: 2px solid var(--cyan); }
.color-dot { grid-row: span 2; width: 18px; height: 18px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px #000, 0 0 0 4px var(--c); }
.color-name { font-weight: 600; }
.color-start { font-size: 12px; color: var(--muted); }
/* The campaign's missions (D-29). */
.level-list { display: grid; gap: 6px; }
.level-opt {
    display: grid; grid-template-columns: 22px auto 1fr auto; column-gap: 10px; align-items: center;
    border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; cursor: pointer; background: var(--surface-2);
}
.level-opt input { position: absolute; opacity: 0; pointer-events: none; }
.level-opt:has(input:checked) { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.level-opt:has(input:focus-visible) { outline: 2px solid var(--cyan); }
.level-opt .color-dot { grid-row: auto; }
.level-num { font: 700 18px var(--mono); color: var(--muted); text-align: center; }
.level-opt:has(input:checked) .level-num { color: var(--c); }
.level-main { display: grid; min-width: 0; }
.level-name { font-weight: 600; }
.level-meta { font-size: 12px; color: var(--muted); }
.level-state { font: 600 10px var(--mono); letter-spacing: .1em; color: var(--good); }
.level-opt.locked { cursor: not-allowed; opacity: .45; }
.level-opt.locked .level-state { color: var(--muted); }
.level-opt.locked .color-dot { filter: grayscale(1); }
.level-note { font-weight: 600; color: var(--good); }
.level-note[data-won="no"] { color: var(--bad); }
.lives { font-size: 12px; color: #ff6b6b; white-space: nowrap; }
.lives[data-low="yes"] { animation: lifeLow 1.2s ease-in-out infinite; }
@keyframes lifeLow { 50% { opacity: .4; } }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 14px; border-right: 1px solid var(--line); }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: #0d4a60; color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--cyan); outline-offset: -2px; }
details { margin: 0 0 20px; color: #c4ccd6; }
summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
.check { display: block; margin: 6px 0; cursor: pointer; }
.check.soon { color: var(--muted); cursor: default; }
.check small { color: var(--amber); }
.field { display: block; margin-top: 10px; }
.field input { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px; width: 180px; }

/* ------------------------------------------------------------ game layout */

.game {
    height: 100vh; display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top top" "board side" "hand side";
}
.game > * { min-width: 0; }
.topbar {
    grid-area: top; display: flex; align-items: center; gap: 18px; padding: 8px 14px;
    background: var(--surface); border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 13px;
}
.brand { font-weight: 800; letter-spacing: .12em; color: var(--cyan); }
.turn { color: var(--muted); }
.dice { display: inline-flex; align-items: center; gap: 4px; min-width: 90px; }
.die { font-size: 26px; line-height: 1; }
.decks { color: var(--muted); display: inline-flex; gap: 12px; align-items: center; }
/* The draw piles: the deck's back, with more card edges under it the more cards are left. */
.deck-pile { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); }
.deck-pile img { height: 30px; width: auto; border-radius: 2px; display: block; }
.deck-pile[data-size="high"] img { box-shadow: 1px 1px 0 #000, 2px 2px 0 #8a8f96, 3px 3px 0 #000, 4px 4px 0 #8a8f96, 5px 5px 0 #000; }
.deck-pile[data-size="mid"] img { box-shadow: 1px 1px 0 #000, 2px 2px 0 #8a8f96, 3px 3px 0 #000; }
.deck-pile[data-size="low"] img { box-shadow: 1px 1px 0 #000; }
.deck-pile[data-size="empty"] img { opacity: .25; filter: grayscale(1); }
.clock-on { color: var(--bad); font-weight: 700; animation: pulse 1s infinite alternate; }
.clock-armed { color: var(--amber); }
.spacer { flex: 1; }

.board-area {
    grid-area: board; position: relative; min-height: 0; background: #000; overflow: hidden;
    container-type: size; display: grid; place-items: center;
}
.board-svg { width: 100%; height: 100%; }
/* Exactly the board's shape (1650 x 870), centred: the SVG has no spare bands,
   so a zoomed board stays inside the frame instead of spilling round it. */
.board-host {
    position: relative;
    width: min(100cqw, calc(100cqh * 1650 / 870)); height: min(100cqh, calc(100cqw * 870 / 1650));
}
/* Fitted like the SVG (contain = preserveAspectRatio meet), so it matches the
   board seen whole and stays still while the SVG zooms underneath. */
.board-frame {
    /* Stretched to the host (which has the board's shape) and a pixel wider all
       round, so rounding never leaves a 1px sliver of the board showing. */
    position: absolute; inset: -1px; pointer-events: none;
    background: url("../../assets/board/board-frame.webp") center / 100% 100% no-repeat;
}
@media (max-width: 900px) { .board-frame { background-image: url("../../assets/board/board-small-frame.webp"); } }
.board-svg { display: block; cursor: grab; touch-action: none; user-select: none; }
.board-svg.panning { cursor: grabbing; }
.zoom-btns { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 4px; }
.zoom-btns button { width: 32px; height: 32px; padding: 0; background: rgba(16, 20, 26, .85); }

.zone { fill: transparent; stroke: none; }
.zone.option { fill: rgba(79, 209, 255, .16); stroke: var(--cyan); stroke-width: 2.4; stroke-dasharray: 6 3; cursor: pointer; animation: march 1s linear infinite; }
.zone.option.hover { fill: rgba(79, 209, 255, .34); stroke-width: 3.2; }
/* A destination tapped once with a finger: it pulses, with its label, until the second tap (boardView.armTouch). */
.zone.option.armed { animation: march 1s linear infinite, armPulse .9s ease-in-out infinite alternate; }
@keyframes armPulse { from { fill: rgba(79, 209, 255, .2); } to { fill: rgba(79, 209, 255, .55); } }
.arm-label { pointer-events: none; }
.arm-label rect { fill: rgba(7, 9, 12, .9); stroke: var(--cyan); stroke-width: 1.2; }
.arm-label text { font: 600 12px var(--font); fill: #fff; }
.zone.flash { animation: flash .8s ease-out; }
/* The route preview, hand-drawn (boardView.js sketchPath, the #route-pencil filter): a wavering
   curve of uneven dashes, a dot where each step lands and an arrowhead at the end. */
.route { pointer-events: none; }
.route-line, .route-edge { fill: none; stroke-dasharray: 12 6 5 7; stroke-linecap: round; stroke-linejoin: round; }
.route-line { stroke: var(--route, #fff); stroke-width: 4.4; }
.route-edge { stroke: rgba(8, 10, 14, .7); stroke-width: 7.4; }   /* a dark rim, so the colour reads on any zone */
.route-dot { fill: var(--route, #fff); stroke: rgba(8, 10, 14, .7); stroke-width: 1.6; }
.route-arrow, .route-arrow-edge { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.route-arrow { stroke: var(--route, #fff); stroke-width: 4.8; }
.route-arrow-edge { stroke: rgba(8, 10, 14, .7); stroke-width: 7.8; }
.token { transition: transform .17s ease-in-out; pointer-events: none; }
.token-base { fill: #000; }
.token-body { stroke: #fff; stroke-width: 2.4; }
.token-halo { fill: none; stroke: transparent; stroke-width: 2.5; }
.token.current .token-halo { stroke: #fff; animation: halo 1.2s ease-out infinite; }

.clue-token { pointer-events: auto; }
.clue-token rect { fill: #0d4a60; stroke: var(--cyan); stroke-width: 2; }
.clue-token text { font: 700 12px var(--font); fill: #fff; pointer-events: none; }
/* A clue token on its way to another zone (moveClueToken). */
.clue-token.flying { filter: drop-shadow(0 0 6px var(--cyan)) drop-shadow(0 6px 4px rgba(0, 0, 0, .6)); }
.dialog.ambush { width: min(520px, 100%); }
.loot { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.loot .card { width: 110px; border-radius: 4px; }
.hint.left { text-align: left; }
.hand-card { position: relative; }
.hand-card .attached { position: absolute; left: 4px; bottom: 4px; background: #000c; color: var(--amber); font: 600 10px var(--mono); padding: 1px 4px; border-radius: 3px; }

/* Your 3D dice (dice3d.js) roll over the board, then fade out before you choose where to go. */
.dice-layer { position: absolute; inset: 0; z-index: 6; pointer-events: none; opacity: 0; transition: opacity .25s ease; }
.dice-layer.show { pointer-events: auto; opacity: 1; cursor: pointer; }
.dice-caption {
    position: absolute; left: 50%; top: 18px; transform: translateX(-50%); z-index: 1; pointer-events: none; white-space: nowrap;
    padding: 8px 16px; border-radius: var(--radius); font: 700 15px var(--font); color: var(--text, #e8e8e8);
    background: rgba(16, 20, 26, .9); border: 1px solid var(--line);
}
.dice-caption:empty { display: none; }

.banner {
    position: absolute; left: 50%; top: 18px; transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
    padding: 10px 18px; border-radius: var(--radius); font: 700 16px var(--font); white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
    background: rgba(16, 20, 26, .95); border: 1px solid var(--line); box-shadow: 0 8px 30px #000c;
}
.banner.show { animation: banner 2.4s ease forwards; }
.banner[data-kind="good"] { border-color: var(--good); color: var(--good); }
.banner[data-kind="bad"] { border-color: var(--bad); color: var(--bad); }
.banner[data-kind="alert"] { border-color: var(--bad); color: #fff; background: #5a1520; }

/* ------------------------------------------------------------ side panels */

.side { grid-area: side; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line); }
/* The panels keep their height (a min-height would let them shrink under the next one); the log takes
   what is left and, on a short screen, the whole column scrolls. */
.side > .panel { flex-shrink: 0; }
.panel { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel h2 { font: 600 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.player { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius); border: 1px solid transparent; }
.player[data-current="yes"] { border-color: var(--cyan-dim); background: #0c1a22; }
.player[data-alive="no"] { opacity: .45; text-decoration: line-through; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 2px #000; vertical-align: -1px; }
.player-name { font-weight: 600; }
.player-where { font-size: 12px; color: var(--muted); }
.player-tags { display: flex; gap: 6px; align-items: center; font-family: var(--mono); }
.player-tags small { color: var(--muted); }
/* A bot's hand, face down (handFan in panels.js). */
.fan { display: inline-flex; align-items: flex-end; padding: 0 6px 0 12px; height: 30px; }
.fan img {
    height: 26px; width: auto; margin-left: -12px; border-radius: 2px; box-shadow: -1px 0 2px #000a;
    transform-origin: 50% 100%; transform: translateY(var(--y)) rotate(var(--r));
}
.tag { font-size: 10px; padding: 1px 5px; border-radius: 3px; background: #4a3510; color: var(--amber); }

.action-panel { min-height: 120px; }
.action-panel:empty { display: none; }
.action { display: grid; gap: 8px; }
.prompt { margin: 0; }
/* "Green is playing…" in the top bar while a bot decides. */
.playing { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.playing:empty { display: none; }
.playing[data-kind="hint"] { color: var(--cyan); }
.playing[data-kind="hint"]::after { content: none; }
.playing::after { content: ""; display: inline-block; width: 1.5ch; animation: dots 1s steps(4) infinite; }
.dest-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 140px; overflow: auto; }
.dest { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; font-size: 13px; }

.spot { display: grid; grid-template-columns: 86px 1fr; gap: 12px; align-items: center; }
.spot-card { width: 86px; border-radius: 4px; }
.spot-who { margin: 0; font-weight: 600; }
.spot-name { margin: 2px 0 6px; font-size: 18px; font-weight: 700; }
.spot-note { margin: 0; font-size: 13px; color: var(--muted); }
.spot-note[data-kind="good"] { color: var(--good); }
.spot-note[data-kind="bad"] { color: var(--bad); }

.log-panel { flex: 1 1 0; min-height: 120px; display: flex; flex-direction: column; border-bottom: 0; }
.log { list-style: none; margin: 0; padding: 0; overflow-y: auto; font-size: 12.5px; color: #c4ccd6; }
.log li { padding: 2px 0; border-bottom: 1px solid #141a22; }
.log li[data-player="yellow"] { border-left: 2px solid #f5d020; padding-left: 6px; }
.log li[data-player="blue"] { border-left: 2px solid #38a6ff; padding-left: 6px; }
.log li[data-player="green"] { border-left: 2px solid #3fd16b; padding-left: 6px; }
.log li[data-player="red"] { border-left: 2px solid #ff4d4d; padding-left: 6px; }
.log li[data-type="prizeFound"], .log li[data-type="escaped"], .log li[data-type="endClockStarted"] { color: #fff; font-weight: 700; }

/* ------------------------------------------------------------ hand */

.hand-bar { grid-area: hand; position: relative; display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--surface); border-top: 1px solid var(--line); min-height: 0; }
.hand-label { font: 600 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); writing-mode: vertical-rl; transform: rotate(180deg); }
.hand-host { flex: 1; overflow-x: auto; overflow-y: visible; }
.hand-cards { display: flex; gap: 8px; padding: 4px 2px; }
.hand-card { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; flex: none; transition: transform .15s, border-color .15s; }
.hand-card:hover { transform: translateY(-4px); border-color: var(--cyan-dim); }
.hand-card .card { width: 84px; border-radius: 4px; }
.hand-card[data-selectable="yes"] { border-color: var(--amber); }
.hand-card[data-selected="yes"] { border-color: var(--bad); transform: translateY(-8px); box-shadow: 0 0 0 2px var(--bad); }
.hand-card[data-selected="yes"] .card { opacity: .6; }
.empty { color: var(--muted); margin: 0; }

/* ------------------------------------------------------------ dialogs */

.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .66); display: grid; place-items: center; padding: 16px; z-index: 20; animation: fade .18s ease; }
.dialog { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px; box-shadow: 0 20px 60px #000c; max-height: calc(100vh - 32px); overflow: auto; }
.dialog h2 { margin: 0 0 10px; font-size: 26px; }
.dialog .row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.dialog.encounter { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 22px; width: min(1000px, 100%); }
.card.big { width: 230px; border-radius: 8px; box-shadow: 0 10px 30px #000a; }
.forced { color: var(--bad); margin: 0 0 12px; font-weight: 600; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.choice { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.choice[data-disabled="yes"] { opacity: .55; }
.choice h3 { margin: 0; font-size: 15px; text-transform: uppercase; letter-spacing: .08em; }
.choice .rule { margin: 0; color: #c4ccd6; }
.choice .chance { margin: 0; font-family: var(--mono); }
.choice .fail { margin: 0; font-size: 12px; color: var(--muted); flex: 1; }
.choice .fail.warn { color: var(--bad); font-weight: 600; }
.choice button { margin-top: 4px; }
.pick { border-top: 1px solid var(--line); padding-top: 6px; }
.pick-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.odds { font-weight: 700; }
/* A weapon's or a friend's fight power, in marks (panels.js power()). */
.power { color: var(--amber); letter-spacing: .05em; font-size: .85em; }

/* The encounter roulette (roulette.js, D-28): pixel-art cells (assets/ui/roulette.png: success
   off/on, failure off/on, 16 px each) at 3x, or 2x for the friends' row. */
/* Card effects (cardfx.js): decks shuffled side by side, a drawn card turning over. */
.cardfx-layer { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity .2s ease; background: radial-gradient(ellipse at center, #000c 0%, #0008 55%, #0000 85%); }
.cardfx-layer.show { pointer-events: auto; opacity: 1; cursor: pointer; }
.fx-shuffle { display: flex; gap: clamp(40px, 10vw, 120px); }
.fx-deck { display: grid; justify-items: center; gap: 14px; }
.fx-slot { position: relative; width: 110px; aspect-ratio: 411 / 561; }
.fx-pile { position: absolute; inset: 0; }
.fx-card {
    position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 6px; box-shadow: 0 4px 10px #000c;
    transform: translateY(calc(var(--i) * -1.5px));
    animation: 1s ease-in-out calc(var(--start, 0ms) + var(--i) * 25ms) 2 both;
}
/* A reshuffle: the discard pile slides in face up from the left and turns into the deck... */
.fx-deck[data-gather="yes"] .fx-pile { animation: fxAppear .15s linear calc(var(--start) - 150ms) both; }
@keyframes fxAppear { from { opacity: 0; } to { opacity: 1; } }
.fx-incoming { position: absolute; inset: 0; z-index: 20; animation: fxGather var(--start) ease-in both; }
.fx-in-card { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 6px; box-shadow: 0 4px 10px #000c; }
.fx-incoming .fx-in-card { transform: translate(calc(var(--k) * 2px), calc(var(--k) * 2px)); }
@keyframes fxGather {
    0% { transform: translateX(-190%) rotate(-10deg); opacity: 1; }
    70% { transform: none; opacity: 1; }
    100% { transform: rotateY(90deg); opacity: 0; }
}
/* ...and the clock card, after the riffles, goes into the bottom half of the encounter deck. */
.fx-clock { position: absolute; inset: 0; z-index: 3; opacity: 0; animation: fxClock 1.4s ease-in-out calc(var(--start) + 2s) both; }
@keyframes fxClock {
    0% { opacity: 0; transform: translateY(-115%) scale(.95); }
    20%, 45% { opacity: 1; transform: translateY(-105%) scale(1); }
    85% { opacity: 1; transform: translateY(6%) scale(.97); }
    100% { opacity: 0; transform: translateY(8%) scale(.97); }
}
.fx-clock-label { color: var(--amber); opacity: 0; animation: fxAppear .3s linear calc(var(--start) + 2s) both; }
/* The discard piles in the top bar: face up, the top card showing. */
.deck-pile.discard img { opacity: .9; }
.deck-pile.discard[data-size="empty"] img { opacity: .2; filter: grayscale(1); }
.deck-pile.discard b { color: var(--muted); font-weight: 400; }
.fx-card.left { animation-name: riffleLeft; }
.fx-card.right { animation-name: riffleRight; }
/* Split the deck in two halves, hold, and let them fall back in, interleaved. */
@keyframes riffleLeft {
    0% { transform: translateY(calc(var(--i) * -1.5px)); }
    30%, 45% { transform: translate(-62%, calc(var(--i) * -1.5px)) rotate(-9deg); }
    80%, 100% { transform: translateY(calc(var(--i) * -1.5px)); }
}
@keyframes riffleRight {
    0% { transform: translateY(calc(var(--i) * -1.5px)); }
    30%, 45% { transform: translate(62%, calc(var(--i) * -1.5px)) rotate(9deg); }
    80%, 100% { transform: translateY(calc(var(--i) * -1.5px)); }
}
/* A prize you found (GameUI.prizeScene). */
.prize-scene {
    display: grid; justify-items: center; gap: 10px; width: min(640px, calc(100% - 32px)); padding: 18px 20px;
    background: var(--surface); border: 1px solid var(--amber); border-radius: 10px; box-shadow: 0 20px 60px #000c;
}
.prize-scene h2 { margin: 0; font-size: 26px; color: var(--amber); }
.prize-scene .kicker { margin: 0; }
.prize-scene .stage { width: 100%; --s: 3; }
.prize-scene .hint { margin: 0; text-align: center; }
.fx-label { font: 600 12px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); text-shadow: 0 1px 3px #000; }
/* The wrapper rises, stays and drops (with the fade); the card inside only turns over, since an
   opacity on the turning element would flatten its 3D and show the back mirrored. */
.fx-reveal { perspective: 900px; animation: cardRise 1.5s ease-in-out both; }
.fx-flip {
    position: relative; width: min(200px, 34vw); aspect-ratio: 411 / 561; transform-style: preserve-3d;
    animation: cardTurn 1.5s ease-in-out both;
}
.fx-flip > img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 8px; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 10px 30px #000d; }
.fx-face { transform: rotateY(180deg); }
/* Up from below, turn over, stay to be read, then drop towards your hand. */
@keyframes cardRise {
    0% { transform: translateY(40%) scale(.6); opacity: 0; }
    15%, 80% { transform: none; opacity: 1; }
    100% { transform: translateY(70%) scale(.5); opacity: 0; }
}
/* ...or, with the card's place in your hand (cardfx.js, reveal), fly there and land at its size.
   Fixed over the board's centre (--cx, --cy), so the board's overflow does not clip it on the way. */
.fx-reveal.to-hand { position: fixed; left: var(--cx); top: var(--cy); animation-name: cardToHand; }
@keyframes cardToHand {
    0% { transform: translate(-50%, -10%) scale(.6); opacity: 0; }
    15%, 68% { transform: translate(-50%, -50%); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--to-x)), calc(-50% + var(--to-y))) scale(var(--to-s)); opacity: 1; }
}
@keyframes cardTurn {
    0%, 15% { transform: rotateY(0); }
    40%, 100% { transform: rotateY(180deg); }
}
.roulette-layer { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity .25s ease; }
.roulette-layer.show { pointer-events: auto; opacity: 1; cursor: pointer; }
.rl-panel { display: grid; justify-items: center; gap: 14px; padding: 16px 20px 20px; border-radius: var(--radius); background: rgba(10, 14, 19, .9); border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(0, 0, 0, .6); max-width: calc(100% - 24px); }
.rl-caption { font: 700 16px var(--font); color: var(--text, #e8e8e8); letter-spacing: .02em; }
.rl-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.roulette { --cell: 48px; display: grid; justify-items: center; gap: 6px; }
.roulette.small { --cell: 32px; }
.rl-label { font: 600 13px var(--font); color: #c4ccd6; }
.rl-grid { display: grid; grid-template-columns: repeat(6, var(--cell)); gap: calc(var(--cell) / 6) calc(var(--cell) / 8); }
.rl-cell {
    width: var(--cell); height: var(--cell); image-rendering: pixelated;
    background: url("../../assets/ui/roulette.png") 0 0 / calc(var(--cell) * 4) var(--cell) no-repeat;
}
.rl-cell.on { background-position-x: calc(var(--cell) * -1); filter: drop-shadow(0 0 8px rgba(80, 220, 120, .8)); }
.rl-cell[data-ok="no"] { background-position-x: calc(var(--cell) * -2); }
.rl-cell[data-ok="no"].on { background-position-x: calc(var(--cell) * -3); filter: drop-shadow(0 0 8px rgba(240, 80, 70, .85)); }
/* Stopped: the winning cell pulses. */
.roulette.stopped .rl-cell.on { animation: rl-pulse .5s ease-in-out 2 alternate; }
@keyframes rl-pulse { to { transform: scale(1.12); } }
@media (max-width: 520px) { .roulette { --cell: 32px; } .roulette.small { --cell: 24px; } }
.odds[data-level="good"] { color: var(--good); }
.odds[data-level="fair"] { color: var(--amber); }
.odds[data-level="poor"] { color: var(--bad); }
.zoom-inner { display: grid; justify-items: center; gap: 8px; max-width: 360px; text-align: center; }
.card.huge { width: min(340px, 80vw); border-radius: 10px; box-shadow: 0 10px 40px #000; }
/* Cards are pressed to look at them: no browser menu, selection or drag on them. */
img[data-id], .hand-card { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
/* A card opened with a long press, over whatever is open. */
.modal.peek { z-index: 40; }
/* The viewer takes horizontal swipes itself (to browse the cards); vertical ones still scroll. */
.modal.zoom { touch-action: pan-y; }
.dialog.menu, .dialog.game-over { width: min(440px, 100%); }
.game-over[data-won="yes"] h2 { color: var(--good); }
.game-over[data-won="no"] h2 { color: var(--bad); }
.final { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 4px; }

/* ------------------------------------------------------------ motion */

@keyframes march { to { stroke-dashoffset: -9; } }
@keyframes pulse { from { opacity: 1; } to { opacity: .55; } }
@keyframes halo { from { opacity: 1; r: 14; } to { opacity: 0; r: 28; } }
@keyframes flash { from { fill: rgba(255, 255, 255, .5); } to { fill: transparent; } }
@keyframes fade { from { opacity: 0; } }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@keyframes banner {
    0% { opacity: 0; transform: translate(-50%, -12px); }
    10%, 80% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -6px); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------------ small screens */

@media (max-width: 900px) {
    .game { height: auto; min-height: 100vh; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 46vh auto auto; grid-template-areas: "top" "board" "hand" "side"; }
    .decks { display: none; }
    .side { border-left: 0; }
    .log-panel { max-height: 260px; }
    .topbar { flex-wrap: wrap; gap: 8px 14px; }
    .dialog.encounter { grid-template-columns: 1fr; }
    .card.big { width: 160px; margin: 0 auto; }
    .hand-label { writing-mode: initial; transform: none; }
}
.resume { margin: 0 0 20px; padding: 12px; border: 1px solid var(--cyan-dim); border-radius: var(--radius); background: #0c1a22; }
.resume .hint { margin-top: 6px; }

/* ------------------------------------------------------------ M5 polish */

.token-initial { font: 800 12px var(--font); text-anchor: middle; pointer-events: none; }
.token.moving .token-body { filter: drop-shadow(0 0 4px #fff); }
.icon { font-size: 16px; padding: 4px 8px; line-height: 1; }
/* The music and effects switches in the top bar: off, dimmed and crossed out. */
.sound-btn { position: relative; min-width: 34px; }
.sound-btn.off { opacity: .5; }
.sound-btn[data-kind="music"].off::after {
    content: ''; position: absolute; left: 22%; right: 22%; top: 50%; height: 2px;
    background: currentColor; transform: rotate(-35deg);
}
.card.flip-in { animation: flipIn .35s ease-out; }
@keyframes flipIn { from { transform: perspective(600px) rotateY(90deg); } to { transform: perspective(600px) rotateY(0); } }
.dialog.help { width: min(640px, 100%); }
.help dl { display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; margin: 8px 0 0; }
.help dt { font: 600 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--cyan); padding-top: 2px; }
.help dd { margin: 0; color: #c4ccd6; }
.final li { display: grid; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.final-hand { display: flex; flex-wrap: wrap; gap: 4px; }
.card.mini { width: 44px; border-radius: 3px; }
.dialog.game-over { width: min(560px, 100%); }
/* Won: Viper's portrait beside the title, 8 frames of 128x128 with his hair in the wind. */
.go-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start; }
.go-viper {
    width: 128px; height: 128px; image-rendering: pixelated;
    background: url("../../assets/ui/viper-bust-wind.png") 0 0 / 1024px 128px no-repeat;
    animation: viperWind 1.1s steps(8) infinite;
}
@keyframes viperWind { to { background-position-x: -1024px; } }
@media (max-width: 520px) { .go-viper { display: none; } }
.menu .check { margin-top: 12px; }

@media (max-width: 900px) {
    /* The action panel becomes a sheet fixed to the bottom of the screen. */
    .game { padding-bottom: var(--sheet-h, 0px); }
    .action-panel {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; max-height: 42vh; overflow-y: auto;
        background: var(--surface); border-top: 1px solid var(--cyan-dim); box-shadow: 0 -10px 30px #000c;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    .action-panel:empty { display: none; }
    .action button { min-height: 40px; }
    .dest { min-height: 36px; }
    .dest-list { max-height: 22vh; }
    .brand { display: none; }
    .topbar { padding: 6px 10px; }
    .hand-card .card { width: 72px; }
    .choices { grid-template-columns: 1fr; }
    .dialog { padding: 16px; }
    .dialog h2 { font-size: 22px; }
    .help dl { grid-template-columns: 1fr; gap: 2px 0; }
    .help dd { margin-bottom: 8px; }
    .zoom-btns { bottom: 8px; right: 8px; }
}

/* ------------------------------------------------------------ card viewer */

.zoom-inner { max-width: min(560px, 100%); }
.viewer-row { display: flex; align-items: center; gap: 12px; }
.viewer-card { position: relative; }
.viewer-card[data-marked="yes"] .card { opacity: .55; outline: 3px solid var(--bad); }
.nav { width: 44px; height: 64px; font-size: 32px; line-height: 1; padding: 0; background: rgba(16, 20, 26, .85); }
.viewer-name { margin: 4px 0 0; font-weight: 700; font-size: 16px; }
.viewer-name small { color: var(--muted); font-weight: 400; }
.row.center { justify-content: center; align-items: center; }
.discard-badge { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) rotate(-12deg); background: var(--bad); color: #fff; font: 800 11px var(--mono); letter-spacing: .1em; padding: 2px 6px; border-radius: 3px; pointer-events: none; }
.discard-badge.big { font-size: 22px; padding: 6px 14px; }
.hand-card[data-selectable="yes"]:not([data-selected="yes"]) { box-shadow: 0 0 0 1px var(--amber); }
@media (max-width: 900px) { .nav { width: 36px; height: 52px; } }

/* ------------------------------------------------------------ copy / load game */

textarea.code { width: 100%; background: #0b0e12; color: #b9f3ff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; font: 12px/1.35 var(--mono); word-break: break-all; resize: vertical; }
.load-box { margin: 16px 0 0; }
.load-box button { margin-top: 8px; }
.error { color: var(--bad); margin: 6px 0 0; min-height: 1em; }

/* ------------------------------------------------------------ goal hints */

.marker { pointer-events: none; }
.marker-ring { fill: none; stroke-width: 5; stroke-dasharray: 9 5; animation: march 1.2s linear infinite; filter: drop-shadow(0 0 3px #000); }
.marker.trade .marker-ring { stroke: var(--amber); }
.marker.escape .marker-ring { stroke: var(--good); }
.marker-pill { stroke: #000; stroke-width: 1.5; }
.marker-pill.trade { fill: #5a3d06; }
.marker-pill.escape { fill: #0f4d2c; }
.marker-text { font: 700 15px var(--font); fill: #fff; }
.pair-badge { position: absolute; left: 2px; right: 2px; top: 2px; background: var(--amber); color: #000; font: 800 9px var(--mono); letter-spacing: .02em; padding: 2px 3px; border-radius: 3px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.hand-card[data-pair="yes"] { border-color: var(--amber); box-shadow: 0 0 10px rgba(255, 176, 46, .45); }
.hand-card[data-dead="yes"] .card { opacity: .4; filter: grayscale(1); }

.tag.prize { background: #5a1520; color: #fff; border: 1px solid var(--bad); font-weight: 700; animation: pulse 1.4s infinite alternate; }

.final-card { padding: 0; border: 1px solid transparent; background: none; border-radius: 4px; }
.final-card:hover { border-color: var(--cyan); transform: translateY(-2px); }

/* ------------------------------------------------------------ turn report */

.dialog.report { width: min(560px, 100%); }
.report-strip { margin: 8px 0; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--line); }
.report-strip[data-kind="lost"] { border-color: var(--bad); background: #2a0f14; }
.report-strip[data-kind="gained"] { border-color: var(--good); background: #0e2418; }
.report-strip h3 { margin: 0 0 6px; font: 600 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.report-strip[data-kind="lost"] h3 { color: var(--bad); }
.report-strip[data-kind="gained"] h3 { color: var(--good); }
.report-cards { display: flex; flex-wrap: wrap; gap: 6px; }
.card.report { width: 76px; border-radius: 4px; }
.report-lines { margin: 10px 0 0; padding-left: 18px; color: #c4ccd6; font-size: 13px; max-height: 30vh; overflow-y: auto; }
.report-lines li { padding: 1px 0; }

.spot-btn { padding: 0; border: 1px solid transparent; border-radius: 5px; background: none; cursor: zoom-in; }
.spot-btn:hover { border-color: var(--cyan); }

/* ------------------------------------------------------------ coloured log text */

.t-num { font-weight: 700; color: #fff; }
.t-zone-red, .t-zone-yellow, .t-zone-white, .t-zone-green { font-weight: 600; }
.t-zone-red { color: #ff8080; }
.t-zone-yellow { color: #f0e65a; }
.t-zone-white { color: #f2f4f7; }
.t-zone-green { color: #5be38a; }
.t-enc { font-weight: 700; color: #ff9d8a; }
.t-card { font-weight: 700; color: #7cc8ff; }
.t-player-yellow, .t-player-blue, .t-player-green, .t-player-red { font-weight: 600; }
.t-player-yellow { color: #f5d020; }
.t-player-blue { color: #38a6ff; }
.t-player-green { color: #3fd16b; }
.t-player-red { color: #ff6b6b; }
.t-good { color: var(--good); font-weight: 600; }
.t-bad { color: var(--bad); font-weight: 600; }
.t-dim { color: var(--muted); font-style: italic; }

/* ------------------------------------------------------------ sprite stage */
/* The player on the left, the opposition on the right (mirrored to face them).
   Sprites are drawn at a whole multiple (--s) of their own pixels. */

.stage {
    --s: 4;
    position: relative; display: flex; justify-content: space-between; align-items: flex-end;
    gap: calc(var(--s) * 6px); padding: calc(var(--s) * 11px) calc(var(--s) * 6px) calc(var(--s) * 2px);
    min-height: calc(var(--s) * 52px); overflow: hidden;
    border: 1px solid var(--line); border-radius: var(--radius);
    background:
        linear-gradient(to top, #1a2029 0, #1a2029 calc(var(--s) * 4px), transparent calc(var(--s) * 4px)),
        radial-gradient(ellipse at 50% 120%, #2a3442 0, #121821 60%, #0b0f15 100%);
}
.stage[data-size="small"] { --s: 2; margin-top: 10px; }
/* The side panel's scene, framed in the colour of whoever plays it (set by GameUI.spotlight). */
.spotlight .stage { box-shadow: 0 0 0 3px var(--who, transparent); }
/* With a scene backdrop (sprites.js, backdrop): no gradient, and the small
   stage is taller to show the street's buildings. */
.stage[data-scene="yes"] { background-color: #0b0f15; image-rendering: pixelated; }
.stage[data-scene="yes"][data-size="small"] { min-height: calc(var(--s) * 64px); }
.stage-side { display: flex; align-items: flex-end; }
/* Room behind the player to fall backwards. */
.stage-side.left { padding-left: calc(var(--s) * 1px * (21 + var(--shift, 0))); }
.stage-side.right { padding-right: calc(var(--s) * 14px); }
.stage-side.right { flex-direction: row-reverse; }
.fig { position: relative; transform-origin: 50% 100%; z-index: 1; }
.stage-side.right .fig + .fig { margin-right: calc(var(--s) * -9px); }
/* Your friends stand behind you, a step further back (and higher) each; you move forward
   (--shift) to make room for them (sprites.js, stage). */
.stage-side.left { position: relative; }
.fig[data-friend="yes"] {
    position: absolute; bottom: calc(var(--s) * (2px + var(--k) * 2px)); z-index: 0; filter: brightness(.85);
    left: calc(var(--s) * 1px * (21 + var(--shift) - (var(--k) + 1) * var(--step)));
}
/* One that did not survive the fight runs off to the left (leaveStage). */
.fig[data-friend="yes"][data-leave="yes"] { animation: runOff 1.1s ease-in forwards; }
.fig[data-back="yes"] { z-index: 0; filter: brightness(.7); }
.fig-body { position: relative; z-index: 1; animation: stageBob 1.4s steps(2, jump-none) infinite; animation-delay: calc(var(--i) * -.45s); }
.sprite { width: calc(var(--w, 24) * var(--s) * 1px); max-width: none; image-rendering: pixelated; }
.stage-side.right .fig-art { transform: scaleX(-1); }
/* An encounter that does not happen here turns its back and runs off: it never saw you. */
.stage[data-result="ignored"] .stage-side.right .fig-art { transform: none; }
.stage[data-result="ignored"] .right .fig { animation: runAway 1s ease-in forwards; animation-delay: calc(var(--i) * .08s); }
@keyframes runAway { 15% { transform: translateX(calc(var(--s) * -2px)); } 100% { transform: translateX(160%); opacity: 0; } }
/* A new encounter in your view runs in from the right and stops (arriveStage, ARRIVE_MS). */
.fig[data-arrive="yes"] { animation: runIn .9s ease-out both; animation-delay: calc(var(--i) * .1s); }
@keyframes runIn { from { transform: translateX(calc(var(--s) * 130px)); opacity: 0; } 20% { opacity: 1; } to { transform: none; } }

/* Animated sprites: one sheet per action, feet lined up with the idle pose. */
.fig-art.animated { position: relative; width: calc(var(--w) * var(--s) * 1px); height: calc(var(--h) * var(--s) * 1px); }
.sheet {
    display: none; position: absolute; bottom: 0; left: calc(var(--dx) * var(--s) * 1px);
    width: calc(var(--fw) * var(--s) * 1px); height: calc(var(--fh) * var(--s) * 1px);
    background-repeat: no-repeat; background-size: auto 100%; image-rendering: pixelated;
    animation: sheetPlay var(--dur) steps(var(--steps)) infinite;
}
/* A group does not breathe in step. */
.sheet[data-action="idle"] { animation-delay: calc(var(--i, 0) * -.37s); }
.sheet[data-loop="no"] { animation-iteration-count: 1; animation-fill-mode: forwards; }
@keyframes sheetPlay { to { background-position-x: calc(var(--fw) * var(--steps) * var(--s) * -1px); } }
.fig[data-anim="idle"] .sheet[data-action="idle"],
.fig[data-anim="shoot"] .sheet[data-action="shoot"],
.fig[data-anim="death"] .sheet[data-action="death"],
.fig[data-anim="victory"] .sheet[data-action="victory"],
.fig[data-anim="run"] .sheet[data-action="run"] { display: block; }
.fig[data-anim="shoot"] .sheet[data-action="shoot"] { animation-iteration-count: 2; }
.fig[data-anim]:not([data-anim=""]) .fig-body { animation: none; }
.stage[data-result] .stage-side .fig[data-anim="shoot"], .stage[data-result] .stage-side .fig[data-anim="death"],
.stage[data-result] .stage-side .fig[data-anim="victory"] { animation: none; }
.stage-side.left .fig[data-anim="run"] .fig-art { transform: scaleX(-1); }
/* Every figure's shadow: black, with a slightly soft edge. */
.fig-base {
    position: absolute; left: 6%; right: 6%; bottom: calc(var(--s) * -1.5px); height: calc(var(--s) * 3.5px);
    border-radius: 50%; background: rgba(0, 0, 0, .5); filter: blur(calc(var(--s) * .4px));
}

@keyframes stageBob { to { transform: translateY(calc(var(--s) * -1px)); } }
@keyframes flinch { 20%, 60% { transform: translateX(calc(var(--s) * -2px)); filter: brightness(2) saturate(0); } 40%, 80% { transform: translateX(calc(var(--s) * 2px)); } }
@keyframes fallRight { 0%, 30% { transform: none; filter: brightness(2) saturate(0); } 100% { transform: translate(calc(var(--s) * -14px), calc(var(--s) * 2px)) rotate(84deg); opacity: .45; } }
@keyframes fallLeft { 0%, 30% { transform: none; filter: brightness(2) saturate(0); } 100% { transform: translate(calc(var(--s) * 14px), calc(var(--s) * 2px)) rotate(-84deg); opacity: .45; } }
@keyframes runOff { 20% { transform: translateX(calc(var(--s) * 3px)); } 100% { transform: translateX(-160%); opacity: 0; } }
/* A new friend glows (no jump): the hearts above say the rest. */
@keyframes joinIn { to { filter: drop-shadow(0 0 calc(var(--s) * 2px) var(--good)); } }

.stage[data-result="won"] .right .fig { animation: fallRight .8s .2s ease-in forwards; }
.stage[data-result="lost"] .left .fig:where(:not([data-friend="yes"])) { animation: fallLeft .8s .2s ease-in forwards; }
.stage[data-result="fled"] .left .fig { animation: runOff .9s ease-in forwards; }
/* Those left behind stand still, puzzled. */
.fig-q {
    display: none; position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%);
    font: 700 calc(var(--s) * 9px)/1 var(--mono); color: #ffe066;
    text-shadow: calc(var(--s) * 1px) calc(var(--s) * 1px) 0 #000;
}
.stage[data-result="fled"] .right .fig-q { display: block; animation: puzzled .9s .35s steps(2, jump-none) both; }
.stage[data-result="fled"] .right .fig-body { animation: none; }
/* ...and some of them look one way and the other (sprites.js, lookAround). */
/* A sprite turns at once (step-end), never through a squashed half-turn. */
.stage[data-result="fled"] .right .fig[data-look="yes"] .fig-art { animation: lookAround var(--look-dur, 1.5s) var(--look-delay, .5s) step-end both; }
@keyframes lookAround {
    0% { transform: scaleX(-1); }
    25% { transform: none; }
    50% { transform: scaleX(-1); }
    75% { transform: none; }
    100% { transform: scaleX(-1); }
}
@keyframes puzzled {
    0% { opacity: 0; transform: translate(-50%, calc(var(--s) * 3px)); }
    40%, 100% { opacity: 1; transform: translate(-50%, 0); }
}
.stage[data-result="friend"] .right .fig { animation: joinIn .9s ease-out forwards; animation-delay: calc(var(--i) * .12s); }
.stage[data-result="hit"] .fig { animation: flinch .45s linear; }
.stage[data-result="won"] .fig-body, .stage[data-result="lost"] .fig-body,
.stage[data-result="fled"] .fig-body { animation: none; }

.enc-body .stage { margin: 4px 0 14px; }

/* Your encounter in the centre (GameUI.openEncounter): the card is drawn face down and turns
   over in --flip (1 s at normal speed), with a lift before it; only then do the zone, the name,
   the scene and the choices appear. The roulette and the result stay in the same view. */
.enc-live .enc-card { perspective: 1000px; }
.enc-flip { position: relative; transform-style: preserve-3d; }
.enc-flip > img { backface-visibility: hidden; -webkit-backface-visibility: hidden; display: block; }
.enc-flip .enc-back { position: absolute; inset: 0; width: 100%; height: 100%; }
.enc-flip .enc-face { transform: rotateY(180deg); }
.enc-flip { transform: rotateY(0); }
.enc-flip.shown { transform: rotateY(180deg); }
.enc-flip.turning { animation: encTurn var(--flip, 1s) cubic-bezier(.5, 0, .3, 1) both; }
@keyframes encTurn {
    0% { transform: rotateY(0) translateY(0) scale(1); }
    35% { transform: rotateY(0) translateY(-10px) scale(1.04); }
    50% { transform: rotateY(25deg) translateY(-12px) scale(1.05); }
    90% { transform: rotateY(185deg) translateY(-2px) scale(1.01); }
    100% { transform: rotateY(180deg) translateY(0) scale(1); }
}
.enc-live .enc-body { opacity: 0; transition: opacity .3s ease; }
.enc-live.open .enc-body { opacity: 1; }
.enc-live.closing { opacity: 0; transition: opacity .2s ease; }
.enc-note { min-height: 1.3em; margin: 0 0 10px; font-weight: 600; }
.enc-note[data-kind="good"] { color: var(--good); }
.enc-note[data-kind="bad"] { color: var(--bad); }
.enc-slot .rl-panel { margin: 0 auto; box-shadow: none; }
.spotlight:empty { display: none; }
@media (max-width: 900px) { .stage:not([data-size="small"]) { --s: 3; } }

/* ------------------------------------------------------------ running strip */
/* Over your hand bar while your token moves, rising over the bottom of the board as far as the
   lowest coloured zone on screen allows (GameUI.stripRise sets its top): the mercenary runs on
   the spot and the parallax layers scroll past (sprites.js, runStrip). The layers sit on the
   strip's foot, so a short strip crops the sky, not the street. */

.run-host {
    position: absolute; inset: 0; z-index: 4; pointer-events: none;
    opacity: 0; transform: translateY(12px); transition: opacity .2s, transform .2s;
}
.run-host.show { opacity: 1; transform: none; }
.run-host.show { pointer-events: auto; cursor: pointer; }
.run-skip {
    position: absolute; right: 10px; bottom: 8px; z-index: 1; padding: 3px 8px; border-radius: 4px;
    font: 600 11px var(--mono); letter-spacing: .06em; color: #fff; background: rgba(0, 0, 0, .55);
}
.run-strip {
    --ps: 2; --s: var(--ps);
    position: relative; height: 100%; overflow: hidden;
    border-top: 2px solid #000; box-shadow: 0 -6px 18px rgba(0, 0, 0, .6); background: #000;
}
.px-layer {
    position: absolute; inset: 0; background-repeat: repeat-x; background-position: 0 100%;
    background-size: calc(var(--lw) * var(--ps) * 1px) calc(var(--lh) * var(--ps) * 1px);
    image-rendering: pixelated; animation: pxScroll var(--dur) linear infinite;
}
@keyframes pxScroll { to { background-position-x: calc(var(--lw) * var(--ps) * -1px); } }
.run-strip .runner { position: absolute; left: 32%; bottom: calc(var(--ps) * 3px); }
/* Your friends run behind you, a little out of step (sprites.js, runStrip). */
.run-strip .follower { left: calc(32% - (var(--k) + 1) * var(--ps) * 20px); }
.run-strip .follower .sheet { animation-delay: calc((var(--k) + 1) * -.13s); }
@media (max-width: 900px) { .run-strip { --ps: 1; } }

/* Befriended: pixel hearts float up over both sides like bubbles. */
.fig-hearts { display: none; position: absolute; left: 0; right: 0; bottom: 100%; height: 0; }
.stage[data-result="friend"] .fig-hearts { display: block; }
.fig-hearts i {
    position: absolute; bottom: 0; left: calc(50% + (var(--j) - 1) * var(--s) * 6px - var(--s) * 3.5px);
    width: calc(var(--s) * 7px); height: calc(var(--s) * 6px); opacity: 0;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 6' shape-rendering='crispEdges'><rect x='1' y='0' width='1' height='1' fill='%23ff4d6d'/><rect x='2' y='0' width='1' height='1' fill='%23ff4d6d'/><rect x='4' y='0' width='1' height='1' fill='%23ff4d6d'/><rect x='5' y='0' width='1' height='1' fill='%23ff4d6d'/><rect x='0' y='1' width='1' height='1' fill='%23ff4d6d'/><rect x='1' y='1' width='1' height='1' fill='%23ffffff'/><rect x='2' y='1' width='1' height='1' fill='%23ff4d6d'/><rect x='3' y='1' width='1' height='1' fill='%23ff4d6d'/><rect x='4' y='1' width='1' height='1' fill='%23ff4d6d'/><rect x='5' y='1' width='1' height='1' fill='%23ff4d6d'/><rect x='6' y='1' width='1' height='1' fill='%23ff4d6d'/><rect x='0' y='2' width='1' height='1' fill='%23ff4d6d'/><rect x='1' y='2' width='1' height='1' fill='%23ff4d6d'/><rect x='2' y='2' width='1' height='1' fill='%23ff4d6d'/><rect x='3' y='2' width='1' height='1' fill='%23ff4d6d'/><rect x='4' y='2' width='1' height='1' fill='%23ff4d6d'/><rect x='5' y='2' width='1' height='1' fill='%23ff4d6d'/><rect x='6' y='2' width='1' height='1' fill='%23ff4d6d'/><rect x='1' y='3' width='1' height='1' fill='%23ff4d6d'/><rect x='2' y='3' width='1' height='1' fill='%23ff4d6d'/><rect x='3' y='3' width='1' height='1' fill='%23ff4d6d'/><rect x='4' y='3' width='1' height='1' fill='%23ff4d6d'/><rect x='5' y='3' width='1' height='1' fill='%23ff4d6d'/><rect x='2' y='4' width='1' height='1' fill='%23ff4d6d'/><rect x='3' y='4' width='1' height='1' fill='%23ff4d6d'/><rect x='4' y='4' width='1' height='1' fill='%23ff4d6d'/><rect x='3' y='5' width='1' height='1' fill='%23ff4d6d'/></svg>") center / 100% 100% no-repeat; image-rendering: pixelated;
    filter: drop-shadow(0 calc(var(--s) * 1px) 0 rgba(0, 0, 0, .6));
    animation: heartUp 1.3s ease-out calc(var(--j) * .28s + var(--i, 0) * .1s) 2;
}
@keyframes heartUp {
    0% { opacity: 0; transform: translate(0, calc(var(--s) * 2px)) scale(.6); }
    20% { opacity: 1; transform: translate(calc(var(--s) * -1px), calc(var(--s) * -2px)) scale(1); }
    55% { opacity: 1; transform: translate(calc(var(--s) * 1px), calc(var(--s) * -6px)) scale(1); }
    100% { opacity: 0; transform: translate(calc(var(--s) * -1px), calc(var(--s) * -10px)) scale(.9); }
}

/* Armed mercenaries without sprite animations (the bots) shoot with CSS:
   three recoils, each with a muzzle flash at the gun's tip (sprites.js, MUZZLE). */
.fig-art { position: relative; }
.stage-side.left .fig { --dir: -1; }
.stage-side.right .fig { --dir: 1; }
.fig-flash {
    display: none; position: absolute; left: 100%; bottom: var(--muzzle);
    width: calc(var(--s) * 5px); height: calc(var(--s) * 5px); margin: 0 0 calc(var(--s) * -2px) calc(var(--s) * -1px);
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 5' shape-rendering='crispEdges'><rect x='2' y='0' width='1' height='1' fill='%23ffd84a'/><rect x='0' y='1' width='1' height='1' fill='%23ffd84a'/><rect x='2' y='1' width='1' height='1' fill='%23ffffff'/><rect x='4' y='1' width='1' height='1' fill='%23ffd84a'/><rect x='1' y='2' width='1' height='1' fill='%23ffffff'/><rect x='2' y='2' width='1' height='1' fill='%23ffffff'/><rect x='3' y='2' width='1' height='1' fill='%23ffffff'/><rect x='0' y='3' width='1' height='1' fill='%23ffd84a'/><rect x='2' y='3' width='1' height='1' fill='%23ffffff'/><rect x='4' y='3' width='1' height='1' fill='%23ffd84a'/><rect x='2' y='4' width='1' height='1' fill='%23ffd84a'/></svg>") center / 100% 100% no-repeat; image-rendering: pixelated;
}
.stage[data-result="won"] .left .fig[data-armed="yes"],
.stage[data-result="lost"] .right .fig[data-armed="yes"] { animation: recoil .75s linear; }
.stage[data-result="won"] .left .fig[data-armed="yes"] .fig-flash,
.stage[data-result="lost"] .right .fig[data-armed="yes"] .fig-flash { display: block; opacity: 0; animation: muzzle .75s steps(1, jump-end); }
@keyframes recoil {
    0%, 33%, 66% { transform: translateX(calc(var(--dir) * var(--s) * 2px)); }
    15%, 48%, 81%, 100% { transform: none; }
}
@keyframes muzzle {
    0% { opacity: 1; } 12% { opacity: 0; }
    33% { opacity: 1; } 45% { opacity: 0; }
    66% { opacity: 1; } 78% { opacity: 0; }
}

/* New York Escape Condensed by Iconian Fonts: free for non-commercial use and
   freely distributable (assets/fonts/new-york-escape-README.txt). */
@font-face {
    font-family: "New York Escape Condensed";
    src: url("../../assets/fonts/new-york-escape-condensed.ttf") format("truetype");
    font-display: swap;
}

/* Marcellus (Brian J. Bonislawsky, SIL Open Font License, assets/fonts/marcellus-OFL.txt):
   a free stand-in for the film's Albertus. New York Escape: see the condensed one. */
@font-face { font-family: "Marcellus"; src: url("../../assets/fonts/marcellus-regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "New York Escape"; src: url("../../assets/fonts/new-york-escape.ttf") format("truetype"); font-display: swap; }

/* ------------------------------------------------------------ opening (opening.js) */

/* Loading screen (preload.js): black like the opening that may follow it. */
.loading { position: fixed; inset: 0; z-index: 110; background: #000; display: grid; place-content: center; justify-items: center; gap: 18px; transition: opacity .3s; }
.loading.out { opacity: 0; pointer-events: none; }
.loading-title { margin: 0; font: 34px "New York Escape", Impact, sans-serif; color: #ffad1f; letter-spacing: .04em; text-shadow: 0 0 12px rgba(255, 173, 31, .5); }
/* The progress bar is a skyline (preload.js skylineBar): dark behind, the orange copy unmasked left to right. */
.loading-bar { position: relative; width: min(360px, 76vw); aspect-ratio: 7 / 1; }
.loading-sky { position: absolute; inset: 0; width: 100%; height: 100%; fill: #262b34; }
.loading-sky.lit { fill: #ffad1f; clip-path: inset(0 100% 0 0); transition: clip-path .15s; filter: drop-shadow(0 0 6px rgba(255, 173, 31, .55)); }
.loading-pct { font: 12px var(--mono); color: #8a93a0; letter-spacing: .1em; }
.opening { position: fixed; inset: 0; z-index: 100; background: #000; cursor: pointer; transition: opacity .3s; user-select: none; -webkit-user-select: none; touch-action: none; }
.opening.out { opacity: 0; }
/* "Hold to skip" (opening.js holdToSkip): an orange ring that fills clockwise while held. */
.hold-skip {
    position: absolute; left: 50%; bottom: 2.5%; transform: translateX(-50%); z-index: 2;
    display: flex; align-items: center; gap: 8px; pointer-events: none;
    font: 11px var(--mono); letter-spacing: .1em; color: rgba(255, 173, 31, .7);
}
.hold-ring { width: 22px; height: 22px; transform: rotate(-90deg); }   /* starts at twelve o'clock */
.hold-track, .hold-fill { fill: none; stroke-width: 2.6; }
.hold-track { stroke: rgba(255, 173, 31, .22); }
.hold-fill { stroke: #ffad1f; filter: drop-shadow(0 0 3px rgba(255, 173, 31, .8)); transition: stroke-dashoffset .25s; }
.hold-ring.held .hold-fill { transition: none; }
/* "Tap to start" (opening.js tapToStart), once the opening is over: it waits for the player. */
.tap-start {
    position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%); z-index: 2; pointer-events: none;
    font: 600 14px var(--mono); letter-spacing: .25em; text-transform: uppercase; color: #ffad1f;
    text-shadow: 0 0 8px rgba(255, 173, 31, .7); animation: tapIn .8s ease-out both, gatePulse 2.4s ease-in-out .8s infinite;
}
@keyframes tapIn { from { opacity: 0; } }
/* A CRT's look over the whole opening: faint scanlines and a darker rim. */
.opening::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
    background:
        repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, .22) 2px 3px),
        radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, .55) 100%);
}
.opening-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* The browser refused to start the music: one click or key starts it (opening.js startMusic). */
.opening-gate { position: absolute; inset: 0; display: grid; place-items: center; background: #000; z-index: 2; }
.opening-gate p { font: 28px Marcellus, Georgia, serif; color: #eef1f7; letter-spacing: .04em; animation: gatePulse 2.4s ease-in-out infinite; }
@keyframes gatePulse { 50% { opacity: .45; } }
button.link { background: none; border: 0; padding: 4px 6px; color: var(--muted); text-decoration: underline; }
button.link:hover:not(:disabled) { background: none; color: var(--text); }
.watch-opening { display: block; margin: 10px auto 0; }
.credits-link { display: block; margin: 6px auto 0; text-align: center; width: fit-content; }

/* ------------------------------------------------------------ intro flight */
/* The Gullfire's nose view (intro.js): green phosphor wireframe on a dark CRT,
   with a soft glow and scan lines on top. */

.intro {
    position: fixed; inset: 0; z-index: 100; background: #020805; cursor: pointer;
    opacity: 0; transition: opacity .25s;
}
.intro.out { opacity: 0 !important; }
.intro-gl, .intro-hud { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.intro-gl { filter: drop-shadow(0 0 2px rgba(90, 255, 140, .75)) drop-shadow(0 0 6px rgba(60, 255, 120, .35)); }
.intro::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background:
        repeating-linear-gradient(to bottom, rgba(0, 0, 0, .28) 0 1px, transparent 1px 3px),
        radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .65) 100%);
}
.intro-label, .intro-readout, .intro-skip {
    position: absolute; left: 0; right: 0; z-index: 1; text-align: center;
    font: 600 14px/1 var(--mono); letter-spacing: .25em; color: #5cff8c;
    text-shadow: 0 0 6px rgba(92, 255, 140, .8);
}
.intro-label { top: 6%; }
.intro-readout {
    bottom: 7%; left: 50%; right: auto; transform: translateX(-50%); padding: 6px 14px;
    font-size: 13px; letter-spacing: .18em; white-space: pre; background: rgba(2, 8, 5, .82);
}
.intro-skip { bottom: 2.5%; font-size: 11px; letter-spacing: .1em; color: rgba(92, 255, 140, .55); text-shadow: none; }
/* The approach before the nose view (playApproach): the harbour at night (480x256 pixel art)
   enlarged by a whole number (--px) to cover the screen, the skyline growing very gently; the
   glider, at two thirds of the scene's scale, comes in from the top right, shows its 3 frames 0.6 s each
   and stops on the last (level); from its first change of frame it slowly recedes towards the city. All of it lasts APPROACH_MS (3.7 s). */
.approach { position: fixed; inset: 0; z-index: 101; overflow: hidden; background: #000; cursor: pointer; opacity: 0; transition: opacity .25s; }
.approach.in { opacity: 1; }
.approach-scene {
    position: absolute; left: 50%; top: 50%; width: 480px; height: 256px;
    transform: translate(-50%, -50%) scale(var(--px, 3)); image-rendering: pixelated;
}
.approach-scene > div { position: absolute; image-rendering: pixelated; }
.approach-bg {
    inset: 0; background: url("../../assets/intro/harbour.png") 0 0 / 100% 100% no-repeat;
    transform-origin: 50% 72%; animation: approachZoom 3.7s linear both;
}
@keyframes approachZoom { to { transform: scale(1.03); } }
.approach-glider {
    left: 278px; top: 93px; width: 160px; height: 64px;   /* at rest over the buildings right of centre */
    background: url("../../assets/intro/glider-rear.png") 0 0 / 480px 64px no-repeat;
    animation: gliderFrames 1.8s step-end both, gliderMove 3.7s both, gliderShrink 3.7s linear both;
}
@keyframes gliderFrames {
    0% { background-position-x: 0; }
    33.333% { background-position-x: -160px; }
    66.667%, 100% { background-position-x: -320px; }
}
/* Flies in from the top right (1.8 s), then drifts a little towards the city. */
@keyframes gliderMove {
    0% { translate: 190px -130px; animation-timing-function: cubic-bezier(.2, .7, .3, 1); }
    49% { translate: 0 0; }
    100% { translate: 0 3px; }
}
/* Recedes slowly from the first change of frame (0.6 s) to the end. */
@keyframes gliderShrink {
    0%, 16.2% { scale: .67; }
    100% { scale: .51; }
}

/* The pilot at the controls, in a monitor on the left: a 12-frame sheet of 128x96 pixel art,
   shown at a whole multiple (--s). */
.intro-pilot {
    --s: 2;
    position: absolute; left: 3%; bottom: 14%; z-index: 1; padding: 6px 6px 4px;
    border: 1px solid rgba(92, 255, 140, .55); background: rgba(2, 8, 5, .9);
    box-shadow: 0 0 12px rgba(60, 255, 120, .25), inset 0 0 0 1px rgba(0, 0, 0, .8);
}
.intro-pilot-cam { position: relative; overflow: hidden; width: calc(128px * var(--s)); height: calc(96px * var(--s)); background: #000; }
.intro-pilot-cam > div { position: absolute; left: 0; top: 0; image-rendering: pixelated; }
.intro-pilot-frame {
    width: 100%; height: 100%;
    background: url("../../assets/ui/viper-cockpit-sheet.png") 0 0 / calc(1536px * var(--s)) 100% no-repeat;
    animation: pilotCam 1.5s steps(12) infinite;
}
@keyframes pilotCam { to { background-position-x: calc(-1536px * var(--s)); } }
/* The city through the side window (the sheet's transparent corner, 44x51): the back layer of
   the 02-red-neon parallax scene (256x128), scrolling slowly. */
.intro-pilot-sky {
    width: calc(44px * var(--s)); height: calc(51px * var(--s));
    background: url("../../assets/parallax/02-red-neon/1-back.png") 0 calc(-14px * var(--s)) / calc(256px * var(--s)) calc(128px * var(--s)) repeat-x;
    animation: pilotSky 32s linear infinite;
}
@keyframes pilotSky { to { background-position-x: calc(256px * var(--s)); } }   /* left to right */
.intro-pilot-label { margin-top: 4px; font: 600 10px/1 var(--mono); letter-spacing: .2em; color: rgba(92, 255, 140, .8); }
@media (max-width: 700px), (max-height: 520px) { .intro-pilot { --s: 1; } }

/* ------------------------------------------------------------ phone in landscape
   One screen, no scrolling, as in the sibling projects (Paranormal): a one-line top bar, the board
   filling the left (fitted to the free space), and a column on the right with your decision and,
   below, one of three sections, never mixed: 🃏 your hand, 👥 the agents and 📜 the log. A bot's
   encounter, an ambush or a prize floats over the middle of the board while it lasts (.float). The music and effects switches are in the menu. The desktop and the
   phone in portrait do not change. */
.phone-btns { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
    html:has(.game), body:has(.game) { height: 100%; overflow: hidden; }
    .game {
        --side-w: clamp(190px, 28vw, 300px);
        height: 100vh; height: 100dvh; min-height: 0; padding-bottom: 0;
        grid-template-columns: minmax(0, 1fr) var(--side-w);
        grid-template-rows: auto minmax(0, auto) minmax(0, 1fr);
        grid-template-areas: "top top" "board side" "board hand";
    }
    .topbar { flex-wrap: nowrap; gap: 8px; padding: 3px 8px; font-size: 12px; }
    .topbar .sound-btn { display: none; }
    .topbar > .ghost { padding: 2px 8px; }
    .dice { min-width: 0; }
    .die { font-size: 20px; }
    .phone-btns { display: flex; gap: 3px; flex-shrink: 0; }
    .drawer-btn { padding: 1px 6px; font-size: 15px; line-height: 22px; }
    .drawer-btn.on { background: var(--cyan-dim); border-color: var(--cyan); }
    .zoom-btns { right: 6px; bottom: 6px; }
    .zoom-btns button { width: 28px; height: 28px; }

    /* The right column: your decision (not a bottom sheet here) and a bot's encounter on top. */
    .side { border-left: 1px solid var(--line); max-height: 62dvh; }
    .side > .panel { padding: 6px 8px; }
    .panel h2 { margin-bottom: 4px; }
    .action-panel {
        position: static; max-height: none; overflow: visible; min-height: 0; box-shadow: none;
        border-top: 0; padding-bottom: 6px;
    }
    .action button { min-height: 32px; }
    .dest-list { max-height: none; }
    /* Each section shows only its own panel. */
    .players-panel, .log-panel, .spotlight { display: none; }
    .spot { grid-template-columns: 56px 1fr; gap: 8px; }
    .spot-card { width: 56px; }
    .spot-name { font-size: 15px; margin: 0 0 4px; }

    /* Your hand under it, the cards in a grid. */
    .hand-bar { grid-area: hand; flex-direction: column; align-items: stretch; gap: 4px; padding: 4px 8px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); overflow: hidden; }
    .hand-label { writing-mode: initial; transform: none; font-size: 10px; }
    .hand-host { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; }
    .hand-cards { flex-wrap: wrap; gap: 5px; padding: 2px; }
    .hand-card .card { width: 54px; }
    .hand-card:hover { transform: none; }

    /* ⚔️ 👥 📜 take the column's place below the decision (your hand goes). */
    .game:not([data-drawer="hand"]) { grid-template-rows: auto minmax(0, 1fr) 0; }
    .game:not([data-drawer="hand"]) .hand-bar { visibility: hidden; padding: 0; border: 0; }
    .game:not([data-drawer="hand"]) .side { max-height: none; }
    .side > .action-panel { order: -1; }
    /* The spotlight floats over the middle of the board while it lasts (GameUI.floatSpot). */
    .side > .spotlight.float {
        display: block; position: fixed; z-index: 12; top: 50%; left: calc((100vw - var(--side-w)) / 2);
        width: min(360px, calc(100vw - var(--side-w) - 24px)); transform: translate(-50%, -50%);
        background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
        box-shadow: 0 14px 40px #000c; animation: fade .2s ease;
    }
    .side > .spotlight.float.sinking { opacity: 0; transition: opacity .2s ease; }
    .game[data-drawer="agents"] .players-panel { display: block; }
    .game[data-drawer="log"] .log-panel { display: flex; min-height: 0; }
    /* The agents, compact: name and place, then their cards and lives below. */
    .side { overflow-x: hidden; }
    .player { grid-template-columns: auto minmax(0, 1fr); gap: 2px 8px; padding: 4px 6px; }
    .player-tags { grid-column: 2; flex-wrap: wrap; gap: 4px; }
    .player-name { font-size: 13px; }
    .player-where { font-size: 11px; }
    .fan { height: 22px; }
    .fan img { height: 20px; }

    /* Your encounter: the card small on the left, a shorter scene and the three choices side by side. */
    .modal { padding: 3px; }
    .dialog { padding: 10px 12px; max-height: calc(100dvh - 6px); }
    .dialog h2 { font-size: 18px; margin: 0 0 4px; }
    .dialog.encounter { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; width: 100%; }
    .dialog.encounter .card.big { width: 96px; margin: 0; }
    .dialog.encounter .kicker { margin: 0; font-size: 10px; }
    .dialog.encounter h2 { font-size: 16px; margin: 0; }
    /* The name and the zone on one line. */
    .enc-body { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: 10px; }
    .enc-body > :not(.kicker, h2) { grid-column: 1 / -1; }
    .enc-body > h2 { order: -1; }
    .enc-body > .kicker { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .choice .fail { line-height: 1.25; }
    .dialog.encounter { padding: 8px 10px; }
    /* The scene as wide as the backdrop is framed for (STAGE_WIDTH.big in sprites.js, 193 scene
       pixels), centred: stretched wider, a still backdrop would leave a black band. */
    .enc-body .stage { --s: 2; margin: 2px 0 4px; padding-top: calc(var(--s) * 3px); min-height: calc(var(--s) * 34px);
        width: calc(var(--s) * 193px); max-width: 100%; justify-self: center; }
    .enc-note { margin: 0 0 4px; min-height: 0; font-size: 13px; }
    .choices { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; }
    .choice { padding: 5px 8px; gap: 2px; font-size: 12.5px; }
    .choice h3 { font-size: 12px; }
    .choice .fail { font-size: 11px; }
    .choice button { min-height: 30px; padding: 4px 8px; }
    /* Weapons and friends side by side, wrapping, instead of one per line. */
    .choice .pick { display: flex; flex-wrap: wrap; gap: 0 10px; padding-top: 3px; }
    .choice .pick-title { flex-basis: 100%; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .choice .check { margin: 0; font-size: 12px; }
    .choice .chance { font-size: 12px; }

    /* The card viewer: the card as tall as the screen allows, its controls beside it (the
       "Discard this card" button stays in sight). */
    .modal.zoom .zoom-inner { max-width: none; grid-template-columns: auto minmax(150px, auto); align-items: center; gap: 6px 14px; }
    .modal.zoom .viewer-row { grid-row: 1 / span 2; gap: 6px; }
    .modal.zoom .card.huge { width: auto; height: min(340px, calc(100dvh - 24px)); }
    .modal.zoom .nav { width: 32px; height: 52px; font-size: 26px; }
    .modal.zoom .viewer-name { align-self: end; justify-self: start; margin: 0; }
    .modal.zoom .row.center { display: flex; flex-direction: column; align-items: flex-start; align-self: start; gap: 6px; }
    .modal.zoom .row.center .hint { margin: 0; text-align: left; }

    /* The start screen scrolls, with "Enter Manhattan" always in sight at the bottom. */
    .setup-card { overflow: clip; }      /* crops the scene like hidden, but lets the button stick */
    .setup button.primary.big { position: sticky; bottom: 6px; z-index: 5; box-shadow: 0 -6px 14px #000c; }

    /* The running strip runs over the bottom of the board (not over your hand, which is on the right). */
    .run-host { position: fixed; left: 0; right: var(--side-w); top: auto !important; bottom: 0; height: 44vh; height: 44dvh; }
    .run-strip { --ps: 1; }
}
