:root{
  --stageTop: 124px;          /* JS updates these dynamically */
  --stageHeight: 480px;
}

/* 80s neon + CRT + mobile-friendly */
*{box-sizing:border-box}
html,body{margin:0;height:100%;background:#02040a;color:#e6f0ff;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;touch-action:none}
.neon{color:#fff;text-shadow:0 0 6px #9ff, 0 0 12px #6ff, 0 0 26px #3cf}
.neon-pink{color:#ffe6fb;text-shadow:0 0 6px #ff85d8,0 0 14px #ff3dcf,0 0 28px #ff00c3}
.neon-gold{color:#fff4cc;text-shadow:0 0 6px #ffd76a,0 0 14px #ffb347,0 0 28px #ff9f1a}

/* Top bar */
.topbar{height:64px;display:flex;align-items:center;justify-content:space-between;padding:8px 12px;
  background:linear-gradient(90deg,rgba(15,20,50,.85),rgba(5,10,30,.75));backdrop-filter:blur(6px);
  border-bottom:1px solid #1a223a;position:fixed;top:0;left:0;right:0;z-index:6}
.brand{font-weight:800;letter-spacing:1.2px;font-size:20px}
.stats{display:flex;gap:18px;font-variant-numeric:tabular-nums;font-size:16px}
.controls{display:flex;gap:8px}
.controls button{cursor:pointer;border:1px solid #2b385f;background:#0f1831;color:#cfe0ff;padding:8px 12px;border-radius:10px}

/* HUD */
#hud{position:fixed;left:0;right:0;top:64px;height:60px;display:flex;align-items:center;justify-content:space-between;padding:10px 14px;
  background:linear-gradient(180deg,rgba(10,14,30,.7),rgba(10,14,30,.45));border-bottom:1px solid #142044;z-index:5}
#hud .bigscore{font-size:22px;font-weight:900}
#hud .tags .tag{border:1px solid #2b385f;padding:5px 10px;border-radius:14px;margin-left:6px;background:#0f1831}
@media (max-width:640px){ .stats span{font-size:14px} #hud .bigscore{font-size:18px} }

/* Stage + canvas (dynamic top/height) */
.stage{position:relative}
#game{display:block;width:100vw;height:var(--stageHeight);background:
  radial-gradient(1200px 800px at 50% 30%,#0e1035,#060913 70%,#01030a 100%);image-rendering:pixelated;position:absolute;left:0;top:var(--stageTop);z-index:1}

/* CRT overlay follows the canvas box */
#crt{position:absolute;left:0;top:var(--stageTop);width:100vw;height:var(--stageHeight);pointer-events:none;z-index:2}
#crt.on::before{content:'';position:absolute;inset:0;background:repeating-linear-gradient(transparent 0 2px,rgba(0,0,0,.18) 2px 4px)}
#crt.on::after{content:'';position:absolute;inset:-2%;border-radius:18px;background:
  radial-gradient(ellipse at center, rgba(255,255,255,.06) 0%, rgba(255,255,255,0) 60%),
  radial-gradient(ellipse at center, rgba(0,0,0,.45) 55%, rgba(0,0,0,.85) 100%);
  box-shadow:0 0 80px rgba(0,0,0,.8) inset, 0 0 40px rgba(0,0,0,.6) inset}

/* Overlay */
.overlay{position:fixed;inset:0;background:linear-gradient(180deg,rgba(5,8,18,.88),rgba(5,8,18,.7));display:grid;place-items:center;z-index:7}
.overlay.hidden{display:none}
.overlay .card{background:#0f162f;border:1px solid #2a3663;border-radius:18px;padding:20px;width:min(680px,94vw);text-align:center;
  box-shadow:0 20px 60px rgba(0,0,0,.55)}
.overlay .card h1,.overlay .card h3{margin:6px 0 10px}
.overlay-actions{display:flex;gap:10px;justify-content:center;margin-top:10px;flex-wrap:wrap}
button{cursor:pointer;border:1px solid #2b385f;background:#0f1831;color:#cfe0ff;padding:10px 14px;border-radius:12px}
button:hover{background:#152352}
button.danger{border-color:#7a2e40;background:#2a0f18}
input[type=text]{padding:10px;border-radius:12px;border:1px solid #2b385f;background:#0f1831;color:#cfe0ff}

/* Weapon picker */
#weaponPicker{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-top:12px}
#weaponPicker button{padding:12px 10px;border-radius:14px}
#weaponPicker button.active{outline:2px solid #6ff;box-shadow:0 0 12px #6ff}

/* Settings block */
.settings{margin-top:16px;text-align:left;background:#0b1430;border:1px solid #23315a;border-radius:14px;padding:12px}
.setting{display:block}
.setting span{font-weight:700}
.rangeRow{display:flex;align-items:center;gap:10px;margin-top:6px}
#zoomRange{width:100%}
.setting small{opacity:.8}

/* Mobile controls (smaller + adaptive) */
#mobileControls{
  position:fixed;
  left:0; right:0;
  bottom:calc(env(safe-area-inset-bottom, 16px) + 8px);
  display:flex; justify-content:center; gap:12px;
  padding:0 14px; z-index:8;
  pointer-events:auto;
}
#btnFire{
  width:96px; height:96px;      /* smaller */
  font-size:36px;
  border-radius:50%;
  background:rgba(20,30,60,.95);
  border:1px solid #2b3b66;
  touch-action:manipulation;
}
#autoFireToggle{
  height:48px; padding:0 14px; border-radius:14px;
  background:rgba(20,30,60,.75);
  border:1px solid #2b3b66;
}

/* Compact mode for short screens */
body.compact #btnFire{ width:80px; height:80px; font-size:30px; }
body.compact #autoFireToggle{ height:42px; }

/* Super-compact for very narrow phones */
@media (max-width:360px){
  #btnFire{ width:84px; height:84px; font-size:30px; }
}

/* Landscape phones: slim or hide if very short */
@media (max-height:420px) and (orientation:landscape){
  #mobileControls{ gap:10px; }
  #btnFire{ width:74px; height:74px; font-size:26px; }
  #autoFireToggle{ height:38px; padding:0 12px; }
}
@media (max-height:360px) and (orientation:landscape){
  #mobileControls{ display:none; } /* tap-to-fire anywhere */
}

/* Hide mobile controls on desktops */
@media (pointer:fine){ #mobileControls{ display:none } }

/* Floating score pop */
.pop{position:absolute;pointer-events:none;font-weight:900}
