/* In-run screens: HUD, level-up, pause, end. Moonlit night: near-black indigo surfaces, silver edges, cool glows.
   Saturated colour is kept for actions, type colours, HP and XP. Loaded after hub.css. */
:root {
  /* Shared night tokens from hub.css, so the run and the menus are one style. Fallbacks keep this file readable alone. */
  --run-night: var(--n1, #080d24);
  --run-deep: var(--n2, #0f1736);
  --run-indigo: var(--n3, #17214a);
  --run-raised: var(--n4, #223066);
  --run-hover: var(--n5, #33458a);
  --run-edge: var(--n0, #03050f);
  --run-silver: var(--silver, #c5d2f0);
  --run-moon: var(--moon, #eef3ff);
  --run-text: var(--moon, #eef3ff);
  --run-dim: #b3c0dc; /* Brighter than --dim: this text sits small on 844x390. */
  --run-glow: rgba(160, 195, 255, .32);
  --run-action: var(--gold, #ffd23f);
  --run-action-hover: var(--gold-hi, #ffe680);
  --run-xp: var(--cyan, #5fd0ff);
  --run-hp: #5fe07a;
  --run-hp-low: var(--red, #ff5a6e);
  --run-boss: #ff8a5c;
  --run-coin: var(--gold, #ffd23f);
  --run-title: var(--pixel, 'Jersey 15', sans-serif);
  --run-stars:
    radial-gradient(1px 1px at 12% 22%, rgba(255,255,255,.85), transparent 60%),
    radial-gradient(1px 1px at 34% 68%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(1.5px 1.5px at 58% 16%, rgba(214,228,255,.9), transparent 60%),
    radial-gradient(1px 1px at 76% 44%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1px 1px at 88% 82%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1.5px 1.5px at 22% 88%, rgba(214,228,255,.65), transparent 60%),
    radial-gradient(1px 1px at 48% 42%, rgba(255,255,255,.4), transparent 60%);
}

/* The menu chrome gives way to the field during a run. The bar stays above overlays so the pause button can resume. */
.game-shell.in-run .topbar { z-index: 8; height: auto; padding: 0; border: 0; background: none; backdrop-filter: none; pointer-events: none; }
.game-shell.in-run .wordmark, .game-shell.in-run .region-tag, .game-shell.in-run .nav-button { display: none; }
.game-shell.in-run .top-actions { position: absolute; top: 22px; right: max(16px, env(safe-area-inset-right)); gap: 8px; pointer-events: auto; }
.game-shell.in-run .icon-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 3px solid var(--run-edge); border-radius: 12px; background: linear-gradient(var(--run-raised), var(--run-deep)); box-shadow: inset 0 1px 0 rgba(214,228,255,.3), 0 3px 0 var(--run-edge); color: var(--run-moon); transition: transform .08s, box-shadow .08s; }
.game-shell.in-run .icon-button:hover { background: var(--run-hover); }
.game-shell.in-run .icon-button:active { box-shadow: none; transform: translateY(3px); }
.game-shell.in-run .icon-button.is-muted { color: var(--run-dim); }
.game-shell.in-run:has(#pause-layer:not([hidden])) #sound-button { display: none; }
.game-shell.in-run:has(#choice-layer:not([hidden])) .top-actions, .game-shell.in-run:has(#end-layer:not([hidden])) .top-actions { display: none; }
.game-shell.in-run .legal-note { display: none; }
.game-shell.in-run .screen-vignette { transition: box-shadow .25s; }
.game-shell.in-run.low-hp .screen-vignette { animation: heartbeat 1.05s ease-in-out infinite; }
@keyframes heartbeat { 0%, 100% { box-shadow: inset 0 0 80px rgba(255, 60, 50, .3); } 18% { box-shadow: inset 0 0 130px rgba(255, 60, 50, .58); } 36% { box-shadow: inset 0 0 90px rgba(255, 60, 50, .36); } 52% { box-shadow: inset 0 0 120px rgba(255, 60, 50, .5); } }


.px-icon { display: inline-block; flex: none; vertical-align: -.15em; }

/* HUD container: fills the screen, only its panels catch input. */
.run-top { position: absolute; z-index: 4; inset: 0; pointer-events: none; color: var(--run-text); }
.xp-rail { position: relative; height: 14px; background: linear-gradient(var(--run-edge), var(--run-night)); box-shadow: 0 2px 0 rgba(2, 4, 13, .7); }
.xp-track { height: 100%; overflow: hidden; }
.xp-track i { display: block; width: 0; height: 100%; background: linear-gradient(#d9f7ff, var(--run-xp) 50%, #2794cf); box-shadow: 0 0 12px rgba(95, 208, 255, .85); transition: width .16s ease-out; }
.xp-label { position: absolute; top: 0; right: 10px; color: var(--run-moon); font: 800 var(--fs-small)/14px var(--font-body); font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #000; }

/* Clock and run ribbon */
.run-status { position: absolute; top: 20px; left: 50%; display: flex; flex-direction: column; align-items: center; gap: 2px; transform: translateX(-50%); }
.run-time { color: var(--run-moon); font: 400 var(--fs-d44)/1 var(--font-display); font-variant-numeric: tabular-nums; paint-order: stroke fill; -webkit-text-stroke: 6px var(--run-edge); text-shadow: 0 0 18px var(--run-glow); }
.run-ribbon { display: flex; align-items: center; gap: 2px; padding: 3px 5px; border: 2px solid var(--run-edge); border-radius: 10px; background: linear-gradient(rgba(28, 37, 88, .96), rgba(11, 16, 41, .96)); box-shadow: inset 0 1px 0 rgba(214,228,255,.25), 0 3px 0 var(--run-edge); white-space: nowrap; }
.ribbon-area { padding: 0 8px; color: #dbe6ff; font: 800 var(--fs-small)/18px var(--font-body); }
.ribbon-area b { color: var(--run-moon); font-weight: 700; }
.ribbon-stat { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border-left: 1px solid rgba(198, 211, 238, .22); color: var(--run-dim); font: 800 var(--fs-small)/18px var(--font-body); }
.ribbon-stat b { color: var(--run-moon); font: 800 var(--fs-label)/18px var(--font-body); font-variant-numeric: tabular-nums; }
.ribbon-kills .px-icon { color: #ff9c92; }
.ribbon-coins .px-icon, .ribbon-coins b { color: var(--run-coin); }
.ribbon-stat > span { display: inline-flex; }

.boss-bar { animation: boss-in .4s cubic-bezier(.2, 1.4, .4, 1) both; position: absolute; top: 92px; left: 50%; width: min(460px, calc(100% - 32px)); transform: translateX(-50%); }
.boss-name { display: block; margin-bottom: 3px; color: var(--run-boss); font: 800 var(--fs-label)/1.1 var(--font-body); text-align: center; paint-order: stroke fill; -webkit-text-stroke: 3px var(--run-edge); }
.boss-track { height: 13px; overflow: hidden; border: 2px solid var(--run-edge); border-radius: 7px; background: var(--run-night); box-shadow: 0 0 0 1px rgba(255, 138, 92, .5), 0 3px 0 var(--run-edge); }
.boss-track i { display: block; height: 100%; background: linear-gradient(#ffc2a4, var(--run-boss) 55%, #d4542a); transition: width .12s linear; }

/* Collapsible night-glass panels */
.hud-panel { position: absolute; pointer-events: auto; overflow: hidden; border: 3px solid var(--run-edge); border-radius: 12px; background: var(--run-stars), linear-gradient(rgba(20, 27, 69, .95), rgba(6, 9, 25, .95)); box-shadow: inset 0 1px 0 rgba(214,228,255,.28), inset 0 0 0 1px rgba(198,211,238,.1), 0 4px 0 var(--run-edge); }
.panel-toggle { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 28px; padding: 3px 8px; border: 0; background: rgba(198, 211, 238, .08); color: var(--run-silver); font: 800 var(--fs-small)/1 var(--font-body); text-align: left; cursor: pointer; }
.panel-toggle:hover { background: rgba(198, 211, 238, .18); }
.panel-toggle:focus-visible { outline: 2px solid var(--run-moon); outline-offset: -2px; }
.panel-title { flex: none; }
.panel-caret { display: inline-flex; margin-left: auto; transition: transform .16s; }
.hud-panel:not(.is-collapsed) .panel-caret { transform: rotate(180deg); }
.hud-panel.is-collapsed .stat-body, .hud-panel.is-collapsed .dps-body { display: none; }

.stat-panel { left: max(16px, env(safe-area-inset-left)); bottom: 16px; width: 246px; }
.stat-body { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; padding: 4px; }
.stat-chip { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 4px; padding: 3px 4px; border-radius: 6px; color: var(--run-dim); font: 800 var(--fs-small)/1.2 var(--font-body); }
.stat-chip .px-icon { color: var(--run-silver); }
.stat-chip b { grid-column: 1 / -1; color: var(--run-moon); font: 800 var(--fs-body)/1.1 var(--font-body); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-chip.is-raised b { color: #a9f0c0; }
.stat-chip.is-capped b { color: var(--run-coin); }

.dps-panel { right: max(16px, env(safe-area-inset-right)); bottom: 16px; width: 276px; }
.dps-value { color: var(--run-moon); font: 400 var(--fs-d20)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.dps-spark { flex: 1; min-width: 20px; height: 18px; }
.dps-body { padding: 4px 6px 6px; }
.dps-totals { display: flex; justify-content: space-between; padding-bottom: 4px; color: var(--run-dim); font: 700 var(--fs-small)/1.2 var(--font-body); }
.dps-totals b { color: var(--run-moon); font-weight: 800; font-variant-numeric: tabular-nums; }
.dps-rows { display: grid; gap: 3px; }
.dps-row { position: relative; display: flex; align-items: center; gap: 5px; min-height: 22px; padding: 0 6px; overflow: hidden; border-radius: 6px; background: rgba(198, 211, 238, .08); color: var(--run-moon); font: 800 var(--fs-small)/1 var(--font-body); }
.dps-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, color-mix(in srgb, var(--type) 62%, transparent), color-mix(in srgb, var(--type) 26%, transparent)); transition: width .3s; }
.dps-row > :not(.dps-fill) { position: relative; }
.dps-row .px-icon { color: color-mix(in srgb, var(--type) 60%, #fff); }
.dps-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 2px #000; }
.dps-row small { color: #dbe6ff; font: 700 var(--fs-small)/1 var(--font-body); text-shadow: 0 1px 2px #000; }
.dps-row b { min-width: 28px; font-weight: 900; text-align: right; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #000; }
.dps-empty { margin: 0; color: var(--run-dim); font: 700 var(--fs-small)/1.3 var(--font-body); }

/* Buff and status chips, just above the dock */
.run-chips { position: absolute; bottom: 112px; left: 50%; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; width: min(560px, 60%); transform: translateX(-50%); }
.run-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 5px; border: 2px solid var(--run-edge); border-radius: 9px; background: var(--run-deep); color: var(--run-moon); font: 800 var(--fs-small)/15px var(--font-body); box-shadow: 0 0 0 1px color-mix(in srgb, var(--type, #c6d3ee) 70%, transparent); }
.run-chip .px-icon { color: color-mix(in srgb, var(--type, #c6d3ee) 70%, #fff); }
.run-chip.regen { --type: var(--run-hp); }
.run-chip.safe { --type: #cfe0ff; }
.run-chip.buff { --type: var(--run-xp); }

/* Bottom dock: partner and moves */
.run-dock { position: absolute; z-index: 4; left: 50%; bottom: 14px; display: flex; align-items: center; gap: 10px; transform: translateX(-50%); color: var(--run-text); pointer-events: none; animation: dock-rise .36s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes dock-rise { from { opacity: 0; transform: translate(-50%, 22px); } to { opacity: 1; transform: translateX(-50%); } }
.dock-partner { display: flex; align-items: center; gap: 8px; width: 276px; padding: 6px 12px 6px 6px; border: 3px solid var(--run-edge); border-radius: 18px 12px 12px 18px; background: var(--run-stars), linear-gradient(rgba(28, 37, 88, .96), rgba(6, 9, 25, .96)); box-shadow: inset 0 1px 0 rgba(214,228,255,.3), 0 4px 0 var(--run-edge); }
.partner-portrait { position: relative; display: grid; flex: none; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: conic-gradient(var(--run-xp) calc(var(--xp, 0) * 360deg), rgba(198, 211, 238, .2) 0); box-shadow: 0 0 12px rgba(127, 227, 255, .3); }
.partner-glyph { display: block; width: 58px; height: 58px; overflow: hidden; border: 3px solid var(--run-edge); border-radius: 50%; background: radial-gradient(circle at 50% 35%, var(--run-hover), var(--run-night)); }
.partner-glyph img { display: block; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.xp-level { position: absolute; bottom: -5px; left: 50%; padding: 1px 7px; border: 2px solid var(--run-edge); border-radius: 8px; background: var(--run-moon); color: var(--run-night); font: 800 var(--fs-badge)/13px var(--font-body); white-space: nowrap; transform: translateX(-50%); }
.xp-level b { font-weight: 900; font-variant-numeric: tabular-nums; }
.dock-vitals { flex: 1; min-width: 0; }
.dock-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.dock-row b { overflow: hidden; color: var(--run-moon); font: 400 var(--fs-d20)/1.1 var(--font-display); text-overflow: ellipsis; white-space: nowrap; }
.dock-row span { flex: none; color: #dbe6ff; font: 800 var(--fs-body)/1.1 var(--font-body); font-variant-numeric: tabular-nums; }
.hp-track { position: relative; height: 16px; overflow: hidden; border: 2px solid var(--run-edge); border-radius: 8px; background: var(--run-night); }
.hp-track i { position: absolute; inset: 0 auto 0 0; display: block; }
.hp-now { background: linear-gradient(#b4f8c2, var(--run-hp) 50%, #2e9e4c); transition: width .14s ease-out; }
.hp-ghost { background: #ffe9c2; transition: width .5s ease-out; }
.low-hp .hp-now { background: linear-gradient(#ffb2a9, var(--run-hp-low) 50%, #c5332a); }

.slot-bar { display: flex; align-items: flex-start; gap: 5px; padding: 6px 6px 3px; border: 3px solid var(--run-edge); border-radius: 12px; background: var(--run-stars), linear-gradient(rgba(28, 37, 88, .96), rgba(6, 9, 25, .96)); box-shadow: inset 0 1px 0 rgba(214,228,255,.3), 0 4px 0 var(--run-edge); pointer-events: auto; }
.move-slot { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 70px; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; }
.move-slot:focus-visible { outline: 2px solid var(--run-moon); outline-offset: 2px; border-radius: 8px; }
.slot-face { position: relative; display: grid; place-items: center; width: 54px; height: 54px; overflow: hidden; clip-path: polygon(14% 0, 86% 0, 100% 14%, 100% 86%, 86% 100%, 14% 100%, 0 86%, 0 14%); background: var(--type, #4a5580); }
.slot-face::before { content: ''; position: absolute; inset: 3px; clip-path: inherit; background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--type, #4a5580) 42%, var(--run-deep)), var(--run-night)); }
.slot-icon { position: relative; display: grid; place-items: center; color: color-mix(in srgb, var(--type, #c6d3ee) 45%, #fff); filter: drop-shadow(0 1px 0 #000); }
.slot-sweep { position: absolute; inset: 3px; clip-path: polygon(14% 0, 86% 0, 100% 14%, 100% 86%, 86% 100%, 14% 100%, 0 86%, 0 14%); background: conic-gradient(rgba(2, 4, 13, .8) calc(var(--cd, 0) * 360deg), transparent 0); }
.slot-cd { position: absolute; color: #fff; font: 400 var(--fs-d28)/1 var(--font-display); text-shadow: 0 0 3px #000, 0 2px 0 #000; font-variant-numeric: tabular-nums; }
.slot-pips { display: flex; justify-content: center; gap: 2px; min-height: 5px; }
.slot-pips i { width: 8px; height: 4px; background: rgba(198, 211, 238, .22); }
.slot-pips i.on { background: var(--run-moon); box-shadow: 0 0 4px var(--run-glow); }
.slot-name { display: block; width: 100%; overflow: hidden; color: #dbe6ff; font: 800 var(--fs-badge)/1.2 var(--font-body); text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.slot-new { position: absolute; top: -7px; right: 0; display: none; padding: 0 5px; border: 2px solid var(--run-edge); border-radius: 6px; background: var(--run-action); color: var(--run-edge); font: 900 var(--fs-badge)/13px var(--font-body); }
.move-slot.is-empty .slot-face { background: rgba(198, 211, 238, .22); }
.move-slot.is-empty .slot-face::before { background: var(--run-night); }
.move-slot.is-empty .slot-icon { color: rgba(198, 211, 238, .6); }
.move-slot.is-empty .slot-sweep { display: none; }
.move-slot.is-empty .slot-name { color: var(--run-dim); font-weight: 700; }
.move-slot.is-new .slot-new { display: block; animation: new-bob .7s ease-in-out infinite alternate; }
.move-slot.is-new .slot-face { animation: slot-glow .9s ease-in-out infinite alternate; }
.move-slot.is-leveled .slot-face { animation: slot-level .5s ease-out 2; }
.move-slot.is-firing .slot-icon { transform: scale(1.18); }
@keyframes new-bob { to { transform: translateY(-3px); } }
@keyframes slot-glow { to { filter: brightness(1.55); } }
@keyframes slot-level { 50% { filter: brightness(2.2); transform: scale(1.1); } }
.slot-tip { position: absolute; bottom: calc(100% + 8px); padding: 5px 10px; border: 2px solid var(--run-edge); border-radius: 9px; background: var(--run-indigo); box-shadow: 0 0 0 1px rgba(198,211,238,.3), 0 3px 0 var(--run-edge); color: var(--run-dim); font: 700 var(--fs-small)/1.25 var(--font-body); white-space: nowrap; transform: translateX(-50%); }
.slot-tip b { color: var(--run-moon); font-weight: 900; }

/* Short event messages sit under the clock and never cover the player. */
.game-shell .combat-feed { position: absolute; z-index: 4; top: 96px; left: 50%; display: flex; flex-direction: column; align-items: center; gap: 5px; width: min(420px, calc(100% - 32px)); max-height: 66px; overflow: hidden; transform: translateX(-50%); pointer-events: none; }
.game-shell.in-run .run-top:has(.boss-bar:not([hidden])) ~ .combat-feed { top: 134px; }
.game-shell .feed-line { animation: feed-slide .22s ease-out both; padding: 3px 12px; border: 2px solid var(--run-edge); border-radius: 10px; background: var(--run-deep); color: var(--run-moon); font: 800 var(--fs-body)/1.2 var(--font-body); text-align: center; }

/* Co-op labels */
.game-shell.in-run .co-op-tag, .game-shell.in-run .remote-tag { top: 26px; left: 16px; right: auto; bottom: auto; border: 2px solid var(--run-edge); border-radius: 12px; background: var(--run-deep); color: var(--run-moon); font: 700 var(--fs-small)/1.2 var(--font-body); }
.game-shell.in-run .remote-tag { top: 74px; }
.game-shell.in-run .room-floating { top: 74px; border-radius: 12px; background: var(--run-deep); }
.game-shell.in-run .room-floating > span, .game-shell.in-run .room-floating code, .game-shell.in-run .room-floating button { font-size: var(--fs-small); }

/* Overlays: a night sky behind every sheet */
.game-shell .overlay-layer { background: radial-gradient(ellipse at 50% 20%, rgba(20, 27, 69, .72), rgba(2, 4, 13, .88)); backdrop-filter: blur(3px); }
.game-shell .choice-modal, .game-shell .pause-modal, .game-shell .end-modal { scrollbar-width: thin; scrollbar-color: var(--run-silver) transparent; position: relative; max-height: calc(100% - 20px); padding: 18px; overflow: auto; animation: panel-pop .26s cubic-bezier(.2, 1.3, .4, 1) both; border: 3px solid var(--run-edge); border-radius: 18px; background: var(--run-stars), var(--run-stars), linear-gradient(165deg, var(--run-indigo), var(--run-night) 70%); background-size: 340px 280px, 210px 190px, auto; box-shadow: inset 0 0 0 1px rgba(198,211,238,.26), inset 0 1px 0 rgba(238,243,255,.3), 0 8px 0 var(--run-edge), 0 0 60px rgba(120, 160, 255, .2); color: var(--run-text); }
/* The crescent moon that marks these sheets. */
.game-shell .pause-modal::before, .game-shell .end-modal::before { content: ''; position: absolute; top: 12px; right: 18px; width: 44px; height: 44px; border-radius: 50%; box-shadow: inset -11px 3px 0 0 var(--run-silver), 0 0 24px -4px rgba(198,211,238,.55); opacity: .75; pointer-events: none; }
.game-shell .overlay-layer h2 { margin: 0; color: var(--run-moon); font: 400 var(--fs-d38)/1.05 var(--font-display); text-shadow: 0 0 18px var(--run-glow); }
.game-shell .overlay-layer h3 { margin: 0 0 6px; color: var(--run-silver); font: 800 var(--fs-label)/1.1 var(--font-body); }

/* Level-up cards */
.game-shell .choice-modal { width: min(1000px, calc(100% - 28px)); }
.choice-head { display: flex; align-items: center; gap: 12px; }
.choice-level { flex: none; margin: 0; padding: 4px 12px; border: 3px solid var(--run-edge); border-radius: 10px; background: var(--run-moon); color: var(--run-night); font: 400 var(--fs-d20)/1.1 var(--font-display); box-shadow: 0 3px 0 var(--run-edge), 0 0 18px var(--run-glow); animation: level-pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes level-pop { from { transform: scale(1.8) rotate(-5deg); opacity: 0; } }
.reroll-button { display: inline-flex; flex: none; align-items: center; gap: 6px; min-height: 40px; margin-left: auto; padding: 0 10px; border: 3px solid var(--run-edge); border-radius: 11px; background: linear-gradient(var(--run-hover), var(--run-indigo)); box-shadow: inset 0 1px 0 rgba(214,228,255,.3), 0 4px 0 var(--run-edge); color: var(--run-moon); font: 800 var(--fs-body)/1 var(--font-body); cursor: pointer; transition: transform .08s, box-shadow .08s; }
.reroll-button > span { display: inline-flex; }
.reroll-button b { display: grid; place-items: center; min-width: 20px; height: 20px; border-radius: 6px; background: var(--run-action); color: var(--run-edge); font: 800 var(--fs-body)/1 var(--font-body); }
.reroll-button:hover:not(:disabled) { background: var(--run-hover); }
.reroll-button:active:not(:disabled) { box-shadow: none; transform: translateY(4px); }
.reroll-button:disabled { opacity: .5; cursor: default; }
.reroll-button:disabled b { background: var(--run-silver); }
.game-shell kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border: 1px solid rgba(198,211,238,.4); border-radius: 5px; background: rgba(2,4,13,.6); color: var(--run-silver); font: 800 var(--fs-badge)/1 var(--font-body); }
.game-shell .upgrade-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.game-shell .upgrade-card { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: 100%; min-height: 280px; padding: 12px; overflow: hidden; border: 3px solid var(--run-edge); border-radius: 14px; background: linear-gradient(170deg, color-mix(in srgb, var(--type) 26%, var(--run-indigo)), var(--run-deep) 58%); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--type) 62%, transparent), 0 6px 0 var(--run-edge), 0 0 22px -6px var(--type); color: var(--run-text); text-align: left; cursor: pointer; transition: transform .12s, box-shadow .12s, filter .12s; animation: card-deal .42s cubic-bezier(.2, 1.4, .4, 1) both; }
.game-shell .upgrade-card:nth-child(2) { animation-delay: .07s; }
.game-shell .upgrade-card:nth-child(3) { animation-delay: .14s; }
/* A slow moonlight sheen crosses each card. */
.game-shell .upgrade-card::after { content: ''; position: absolute; inset: -40% auto -40% -60%; width: 40%; background: linear-gradient(90deg, transparent, rgba(238,243,255,.16), transparent); transform: rotate(14deg); animation: card-sheen 3.4s ease-in-out infinite; pointer-events: none; }
.game-shell .upgrade-card:nth-child(2)::after { animation-delay: .5s; }
.game-shell .upgrade-card:nth-child(3)::after { animation-delay: 1s; }
@keyframes card-sheen { 0%, 55% { left: -60%; } 100% { left: 130%; } }
.game-shell .upgrade-card:hover, .game-shell .upgrade-card:focus-visible { outline: 0; filter: brightness(1.14); box-shadow: inset 0 0 0 2px var(--type), 0 10px 0 var(--run-edge), 0 0 30px -2px var(--type); transform: translateY(-4px); }
.game-shell .upgrade-card:active { box-shadow: inset 0 0 0 2px var(--type), 0 1px 0 var(--run-edge); transform: translateY(5px); }
.card-tag { position: absolute; z-index: 1; top: 0; right: 0; padding: 3px 10px; border-bottom: 3px solid var(--run-edge); border-left: 3px solid var(--run-edge); border-radius: 0 0 0 10px; background: var(--run-silver); color: var(--run-night); font: 900 var(--fs-badge)/14px var(--font-body); }
.kind-new .card-tag { background: var(--run-action); }
.kind-level .card-tag { background: var(--run-xp); }
.game-shell .upgrade-card kbd { position: absolute; z-index: 1; left: 6px; bottom: 6px; }
.card-top { display: flex; flex-direction: column; gap: 8px; }
.card-art { position: relative; display: block; height: 96px; overflow: hidden; border: 2px solid var(--run-edge); border-radius: 9px; background: var(--run-stars), radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--type) 24%, var(--run-deep)), var(--run-night)); box-shadow: inset 0 0 0 1px rgba(198,211,238,.16); }
.card-preview { display: block; width: 100%; height: 100%; }
.card-glyph { position: absolute; left: 4px; top: 4px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--type); color: var(--run-edge); }
.card-emblem { display: grid; place-items: center; color: var(--run-moon); filter: drop-shadow(0 0 8px var(--run-glow)); }
.card-head { display: block; min-width: 0; }
.card-name { display: block; overflow: hidden; color: var(--run-moon); font: 400 var(--fs-d24)/1.1 var(--font-display); text-overflow: ellipsis; white-space: nowrap; }
.card-sub { display: block; margin-top: 1px; color: color-mix(in srgb, var(--type) 50%, #fff); font: 800 var(--fs-small)/1.25 var(--font-body); }
.card-pips { justify-content: flex-start; margin-top: 3px; }
.card-text { display: block; color: #dbe6ff; font: 700 var(--fs-small)/1.32 var(--font-body); }
.card-facts { display: grid; gap: 2px; margin-top: auto; padding: 5px 7px 5px; border-radius: 8px; background: rgba(2, 4, 13, .55); }
.card-fact { display: flex; align-items: baseline; gap: 4px; color: var(--run-moon); font: 800 var(--fs-small)/1.3 var(--font-body); font-variant-numeric: tabular-nums; }
.card-fact i { margin-right: auto; color: var(--run-dim); font-style: normal; font-weight: 700; }
.card-fact s { color: var(--run-dim); text-decoration: none; }
.card-fact em { color: var(--run-dim); font-style: normal; }
.card-fact b { color: #a9f0c0; font-weight: 900; }
.game-shell .upgrade-card:has(kbd) .card-facts { margin-left: 22px; }

/* Buttons on overlays */
.game-shell .overlay-layer .primary-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; margin: 0; padding: 0 16px; border: 3px solid var(--run-edge); border-radius: 13px; background: linear-gradient(var(--run-action-hover), var(--run-action)); box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 5px 0 var(--run-edge); color: var(--run-edge); transition: transform .08s, box-shadow .08s, filter .12s; font: 400 var(--fs-d24)/1 var(--font-display); cursor: pointer; }
.game-shell .overlay-layer .primary-button:hover { filter: brightness(1.08); transform: none; }
.game-shell .overlay-layer .primary-button:active { box-shadow: 0 1px 0 var(--run-edge); transform: translateY(4px); }
.ghost-button { white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 10px; border: 3px solid var(--run-edge); border-radius: 11px; background: linear-gradient(var(--run-raised), var(--run-indigo)); box-shadow: inset 0 1px 0 rgba(214,228,255,.26), 0 3px 0 var(--run-edge); color: var(--run-moon); font: 800 var(--fs-body)/1 var(--font-body); cursor: pointer; transition: transform .08s, box-shadow .08s; }
.ghost-button:hover { background: var(--run-hover); }
.ghost-button:active { box-shadow: none; transform: translateY(3px); }
.quit-button.is-armed { background: #7c1f2c; color: #fff; }
.game-shell .overlay-layer button:focus-visible { outline: 2px solid var(--run-moon); outline-offset: 2px; }

.card-type-icon, .slot-type { display: inline-flex; flex: none; }
.card-sub { display: flex; align-items: center; gap: 4px; }
.slot-type { position: absolute; top: -3px; left: 2px; padding: 1px; border-radius: 5px; background: var(--run-night); box-shadow: 0 0 0 1px var(--run-edge); }
.pause-slot-head small { display: inline-flex; align-items: center; gap: 3px; }
.end-move .pokemon-type-icon { margin-right: -1px; }

/* Pause */
.game-shell .pause-modal, .game-shell .end-modal { text-align: left; }
.game-shell .pause-modal { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; width: min(940px, calc(100% - 28px)); }
.pause-side { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.pause-partner { display: flex; align-items: center; gap: 10px; padding: 8px; border: 2px solid var(--run-edge); border-radius: 12px; background: rgba(2, 4, 13, .5); box-shadow: inset 0 0 0 1px rgba(198,211,238,.14); }
.pause-portrait { display: block; flex: none; width: 62px; height: 62px; overflow: hidden; border: 3px solid var(--run-silver); border-radius: 50%; background: radial-gradient(circle at 50% 35%, var(--run-hover), var(--run-night)); box-shadow: 0 0 14px var(--run-glow); }
.pause-portrait img { display: block; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.pause-partner-copy { flex: 1; min-width: 0; }
.pause-partner-copy b { display: block; overflow: hidden; color: var(--run-moon); font: 400 var(--fs-d20)/1.1 var(--font-display); text-overflow: ellipsis; white-space: nowrap; }
.pause-partner-copy small { display: block; color: var(--run-dim); font: 700 var(--fs-small)/1.3 var(--font-body); white-space: nowrap; }
.pause-hp-track { height: 9px; margin: 3px 0 1px; overflow: hidden; border: 1px solid var(--run-edge); border-radius: 5px; background: var(--run-night); }
.pause-hp-track i { display: block; height: 100%; background: var(--run-hp); }
.pause-run-line { margin: 0; color: var(--run-silver); font: 700 var(--fs-small)/1.2 var(--font-body); }
.pause-minor { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pause-controls { display: flex; flex-wrap: wrap; gap: 3px 10px; margin: auto 0 0; color: var(--run-dim); font: 700 var(--fs-small)/1.6 var(--font-body); }
.pause-controls span { display: inline-flex; align-items: center; gap: 3px; }
.pause-main { min-width: 0; overflow: auto; padding-top: 2px; }
.pause-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.pause-slot { display: flex; gap: 8px; min-width: 0; padding: 6px 8px; border: 2px solid var(--run-edge); border-radius: 10px; background: linear-gradient(120deg, color-mix(in srgb, var(--type, #5b6794) 20%, var(--run-deep)), var(--run-deep)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--type, #c6d3ee) 42%, transparent); }
.pause-slot.is-free, .pause-slot.is-locked { color: var(--run-dim); background: rgba(2, 4, 13, .4); }
.pause-slot-icon { display: grid; flex: none; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--type, rgba(198,211,238,.16)); color: var(--run-edge); }
.pause-slot.is-free .pause-slot-icon, .pause-slot.is-locked .pause-slot-icon { color: var(--run-silver); }
.pause-slot-copy { min-width: 0; }
.pause-slot-head { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.pause-slot-copy b { color: var(--run-moon); font: 800 var(--fs-label)/1.15 var(--font-body); }
.pause-slot-head small { color: color-mix(in srgb, var(--type) 50%, #fff); font: 800 var(--fs-small)/1.2 var(--font-body); }
.pause-slot-copy p { margin: 1px 0 0; color: #d3def5; font: 700 var(--fs-small)/1.28 var(--font-body); }
.pause-slot-facts { display: block; margin-top: 1px; color: var(--run-dim); font: 700 var(--fs-small)/1.3 var(--font-body); }
.pause-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.pause-stat { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0 5px; min-height: 36px; padding: 3px 7px; border: 2px solid var(--run-edge); border-radius: 8px; background: rgba(2, 4, 13, .5); color: var(--run-dim); font: 700 var(--fs-small)/1.2 var(--font-body); text-align: left; cursor: help; }
.pause-stat .px-icon { color: var(--run-silver); }
.pause-stat b { color: var(--run-moon); font: 800 var(--fs-body)/1.15 var(--font-body); font-variant-numeric: tabular-nums; }
.pause-stat small { grid-column: 2 / -1; color: #93a2c6; font: 700 var(--fs-small)/1.2 var(--font-body); text-align: right; }
.pause-stat.is-raised b { color: #a9f0c0; }
.pause-stat.is-capped b { color: var(--run-coin); }
.pause-stat:hover, .pause-stat.is-active { background: var(--run-raised); box-shadow: inset 0 0 0 1px var(--run-silver); }
.stat-explain { min-height: 18px; margin: 6px 0 0; color: var(--run-silver); font: 700 var(--fs-small)/1.3 var(--font-body); }

/* End */
.game-shell .end-modal { display: flex; flex-direction: column; gap: 10px; width: min(820px, calc(100% - 28px)); overflow: auto; }
.end-head { display: flex; align-items: center; gap: 10px; padding-right: 60px; }
.end-head p { margin: 2px 0 0; color: var(--run-dim); font: 700 var(--fs-small)/1.2 var(--font-body); }
.end-head .pause-portrait { width: 52px; height: 52px; }
.end-body { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.end-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.game-shell .report-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 0; padding: 0; border: 0; }
.game-shell .report-stats div, .game-shell .report-stats div + div { padding: 7px 8px; border: 2px solid var(--run-edge); border-radius: 10px; background: rgba(2, 4, 13, .5); box-shadow: inset 0 0 0 1px rgba(198,211,238,.14); animation: stat-rise .4s cubic-bezier(.2, 1.4, .4, 1) both; text-align: center; }
.game-shell .report-stats div:nth-child(2) { animation-delay: .06s; }
.game-shell .report-stats div:nth-child(3) { animation-delay: .12s; }
.game-shell .report-stats div:nth-child(4) { animation-delay: .18s; }
.game-shell .report-stats div:nth-child(5) { animation-delay: .24s; }
.game-shell .report-stats .is-coins { grid-column: 1 / -1; box-shadow: inset 0 0 0 1px rgba(255,210,63,.5); }
.game-shell .report-stats span { display: block; color: var(--run-dim); font: 800 var(--fs-small)/1.2 var(--font-body); }
.game-shell .report-stats b { display: block; margin-top: 1px; color: var(--run-moon); font: 400 var(--fs-d28)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.game-shell .report-stats .is-coins b { color: var(--run-coin); }
.end-moves { display: flex; flex-wrap: wrap; gap: 4px; }
.end-move { display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px; border: 2px solid var(--run-edge); border-radius: 8px; background: color-mix(in srgb, var(--type) 22%, var(--run-deep)); color: var(--run-moon); font: 800 var(--fs-small)/1.2 var(--font-body); }
.end-move .px-icon { color: color-mix(in srgb, var(--type) 60%, #fff); }
.end-move small { color: var(--run-silver); font: 700 var(--fs-small)/1 var(--font-body); }
.end-damage { display: flex; flex-direction: column; gap: 6px; padding: 7px; border: 2px solid var(--run-edge); border-radius: 12px; background: rgba(2, 4, 13, .5); box-shadow: inset 0 0 0 1px rgba(198,211,238,.2); }
.end-damage-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 8px; }
.end-tile { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.end-tile span { color: var(--run-dim); font: 700 var(--fs-small)/1.3 var(--font-body); }
.end-tile b { color: var(--run-moon); font: 400 var(--fs-d20)/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.end-tile.is-record b { color: var(--run-coin); }
.game-shell .run-rewards { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 4px; min-height: 0; margin: 0; padding: 0; border: 0; background: none; }
.reward-chip { animation: stat-rise .35s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: .3s; padding: 3px 9px; border: 2px solid var(--run-edge); border-radius: 9px; background: rgba(255, 210, 63, .14); color: var(--run-coin); font: 800 var(--fs-small)/1.25 var(--font-body); }
.reward-chip.is-new { background: rgba(127, 227, 255, .14); color: var(--run-xp); }
.end-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.end-actions .ghost-button { min-height: 48px; }

/* Damage report */
.game-shell .end-modal:has(.damage-report:not([hidden])) { height: min(640px, calc(100% - 8px)); overflow: hidden; }
.damage-report { position: absolute; z-index: 2; inset: 0; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; overflow: auto; border-radius: 15px; background: var(--run-stars), linear-gradient(165deg, var(--run-indigo), var(--run-night) 70%); animation: panel-pop .2s ease-out both; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-shell .overlay-layer .report-head h3 { display: inline; margin: 0 8px 0 0; color: var(--run-moon); font-size: var(--fs-lead); }
.report-head small { color: var(--run-dim); font: 700 var(--fs-small)/1 var(--font-body); }
.report-close { display: grid; flex: none; place-items: center; width: 40px; height: 40px; padding: 0; border: 3px solid var(--run-edge); border-radius: 10px; background: var(--run-raised); box-shadow: 0 3px 0 var(--run-edge); color: var(--run-moon); cursor: pointer; }
.report-close:hover { background: var(--run-hover); }
.report-body { display: grid; flex: 1; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 10px; min-height: 0; }
.report-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.report-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.report-tile { padding: 4px 3px; border: 2px solid var(--run-edge); border-radius: 8px; background: rgba(2, 4, 13, .55); text-align: center; }
.report-tile span { display: block; color: var(--run-dim); font: 700 var(--fs-small)/1.15 var(--font-body); }
.report-tile b { display: block; color: var(--run-moon); font: 400 var(--fs-d24)/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.report-tile em { display: flex; align-items: center; justify-content: center; gap: 2px; color: var(--run-coin); font: 800 var(--fs-small)/1.2 var(--font-body); font-style: normal; }
.report-tile.is-record { box-shadow: inset 0 0 0 1px var(--run-coin); }
.report-chart { display: flex; flex: 1; flex-direction: column; min-height: 130px; padding: 5px 6px; border: 2px solid var(--run-edge); border-radius: 10px; background: rgba(2, 4, 13, .55); }
.report-chart span { color: var(--run-silver); font: 800 var(--fs-small)/1.2 var(--font-body); }
#dps-chart { display: block; flex: 1; width: 100%; min-height: 110px; touch-action: none; }
.report-table-wrap { min-width: 0; overflow: auto; border: 2px solid var(--run-edge); border-radius: 10px; background: rgba(2, 4, 13, .55); }
.report-table { width: 100%; border-collapse: separate; border-spacing: 0 2px; padding: 2px 4px; color: var(--run-moon); font: 700 var(--fs-small)/1.2 var(--font-body); font-variant-numeric: tabular-nums; }
.report-table thead th { position: sticky; top: 0; padding: 4px 5px; background: var(--run-deep); color: var(--run-dim); font: 800 var(--fs-small)/1.2 var(--font-body); text-align: right; }
.report-table thead th:first-child, .report-table tbody th { text-align: left; }
.report-table tbody tr { background: linear-gradient(90deg, color-mix(in srgb, var(--type) 40%, transparent) var(--share), rgba(198,211,238,.06) var(--share)); }
.report-table tbody th { padding: 5px; border-radius: 6px 0 0 6px; font-weight: 800; }
.report-table tbody td { padding: 5px; text-align: right; }
.report-table tbody td:last-child { border-radius: 0 6px 6px 0; }
.report-source { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; text-shadow: 0 1px 2px #000; }
.report-source .px-icon { color: color-mix(in srgb, var(--type) 60%, #fff); }
.report-empty { color: var(--run-dim); text-align: center !important; }

/* Center-screen moments */
.run-banner { position: absolute; z-index: 5; top: 34%; left: 50%; opacity: 0; color: var(--run-moon); font: 700 clamp(36px, 6vw, 72px)/1 var(--run-title); paint-order: stroke fill; -webkit-text-stroke: 8px var(--run-edge); text-align: center; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap; text-shadow: 0 0 22px var(--run-glow); }
.run-banner.is-boss { color: var(--run-boss); }
.run-banner.is-win { color: var(--run-coin); }
.run-banner.is-pick { color: var(--run-xp); font-size: clamp(26px, 4vw, 48px); }
@keyframes card-deal { from { opacity: 0; transform: translateY(46px) rotate(-3deg) scale(.88); } to { opacity: 1; transform: none; } }
@keyframes stat-rise { from { opacity: 0; transform: translateY(14px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes boss-in { from { opacity: 0; transform: translate(-50%, -14px); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes feed-slide { from { opacity: 0; transform: translateY(-7px); } to { opacity: 1; transform: none; } }
@media (pointer: coarse) { .game-shell .upgrade-card kbd, .reroll-button kbd { display: none; } .game-shell .upgrade-card:has(kbd) .card-facts { margin-left: 0; } }

/* Compact layout: phones in landscape and narrow windows. Panels tuck behind tap targets along the top, the dock sits between the thumbs. */
@media (max-width: 1179px), (max-height: 519px) {
  .xp-rail { height: 8px; }
  .xp-label { display: none; }
  .run-status { top: 7px; }
  .run-time { font-size: var(--fs-d28); -webkit-text-stroke-width: 4px; }
  .run-ribbon { padding: 1px 3px; border-radius: 8px; box-shadow: inset 0 1px 0 rgba(214,228,255,.25), 0 2px 0 var(--run-edge); }
  .ribbon-area { padding: 0 5px; font-size: var(--fs-small); line-height: 16px; }
  .area-place { display: none; }
  .ribbon-stat { padding: 0 5px; gap: 3px; font-size: var(--fs-small); line-height: 16px; }
  .ribbon-stat b { font-size: var(--fs-small); line-height: 16px; }
  .ribbon-wave { display: none; }
  .game-shell.in-run .top-actions { top: 12px; right: max(8px, env(safe-area-inset-right)); gap: 5px; }
  .game-shell.in-run .icon-button { width: 38px; height: 38px; border-radius: 10px; }
  .game-shell.in-run #sound-button { display: none; }
  .hud-panel { border-width: 2px; border-radius: 10px; box-shadow: inset 0 1px 0 rgba(214,228,255,.28), 0 3px 0 var(--run-edge); }
  .panel-toggle { min-height: 34px; padding: 3px 7px; }
  .stat-panel { top: 12px; bottom: auto; left: max(8px, env(safe-area-inset-left)); width: 216px; }
  .stat-panel.is-collapsed { width: auto; }
  .stat-panel .panel-caret { margin-left: 6px; }
  .stat-panel:not(.is-collapsed) .panel-caret { margin-left: auto; }
  .dps-panel { top: 12px; bottom: auto; right: calc(max(8px, env(safe-area-inset-right)) + 44px); width: 236px; }
  .dps-panel.is-collapsed { width: auto; }
  .dps-panel.is-collapsed .dps-spark { display: none; }
  .dps-panel.is-collapsed .panel-caret { margin-left: 2px; }
  .dps-value { font-family: var(--font-body); font-weight: 800; font-size: var(--fs-body); }
  .dps-row { min-height: 20px; }
  .run-chips { bottom: 60px; gap: 3px; }
  .run-chip { padding: 1px 6px 1px 3px; font-size: var(--fs-small); line-height: 13px; }
  .run-dock { bottom: max(4px, env(safe-area-inset-bottom)); gap: 4px; animation: none; }
  .dock-partner { width: 180px; gap: 5px; padding: 2px 6px 2px 2px; border-width: 2px; border-radius: 14px 8px 8px 14px; box-shadow: inset 0 1px 0 rgba(214,228,255,.3), 0 2px 0 var(--run-edge); }
  .partner-portrait { width: 42px; height: 42px; }
  .partner-glyph { width: 36px; height: 36px; border-width: 2px; }
  .xp-level { bottom: -3px; padding: 0 4px; border-width: 1px; font-size: var(--fs-badge); line-height: 12px; }
  .dock-row { margin-bottom: 2px; gap: 4px; }
  .dock-row b { font-family: var(--font-body); font-weight: 800; font-size: var(--fs-small); }
  .dock-row span { font-size: var(--fs-small); }
  .hp-track { height: 11px; border-width: 1px; border-radius: 6px; }
  .slot-bar { gap: 3px; padding: 3px 3px 2px; border-width: 2px; border-radius: 9px; box-shadow: inset 0 1px 0 rgba(214,228,255,.3), 0 2px 0 var(--run-edge); }
  .move-slot { width: 38px; gap: 1px; }
  .slot-face { width: 36px; height: 36px; }
  .slot-face::before, .slot-sweep { inset: 2px; }
  .slot-icon .px-icon { width: 24px; height: 24px; }
  .slot-cd { font-family: var(--font-body); font-weight: 800; font-size: var(--fs-body); }
  .run-dock .move-slot .slot-name { display: none; }
  .slot-pips i { width: 6px; height: 3px; }
  .slot-pips { min-height: 3px; gap: 1px; }
  .slot-new { top: -6px; right: -2px; padding: 0 3px; border-width: 1px; font-size: var(--fs-badge); line-height: 11px; }
  .boss-bar { top: 62px; width: min(42vw, 380px); }
  .boss-name { margin-bottom: 1px; font-size: var(--fs-small); -webkit-text-stroke-width: 2px; }
  .boss-track { height: 9px; border-width: 1px; }
  .game-shell .combat-feed { top: 54px; max-height: 26px; width: min(46vw, 380px); }
  .game-shell.in-run .run-top:has(.boss-bar:not([hidden])) ~ .combat-feed { top: 96px; }
  .game-shell .feed-line { padding: 1px 8px; font-size: var(--fs-small); }
  .run-banner { font-size: var(--fs-lead); -webkit-text-stroke-width: 6px; }
  .run-banner.is-pick { font-size: var(--fs-lead); }
  .game-shell .touch-controls { left: max(16px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); }
  .game-shell .joystick { width: 104px; height: 104px; }
  .game-shell .joystick-knob { width: 46px; height: 46px; }
}

/* Overlays on short screens: everything stays one glance, columns instead of stacking. */
@media (max-height: 519px) {
  .game-shell .choice-modal, .game-shell .pause-modal, .game-shell .end-modal { max-height: calc(100% - 8px); padding: 7px 9px 9px; border-width: 2px; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(198,211,238,.26), 0 3px 0 var(--run-edge); }
  .game-shell .pause-modal::before, .game-shell .end-modal::before { display: none; }
  .game-shell .overlay-layer h2 { font-size: var(--fs-d24); }
  .game-shell .overlay-layer h3 { margin-bottom: 3px; font-size: var(--fs-small); }
  .game-shell .choice-modal { width: calc(100% - max(16px, env(safe-area-inset-left) + env(safe-area-inset-right))); }
  .choice-head { gap: 8px; }
  .choice-level { padding: 1px 8px; border-width: 2px; font-family: var(--font-body); font-weight: 800; font-size: var(--fs-body); box-shadow: 0 2px 0 var(--run-edge); }
  .reroll-button { min-height: 32px; padding: 0 7px; border-width: 2px; font-size: var(--fs-small); box-shadow: 0 2px 0 var(--run-edge); }
  .reroll-button .px-icon { width: 12px; height: 12px; }
  .game-shell .upgrade-list { gap: 7px; margin-top: 7px; }
  .game-shell .upgrade-card { gap: 4px; min-height: 0; padding: 6px 7px; border-width: 2px; border-radius: 10px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--type) 62%, transparent), 0 3px 0 var(--run-edge); }
  .card-top { flex-direction: row; gap: 6px; padding-right: 2px; }
  .card-art { flex: none; width: 84px; height: 62px; border-radius: 7px; }
  .card-emblem .px-icon { width: 36px; height: 36px; }
  .card-glyph { width: 18px; height: 18px; left: 2px; top: 2px; }
  .card-head { align-self: center; padding-top: 12px; }
  .card-name { font-family: var(--font-body); font-weight: 800; font-size: var(--fs-body); white-space: normal; line-height: 1; }
  .card-sub { font-size: var(--fs-small); }
  .card-tag { padding: 1px 6px; border-width: 0 0 2px 2px; font-size: var(--fs-badge); line-height: 13px; }
  .card-text { font-size: var(--fs-small); line-height: 1.24; }
  .card-facts { padding: 2px 5px; gap: 0; }
  .card-fact { font-size: var(--fs-small); line-height: 1.28; }
  .game-shell .pause-layer { padding-right: 46px; justify-items: start; padding-left: max(4px, env(safe-area-inset-left)); }
  .game-shell .pause-modal { grid-template-columns: 186px minmax(0, 1fr); gap: 8px; width: 100%; height: calc(100% - 8px); overflow: hidden; }
  .pause-side { gap: 5px; overflow: auto; }
  .pause-partner { gap: 6px; padding: 3px 5px; }
  .pause-portrait { width: 40px; height: 40px; border-width: 2px; }
  .pause-partner-copy b { font-family: var(--font-body); font-weight: 800; font-size: var(--fs-body); }
  .pause-partner-copy small { font-size: var(--fs-small); }
  .pause-hp-track { height: 6px; }
  .pause-run-line { font-size: var(--fs-small); }
  .game-shell .overlay-layer .primary-button { min-height: 38px; border-width: 2px; font-size: var(--fs-label); box-shadow: 0 3px 0 var(--run-edge); }
  .pause-minor .ghost-button { padding: 0 4px; font-size: var(--fs-small); }
  .ghost-button { min-height: 34px; border-width: 2px; font-size: var(--fs-small); box-shadow: 0 2px 0 var(--run-edge); }
  .pause-controls { font-size: var(--fs-small); line-height: 1.3; }
  .pause-slots { gap: 3px; margin-bottom: 5px; }
  .pause-slot { gap: 5px; padding: 3px 5px; border-width: 1px; }
  .pause-slot-icon { width: 26px; height: 26px; border-radius: 6px; }
  .pause-slot-icon .px-icon { width: 24px; height: 24px; }
  .pause-slot-copy b { font-size: var(--fs-small); }
  .pause-slot-copy p { font-size: var(--fs-small); line-height: 1.2; }
  .pause-slot-facts { font-size: var(--fs-small); }
  .pause-stats { gap: 2px; }
  .pause-stat { min-height: 24px; padding: 1px 5px; border-width: 1px; font-size: var(--fs-small); }
  .pause-stat b { font-size: var(--fs-small); }
  .pause-stat small { display: none; }
  .stat-explain { margin-top: 3px; font-size: var(--fs-small); }
  .game-shell .end-modal { gap: 5px; width: calc(100% - 16px); }
  .end-head { gap: 6px; padding-right: 0; }
  .end-head > div { display: flex; align-items: baseline; gap: 8px; }
  .end-head p { margin: 0; font-size: var(--fs-small); }
  .end-head .pause-portrait { width: 30px; height: 30px; }
  .end-body { gap: 7px; }
  .end-col { gap: 4px; }
  .game-shell .report-stats { grid-template-columns: repeat(3, 1fr); gap: 3px; }
  .game-shell .report-stats div, .game-shell .report-stats div + div { padding: 2px 3px; border-width: 1px; border-radius: 7px; }
  .game-shell .report-stats .is-coins { grid-column: auto / span 2; }
  .game-shell .report-stats span { font-size: var(--fs-small); }
  .game-shell .report-stats b { font-size: var(--fs-d20); }
  .end-move { padding: 1px 5px; border-width: 1px; font-size: var(--fs-small); }
  .end-damage { gap: 3px; padding: 4px 6px; border-width: 1px; }
  .end-tile span { font-size: var(--fs-small); }
  .end-tile b { font-family: var(--font-body); font-weight: 800; font-size: var(--fs-small); }
  .reward-chip { padding: 1px 6px; border-width: 1px; font-size: var(--fs-small); }
  .end-actions .ghost-button { min-height: 38px; }
  .damage-report { padding: 5px 8px 7px; gap: 3px; border-radius: 10px; }
  .report-close { width: 32px; height: 32px; border-width: 2px; box-shadow: 0 2px 0 var(--run-edge); }
  .game-shell .overlay-layer .report-head h3 { font-size: var(--fs-label); }
  .report-tile { padding: 1px 2px; border-width: 1px; }
  .report-tile span { font-size: var(--fs-small); }
  .report-tile b { font-family: var(--font-body); font-weight: 800; font-size: var(--fs-body); }
  .report-tile em { font-size: var(--fs-small); }
  .report-chart { min-height: 90px; padding: 2px 3px; }
  #dps-chart { min-height: 70px; }
  .report-table { font-size: var(--fs-small); padding: 0 2px; }
  .report-table thead th { padding: 2px 3px; font-size: var(--fs-small); }
  .report-table tbody th, .report-table tbody td { padding: 3px; }
  .col-peak { display: none; }
}

/* Narrow upright windows (desktop only; phones get the rotate prompt). */
@media (max-width: 760px) and (min-height: 520px) {
  .game-shell .upgrade-list { grid-template-columns: 1fr; }
  .game-shell .upgrade-card { min-height: 0; }
  .card-art { height: 60px; }
  .game-shell .pause-modal { grid-template-columns: 1fr; }
  .pause-slots, .end-body, .report-body { grid-template-columns: 1fr; }
  .run-dock { flex-direction: column; }
  .run-chips { bottom: 120px; }
}

/* Follows the in-game Motion setting, not the OS. */
html.motion-reduced .game-shell .upgrade-card, html.motion-reduced .xp-track i, html.motion-reduced .hp-track i, html.motion-reduced .boss-track i, html.motion-reduced .dps-fill, html.motion-reduced .panel-caret { transition: none; }html.motion-reduced .game-shell .upgrade-card, html.motion-reduced .game-shell .upgrade-card::after, html.motion-reduced .game-shell .report-stats div, html.motion-reduced .reward-chip, html.motion-reduced .boss-bar, html.motion-reduced .run-dock, html.motion-reduced .game-shell .feed-line, html.motion-reduced .game-shell .choice-modal, html.motion-reduced .game-shell .pause-modal, html.motion-reduced .game-shell .end-modal, html.motion-reduced .damage-report, html.motion-reduced .choice-level, html.motion-reduced .move-slot .slot-new, html.motion-reduced .move-slot .slot-face { animation: none !important; }html.motion-reduced .game-shell .upgrade-card::after { display: none; }html.motion-reduced .game-shell.in-run.low-hp .screen-vignette { animation: none; box-shadow: inset 0 0 110px rgba(255, 60, 50, .42); }html.motion-reduced .game-shell .upgrade-card:hover { transform: none; }

/* Size dial: the run's DOM panels follow --ui-scale from hub.css, more gently on phones so the field stays open. */
.game-shell.in-run .run-top, .game-shell .run-dock, .game-shell .overlay-layer { zoom: var(--run-scale, var(--ui-scale)); }
@media (max-height: 520px) { :root { --run-scale: 1.1; } }
