* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b141d; color: #d6f3ff; font-family: "Share Tech Mono", "Consolas", ui-monospace, monospace; touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
#game canvas { position: fixed; inset: 0; display: block; }
#hudCanvas { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.hidden { display: none !important; }

#hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#boostFx, #dmgFlash { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
#boostFx { background: radial-gradient(ellipse at center, transparent 45%, rgba(110, 210, 255, 0.35) 100%); }
#dmgFlash { background: radial-gradient(ellipse at center, transparent 35%, rgba(255, 30, 30, 0.6) 100%); }

#topbar { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 16px; font-size: 13px; letter-spacing: 2px; color: #9fe7ff; text-shadow: 0 0 6px #0008; }
#modeTxt { color: #ffcf8a; }
#feed { position: absolute; top: max(12px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); font-size: 12px; line-height: 1.6; text-shadow: 0 1px 2px #000; }
#feed b { color: #ffcf8a; } #feed i { color: #9fe7ff; font-style: normal; }
#scores { position: absolute; top: max(46px, calc(env(safe-area-inset-top) + 36px)); right: max(14px, env(safe-area-inset-right)); font-size: 11px; min-width: 140px; background: #04101a88; border: 1px solid #2c5868; padding: 6px 8px; }
#scores div { display: flex; justify-content: space-between; gap: 10px; }
#scores .hd { color: #6fb4c8; letter-spacing: 2px; margin-bottom: 2px; }
#scores.big { transform: scale(1.5); transform-origin: top right; }

#reticle { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; transform: translate(-50%, -50%); transition: transform .12s; }
#reticle i { position: absolute; background: #b8f6ff; box-shadow: 0 0 4px #4cf; }
#reticle i:nth-child(1) { left: 0; top: 21px; width: 12px; height: 2px; }
#reticle i:nth-child(2) { right: 0; top: 21px; width: 12px; height: 2px; }
#reticle i:nth-child(3) { top: 0; left: 21px; width: 2px; height: 12px; }
#reticle i:nth-child(4) { bottom: 0; left: 21px; width: 2px; height: 12px; }
#reticle b { position: absolute; left: 20px; top: 20px; width: 4px; height: 4px; border-radius: 50%; background: #fff; }
#reticle.locked { transform: translate(-50%, -50%) rotate(45deg) scale(.8); }
#reticle.locked i { background: #ff5050; box-shadow: 0 0 6px #f44; }

#readL, #readR { position: absolute; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; font-size: 26px; color: #c8f8ff; text-shadow: 0 0 8px #0af8, 0 1px 2px #000; }
#readL { right: calc(50% + 70px); text-align: right; align-items: flex-end; }
#readR { left: calc(50% + 70px); }
#readL small, #readR small { font-size: 10px; letter-spacing: 2px; color: #7fc3d6; }

#bars { position: absolute; left: 50%; top: calc(50% + 46px); transform: translateX(-50%); width: 200px; font-size: 10px; }
.bar { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.bar label { width: 18px; color: #7fc3d6; }
.bar div { flex: 1; height: 5px; background: #0009; border: 1px solid #2c5868; }
.bar i { display: block; height: 100%; background: #5dffa1; transition: width .1s; }
.bar i.low { background: #ff4a4a; }
#enFill { background: #45d4ff; } #enFill.hot { background: #ff5a2a; animation: blink .3s infinite alternate; }
.wpn { display: flex; justify-content: space-between; color: #ffcf8a; margin-top: 2px; }
@keyframes blink { to { opacity: .3; } }

#msg { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); font-size: 20px; letter-spacing: 3px; color: #e6fbff; text-shadow: 0 0 12px #0af, 0 2px 3px #000; opacity: 0; transition: opacity .25s; text-align: center; white-space: nowrap; }
#msg.show { opacity: 1; }
#msg.bad { color: #ff7a6a; text-shadow: 0 0 12px #f30, 0 2px 3px #000; }
#msg.good { color: #b6ffc8; text-shadow: 0 0 12px #0f8, 0 2px 3px #000; }

#dead { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(#300a, #000c); }
#dead.show { display: flex; }
#dead b { font-size: 44px; letter-spacing: 8px; color: #ff5a4a; }
#dead small { letter-spacing: 3px; color: #ffb0a0; }

#pauseBtn { position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); pointer-events: auto; background: #0a1a26aa; color: #9fe7ff; border: 1px solid #2c5868; font: inherit; width: 38px; height: 32px; z-index: 5; }
#scores { margin-top: 0; }
#viewBtn { position: absolute; top: max(8px, env(safe-area-inset-top)); right: calc(max(10px, env(safe-area-inset-right)) + 46px); pointer-events: auto; background: #0a1a26aa; color: #9fe7ff; border: 1px solid #2c5868; font: 16px/1 inherit; width: 38px; height: 32px; z-index: 5; touch-action: none; }
details select { background: #0a1a26; color: #e6fbff; border: 1px solid #2c5868; font: inherit; padding: 4px; flex: 1; }
/* No browser gestures (pinch/double-tap zoom) anywhere in the game */
#hud, #hud *, #game, canvas, button { touch-action: none; }
/* iOS zooms into text boxes under 16px: keep them at 16px */
#menu input, #menu select { font-size: 16px; }

/* Touch controls */
#touch { position: absolute; inset: 0; pointer-events: auto; display: none; touch-action: none; }
body.touch #touch { display: block; }
#stickBase { position: absolute; display: none; width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; border: 2px solid #6fdcff66; background: #0a20304d; pointer-events: none; }
#stickKnob { position: absolute; left: 37px; top: 37px; width: 50px; height: 50px; border-radius: 50%; background: #8fe9ffaa; box-shadow: 0 0 12px #4cf; }
.tb { position: absolute; border-radius: 50%; border: 2px solid #6fdcff88; background: #0a2030a0; color: #c8f6ff; font: 700 12px/1 inherit; font-family: inherit; letter-spacing: 1px; touch-action: none; }
.tb.on { background: #3fb6e0d0; color: #001018; border-color: #c8f6ff; }
#bFire { right: calc(26px + env(safe-area-inset-right)); bottom: 34px; width: 96px; height: 96px; font-size: 15px; border-color: #ffb36a; color: #ffd9a8; }
#bFire.on { background: #ff9a3ad0; color: #200; }
#bQB { right: calc(136px + env(safe-area-inset-right)); bottom: 22px; width: 64px; height: 64px; }
#bMsl { right: calc(134px + env(safe-area-inset-right)); bottom: 100px; width: 58px; height: 58px; border-color: #ff7a6a; }
#bRise { right: calc(30px + env(safe-area-inset-right)); bottom: 146px; width: 66px; height: 66px; }
#bDive { right: calc(106px + env(safe-area-inset-right)); bottom: 172px; width: 52px; height: 52px; font-size: 10px; }
#bBoost { left: calc(24px + env(safe-area-inset-left)); bottom: 170px; width: 64px; height: 64px; }

/* Menu */
#menu { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: flex-start; padding: 16px max(4vw, env(safe-area-inset-left)); background: linear-gradient(90deg, #050b11ee 0%, #050b11bb 45%, transparent 75%); overflow-y: auto; }
#menu.paused { background: #050b11cc; justify-content: center; }
.panel { width: min(430px, 92vw); }
h1 { margin: 0; font-size: clamp(34px, 7vw, 58px); letter-spacing: 6px; line-height: 1; color: #e8fbff; text-shadow: 0 0 18px #2bb8ff88; }
h1 span { color: #ffb347; margin-left: 10px; }
.sub { margin: 6px 0 14px; letter-spacing: 3px; color: #7fc3d6; font-size: 12px; }
#menu input:not([type]), #menu input[maxlength] { background: #0a1a26; border: 1px solid #2c5868; color: #e6fbff; font: inherit; padding: 10px 12px; letter-spacing: 2px; width: 100%; }
#frames { display: flex; gap: 8px; margin: 10px 0; }
.frame { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px; background: #0a1a26cc; border: 1px solid #2c5868; color: #cfefff; font: inherit; text-align: left; cursor: pointer; }
.frame i { width: 100%; height: 6px; margin-bottom: 4px; }
.frame b { letter-spacing: 2px; font-size: 13px; }
.frame small { font-size: 10px; color: #7fa9b8; }
.frame.sel { border-color: #ffb347; box-shadow: 0 0 0 1px #ffb347 inset; }
.play { display: flex; flex-direction: column; gap: 8px; }
.play button, .pvp button { background: #0e2a3a; border: 1px solid #3c87a2; color: #e6fbff; font: inherit; letter-spacing: 3px; padding: 12px; cursor: pointer; }
.play button.big { background: linear-gradient(90deg, #ff9a3a, #ffb347); color: #1a0d00; border: 0; font-size: 17px; font-weight: 700; padding: 15px; }
.play button:active { transform: scale(.98); }
.pvp { display: flex; gap: 6px; }
.pvp #btnHost { flex: 1.4; }
.pvp #roomCode { width: 84px !important; text-align: center; }
.pvp #btnJoin { flex: 0.8; }
#menu.paused .menuOnly, #menu:not(.paused) .pausedOnly { display: none; }
#notice { min-height: 1.2em; color: #ffcf8a; font-size: 12px; margin: 8px 0; }
details { font-size: 12px; color: #9fc7d6; }
summary { cursor: pointer; letter-spacing: 2px; margin-bottom: 6px; }
details label { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
details input[type=range] { flex: 1; }
#controlsHelp { line-height: 1.6; color: #7fa9b8; }
#rotate { display: none; position: fixed; bottom: 12px; left: 0; right: 0; text-align: center; font-size: 12px; color: #ffcf8a; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: block; } }
@media (max-height: 430px) {
  .sub { margin-bottom: 6px; } #frames { margin: 6px 0; } .frame small { display: none; }
  .play button { padding: 9px; } .play button.big { padding: 11px; }
  #readL, #readR { font-size: 20px; }
}

/* Melee button with cooldown fill */
#bMelee { right: calc(212px + env(safe-area-inset-right)); bottom: 58px; width: 62px; height: 62px; font-size: 22px; border-color: #ff6ab0; color: #ffd0e6;
  background: linear-gradient(to top, #0a2030a0 calc((1 - var(--cd, 0)) * 100%), #40102aa0 0); }
.wpn i { font-style: normal; color: #ffcf8a99; }
#viewBtn.active { background: #3fb6e0d0; color: #001018; }
#viewBtn.cool { color: #ff9a7a; font-size: 12px; }
.hangarBtn { width: 100%; margin-bottom: 8px; background: #1a2f12; border: 1px solid #7fae55; color: #dfffc8; font: inherit; letter-spacing: 3px; padding: 11px; cursor: pointer; }

/* Hangar */
#hangar { display: none; width: min(500px, 58vw); max-height: 100%; overflow-y: auto; padding-right: 6px; }
#menu.hangar .panel { display: none; }
#menu.hangar #hangar { display: block; }
#menu.hangar { align-items: flex-start; }
.hhead { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; background: #050b11f0; padding: 6px 0; }
.hhead h2 { margin: 0 auto 0 0; letter-spacing: 6px; color: #ffb347; font-size: 22px; }
.hhead button { background: #0e2a3a; border: 1px solid #3c87a2; color: #e6fbff; font: inherit; letter-spacing: 2px; padding: 8px 12px; cursor: pointer; }
.hhead .done { background: linear-gradient(90deg, #ff9a3a, #ffb347); color: #1a0d00; border: 0; font-weight: 700; }
#hangarStats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: #7fc3d6; margin: 4px 0 8px; }
#hangarStats b { color: #e6fbff; }
.sec h3 { margin: 10px 0 5px; font-size: 11px; letter-spacing: 3px; color: #6fb4c8; font-weight: 600; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 5px; }
.opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px; background: #0a1a26cc; border: 1px solid #2c5868; color: #cfefff; font: inherit; text-align: left; cursor: pointer; }
.opt b { font-size: 11px; letter-spacing: 1px; }
.opt small { font-size: 9px; color: #7fa9b8; line-height: 1.3; }
.opt.sel { border-color: #ffb347; box-shadow: 0 0 0 1px #ffb347 inset; background: #2a1d0acc; }
.opt:disabled { opacity: .35; }
.note { font-size: 10px; color: #7fffd8; margin: 4px 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 34px; height: 30px; border: 2px solid #0008; cursor: pointer; }
.sw.def { width: auto; padding: 0 8px; background: #0a1a26; color: #9fc7d6; font: 10px inherit; font-family: inherit; border-color: #2c5868; }
.sw.sel { border-color: #ffb347; box-shadow: 0 0 0 2px #ffb347; }
#viewBtn { width: auto; min-width: 38px; padding: 0 6px; white-space: nowrap; font-size: 14px; }
#bFire.empty { opacity: .4; border-color: #775; }

.maps { display: flex; gap: 6px; align-items: center; }
.maps span { font-size: 11px; letter-spacing: 3px; color: #6fb4c8; width: 40px; }
.maps button { flex: 1; background: #0a1a26; border: 1px solid #2c5868; color: #9fc7d6; font: inherit; letter-spacing: 3px; padding: 9px; cursor: pointer; }
.maps button.sel { border-color: #ffb347; color: #ffe2b0; box-shadow: 0 0 0 1px #ffb347 inset; background: #2a1d0a; }
