:root {
  --bg: #02040d;
  --panel: rgba(7, 13, 28, 0.74);
  --panel-strong: rgba(7, 13, 28, 0.92);
  --line: rgba(112, 225, 255, 0.22);
  --cyan: #67eaff;
  --cyan-bright: #b8f7ff;
  --magenta: #ff4bd8;
  --orange: #ffad52;
  --danger: #ff526d;
  --good: #70ffb2;
  --text: #ecfaff;
  --muted: #8ca3ba;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.56);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
body { user-select: none; }
button, select, input { font: inherit; }
button { color: inherit; }

#app { position: relative; width: 100%; height: 100%; isolation: isolate; background: radial-gradient(circle at 50% 45%, #0b1740 0%, #030612 45%, #010207 100%); }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#scanlines { position: absolute; inset: 0; pointer-events: none; z-index: 3; opacity: .1; background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(80, 205, 255, .17) 4px); mix-blend-mode: screen; }
#vignette { position: absolute; inset: 0; pointer-events: none; z-index: 4; background: radial-gradient(ellipse at center, transparent 35%, rgba(0, 2, 10, .28) 70%, rgba(0, 1, 5, .75) 100%); }

.screen { position: absolute; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: clamp(18px, 4vw, 54px); background: linear-gradient(135deg, rgba(1, 4, 14, .16), rgba(2, 6, 18, .62)); backdrop-filter: blur(3px); }
.screen-visible { display: flex; }
.hidden { display: none !important; }

.glass-panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(12, 23, 48, .86), rgba(4, 9, 24, .74)); box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.07); backdrop-filter: blur(18px) saturate(135%); border-radius: 22px; }
.boot-card { min-width: 270px; padding: 38px; text-align: center; letter-spacing: .15em; }
.boot-card h1 { margin: 12px 0 0; font-size: 74px; line-height: .9; color: var(--cyan); text-shadow: 0 0 25px rgba(103,234,255,.65); }
.boot-card p { margin: 15px 0 20px; color: var(--cyan-bright); font-size: 12px; }
.boot-card small { color: var(--muted); letter-spacing: .06em; }
.boot-spinner { width: 36px; height: 36px; margin: auto; border-radius: 50%; border: 2px solid rgba(103,234,255,.18); border-top-color: var(--cyan); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#main-menu { align-items: stretch; justify-content: stretch; }
.hero-panel { align-self: center; width: min(710px, calc(100vw - 44px)); padding: clamp(30px, 5vw, 58px); margin-left: clamp(0px, 6vw, 90px); }
.hero-panel h1 { display: flex; gap: 5px; margin: 8px 0 0; font-size: clamp(78px, 11vw, 150px); line-height: .78; font-weight: 950; letter-spacing: -.08em; }
.hero-panel h1 span:first-child { color: var(--cyan); text-shadow: 0 0 35px rgba(103,234,255,.85); }
.hero-panel h1 span:last-child { color: var(--magenta); text-shadow: 0 0 35px rgba(255,75,216,.72); }
.hero-panel h2 { margin: 25px 0 12px; font-size: clamp(19px, 2.3vw, 34px); letter-spacing: .12em; }
.eyebrow { color: var(--cyan); font-size: 11px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.hero-copy { max-width: 610px; margin: 0 0 28px; color: #b5cce0; line-height: 1.65; }
.menu-actions { display: grid; gap: 10px; max-width: 430px; }
.menu-footer { display: flex; flex-wrap: wrap; gap: 8px 25px; margin-top: 25px; padding-top: 18px; border-top: 1px solid rgba(103,234,255,.12); color: var(--muted); font-size: 12px; }
.highscore-panel { position: absolute; right: clamp(24px, 5vw, 72px); top: 50%; transform: translateY(-50%); width: min(320px, 27vw); padding: 24px; }
.panel-title { color: var(--cyan); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
#highscore-list { margin: 16px 0 0; padding-left: 28px; color: #cde9f7; }
#highscore-list li { margin: 10px 0; padding-left: 6px; }
#highscore-list li::marker { color: var(--magenta); font-weight: 800; }
.score-line { display: flex; justify-content: space-between; gap: 15px; }
.score-line span:last-child { color: var(--cyan-bright); font-variant-numeric: tabular-nums; }

.btn { appearance: none; border: 1px solid rgba(103,234,255,.24); border-radius: 12px; background: rgba(12,31,58,.78); padding: 13px 18px; cursor: pointer; font-size: 12px; font-weight: 850; letter-spacing: .1em; transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.btn:hover, .btn:focus-visible { transform: translateY(-1px); border-color: rgba(103,234,255,.75); background: rgba(20,54,86,.88); box-shadow: 0 0 22px rgba(103,234,255,.14); outline: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { color: #04111a; border-color: transparent; background: linear-gradient(90deg, var(--cyan), #b8fff0); box-shadow: 0 0 25px rgba(103,234,255,.2); }
.btn-primary:hover, .btn-primary:focus-visible { background: linear-gradient(90deg, #9ff3ff, #d6fff7); }
.btn-danger { border-color: rgba(255,82,109,.34); color: #ffc0ca; background: rgba(88,14,34,.55); }
.btn-small { padding: 10px 13px; font-size: 10px; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: rgba(7,18,40,.72); color: var(--cyan-bright); font-size: 26px; line-height: 1; cursor: pointer; }

.modal-panel { width: min(820px, calc(100vw - 34px)); max-height: calc(100vh - 36px); overflow: auto; padding: clamp(24px, 4vw, 42px); }
.modal-panel.wide { width: min(1050px, calc(100vw - 34px)); }
.modal-panel.compact { width: min(430px, calc(100vw - 34px)); display: grid; gap: 12px; text-align: center; }
.modal-panel h2 { margin: 5px 0 0; font-size: clamp(28px, 4vw, 46px); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 26px; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 25px; }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
fieldset { min-width: 0; border: 1px solid rgba(103,234,255,.14); border-radius: 14px; padding: 18px; background: rgba(2,8,23,.42); }
legend { padding: 0 8px; color: var(--cyan); font-size: 11px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
label { display: grid; gap: 7px; margin: 14px 0; color: #bed4e3; font-size: 12px; }
select, input[type="range"] { width: 100%; }
select { appearance: none; border: 1px solid rgba(103,234,255,.2); border-radius: 9px; background: #071428; color: var(--text); padding: 10px 34px 10px 11px; background-image: linear-gradient(45deg, transparent 50%, var(--cyan) 50%), linear-gradient(135deg, var(--cyan) 50%, transparent 50%); background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px; background-size: 5px 5px; background-repeat: no-repeat; }
input[type="range"] { accent-color: var(--cyan); }
output { justify-self: end; margin-top: -4px; color: var(--cyan-bright); font-variant-numeric: tabular-nums; }
.toggle-row { grid-template-columns: auto 1fr; align-items: center; gap: 10px; cursor: pointer; }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--cyan); }
.controller-map { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 18px; }
.controller-slot { display: flex; flex-direction: column; gap: 3px; padding: 11px; border: 1px solid rgba(103,234,255,.13); border-radius: 10px; background: rgba(2,8,23,.4); font-size: 11px; color: var(--muted); }
.controller-slot b { color: var(--cyan); }
.controller-slot.connected { border-color: rgba(112,255,178,.38); box-shadow: inset 0 0 18px rgba(112,255,178,.04); }
.controller-slot.connected b { color: var(--good); }
.help-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.help-grid article { border: 1px solid rgba(103,234,255,.13); border-radius: 14px; padding: 18px; background: rgba(2,8,23,.42); }
.help-grid h3 { margin: 0 0 14px; color: var(--cyan-bright); }
.help-grid p { color: #aec4d6; font-size: 13px; line-height: 1.55; }
.key-row { display: flex; align-items: center; gap: 8px; margin: 9px 0; color: #b9ccdc; font-size: 12px; }
kbd { display: inline-grid; place-items: center; min-width: 32px; height: 27px; padding: 0 8px; border: 1px solid rgba(103,234,255,.28); border-bottom-width: 3px; border-radius: 6px; background: rgba(10,29,54,.9); color: var(--cyan-bright); font: 800 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }

.hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#hud-top-center { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); text-align: center; text-shadow: 0 2px 10px #000; }
#wave-label { color: var(--cyan-bright); font-size: 16px; font-weight: 950; letter-spacing: .12em; }
#objective-label { margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: .08em; }
#player-huds { position: absolute; inset: 0; }
.player-hud { position: absolute; width: min(280px, 32vw); padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--player-color) 40%, transparent); border-radius: 12px; background: linear-gradient(145deg, rgba(3,8,20,.78), rgba(4,13,30,.56)); box-shadow: 0 0 24px color-mix(in srgb, var(--player-color) 10%, transparent); backdrop-filter: blur(8px); }
.player-hud[data-slot="0"] { left: 14px; top: 14px; }
.player-hud[data-slot="1"] { right: 14px; top: 14px; }
.player-hud[data-slot="2"] { left: 14px; bottom: 14px; }
.player-hud[data-slot="3"] { right: 14px; bottom: 14px; }
.player-hud-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.player-name { color: var(--player-color); font-size: 11px; font-weight: 900; letter-spacing: .1em; }
.player-score { font-size: 17px; font-weight: 900; font-variant-numeric: tabular-nums; }
.player-sub { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; color: var(--muted); font-size: 9px; letter-spacing: .05em; }
.meter { height: 5px; margin-top: 8px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.07); }
.meter > i { display: block; width: 100%; height: 100%; background: var(--player-color); box-shadow: 0 0 9px var(--player-color); transition: width .08s linear; }
.meter.shield > i { background: #8af7ff; }
.player-weapon { margin-top: 6px; color: #d9f8ff; font-size: 10px; font-weight: 750; }
.debug-chip { position: absolute; right: 12px; bottom: 12px; color: rgba(174,225,241,.55); font: 10px/1.2 ui-monospace, monospace; }

.wave-banner { position: absolute; z-index: 15; left: 50%; top: 50%; width: min(640px, 85vw); transform: translate(-50%, -50%); text-align: center; pointer-events: none; text-shadow: 0 0 25px rgba(103,234,255,.75); animation: waveIn 2.4s ease both; }
.wave-banner span, .wave-banner em { display: block; color: var(--muted); font-size: 11px; font-style: normal; font-weight: 800; letter-spacing: .3em; }
.wave-banner strong { display: block; margin: 7px 0; color: var(--cyan-bright); font-size: clamp(44px, 9vw, 96px); line-height: .95; letter-spacing: .04em; }
@keyframes waveIn { 0% { opacity: 0; transform: translate(-50%, -45%) scale(.86); } 15%, 72% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -55%) scale(1.06); } }

#toast-layer { position: absolute; z-index: 30; left: 50%; bottom: 7vh; transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 260px; max-width: 70vw; padding: 11px 16px; border: 1px solid rgba(103,234,255,.3); border-radius: 10px; background: rgba(3,11,28,.9); box-shadow: 0 10px 35px rgba(0,0,0,.42); color: #dffaff; text-align: center; font-size: 11px; font-weight: 750; letter-spacing: .05em; animation: toastLife 2.8s ease both; }
.toast.good { border-color: rgba(112,255,178,.42); color: #b9ffd9; }
.toast.danger { border-color: rgba(255,82,109,.45); color: #ffd0d8; }
@keyframes toastLife { 0% { opacity: 0; transform: translateY(12px); } 10%, 75% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-8px); } }

#final-scoreboard { display: grid; gap: 8px; margin: 24px 0; }
.final-row { display: grid; grid-template-columns: 60px 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid rgba(103,234,255,.13); border-radius: 10px; background: rgba(2,8,23,.46); }
.final-row b { color: var(--pcolor); }
.final-row span { color: var(--muted); font-size: 12px; }
.final-row strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.fatal-error { position: absolute; z-index: 100; inset: 20px; display: grid; place-items: center; padding: 30px; border: 1px solid rgba(255,82,109,.55); border-radius: 16px; background: rgba(18,2,9,.95); color: #ffd3dc; white-space: pre-wrap; text-align: center; }

/* ---------------------------------------------------------------- 3.1 classic vector update */
.attract-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.attract-tab { flex: 1; min-width: 0; padding: 6px 4px; border: 1px solid rgba(103,234,255,.18); border-radius: 8px; background: transparent; color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .12em; cursor: pointer; }
.attract-tab.active, .attract-tab:hover, .attract-tab:focus-visible { color: var(--cyan-bright); border-color: rgba(103,234,255,.6); outline: none; }
.attract-page { display: none; min-height: 318px; }
.attract-page.active { display: block; animation: pageIn .45s ease both; }
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }
.hs-table { list-style: none; margin: 12px 0 0; padding: 0; font: 600 13px/1.25 ui-monospace, "Cascadia Mono", SFMono-Regular, Consolas, monospace; color: #e8fbff; }
.hs-table li { display: grid; grid-template-columns: 2.1em minmax(0, 1fr) auto 4.6em; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid rgba(103,234,255,.06); }
.hs-rank { color: var(--magenta); }
.hs-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; letter-spacing: .14em; }
.hs-score { color: var(--cyan-bright); font-variant-numeric: tabular-nums; text-align: right; text-shadow: 0 0 8px rgba(103,234,255,.45); }
.hs-meta { color: var(--muted); font-size: 10px; text-align: right; }
.hs-table.placeholder { opacity: .6; }
.hs-table li.fresh { color: #fff; background: linear-gradient(90deg, rgba(103,234,255,.16), transparent); animation: freshBlink 1.1s steps(2, end) 4; }
@keyframes freshBlink { 50% { opacity: .45; } }
.score-table { list-style: none; margin: 12px 0 0; padding: 0; }
.score-table li { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; padding: 3px 0; color: #cde9f7; font-size: 12px; }
.score-table svg { width: 34px; height: 34px; fill: none; stroke: #eefcff; stroke-width: 1.6; stroke-linejoin: round; filter: drop-shadow(0 0 3px rgba(190,240,255,.8)); }
.score-table b { color: var(--cyan-bright); font: 800 14px ui-monospace, Consolas, monospace; text-shadow: 0 0 8px rgba(103,234,255,.5); }
.score-footnote { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.mini-controls { display: grid; gap: 7px; margin-top: 12px; }
.mini-controls div { display: flex; align-items: center; gap: 6px; color: #b9ccdc; font-size: 12px; }
.mini-controls span { margin-left: 4px; }

.btn.pad-focus, select.pad-focus, input.pad-focus, .attract-tab.pad-focus { outline: 2px solid var(--cyan); outline-offset: 3px; box-shadow: 0 0 18px rgba(103,234,255,.35); }
#reset-highscores.armed { color: #fff; border-color: var(--danger); background: rgba(150,20,48,.75); }

.pause-audio { display: grid; gap: 8px; margin-top: 6px; padding-top: 12px; border-top: 1px solid rgba(103,234,255,.12); text-align: left; }
.pause-audio label { grid-template-columns: 6.5em 1fr; align-items: center; margin: 0; }
.pause-audio .btn { justify-self: center; }

.hs-entry { margin: 4px 0 18px; padding: 16px; border: 1px solid color-mix(in srgb, var(--pcolor, var(--cyan)) 55%, transparent); border-radius: 14px; background: rgba(2,8,23,.55); text-align: center; }
.hs-entry-title { color: var(--pcolor, var(--cyan)); font-size: 12px; font-weight: 900; letter-spacing: .16em; }
.hs-entry-letters { display: flex; justify-content: center; gap: 14px; margin: 14px 0 8px; font: 800 clamp(40px, 9vw, 62px)/1 ui-monospace, "Cascadia Mono", Consolas, monospace; color: #f2fdff; text-shadow: 0 0 14px rgba(160,240,255,.75); }
.entry-letter { min-width: 1.05em; padding-bottom: 6px; border-bottom: 3px solid rgba(255,255,255,.18); }
.entry-letter.active { color: var(--pcolor, var(--cyan)); border-bottom-color: currentColor; animation: freshBlink .9s steps(2, end) infinite; }
.hs-entry-hint { color: var(--muted); font-size: 11px; }
.hs-entry-pad { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hs-entry-pad .btn { min-width: 48px; font-size: 14px; }
.gameover-highscores { margin: 6px 0 0; }
.gameover-highscores .hs-table { columns: 2; column-gap: 26px; }
.gameover-highscores .hs-table li { break-inside: avoid; }

.demo-overlay { position: absolute; z-index: 16; left: 50%; bottom: 13vh; transform: translateX(-50%); display: grid; justify-items: center; gap: 6px; padding: 14px 26px; cursor: pointer; text-align: center; text-shadow: 0 0 16px rgba(160,240,255,.8); }
.demo-overlay .demo-tag { color: var(--magenta); font: 800 12px ui-monospace, Consolas, monospace; letter-spacing: .5em; }
.demo-overlay strong { color: #f4feff; font: 900 clamp(22px, 4vw, 38px) ui-monospace, Consolas, monospace; letter-spacing: .14em; animation: freshBlink 1.2s steps(2, end) infinite; }
.demo-overlay em { color: var(--muted); font-size: 11px; font-style: normal; letter-spacing: .12em; }
body.demo-running .player-hud { opacity: .75; }

.life-ship { width: 10px; height: 12px; margin-right: 3px; fill: none; stroke: var(--player-color); stroke-width: 1.2; stroke-linejoin: round; vertical-align: -1px; filter: drop-shadow(0 0 2px var(--player-color)); }
.lives em { font-style: normal; color: var(--text); }
.player-hud[data-state="respawn"] { opacity: .7; }
.player-hud[data-state="out"] { opacity: .4; }

/* Vector look: thin glowing type, no glass behind the HUD. */
body.style-vector #app { background: radial-gradient(circle at 50% 45%, #050b1e 0%, #01030a 55%, #000 100%); }
body.style-vector #scanlines { opacity: .07; }
body.style-vector .player-hud { border-color: transparent; background: none; box-shadow: none; backdrop-filter: none; font-family: ui-monospace, "Cascadia Mono", SFMono-Regular, Consolas, monospace; text-shadow: 0 0 8px color-mix(in srgb, var(--player-color) 70%, transparent); }
body.style-vector .player-score { font-size: 22px; letter-spacing: .06em; color: #f4feff; }
body.style-vector .meter { height: 3px; background: rgba(255,255,255,.08); }
body.style-vector #wave-label { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; text-shadow: 0 0 10px rgba(160,240,255,.7); }
body.style-vector .wave-banner strong { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 700; color: #f2fdff; text-shadow: 0 0 18px rgba(160,240,255,.85), 0 0 2px #fff; }

/* Touch controls */
.touch-controls { position: absolute; inset: 0; z-index: 12; pointer-events: none; --tb: clamp(54px, 15vw, 80px); }
.touch-cluster { position: absolute; display: flex; align-items: flex-end; gap: 12px; }
.touch-left { left: max(14px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); }
.touch-right { right: max(14px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); }
.touch-top { right: max(14px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + var(--tb) * 1.25 + 16px); gap: 8px; }
.touch-btn { pointer-events: auto; touch-action: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; width: var(--tb); height: var(--tb); border: 1.5px solid rgba(200,245,255,.42); border-radius: 50%; background: rgba(6,16,34,.28); color: rgba(230,250,255,.85); font: 800 calc(var(--tb) * .34) ui-monospace, Consolas, monospace; text-shadow: 0 0 8px rgba(160,240,255,.8); }
.touch-btn.pressed { background: rgba(103,234,255,.28); border-color: #e8fdff; color: #fff; box-shadow: 0 0 18px rgba(103,234,255,.45); }
.touch-small { width: calc(var(--tb) * .74); height: calc(var(--tb) * .74); font-size: calc(var(--tb) * .17); }
.touch-fire { width: calc(var(--tb) * 1.25); height: calc(var(--tb) * 1.25); border-color: rgba(255,140,220,.55); }
.touch-mini { width: auto; height: calc(var(--tb) * .5); padding: 0 10px; border-radius: 10px; font-size: 10px; letter-spacing: .08em; }
body.in-game .touch-controls:not(.hidden) ~ #toast-layer { bottom: auto; top: calc(max(8px, env(safe-area-inset-top)) + 92px); }

/* ---------------------------------------------------------------- 3.2 arsenal (special weapons) */
:root { --tb: clamp(54px, 15vw, 80px); }
.arsenal-bar { position: absolute; z-index: 11; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; grid-template-columns: repeat(12, var(--as)); gap: 5px; --as: clamp(40px, 3.6vw, 56px); pointer-events: none; }
.arsenal-slot { position: relative; display: block; width: var(--as); height: calc(var(--as) * 1.06); margin: 0; padding: 0; overflow: hidden; border: 1px solid color-mix(in srgb, var(--sc) 42%, transparent); border-radius: 8px; background: rgba(2,6,16,.58); color: var(--sc); font: 700 9px/1 ui-monospace, "Cascadia Mono", SFMono-Regular, Consolas, monospace; text-shadow: 0 0 6px color-mix(in srgb, var(--sc) 80%, transparent); pointer-events: none; touch-action: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; transition: opacity .15s ease, border-color .15s ease; }
.arsenal-slot svg { position: absolute; left: 50%; top: 50%; width: 54%; height: 54%; transform: translate(-50%, -46%); fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 2.5px var(--sc)); }
.as-key { position: absolute; left: 4px; top: 3px; color: #eefcff; font-size: 9px; text-shadow: 0 0 5px rgba(160,240,255,.7); }
.as-count { position: absolute; right: 4px; top: 3px; color: #fff; font-size: 10px; font-weight: 800; font-variant-numeric: tabular-nums; }
.arsenal-slot[data-special="shield"] .as-count { display: none; }
.arsenal-slot[data-special="shield"] .as-fill { height: 3px; }
.as-name { display: none; position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 7px; letter-spacing: .06em; opacity: .85; }
.as-fill { position: absolute; left: 0; bottom: 0; width: calc(var(--fill, 0) * 100%); height: 2px; background: var(--sc); box-shadow: 0 0 6px var(--sc); transition: width .12s linear; }
/* Cooldown sweep: the dark wedge shrinks clockwise as the slot recharges. */
.arsenal-slot::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: conic-gradient(rgba(0,3,10,.74) calc(var(--cd, 0) * 1turn), transparent 0); pointer-events: none; }
.arsenal-slot.empty { color: #6d7d8c; border-color: rgba(140,163,186,.18); filter: grayscale(1); opacity: .42; text-shadow: none; }
.arsenal-slot.empty svg { filter: none; }
.arsenal-slot.active { border-color: var(--sc); box-shadow: 0 0 14px color-mix(in srgb, var(--sc) 55%, transparent), inset 0 0 12px color-mix(in srgb, var(--sc) 30%, transparent); }
.arsenal-slot.selected { outline: 1px solid #f4feff; outline-offset: 2px; }
.arsenal-slot.flash { border-color: var(--sc); animation: arsenalFlash .38s ease-out; }
.arsenal-slot.deny { animation: arsenalDeny .3s linear; border-color: var(--danger); }
.arsenal-slot.pressed { background: color-mix(in srgb, var(--sc) 30%, rgba(2,6,16,.6)); }
@keyframes arsenalFlash { 0% { background: color-mix(in srgb, var(--sc) 75%, transparent); box-shadow: 0 0 26px var(--sc); transform: scale(1.14); } 100% { background: rgba(2,6,16,.58); box-shadow: none; transform: scale(1); } }
@keyframes arsenalDeny { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
body.in-game.arsenal-on #toast-layer { bottom: calc(7vh + 64px); }
@media (min-width: 1280px) and (min-height: 700px) {
  .arsenal-slot svg { width: 46%; height: 46%; transform: translate(-50%, -62%); }
  .as-name { display: block; }
}

/* Compact cells inside co-op player HUDs. */
.mini-arsenal { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; margin-top: 6px; }
.mini-arsenal .arsenal-slot { width: auto; height: 20px; border-radius: 4px; }
.mini-arsenal .arsenal-slot svg { width: 13px; height: 13px; top: 2px; transform: translateX(-50%); }
.mini-arsenal .as-count { left: 0; right: 0; top: auto; bottom: 1px; text-align: center; font-size: 7px; }
.mini-arsenal .arsenal-slot[data-special="shield"] .as-count { display: none; }

/* Touch: the bar doubles as the special-weapon pad. */
body.touch-ui .arsenal-slot { pointer-events: auto; }
/* Key labels mean nothing on a phone: show the weapon name instead. */
body.touch-ui .as-key { display: none; }
body.touch-ui .as-name { display: block; bottom: 3px; }
body.touch-ui .arsenal-slot svg { width: 48%; height: 48%; transform: translate(-50%, -62%); }
body.touch-ui.arsenal-collapsed .arsenal-bar { display: none; }
#touch-arsenal-toggle.active { border-color: rgba(255,180,90,.7); color: #ffe0b8; }
@media (max-width: 640px) {
  .arsenal-bar { grid-template-columns: repeat(6, var(--as)); --as: 40px; gap: 4px; }
}
@media (orientation: portrait) {
  body.touch-ui .arsenal-bar { grid-template-columns: repeat(6, var(--as)); --as: clamp(40px, 11vw, 54px); bottom: calc(max(18px, env(safe-area-inset-bottom)) + var(--tb) * 1.75 + 30px); }
}
@media (orientation: landscape) {
  body.touch-ui .arsenal-bar { --as: clamp(32px, 4.4vw, 46px); gap: 4px; bottom: calc(max(18px, env(safe-area-inset-bottom)) + var(--tb) * 1.75 + 30px); }
}
@media (orientation: landscape) and (max-height: 520px) {
  body.touch-ui .arsenal-bar { --as: 33px; gap: 3px; bottom: max(10px, env(safe-area-inset-bottom)); }
}
@media (orientation: landscape) and (max-height: 520px) and (max-width: 760px) {
  body.touch-ui .arsenal-bar { grid-template-columns: repeat(6, var(--as)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + var(--tb) * 1.75 + 24px); }
}

@media (max-width: 1050px) {
  #main-menu { flex-direction: column; align-items: center; justify-content: flex-start; gap: 18px; overflow-y: auto; }
  .hero-panel { margin: 0 auto; flex: none; }
  .highscore-panel { position: static; transform: none; width: min(710px, calc(100vw - 44px)); flex: none; }
  .attract-page { min-height: 0; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid fieldset:last-child { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .screen { padding: max(12px, env(safe-area-inset-top)) 12px 12px; }
  .settings-grid, .help-grid { grid-template-columns: 1fr; }
  .settings-grid fieldset:last-child { grid-column: auto; }
  .controller-map { grid-template-columns: 1fr 1fr; }
  .hero-panel { padding: 24px; width: calc(100vw - 24px); }
  .highscore-panel { width: calc(100vw - 24px); padding: 18px; }
  .hero-panel h2 { margin-top: 16px; }
  .hero-copy { margin-bottom: 18px; font-size: 14px; }
  .player-hud { width: 40vw; padding: 7px 9px; }
  .player-hud[data-slot="0"] { left: 8px; top: max(8px, env(safe-area-inset-top)); }
  .player-hud[data-slot="1"] { right: 8px; top: max(8px, env(safe-area-inset-top)); }
  .player-score, body.style-vector .player-score { font-size: 15px; }
  .player-weapon { font-size: 9px; }
  #hud-top-center { top: max(8px, env(safe-area-inset-top)); }
  #wave-label { font-size: 12px; }
  #objective-label { display: none; }
  .gameover-highscores .hs-table { columns: 1; }
  .modal-actions { justify-content: stretch; }
  .modal-actions .btn { flex: 1 1 auto; }
  .demo-overlay { bottom: 18vh; }
}
@media (max-height: 520px) and (orientation: landscape) {
  :root, .touch-controls { --tb: clamp(48px, 12vh, 66px); }
  .attract-page { min-height: 0; }
  #main-menu { overflow-y: auto; }
}
@media (pointer: coarse) {
  .btn { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
  /* Keep messages readable instead of jumping to their faded end frame. */
  .toast, .wave-banner, .attract-page.active, .entry-letter.active, .demo-overlay strong, .hs-table li.fresh, .arsenal-slot.flash, .arsenal-slot.deny { animation: none !important; }
}
