/* style.css: layout for the stage, HUD and the nine screens. Panels, buttons, cards and bars are CSS, not images. */
:root {
  --ink: #101426; --slate: #26304A; --cyan: #35E6ED; --pink: #FF4385; --amber: #FFC65A; --mint: #7FF3B0; --white: #F3F0DF;
  --edge: #3D4B73; --hud-b: 96px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #07090F; color: var(--white); font: 16px/1.4 var(--font); overflow: hidden; }
body { -webkit-user-select: none; user-select: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
img.art { image-rendering: pixelated; image-rendering: crisp-edges; image-rendering: pixelated; display: block; }
kbd { font: 700 16px/1 var(--font); background: var(--ink); color: var(--amber); border: 1px solid var(--edge); border-bottom-width: 3px; border-radius: 4px; padding: 3px 7px; min-width: 24px; text-align: center; }

#app { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

/* ---------- stage: 16:9 world, HUD overlays it in landscape ---------- */
.stage { position: relative; width: min(100vw, calc(100vh * 16 / 9)); aspect-ratio: 16 / 9; background: var(--ink); overflow: hidden; }
.world { position: absolute; inset: 0; }
#canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; image-rendering: pixelated; background: var(--ink); }

/* ---------- focus: always a 2 px amber outline ---------- */
button:focus, input:focus, button:focus-visible, input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; min-width: 48px; padding: 8px 18px; font: 700 18px/1 var(--font); color: var(--white);
  background: var(--slate); border: 2px solid var(--edge); border-bottom-width: 4px; border-radius: 4px; cursor: pointer; text-align: center; }
.btn:hover { border-color: var(--cyan); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--cyan); color: var(--ink); border-color: #1fa9af; }
.btn.primary:hover { border-color: var(--white); }
.btn.danger { border-color: var(--pink); }
.btn.small { min-height: 44px; font-size: 16px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn .ico { width: 24px; height: 24px; }
.icon-btn { padding: 6px; }
.icon-btn .ico { width: 28px; height: 28px; }

.ico { width: 32px; height: 32px; flex: none; }
.ico.big { width: 40px; height: 40px; }
.ico.huge { width: 64px; height: 64px; }

/* ---------- bars ---------- */
.bar { position: relative; height: 18px; background: var(--ink); border: 2px solid var(--edge); border-radius: 3px; overflow: hidden; flex: 1; min-width: 60px; }
.bar .fill { height: 100%; width: 0; background: var(--mint); transition: width 0.12s linear; }
.bar-hull .fill.low { background: var(--pink); }
.bar-level .fill { background: var(--cyan); }
.bar-boss .fill { background: var(--pink); }
.bar-combo .fill { background: var(--amber); }
.num { font: 800 18px/1 var(--font); font-variant-numeric: tabular-nums; text-shadow: 0 2px 0 var(--ink); white-space: nowrap; }
.num.sub, .sub { color: #AAB3CC; font-weight: 600; }

/* ---------- HUD (landscape: overlays the 16:9 world; portrait: stacked around it, see the media query) ---------- */
.hud-head { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; flex-direction: column; align-items: stretch; pointer-events: none; }
.hud-head > * { pointer-events: auto; }
.hud-top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "hull mid right" "boss boss boss"; align-items: center; gap: 4px 12px; padding: 8px 12px;
  background: linear-gradient(rgba(16,20,38,0.9), rgba(16,20,38,0)); }
.hud-hull { grid-area: hull; display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 360px; }
.hud-hull .bar { height: 22px; }
.hud-mid { grid-area: mid; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 200px; }
.hud-time { display: flex; align-items: center; gap: 8px; }
.hud-time .ico { width: 24px; height: 24px; }
.hud-district { font: 800 16px/1 var(--font); letter-spacing: 2px; color: var(--amber); text-shadow: 0 2px 0 var(--ink); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.hud-boss { grid-area: boss; display: flex; align-items: center; gap: 10px; width: min(560px, 100%); justify-self: center; }
.boss-name { font: 800 16px/1 var(--font); color: var(--pink); letter-spacing: 1px; text-shadow: 0 2px 0 var(--ink); }
.hud-right { grid-area: right; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.hud-scrap { display: flex; align-items: center; gap: 6px; background: rgba(16,20,38,0.7); border: 2px solid var(--edge); padding: 4px 10px; border-radius: 4px; }
.hud-scrap .num { color: var(--amber); }

/* teaching strip: sky band under the top bar, at most 60% of the world width, never over the road */
.hud-tip { align-self: flex-start; max-width: 60%; margin: 4px 12px 0; display: flex; align-items: center; gap: 10px; background: rgba(16,20,38,0.94); border: 2px solid var(--amber); border-radius: 4px; padding: 4px 4px 4px 12px; font-size: 16px; line-height: 1.3; }
.hud-tip > span { flex: 1; }
.tip-close { min-height: 44px; min-width: 44px; padding: 4px; }

.hud-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; align-items: center; gap: 12px; padding: 18px 12px 8px;
  background: linear-gradient(rgba(16,20,38,0), rgba(16,20,38,0.92)); }
.hud-status { display: flex; align-items: center; gap: 10px; flex: 1 1 0; min-width: 0; }
.hud-level { display: flex; align-items: center; gap: 10px; flex: 0 0 210px; }
.lv-col { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lv-row { display: flex; align-items: center; gap: 6px; }
.lv-row .ico { width: 24px; height: 24px; }
.lv-row .sub { margin-left: auto; }
.hud-perks { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; flex-wrap: wrap; max-height: 44px; overflow: hidden; }
.perk-chip { position: relative; display: inline-flex; background: var(--slate); border: 2px solid var(--edge); border-radius: 4px; padding: 2px; }
.perk-chip .ico { width: 32px; height: 32px; }
.perk-chip i { position: absolute; right: -4px; bottom: -6px; font: 800 16px/1 var(--font); font-style: normal; background: var(--ink); border-radius: 3px; padding: 0 3px; color: var(--white); }
.perk-ram { border-color: var(--amber); } .perk-cannon { border-color: var(--cyan); } .perk-sustain { border-color: var(--mint); } .perk-utility { border-color: var(--white); }
.perk-more { font: 800 18px/1 var(--font); color: var(--amber); padding: 0 6px; }
.hud-stances { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; flex: 0 1 880px; }
.stance-btn { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; justify-content: stretch; text-align: left; gap: 8px; min-height: 52px; min-width: 0; padding: 5px 10px; }
.stance-btn .ico { width: 32px; height: 32px; }
.st-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.st-name { font: 800 16px/1.1 var(--font); }
.st-short { font: 600 16px/1.1 var(--font); color: #C9D0E6; }
.stance-btn.active { border-color: var(--amber); background: #34416B; box-shadow: inset 0 0 0 2px rgba(255,198,90,0.35); }
.stance-btn.cooling { opacity: 0.6; }
/* landscape: the second line on each button carries the tradeoff, the caption stays for assistive tech only */
.stance-cap { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hud-combo { position: absolute; right: 12px; bottom: 100%; display: flex; flex-direction: column; gap: 4px; align-items: stretch; width: 200px; margin-bottom: -4px; }
.combo-text { font: 900 22px/1 var(--font); color: var(--amber); text-align: right; text-shadow: 0 2px 0 var(--ink), 0 0 12px rgba(255,198,90,0.5); }
.hud-combo .bar { height: 10px; }

/* banners and toasts: only ever in the top 35% of the world, so the player (83%) and lane warnings stay clear */
.hud-float { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.hud-float > * { pointer-events: none; }
.banner { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); text-align: center; opacity: 0; font: 900 clamp(22px, 4.6vmin, 54px)/1.05 var(--font); letter-spacing: 3px; color: var(--amber);
  text-shadow: 3px 3px 0 var(--ink), 0 0 18px rgba(255,198,90,0.45); white-space: nowrap; z-index: 2; }
.banner .b-sub { font-size: 18px; letter-spacing: 1px; color: var(--white); margin-top: 4px; text-shadow: 0 2px 0 var(--ink); }
.banner.boss { color: var(--pink); text-shadow: 3px 3px 0 var(--ink), 0 0 18px rgba(255,67,133,0.5); }
.banner.show { animation: pop 0.8s ease-out forwards; }
@keyframes pop { 0% { opacity: 0; transform: translateX(-50%) scale(0.6); } 14% { opacity: 1; transform: translateX(-50%) scale(1.1); } 28% { transform: translateX(-50%) scale(1); } 82% { opacity: 1; } 100% { opacity: 0; } }
.banner.deadline { top: 24%; opacity: 1; z-index: 1; color: var(--pink); font-size: clamp(18px, 3.4vmin, 36px); animation: blink 0.9s steps(2) infinite; background: rgba(16,20,38,0.78); border: 3px solid var(--pink); padding: 4px 16px; }
@keyframes blink { 50% { opacity: 0.6; } }
.toast { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); background: rgba(16,20,38,0.9); border: 2px solid var(--amber); border-radius: 4px; padding: 3px 12px; font: 700 16px/1.2 var(--font); opacity: 0; transition: opacity 0.2s; white-space: nowrap; }
.toast.show { opacity: 1; }

/* ---------- debug (only built with ?debug=1) ---------- */
.debug-overlay { position: fixed; left: 6px; bottom: 6px; z-index: 50; font: 12px/1.2 monospace; background: rgba(0,0,0,0.65); color: #9fffb0; padding: 3px 6px; border-radius: 3px; pointer-events: none; }
.debug-panel { position: fixed; z-index: 60; top: 8px; right: 8px; width: min(520px, calc(100vw - 16px)); max-height: calc(100vh - 16px); display: flex; flex-direction: column; background: rgba(0,0,0,0.9); color: #cfffd8; border: 2px solid #3d8a52; border-radius: 4px; font: 12px/1.35 monospace; user-select: text; -webkit-user-select: text; }
.debug-panel header { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid #3d8a52; font-weight: 700; }
.debug-panel header span { flex: 1; }
.debug-panel .dbg-body { overflow: auto; padding: 6px 8px; min-height: 60px; scrollbar-color: #3d8a52 #000; }
.debug-panel button { font: 12px monospace; padding: 4px 10px; min-height: 28px; background: #12301c; color: #cfffd8; border: 1px solid #3d8a52; border-radius: 3px; cursor: pointer; }
.debug-panel table { border-collapse: collapse; width: 100%; }
.debug-panel td, .debug-panel th { padding: 1px 6px; text-align: left; white-space: nowrap; border-bottom: 1px solid #1b3a25; }
.debug-panel .prot { color: #ffd93d; }
.debug-panel pre { margin: 0; white-space: pre-wrap; word-break: break-all; }

/* ---------- screens ---------- */
#screens { position: fixed; inset: 0; z-index: 10; }
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; overflow: hidden; }
.screen-title { background: linear-gradient(rgba(16,20,38,0.2), rgba(16,20,38,0.82)); overflow-y: auto; }
.screen-loadout { background: var(--ink); }
.screen-perk, .screen-event { background: rgba(16,20,38,0.7); }
.screen-pause { background: rgba(16,20,38,0.78); }
.screen-settings { background: rgba(16,20,38,0.9); }
.screen-defeat { background: rgba(16,20,38,0.86); }
.screen-victory { background: #1B2540; }
.screen-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.screen > * { position: relative; }
.screen > .screen-bg { position: absolute; }
.screen-victory .screen-bg { opacity: 0.85; }

/* shared scroll panel: header / .panel-body / .panel-actions. Only the body scrolls; the actions are always visible. */
.panel { display: flex; flex-direction: column; background: rgba(16,20,38,0.95); border: 2px solid var(--cyan); border-radius: 6px; box-shadow: 0 0 0 3px var(--ink), 0 0 28px rgba(53,230,237,0.25); width: 100%; max-width: 980px; max-height: 100%; margin: auto; overflow: hidden; }
.panel-head { flex: none; padding: 16px 24px 6px; }
.panel-main { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 24px 14px; scrollbar-width: auto; scrollbar-color: var(--cyan) var(--slate);
  --ft: 0px; --fb: 0px; -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--ft), #000 calc(100% - var(--fb)), transparent 100%); mask-image: linear-gradient(to bottom, transparent 0, #000 var(--ft), #000 calc(100% - var(--fb)), transparent 100%); }
.panel-body.more-above { --ft: 30px; }
.panel-body.more-below { --fb: 30px; }
.panel-body::-webkit-scrollbar { width: 14px; }
.panel-body::-webkit-scrollbar-track { background: var(--slate); border-left: 2px solid var(--ink); }
.panel-body::-webkit-scrollbar-thumb { background: var(--cyan); border: 3px solid var(--slate); border-radius: 8px; min-height: 40px; }
.panel-body:focus-visible { outline: 2px solid var(--amber); outline-offset: -4px; }
.scroll-cue { position: absolute; left: 50%; transform: translateX(-50%); z-index: 2; display: none; align-items: center; gap: 6px; min-height: 28px; padding: 3px 12px; font: 800 16px/1 var(--font); color: var(--ink); background: var(--amber); border: 2px solid var(--ink); border-radius: 999px; cursor: pointer; box-shadow: 0 2px 0 rgba(0,0,0,0.5); }
.cue-top { top: 8px; } .cue-bottom { bottom: 8px; }
.panel-main.more-above .cue-top, .panel-main.more-below .cue-bottom { display: inline-flex; }
.panel-actions { flex: none; position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; padding: 12px 24px 16px; border-top: 2px solid var(--edge); background: #0E1224; }
.panel-actions .hint-text { margin-right: auto; color: #C9D0E6; font-weight: 600; }
.panel h2 { margin: 0 0 6px; font: 900 clamp(24px, 4vmin, 40px)/1.1 var(--font); letter-spacing: 1px; display: flex; align-items: center; gap: 10px; }
.panel h3 { margin: 16px 0 8px; font: 800 18px/1.2 var(--font); color: var(--cyan); letter-spacing: 1px; text-transform: uppercase; }
.panel-body > h3:first-child { margin-top: 4px; }
.eyebrow { font: 800 16px/1 var(--font); letter-spacing: 3px; color: var(--pink); text-transform: uppercase; margin-bottom: 6px; }
.lead { margin: 0 0 10px; font-size: 18px; color: var(--white); }
.warn-line { color: var(--amber); font-weight: 700; margin: 6px 0 0; }

/* title */
.title-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 8px; margin: auto; }
.logo-box { width: min(720px, 92vw); }
.logo-box .logo { width: 100%; height: auto; }
/* opaque ink backplate so the tagline reads against sky_sunset */
.tagline { margin: 0; font-size: 18px; color: var(--white); background: #101426; border: 2px solid var(--slate); padding: 8px 10px; max-width: min(92vw, 620px); }
.menu { display: flex; flex-direction: column; gap: 10px; width: min(300px, 86vw); margin-top: 6px; }
.menu .btn { width: 100%; font-size: 20px; min-height: 52px; justify-content: flex-start; padding-left: 20px; }
.progress { width: min(300px, 86vw); height: 10px; background: var(--ink); border: 2px solid var(--edge); border-radius: 3px; overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--cyan); transition: width 0.1s linear; }
.ready .progress { opacity: 0.35; }
.load-status, .title-best { color: #C9D0E6; font-weight: 600; text-shadow: 0 2px 0 var(--ink); }
.title-best { color: var(--amber); }
.hint { margin: 4px 0 0; color: #AAB3CC; font-size: 16px; max-width: 560px; }

/* loadout */
.loadout-panel { background: rgba(16,20,38,0.88); }
.loadout-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.loadout-grid .cards { grid-template-columns: 1fr; }
.card { position: relative; display: flex; flex-direction: column; gap: 8px; text-align: left; font: 16px/1.35 var(--font); color: var(--white); background: var(--slate); border: 3px solid var(--edge); border-radius: 6px; padding: 16px; cursor: pointer; min-height: 44px; }
.card:hover, .card:focus { border-color: var(--cyan); background: #2D3A5E; }
.card.selected, .card[aria-pressed="true"] { border-color: var(--amber); box-shadow: inset 0 0 0 2px rgba(255,198,90,0.35); }
.card .card-title { font: 900 22px/1.15 var(--font); }
.card .card-text { color: #D4D9EA; }
.card kbd, .card .card-key { position: absolute; top: 10px; right: 10px; }
.loadout-card { flex-direction: row; align-items: center; gap: 14px; }
.loadout-card kbd { top: 8px; }
.perk-card { padding-top: 40px; }
.perk-card.perk-ram { border-color: var(--amber); } .perk-card.perk-cannon { border-color: var(--cyan); } .perk-card.perk-sustain { border-color: var(--mint); } .perk-card.perk-utility { border-color: var(--white); }
.perk-card:hover, .perk-card:focus { filter: brightness(1.18); }
.rank-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #C9D0E6; font-weight: 700; }
.pips { display: inline-flex; gap: 4px; }
.pip { width: 14px; height: 14px; border: 2px solid var(--white); border-radius: 2px; background: transparent; }
.pip.on { background: var(--amber); border-color: var(--amber); }
.garage-preview { position: relative; width: 100%; max-width: 400px; aspect-ratio: 320 / 200; margin: 0 auto; background: rgba(0,0,0,0.25); border: 2px solid var(--edge); border-radius: 4px; }
.garage-car { position: absolute; inset: 0; width: 100%; height: 100%; }
.stat-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.stat-list dt { color: #AAB3CC; font-weight: 600; }
.stat-list dd { margin: 0; font-weight: 800; text-align: right; }

/* choice panels */
.choice-panel { max-width: 1040px; }
.event-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.event-head .portrait { width: 120px; height: 120px; border: 2px solid var(--edge); border-radius: 4px; background: var(--slate); flex: none; }
.event-head .event-prop { width: 160px; height: auto; flex: none; opacity: 0.9; }
.event-title { flex: 1; min-width: 0; }
.event-status { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-weight: 800; flex-wrap: wrap; }
.event-status .ico { width: 24px; height: 24px; margin-left: 10px; }
.event-card .card-title { font-size: 20px; }
.event-card.disabled { opacity: 0.55; cursor: not-allowed; background-image: repeating-linear-gradient(135deg, transparent 0 10px, rgba(255,255,255,0.04) 10px 20px); }
.reason { display: flex; align-items: center; gap: 6px; color: var(--pink); font-weight: 800; }
.reason .ico { width: 24px; height: 24px; }

/* pause */
.pause-panel { max-width: 760px; }
.confirm-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; flex: 1 1 100%; padding: 8px 10px; border: 2px solid var(--pink); border-radius: 4px; }
.confirm-text { flex: 1 1 auto; font-weight: 700; }
.build-list, .chips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.build-perk { display: flex; gap: 10px; align-items: center; padding: 6px 8px; background: var(--slate); border: 2px solid var(--edge); border-radius: 4px; }
.build-perk .ico { width: 40px; height: 40px; }

/* settings */
.settings-panel { max-width: 780px; }
.settings-list { display: flex; flex-direction: column; gap: 10px; }
.setting-row { display: grid; grid-template-columns: 170px 1fr 56px; align-items: center; gap: 14px; min-height: 48px; }
.setting-row .name { font-weight: 800; }
.setting-row .val { text-align: right; font-weight: 800; color: var(--amber); }
input[type="range"] { width: 100%; height: 32px; accent-color: var(--cyan); cursor: pointer; }
.switch { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; text-align: left; width: 100%; min-height: 56px; padding: 8px 14px; background: var(--slate); color: var(--white); border: 2px solid var(--edge); border-radius: 4px; cursor: pointer; font: 16px/1.3 var(--font); }
.switch .name { font-weight: 800; }
.switch .sub { grid-column: 1; }
.switch .state { grid-row: 1 / span 2; grid-column: 2; min-width: 56px; text-align: center; font-weight: 900; padding: 6px 10px; border-radius: 4px; background: var(--ink); border: 2px solid var(--edge); }
.switch.on .state { background: var(--mint); color: var(--ink); border-color: var(--mint); }
.help { width: 100%; border-collapse: collapse; font-size: 16px; }
.help th, .help td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--edge); vertical-align: top; }
.help th { color: var(--amber); white-space: nowrap; }

/* results */
.result-panel { max-width: 760px; }
.result-panel.win { border-color: var(--amber); }
.result-panel.lose { border-color: var(--pink); }
.cause { font: 800 22px/1.2 var(--font); margin: 0 0 14px; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--slate); border: 2px solid var(--edge); border-radius: 4px; }
.stat strong { font-size: 20px; }
.score-table { width: 100%; border-collapse: collapse; }
.score-table th { text-align: left; font-weight: 600; color: #C9D0E6; padding: 4px 0; }
.score-table td { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-table .total th, .score-table .total td { border-top: 2px solid var(--edge); padding-top: 8px; font-size: 24px; color: var(--amber); }
.best-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-weight: 700; }
.new-best { background: var(--amber); color: var(--ink); font-weight: 900; padding: 2px 10px; border-radius: 3px; }
.chips { flex-direction: row; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; background: var(--slate); border: 2px solid var(--edge); border-radius: 4px; font-weight: 700; }
.chip .ico { width: 28px; height: 28px; }

/* ---------- high contrast ---------- */
body.hc .panel, body.hc .hud-scrap, body.hc .hud-tip, body.hc .toast, body.hc .panel-actions, body.hc .tagline { background: #000; border-color: #fff; }
body.hc .hud-top { background: linear-gradient(#000, rgba(0,0,0,0.0)); }
body.hc .hud-top, body.hc .hud-bottom { background-color: rgba(0,0,0,0.88); background-image: none; }
body.hc .btn, body.hc .card, body.hc .switch, body.hc .stat { border-color: #fff; background: #0A0F24; }
body.hc .btn.primary { background: #35E6ED; }
body.hc .bar { border-color: #fff; }

/* ---------- portrait: top HUD, untouched 16:9 world, then level / stances / caption / combo / tip ---------- */
@media (max-aspect-ratio: 1/1) {
  .stage { width: 100vw; height: 100%; aspect-ratio: auto; display: flex; flex-direction: column; justify-content: flex-start; background: var(--ink); }
  .world { position: relative; inset: auto; width: 100%; aspect-ratio: 16 / 9; flex: none; order: 2; }
  .hud-head { display: contents; }
  .hud-top { order: 1; position: relative; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "hull right" "mid mid" "boss boss"; background: var(--ink); padding: 8px 10px 6px; gap: 6px 10px; flex: none; }
  .hud-hull { max-width: none; }
  .hud-mid { flex-direction: row; justify-content: space-between; width: 100%; min-width: 0; gap: 10px; }
  .hud-boss { width: 100%; }
  .hud-district { letter-spacing: 0; }
  .hud-bottom { order: 3; position: relative; flex-direction: column; align-items: stretch; background: var(--ink); padding: 8px 10px 4px; gap: 8px; flex: none; justify-content: flex-start; }
  .hud-status { flex: none; }
  .hud-level { flex: 0 0 46%; }
  .hud-perks { justify-content: flex-end; }
  /* three equal columns, icon + name + key */
  .hud-stances { flex: none; width: 100%; }
  .stance-btn { grid-template-columns: auto 1fr; grid-template-areas: "ico key" "txt txt"; justify-items: start; gap: 2px 6px; min-height: 60px; padding: 5px 8px; text-align: left; }
  .stance-btn .ico { grid-area: ico; width: 28px; height: 28px; }
  .stance-btn kbd { grid-area: key; justify-self: end; }
  .st-text { grid-area: txt; }
  .st-short { display: none; }
  .stance-cap { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; margin: 0; padding: 6px 10px; font: 700 16px/1.25 var(--font); color: var(--white); background: var(--slate); border: 2px solid var(--amber); border-radius: 4px; min-height: 44px; }
  .hud-combo { position: static; width: 100%; margin: 0; flex-direction: row; align-items: center; }
  .combo-text { font-size: 18px; text-align: left; white-space: nowrap; }
  .hud-tip { order: 4; align-self: stretch; max-width: none; margin: 4px 10px 8px; }
  /* banners and toasts: top 35% of a 16:9 world that is only 202 to 219 px tall */
  .banner { top: 15.4%; font-size: clamp(18px, 5.2vw, 40px); letter-spacing: 2px; }
  .banner .b-sub { font-size: 16px; margin-top: 0; }
  .banner.deadline { top: 15.4%; font-size: 16px; padding: 3px 10px; border-width: 2px; }
  .toast { top: 1.5%; }
  .loadout-grid { grid-template-columns: 1fr; }
  .cards, .cards-3, .cards-2 { grid-template-columns: 1fr; }
  .perk-card { flex-direction: column; padding-top: 16px; }
  .event-head .event-prop { display: none; }
  .event-head .portrait { width: 80px; height: 80px; }
  .setting-row { grid-template-columns: 1fr 56px; }
  .setting-row input { grid-column: 1 / span 2; grid-row: 2; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-head { padding: 12px 14px 4px; }
  .panel-body { padding: 4px 14px 12px; }
  .panel-actions { padding: 10px 14px 12px; gap: 8px; }
  .panel-actions .btn { flex: 1 1 140px; }
  .help th { white-space: normal; }
}
/* landscape, short screens (phones on their side) */
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  .hud-top { padding: 4px 8px; gap: 2px 8px; }
  .hud-bottom { padding: 10px 8px 4px; gap: 8px; }
  .stance-btn { min-height: 46px; padding: 3px 8px; }
  .banner { top: 20%; font-size: 20px; }
  .banner .b-sub { font-size: 16px; margin-top: 0; }
  .banner.deadline { top: 20%; font-size: 16px; }
  .toast { top: 12%; }
  .panel-head { padding: 10px 16px 4px; }
  .panel-body { padding: 4px 16px 10px; }
  .panel-actions { padding: 8px 16px 10px; }
  .lead { margin-bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) { .banner.show { animation-duration: 0.01s; animation-fill-mode: forwards; } .banner.deadline { animation: none; } }
