:root {
  --font: "Arial Black", "Segoe UI Black", "Helvetica Neue", Arial, sans-serif;
  --navy: #262c3d; --navy2: #1b2030; --line: #d9dde6; --blue: #2f8be8; --blue2: #1a62c2;
  --green: #6ed12b; --green2: #3c9a12; --pink: #e8456f; --pink2: #b4234f; --gold: #ffc94a;
  --common: #c8ccd4; --rare: #3d8bff; --epic: #b05cff;
  font-family: var(--font); color: #fff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2b2a28; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.stroke, .wave-title, .kills b, .banner, .title, .btn, .tip, h2, .hp-label b, .ammo, .num {
  paint-order: stroke fill; -webkit-text-stroke: 4px #141821; text-shadow: 0 3px 0 #141821;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 55%, transparent 55%, rgba(10,8,6,.55) 100%); }
.hurt { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at 50% 70%, transparent 40%, rgba(220,30,20,.9) 100%); transition: opacity .25s; }
body.danger .vignette { animation: danger 1.1s ease-in-out infinite; background: radial-gradient(ellipse at 50% 55%, transparent 40%, rgba(170,20,14,.6) 100%); box-shadow: inset 0 0 90px 24px rgba(210,24,14,.7); }
@keyframes danger { 50% { opacity: .55; } }
.bump { animation: bump .22s ease-out; }
@keyframes bump { 40% { transform: scale(1.3); } }
.combo { margin: 6px 0 0 6px; font-size: 26px; color: #ffcf3a; paint-order: stroke fill; -webkit-text-stroke: 4px #141821; text-shadow: 0 3px 0 #141821; transform-origin: left center; }
.combo::after { content: ' COMBO'; font-size: 12px; color: #fff; }
.hp.shake { animation: hpshake .28s linear; }
@keyframes hpshake { 20% { transform: translate(-4px, 1px); } 40% { transform: translate(4px, -1px); } 60% { transform: translate(-3px, 0); } 80% { transform: translate(2px, 1px); } }
.ability.ready { animation: ready 1.2s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 0 0 3px #ffc94a, 0 0 22px 6px rgba(255,201,74,.75), 0 4px 0 #141821; } }

/* ---------- world-anchored UI */
#world-ui, #labels, #bars, #numbers { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.ammo { position: absolute; transform: translate(-50%, 0); font-size: 11px; -webkit-text-stroke-width: 3px; white-space: nowrap; text-align: center; }
.ammo i { display: block; width: 46px; height: 5px; margin: 0 auto 3px; background: #1b1d24; border: 1px solid #141821; border-radius: 3px; overflow: hidden; }
.ammo i::after { content: ""; display: block; height: 100%; width: var(--fill, 100%); background: linear-gradient(#ffb24a, #f07a14); }
.ammo.reload i::after { background: linear-gradient(#9fd6ff, #3b8fe0); }
.ammo .mag { opacity: .8; margin-right: 3px; }
.ammo .you { display: none; position: absolute; left: 50%; bottom: calc(100% + 46px); transform: translateX(-50%); font-size: 11px; color: #6fd0ff; white-space: nowrap; }
.ammo.player .you { display: block; }
.ammo.player.idle .you::after { content: ' · HOLD TO FIRE'; color: #ffd84a; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.ebar { position: absolute; width: 64px; height: 7px; transform: translate(-50%, -50%); background: #1b1d24; border: 2px solid #141821; border-radius: 4px; overflow: hidden; }
.ebar i { display: block; height: 100%; background: linear-gradient(#ff5a4a, #c0221a); }
.num { position: absolute; font-size: 17px; transform: translate(-50%, -50%); animation: pop .7s ease-out forwards; -webkit-text-stroke-width: 3px; }
.num.crit { color: #ff5ad9; font-size: 23px; }
.num.explosive { color: #ffd84a; }
.num.energy { color: #6fdcff; }
.num.elemental { color: #d6a2ff; }
.num.burn { color: #ffa24a; font-size: 13px; }
@keyframes pop { 0% { transform: translate(-50%, -30%) scale(.5) rotate(var(--rot, 0deg)); opacity: 1; } 16% { transform: translate(calc(-50% + var(--dx, 0px) * .4), -90%) scale(1.25) rotate(var(--rot, 0deg)); } 30% { transform: translate(calc(-50% + var(--dx, 0px) * .55), -95%) scale(1) rotate(var(--rot, 0deg)); } 70% { opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx, 0px)), -170%) scale(.85) rotate(var(--rot, 0deg)); opacity: 0; } }
.num.crit { animation-name: popcrit; }
@keyframes popcrit { 0% { transform: translate(-50%, -30%) scale(.3) rotate(var(--rot)); opacity: 1; } 14% { transform: translate(calc(-50% + var(--dx) * .4), -100%) scale(1.6) rotate(var(--rot)); } 28% { transform: translate(calc(-50% + var(--dx) * .5), -100%) scale(1.1) rotate(var(--rot)); } 75% { opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), -180%) scale(1) rotate(var(--rot)); opacity: 0; } }

/* ---------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }
.top-left { position: absolute; left: 14px; top: 12px; }
.level { display: flex; align-items: center; }
.badge { position: relative; width: 40px; height: 44px; display: grid; place-items: center; z-index: 1;
  background: linear-gradient(#58b0ff, #1f6fd8); clip-path: polygon(50% 0, 100% 22%, 100% 70%, 50% 100%, 0 70%, 0 22%); }
.badge::before { content: ""; position: absolute; inset: 3px; background: linear-gradient(#3e9bf7, #1a5bb8); clip-path: inherit; }
.badge span { position: relative; font-size: 17px; paint-order: stroke fill; -webkit-text-stroke: 3px #0b2240; }
.xp { width: 140px; height: 16px; margin-left: -6px; background: #141821; border: 2px solid #141821; border-radius: 0 6px 6px 0; overflow: hidden; }
.xp i { display: block; height: 100%; width: 0; background: linear-gradient(#7fd2ff, #2f8be8); transition: width .25s; }
.kills { display: flex; align-items: center; gap: 6px; margin: 10px 0 0 4px; font-size: 18px; }
.skull { font-size: 24px; color: #f1ead8; text-shadow: 0 2px 0 #141821; }
.wave-title { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); font-size: 20px; color: var(--gold); white-space: nowrap; }
.top-right { position: absolute; right: 14px; top: 12px; display: flex; gap: 8px; }
.square { width: 42px; height: 42px; border-radius: 8px; border: 2px solid #0e2a4d; background: linear-gradient(#4aa6ff, #1d64c9); box-shadow: inset 0 -4px 0 #134a9a, 0 2px 0 #0b1a30; font-size: 20px; display: grid; place-items: center; }
.square.off { filter: grayscale(.8) brightness(.8); }
.pause-bars { width: 14px; height: 16px; border-left: 5px solid #fff; border-right: 5px solid #fff; filter: drop-shadow(0 1px 0 #0b2240); }
.ability { position: absolute; right: 14px; top: 46%; width: 66px; height: 66px; border-radius: 50%; border: 3px solid #141821; background: radial-gradient(#3d4a64, #1d2333); box-shadow: 0 0 0 3px #ffc94a, 0 4px 0 #141821; display: grid; place-items: center; padding: 0; }
.ability img { width: 46px; height: 46px; pointer-events: none; }
.ability::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(rgba(8,10,16,.72) var(--cd, 0%), transparent 0); }
.ability:disabled { box-shadow: 0 0 0 3px #59606f, 0 4px 0 #141821; }
.ability span { position: absolute; z-index: 1; font-size: 18px; paint-order: stroke fill; -webkit-text-stroke: 3px #141821; }
.ability kbd { position: absolute; bottom: -20px; font: 9px var(--font); color: #e7e9ef; opacity: .8; }
#boss { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); width: min(380px, 60vw); text-align: center; }
.boss-name { font-size: 13px; color: #ffb0a0; paint-order: stroke fill; -webkit-text-stroke: 3px #141821; margin-bottom: 4px; }
.boss-track { height: 12px; border: 2px solid #141821; border-radius: 6px; background: #2a1414; overflow: hidden; }
.boss-track i { display: block; height: 100%; background: linear-gradient(#ff6a50, #c0221a); transition: width .15s; }
.hp { position: absolute; left: 14px; right: 14px; bottom: 12px; height: 18px; }
.hp-track { position: relative; height: 14px; border: 2px solid #141821; border-radius: 4px; background: #182016; overflow: hidden; }
.hp-track i { position: absolute; left: 0; top: 0; bottom: 0; }
#hp-bar { background: linear-gradient(#5ee66a, #1fa63a); z-index: 1; }
#hp-loss { background: #e8e1c8; transition: width .6s .25s; }
.hp.low #hp-bar { background: linear-gradient(#ff7a5a, #d42a1a); }
.hp-label { position: absolute; right: 8px; top: -6px; display: flex; align-items: center; gap: 4px; z-index: 2; }
.hp-label b { font-size: 13px; -webkit-text-stroke-width: 3px; }
.shield { font-size: 22px; color: #6fb6ff; text-shadow: 0 2px 0 #141821; }
.tip { position: absolute; right: 18px; top: 92px; max-width: 240px; padding: 10px 14px; background: #fff; color: #141821; border-radius: 12px; font: 13px/1.35 var(--font); -webkit-text-stroke: 0; text-shadow: none; box-shadow: 0 4px 0 rgba(0,0,0,.35); animation: tipIn .3s ease-out; }
.tip::after { content: ""; position: absolute; bottom: -10px; left: 30px; border: 10px solid transparent; border-top-color: #fff; border-bottom: 0; }
@keyframes tipIn { from { transform: scale(.7); opacity: 0; } }
.banner { position: absolute; top: 15%; left: 50%; transform: translate(-50%, 0) scale(.6); font-size: 46px; opacity: 0; white-space: nowrap; letter-spacing: 1px; }
.banner.show { animation: banner 1.6s ease-out forwards; }
.banner.red { color: #ff6a5a; font-size: 32px; }
.banner.gold { color: var(--gold); }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 0) scale(.5); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1.12); } 22% { transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -12px) scale(1); } }

/* ---------- buttons */
.btn { border: 2px solid #141821; border-radius: 10px; padding: 10px 26px; font-size: 18px; min-height: 48px; transition: transform .08s, filter .12s; }
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:active:not(:disabled) { transform: translateY(3px); }
.btn.blue { background: linear-gradient(#5cc0ff, #1f7fe0); box-shadow: inset 0 -5px 0 #1658b0, 0 3px 0 #141821; }
.btn.green { background: linear-gradient(#8ee84a, #3faa16); box-shadow: inset 0 -5px 0 #2d7f0e, 0 3px 0 #141821; }
.btn.red { background: linear-gradient(#ff7a6a, #d6382a); box-shadow: inset 0 -5px 0 #a3241a, 0 3px 0 #141821; }
.btn.grey { background: linear-gradient(#8b93a6, #5a6172); box-shadow: inset 0 -5px 0 #434957, 0 3px 0 #141821; }
.btn.big { font-size: 26px; padding: 12px 60px; min-height: 62px; }

/* ---------- menu */
.menu { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 20px; background: radial-gradient(ellipse at center, rgba(20,16,12,.25), rgba(12,10,8,.7)); }
.title { text-align: center; line-height: .85; font-size: clamp(64px, 12vw, 128px); -webkit-text-stroke-width: 8px; text-shadow: 0 7px 0 #141821; transform: rotate(-3deg); }
.title .t1 { color: #f2ead2; } .title .t2 { color: #ff5a4a; }
.title small { display: block; font-size: .2em; color: var(--gold); letter-spacing: 6px; margin-top: 12px; -webkit-text-stroke-width: 5px; }
.menu-card { width: min(720px, 100%); padding: 20px 22px 18px; background: rgba(27,32,48,.92); border: 3px solid var(--line); border-radius: 14px; text-align: center; box-shadow: 0 8px 0 rgba(0,0,0,.35); }
.menu-card p { margin: 0 0 16px; font: 14px/1.45 var(--font); color: #cfd5e2; }
.difficulty { display: flex; gap: 6px; justify-content: center; margin: 0 auto 18px; max-width: 420px; }
.menu-label { font: 12px var(--font); letter-spacing: 2px; color: var(--gold); text-transform: uppercase; margin-bottom: 8px; }
.maps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.map-card { position: relative; padding: 0 0 8px; border: 3px solid #3a4258; border-radius: 10px; background: #1b2030; overflow: hidden; display: flex; flex-direction: column; text-align: left; transition: transform .1s, border-color .1s; }
.map-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; filter: saturate(.8) brightness(.85); }
.map-card:hover { transform: translateY(-2px); border-color: #8f9ab5; }
.map-card.on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255,201,74,.35), 0 6px 0 rgba(0,0,0,.35); }
.map-card.on img { filter: none; }
.map-card.on::after { content: '✔'; position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: #3a2400; display: grid; place-items: center; font-size: 13px; }
.map-name { font-size: 14px; margin: 7px 8px 2px; paint-order: stroke fill; -webkit-text-stroke: 3px #141821; }
.map-twist { font: 10px var(--font); color: #ffb35a; margin: 0 8px; }
.map-best { font: 9px var(--font); color: #8f9ab5; margin: 4px 8px 0; }
.map-blurb { min-height: 34px; margin: 10px 0 14px !important; font-size: 12px !important; color: #aab3c6 !important; }
.difficulty button { flex: 1; border: 2px solid #141821; border-radius: 8px; padding: 9px 0; background: #3a4258; color: #c9cfdc; font-size: 15px; box-shadow: inset 0 -4px 0 #2a3043; }
.difficulty button.on { background: linear-gradient(#ffd96a, #f0a91a); color: #3a2400; box-shadow: inset 0 -4px 0 #b97b0a; }
.record { margin-top: 14px; font: 13px var(--font); color: var(--gold); min-height: 16px; }
.howto { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 12px; font: 11px var(--font); color: #9aa3b8; }
.howto b { color: #fff; }
.loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: #1b2030; font-size: 16px; z-index: 30; }
.loading.done { opacity: 0; pointer-events: none; transition: opacity .4s; }
.spinner { width: 44px; height: 44px; border: 6px solid #3a4258; border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- modals */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(6,8,14,.62); }
#modal-box { width: min(760px, 100%); max-height: 96dvh; overflow: auto; display: flex; flex-direction: column; align-items: center; }
.ribbon { position: relative; width: 100%; padding: 12px 20px 16px; text-align: center; font-size: 22px; margin-bottom: 18px; clip-path: polygon(0 0, 100% 0, 100% 78%, 96% 100%, 88% 84%, 75% 100%, 60% 86%, 45% 100%, 30% 86%, 15% 100%, 5% 84%, 0 100%); }
.ribbon.green { background: linear-gradient(#9cf04f 0 40%, #5cc41f 41%); }
.ribbon.pink { width: min(420px, 100%); background: linear-gradient(#ff6a90 0 40%, #e3346a 41%); clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%); padding-bottom: 26px; }
.ribbon.blue { width: min(420px, 100%); background: linear-gradient(#5cc0ff 0 40%, #2f8be8 41%); clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%); padding-bottom: 26px; }
.ribbon.red { width: min(420px, 100%); background: linear-gradient(#ff7a6a 0 40%, #cc3324 41%); clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%); padding-bottom: 26px; }
.ribbon span { paint-order: stroke fill; -webkit-text-stroke: 4px #141821; text-shadow: 0 3px 0 #141821; }
.ribbon small { display: block; font-size: 11px; margin-top: 3px; color: #e9f0ff; -webkit-text-stroke: 0; text-shadow: none; }
.cards { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.wcard { width: 200px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.wbox { flex: 1; }
.wbox { width: 100%; padding: 10px 12px 12px; background: var(--navy); border: 2px solid var(--line); border-radius: 6px; box-shadow: 0 4px 0 rgba(0,0,0,.4); }
.wbox h3 { margin: 0 0 8px; text-align: center; font-size: 15px; }
.wicon { width: 76px; height: 76px; margin: 0 auto 6px; border: 2px solid #e9ecf2; border-radius: 6px; background: linear-gradient(#5b6278, #3a4054); display: grid; place-items: center; box-shadow: inset 0 0 12px rgba(0,0,0,.4); }
.wicon img { width: 92px; height: 92px; filter: drop-shadow(0 3px 2px rgba(0,0,0,.5)); }
.power { text-align: center; font-size: 12px; color: var(--gold); }
.tags { text-align: center; font-size: 10px; color: #ff9b3a; margin-bottom: 8px; }
.stat { display: flex; justify-content: space-between; font: 12px/1.6 var(--font); color: #ffd98a; }
.stat b { color: #fff; }
.trait { font: 11px/1.35 var(--font); color: #fff; margin-top: 4px; min-height: 30px; }
.trait g, .rows g { color: #6eea4a; } .trait r { color: #ff5a4a; }
.rows { display: flex; flex-direction: column; gap: 8px; width: min(380px, 100%); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px 8px 8px; background: var(--navy); border: 2px solid #3d4459; border-radius: 6px; text-align: left; box-shadow: 0 4px 0 rgba(0,0,0,.4); transition: transform .08s, border-color .1s; }
.row:hover, .row:focus-visible { border-color: #fff; transform: translateX(3px); }
.ricon { width: 56px; height: 56px; flex: none; border-radius: 5px; border: 3px solid var(--common); background: linear-gradient(#5a6175, #3c4256); display: grid; place-items: center; }
.ricon img { width: 46px; height: 46px; }
.row.rare .ricon { border-color: var(--rare); background: linear-gradient(#3b78e0, #1d4aa6); }
.row.epic .ricon { border-color: var(--epic); background: linear-gradient(#9a4ee0, #5c22a6); }
.rname { font-size: 17px; paint-order: stroke fill; -webkit-text-stroke: 3px #141821; }
.rname g { margin-left: 4px; }
.rval { font: 13px var(--font); color: #e3e6ee; margin-top: 4px; }
.row.rare .rname g { color: #6fb6ff; } .row.epic .rname g { color: #d79bff; }
.side-btn { position: absolute; right: 10px; bottom: 10px; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.panel { width: min(520px, 100%); padding: 18px; background: var(--navy2); border: 2px solid var(--line); border-radius: 10px; }
.rewards { display: flex; gap: 10px; justify-content: center; margin: 4px 0 6px; }
.reward { width: 92px; padding: 10px 4px 8px; border: 3px solid #6fdc3a; border-radius: 8px; background: linear-gradient(#3f8a2a, #2b5c1d); text-align: center; }
.reward.blue { border-color: #4aa6ff; background: linear-gradient(#2c66b8, #1c3f7a); }
.reward.purple { border-color: #c27cff; background: linear-gradient(#7a3fc0, #4b2280); }
.reward b { display: block; font-size: 22px; paint-order: stroke fill; -webkit-text-stroke: 3px #141821; }
.reward span { font: 10px var(--font); color: #e9f0ff; }
.reward .ico { font-size: 26px; display: block; margin-bottom: 2px; }
.note { font: 12px/1.5 var(--font); color: #aab3c6; text-align: center; margin-top: 12px; }
.attrs { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 6px; width: 100%; }
.attr { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 9px; background: linear-gradient(#2d5ea8, #1f4479); border: 2px solid #4f7fcf; border-radius: 6px; font: 12px var(--font); }
.attr img { width: 20px; height: 20px; }
.attr span { flex: 1; } .attr b.up { color: #6eea4a; }
.squad-list { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0 0; }
.squad-list div { width: 64px; height: 64px; border: 2px solid var(--line); border-radius: 6px; background: linear-gradient(#5b6278, #3a4054); display: grid; place-items: center; }
.squad-list img { width: 70px; }
#fatal { position: fixed; inset: 20%; z-index: 40; padding: 30px; background: #262c3d; border: 3px solid #fff; border-radius: 12px; font: 18px/1.5 var(--font); }

@media (max-width: 700px) {
  .maps { grid-template-columns: repeat(2, 1fr); }
  .menu { justify-content: flex-start; overflow-y: auto; padding-top: 24px; }
  .title { font-size: 54px; }
  .wave-title { top: 64px; font-size: 17px; }
  .xp { width: 96px; }
  .wcard { width: calc(33.3% - 7px); min-width: 0; }
  .wbox { padding: 8px 6px; } .wbox h3 { font-size: 12px; }
  .wicon { width: 56px; height: 56px; } .wicon img { width: 66px; height: 66px; }
  .stat { font-size: 10px; } .trait { font-size: 9px; }
  .ribbon { font-size: 18px; }
  .btn { padding: 8px 14px; font-size: 15px; }
  .ability { width: 56px; height: 56px; top: auto; bottom: 120px; } .ability img { width: 38px; height: 38px; } .ability kbd { display: none; }
  .tip { top: 110px; }
  .num { font-size: 14px; } .num.crit { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) { .num, .banner.show, .tip { animation-duration: .01s; } }
#kills { display: inline-block; }
