:root {
  --bg: #050508;
  --neon-cyan: #00f0ff;
  --neon-pink: #ff2bd6;
  --neon-lime: #b8ff3c;
  --neon-orange: #ff9a1a;
  --neon-red: #ff2a4a;
  --neon-purple: #b44dff;
  --neon-yellow: #ffe566;
  --chalk: #e8e6df;
  --panel: rgba(8, 10, 20, 0.88);
  --glow-cyan: 0 0 8px #00f0ff, 0 0 24px rgba(0, 240, 255, 0.45);
  --glow-pink: 0 0 8px #ff2bd6, 0 0 24px rgba(255, 43, 214, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  color: var(--chalk);
  font-family: "Orbitron", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

#crt {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 30%, #0a0c18 0%, var(--bg) 70%),
    #000;
}

#scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.18) 2px,
    rgba(0, 0, 0, 0.18) 4px
  );
  opacity: 0.55;
  mix-blend-mode: multiply;
}

#vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 49;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.65) 100%);
}

#top-bar,
#bottom-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 22px;
  gap: 16px;
  flex-shrink: 0;
}

#top-bar {
  border-bottom: 1px solid rgba(0, 240, 255, 0.25);
  box-shadow: 0 1px 20px rgba(0, 240, 255, 0.08);
}

#obj-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 22px 8px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(184, 255, 60, 0.15);
  background: rgba(0, 0, 0, 0.35);
}

#obj-bar .label {
  display: block;
  font-size: 8px;
  letter-spacing: 0.22em;
  color: var(--neon-lime);
  text-shadow: 0 0 8px rgba(184, 255, 60, 0.5);
  margin-bottom: 3px;
  font-family: "Press Start 2P", monospace;
}

#objective, #dist-exit, #progress-label, #kills, #checkpoint {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  color: var(--chalk);
}

#objective {
  color: var(--neon-lime);
  text-shadow: 0 0 8px rgba(184, 255, 60, 0.4);
}

.progress-wrap {
  flex: 1;
  max-width: 360px;
  height: 12px;
  border: 1px solid rgba(0, 240, 255, 0.4);
  position: relative;
  background: rgba(0, 240, 255, 0.05);
  box-shadow: inset 0 0 8px rgba(0, 240, 255, 0.1);
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink), var(--neon-lime));
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
  transition: width 0.15s linear;
}

#progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #fff;
  text-shadow: 0 0 4px #000;
  pointer-events: none;
}

.obj-left { min-width: 180px; }
.obj-right { min-width: 90px; text-align: right; }

.hi-pink {
  color: var(--neon-pink);
  text-shadow: var(--glow-pink);
}

.menu-hint {
  font-size: 11px;
  color: rgba(232, 230, 223, 0.7);
  margin-bottom: 18px;
  letter-spacing: 0.08em;
}

.neon-title.win {
  color: var(--neon-lime);
  text-shadow: 0 0 8px #b8ff3c, 0 0 28px rgba(184, 255, 60, 0.55);
}

.menu-info strong {
  color: var(--neon-cyan);
}

#bottom-bar {
  border-top: 1px solid rgba(255, 43, 214, 0.25);
  box-shadow: 0 -1px 20px rgba(255, 43, 214, 0.08);
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 18px;
}

.hud-block {
  min-width: 120px;
}

.hud-block.right {
  text-align: right;
}

.hud-block .label,
.lives-wrap .label,
.wave-wrap .label {
  display: block;
  font-size: 9px;
  letter-spacing: 0.25em;
  color: var(--neon-cyan);
  text-shadow: var(--glow-cyan);
  margin-bottom: 4px;
  font-family: "Press Start 2P", monospace;
}

#score, #hiscore, #wave, #lives {
  font-family: "Press Start 2P", monospace;
  font-size: 14px;
  color: var(--chalk);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}

.title-block {
  text-align: center;
  flex: 1;
}

.title-block h1 {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(12px, 2.2vw, 18px);
  color: var(--neon-pink);
  text-shadow: var(--glow-pink);
  letter-spacing: 0.12em;
}

.tagline {
  font-size: 10px;
  letter-spacing: 0.35em;
  color: var(--neon-cyan);
  margin-top: 6px;
  opacity: 0.85;
}

#game-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 8px 16px;
}

#game {
  width: min(960px, 100%);
  height: auto;
  max-height: 100%;
  background: #000;
  border: 2px solid rgba(0, 240, 255, 0.35);
  box-shadow:
    0 0 0 1px rgba(255, 43, 214, 0.2),
    0 0 40px rgba(0, 240, 255, 0.15),
    inset 0 0 60px rgba(0, 240, 255, 0.04);
  image-rendering: pixelated;
  cursor: crosshair;
}

#overlay {
  position: absolute;
  inset: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
}

.panel {
  pointer-events: auto;
  background: var(--panel);
  border: 2px solid var(--neon-cyan);
  box-shadow: var(--glow-cyan), inset 0 0 40px rgba(0, 240, 255, 0.06);
  padding: 28px 36px;
  max-width: 520px;
  text-align: center;
  backdrop-filter: blur(4px);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--neon-cyan) rgba(0, 240, 255, 0.08);
}

.hidden { display: none !important; }

#rotate-hint {
  display: none;
  position: fixed;
  top: max(82px, env(safe-area-inset-top) + 72px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 28px);
  padding: 9px 12px;
  border: 1px solid rgba(184, 255, 60, 0.75);
  border-radius: 999px;
  color: var(--neon-lime);
  background: rgba(3, 8, 12, 0.9);
  box-shadow: 0 0 18px rgba(184, 255, 60, 0.25);
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}

#rotate-hint span {
  font-family: system-ui, sans-serif;
  font-size: 18px;
  line-height: 1;
}

.panel.hidden {
  display: none;
}

.neon-title {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(16px, 3vw, 24px);
  color: var(--neon-pink);
  text-shadow: var(--glow-pink);
  margin-bottom: 12px;
  line-height: 1.5;
}

.neon-title.danger {
  color: var(--neon-red);
  text-shadow: 0 0 8px #ff2a4a, 0 0 24px rgba(255, 42, 74, 0.5);
}

.menu-sub {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--neon-cyan);
  margin-bottom: 18px;
}

.menu-info {
  list-style: none;
  text-align: left;
  font-size: 12px;
  line-height: 1.7;
  color: var(--chalk);
  opacity: 0.9;
  margin-bottom: 22px;
}

.menu-info li {
  margin-bottom: 8px;
  padding-left: 10px;
  border-left: 2px solid rgba(0, 240, 255, 0.35);
}

kbd {
  display: inline-block;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  padding: 3px 6px;
  margin: 0 2px;
  border: 1px solid var(--neon-lime);
  color: var(--neon-lime);
  background: rgba(184, 255, 60, 0.08);
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(184, 255, 60, 0.25);
}

.arcade-btn {
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  padding: 14px 20px;
  border: 2px solid var(--neon-lime);
  background: transparent;
  color: var(--neon-lime);
  cursor: pointer;
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(184, 255, 60, 0.6);
  box-shadow: 0 0 16px rgba(184, 255, 60, 0.25);
  transition: transform 0.12s, background 0.12s, color 0.12s;
}

.arcade-btn:hover,
.arcade-btn:focus {
  background: var(--neon-lime);
  color: #050508;
  outline: none;
  transform: scale(1.03);
}

.arcade-btn.secondary {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
  font-size: 9px;
  padding: 10px 14px;
}

.arcade-btn.secondary:hover,
.arcade-btn.secondary:focus {
  background: var(--neon-cyan);
  color: #050508;
}

.weapon-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  opacity: 0.28;
  transition: opacity 0.15s, border-color 0.15s, box-shadow 0.15s;
  font-size: 11px;
  filter: grayscale(0.6);
}

.weapon-slot.owned {
  opacity: 0.7;
  filter: none;
  border-color: rgba(255, 255, 255, 0.25);
}

.weapon-slot.active {
  opacity: 1;
  filter: none;
  border-color: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
  color: var(--neon-cyan);
}

.weapon-slot.locked .w-name {
  text-decoration: line-through;
  opacity: 0.5;
}

.w-key {
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  color: var(--neon-yellow);
}

.w-name {
  letter-spacing: 0.12em;
}

.w-ammo {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--neon-yellow);
  min-width: 1.5em;
}

#gun-label, #threat, #combo, #best-stage, #stage-name {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  color: var(--neon-cyan);
  text-shadow: var(--glow-cyan);
}

#stage-name {
  font-size: 8px;
  letter-spacing: 0.12em;
  color: var(--neon-lime);
}

#mod-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px 22px;
  flex-wrap: wrap;
  padding: 4px 22px 6px;
  border-bottom: 1px solid rgba(255, 43, 214, 0.12);
  background: rgba(0, 0, 0, 0.25);
  font-size: 10px;
}

#mod-bar .label {
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  letter-spacing: 0.18em;
  color: var(--neon-pink);
  margin-right: 6px;
}

#stage-mods {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(255, 229, 102, 0.4);
  flex: 1;
  min-width: 120px;
}

#combo {
  color: var(--neon-orange);
  text-shadow: 0 0 8px rgba(255, 154, 26, 0.5);
}

#threat {
  color: var(--neon-red);
  text-shadow: 0 0 8px rgba(255, 42, 74, 0.5);
}

.threat-band {
  display: block;
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  margin-top: 3px;
  letter-spacing: 0.08em;
  color: var(--neon-yellow);
}

.w-role {
  font-family: "Press Start 2P", monospace;
  font-size: 6px;
  color: var(--neon-lime);
  letter-spacing: 0.06em;
  opacity: 0.85;
}

.legend-btn {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--neon-cyan);
  background: transparent;
  color: var(--neon-cyan);
  cursor: pointer;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.25);
  flex-shrink: 0;
}

.legend-btn:active {
  background: var(--neon-cyan);
  color: #000;
}

.mod-hint {
  position: relative;
  z-index: 10;
  min-height: 0;
  padding: 0 22px;
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  color: rgba(255, 229, 102, 0.85);
  letter-spacing: 0.06em;
  line-height: 1.5;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.2s, opacity 0.2s, padding 0.2s;
}

.mod-hint.show {
  max-height: 48px;
  opacity: 1;
  padding: 2px 22px 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  text-align: left;
  margin-bottom: 14px;
}

.legend-col h3 {
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  color: var(--neon-cyan);
  margin-bottom: 8px;
  letter-spacing: 0.1em;
}

.legend-list {
  list-style: none;
  font-size: 10px;
  line-height: 1.65;
  color: var(--chalk);
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 8px var(--c);
  flex-shrink: 0;
}

.legend-list .role {
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  color: var(--neon-lime);
  min-width: 36px;
}

/* Coach toast */
#coach {
  position: absolute;
  left: 50%;
  bottom: max(118px, env(safe-area-inset-bottom) + 100px);
  transform: translateX(-50%);
  z-index: 35;
  width: min(92vw, 420px);
  background: rgba(5, 8, 16, 0.92);
  border: 2px solid var(--neon-lime);
  box-shadow: 0 0 20px rgba(184, 255, 60, 0.3);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

#coach.hidden {
  display: none;
}

#coach-text {
  flex: 1;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  line-height: 1.55;
  color: var(--chalk);
  text-align: left;
}

.coach-ok {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  padding: 10px 12px;
  border: 1px solid var(--neon-lime);
  background: transparent;
  color: var(--neon-lime);
  cursor: pointer;
  flex-shrink: 0;
}

.coach-ok:active {
  background: var(--neon-lime);
  color: #050508;
}

.weapon-slot.flash-empty {
  animation: emptyPulse 0.45s ease 2;
  border-color: var(--neon-red) !important;
}

@keyframes emptyPulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 14px rgba(255, 42, 74, 0.7); }
}

.weapon-slot.flash-pickup {
  animation: pickPulse 0.5s ease 1;
}

@keyframes pickPulse {
  0% { box-shadow: 0 0 0 transparent; }
  40% { box-shadow: 0 0 16px rgba(184, 255, 60, 0.8); }
  100% { box-shadow: none; }
}

#combo.hot {
  color: var(--neon-orange);
  text-shadow: 0 0 12px rgba(255, 154, 26, 0.8);
  transform: scale(1.08);
}

#objective.pulse {
  animation: objPulse 1s ease infinite;
}

@keyframes objPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

#hurt-flash {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 40;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 42, 74, 0.45) 100%);
  opacity: 0;
  transition: opacity 0.08s;
}

#hurt-flash.on {
  opacity: 1;
}

#stage-banner {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  transition: opacity 0.4s;
}

#stage-banner.hidden {
  display: none;
}

#stage-banner.fade {
  opacity: 0;
}

.banner-inner {
  text-align: center;
  border: 2px solid var(--neon-cyan);
  padding: 22px 36px;
  box-shadow: var(--glow-cyan);
  background: rgba(5, 5, 12, 0.9);
}

.banner-stage {
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  color: var(--neon-cyan);
  margin-bottom: 10px;
  letter-spacing: 0.15em;
}

.banner-name {
  font-family: "Press Start 2P", monospace;
  font-size: 16px;
  color: var(--neon-pink);
  text-shadow: var(--glow-pink);
  margin-bottom: 12px;
  line-height: 1.5;
}

.banner-mods {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--neon-yellow);
  line-height: 1.8;
  max-width: 420px;
}

.lives-wrap, .wave-wrap {
  margin-left: 8px;
  text-align: center;
}

#lives {
  color: var(--neon-pink);
  text-shadow: var(--glow-pink);
  letter-spacing: 0.15em;
}

/* ─── On-screen touch controls ───────────────────────────────────── */
#touch-ui {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 max(10px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
  gap: 12px;
}

.menu-pitch {
  max-width: 520px;
  margin: 10px auto 12px;
  color: #e8e6df;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(8px, 1.5vw, 11px);
  line-height: 1.7;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.42);
}

.menu-details {
  max-width: 580px;
  margin: 0 auto 8px;
  border: 1px solid rgba(0, 240, 255, 0.22);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
}

.menu-details summary {
  min-height: 44px;
  display: grid;
  place-items: center;
  color: #00f0ff;
  cursor: pointer;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
}

.compat-note,
.status-pill {
  max-width: 540px;
  margin: 8px auto 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 229, 102, 0.28);
  border-radius: 8px;
  background: rgba(255, 229, 102, 0.06);
  color: #f7f2d5;
  font-size: 12px;
  line-height: 1.5;
}

.service-record {
  max-width: 560px;
  margin: 10px auto 0;
  padding: 9px 12px;
  border-top: 1px solid rgba(184, 255, 60, 0.22);
  color: #b8ff3c;
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  line-height: 1.65;
}

.volume-row { gap: 12px; }
.volume-row input[type="range"] { flex: 1; accent-color: #00f0ff; }

.arcade-btn.daily {
  border-color: #ffe566;
  color: #ffe566;
  background: linear-gradient(135deg, rgba(255, 229, 102, 0.13), rgba(255, 43, 214, 0.1));
  box-shadow: 0 0 18px rgba(255, 229, 102, 0.14);
}

.upgrade-choices {
  width: min(560px, 96%);
  margin: 12px auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.upgrade-choices > p { grid-column: 1 / -1; }

.upgrade-btn {
  min-height: 68px;
  padding: 10px 8px;
  border: 1px solid rgba(0, 240, 255, 0.45);
  border-radius: 8px;
  color: #e8e6df;
  background: rgba(5, 10, 20, 0.86);
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  line-height: 1.45;
  cursor: pointer;
}

.upgrade-btn small {
  display: block;
  margin-top: 7px;
  color: #9eefff;
  font-family: system-ui, sans-serif;
  font-size: 11px;
}

.upgrade-btn.selected {
  border-color: #b8ff3c;
  color: #b8ff3c;
  box-shadow: 0 0 14px rgba(184, 255, 60, 0.28);
}

body.ui-large .panel { font-size: 1.16em; }
body.ui-large .menu-hint,
body.ui-large .menu-info,
body.ui-large .compat-note { font-size: 13px; }
body.ui-small .panel { font-size: 0.9em; }

body.high-contrast #top-bar,
body.high-contrast #obj-bar,
body.high-contrast #mod-bar {
  background: #000;
  border-color: #fff;
}
body.high-contrast .menu-hint,
body.high-contrast .compat-note { color: #fff; }

body.reduced-effects *,
body.reduced-effects *::before,
body.reduced-effects *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}
body.reduced-effects #hurt-flash,
body.reduced-effects .crt::after { display: none !important; }

.ladder-list .verified { color: #b8ff3c; margin-left: 5px; }
.ladder-list .legacy { color: #75839b; margin-left: 5px; }
#mp-menu .room-action { display: none; }
#mp-menu .room-action.room-live { display: inline-flex; }

@media (max-width: 700px), (pointer: coarse) {
  #local-menu .arcade-btn.local-unsupported {
    opacity: 0.48;
    filter: grayscale(0.7);
  }
  .upgrade-choices { grid-template-columns: 1fr; }
  .upgrade-btn { min-height: 50px; }
}

body.touch-left #touch-ui {
  flex-direction: row-reverse;
}

body.touch-left #action-zone {
  align-items: flex-start;
}

body.touch-left #action-zone .main-row {
  flex-direction: row-reverse;
}

#touch-ui.inactive {
  opacity: 0;
  visibility: hidden;
  pointer-events: none !important;
}

#touch-ui.inactive #stick-zone,
#touch-ui.inactive #action-zone,
#touch-ui.inactive .touch-btn {
  pointer-events: none !important;
}

#stick-zone,
#action-zone {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.touch-zone-label {
  align-self: center;
  padding: 4px 8px;
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 999px;
  color: rgba(184, 255, 255, 0.88);
  background: rgba(0, 10, 18, 0.62);
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  letter-spacing: 0.12em;
  line-height: 1;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
}

.touch-zone-label.action-label {
  align-self: flex-end;
  color: rgba(255, 196, 239, 0.94);
  border-color: rgba(255, 43, 214, 0.38);
  text-shadow: 0 0 8px rgba(255, 43, 214, 0.55);
}

body.touch-left .touch-zone-label.action-label {
  align-self: flex-start;
}

#stick-zone {
  align-items: center;
  width: min(42vw, 200px);
}

#stick-base {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(0, 240, 255, 0.45);
  background: rgba(0, 20, 30, 0.35);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.15), inset 0 0 24px rgba(0, 0, 0, 0.45);
  touch-action: none;
}

#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  border: 2px solid var(--neon-cyan);
  background: rgba(0, 240, 255, 0.18);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.45);
  pointer-events: none;
  transition: transform 0.05s linear;
}

#stick-base::before,
#stick-base::after {
  content: "";
  position: absolute;
  pointer-events: none;
  opacity: 0.32;
}

#stick-base::before {
  left: 14%;
  right: 14%;
  top: 50%;
  border-top: 1px solid var(--neon-cyan);
}

#stick-base::after {
  top: 14%;
  bottom: 14%;
  left: 50%;
  border-left: 1px solid var(--neon-cyan);
}

.dpad-fallback {
  display: flex;
  gap: 10px;
}

#action-zone {
  align-items: flex-end;
  min-width: min(48vw, 240px);
}

.action-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.touch-btn {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  color: var(--chalk);
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(8, 10, 20, 0.55);
  border-radius: 12px;
  min-height: 52px;
  min-width: 52px;
  padding: 12px 14px;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
  user-select: none;
  transition: transform 0.08s ease, background 0.08s ease, border-color 0.08s ease, opacity 0.08s ease;
}

.touch-btn:active,
.touch-btn.active {
  transform: scale(0.96);
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
}

.touch-btn.dpad {
  width: 64px;
  height: 56px;
  font-size: 16px;
  border-color: rgba(0, 240, 255, 0.4);
  color: var(--neon-cyan);
}

.touch-btn.jump {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border-color: var(--neon-lime);
  color: var(--neon-lime);
  font-size: 11px;
  box-shadow: 0 0 18px rgba(184, 255, 60, 0.25);
}

.touch-btn.fire {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  font-size: 12px;
  box-shadow: 0 0 22px rgba(255, 43, 214, 0.35);
  background: rgba(40, 0, 30, 0.45);
}

.touch-btn.fire span,
.touch-btn.fire small {
  display: block;
  pointer-events: none;
}

.touch-btn.fire small {
  margin-top: 5px;
  font-family: "Orbitron", system-ui, sans-serif;
  font-size: 6px;
  letter-spacing: 0.08em;
  opacity: 0.78;
}

.touch-btn.fire.active {
  border-color: var(--neon-pink);
  color: #fff;
  background: rgba(255, 43, 214, 0.35);
  box-shadow: var(--glow-pink);
}

.touch-btn.jump.active {
  background: rgba(184, 255, 60, 0.25);
  color: #fff;
}

.touch-btn.util {
  min-height: 40px;
  min-width: 44px;
  font-size: 8px;
  padding: 8px 10px;
  border-color: rgba(255, 229, 102, 0.35);
  color: var(--neon-yellow);
  opacity: 0.9;
}

.touch-settings-hint {
  max-width: 360px;
  margin: 8px auto 12px;
  color: rgba(0, 240, 255, 0.82);
  line-height: 1.55;
}

/* Desktop with mouse: fade controls but keep usable if wanted */
@media (hover: hover) and (pointer: fine) {
  #touch-ui {
    opacity: 0.22;
  }
  #touch-ui:hover,
  body.force-touch #touch-ui {
    opacity: 0.85;
  }
  .desktop-hint { display: block; }
}

@media (hover: none), (pointer: coarse) {
  #touch-ui { opacity: 1; }
  .desktop-hint { display: none; }
  #game { cursor: default; border-width: 1px; }
  #scanlines { opacity: 0.35; }
}

.desktop-hint {
  display: none;
  margin-top: 14px;
  font-size: 10px;
}

@media (max-width: 900px) {
  #top-bar { padding: 6px 10px; }
  #obj-bar, #mod-bar { padding: 4px 10px; gap: 8px; }
  #game-wrap { padding: 4px 6px 0; }
  #overlay { inset: 4px 6px; }
  #bottom-bar {
    padding: 6px 8px;
    gap: 6px 8px;
    max-height: 22vh;
    overflow-x: auto;
    justify-content: flex-start;
  }
  .weapon-slot { padding: 4px 6px; font-size: 9px; }
  .w-name { letter-spacing: 0.04em; }
  .title-block h1 { font-size: 10px; }
  .tagline { font-size: 7px; letter-spacing: 0.12em; }
  #stage-mods { font-size: 7px; }
  #objective, #dist-exit, #progress-label { font-size: 8px; }
  .panel { padding: 16px 12px; max-width: 92vw; }
  .menu-info { font-size: 10px; }
  .arcade-btn { font-size: 10px; padding: 16px 18px; width: 100%; max-width: 280px; }
  #stick-base { width: 108px; height: 108px; }
  #stick-knob { width: 46px; height: 46px; margin: -23px 0 0 -23px; }
  .touch-btn.fire { width: 92px; height: 92px; }
  .touch-btn.jump { width: 78px; height: 78px; }
}

@media (max-width: 700px) {
  #top-bar { padding: 6px 8px; }
  .title-block h1 { font-size: 9px; }
  .tagline { display: none; }
  #mod-bar .best-wrap { display: none; }
  .panel { padding: 14px 10px; margin: 0 4px; }
  .menu-info { font-size: 10px; line-height: 1.55; }
  .hud-block { min-width: 70px; }
  #score, #hiscore, #lives { font-size: 11px; }
}

@media (max-width: 600px) {
  .dpad-fallback { display: none !important; }
  #touch-ui { padding: 0 max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); gap: 8px; }
  #stick-zone { width: min(34vw, 126px); gap: 6px; }
  #stick-base { width: 104px; height: 104px; }
  #stick-knob { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
  .touch-btn.fire { width: 82px; height: 82px; font-size: 10px; }
  .touch-btn.jump { width: 72px; height: 72px; font-size: 9px; }
  .touch-btn.util { min-height: 44px; min-width: 44px; padding: 7px 8px; }
  #action-zone { gap: 6px; }
  .action-row { gap: 8px; }
  .touch-zone-label { font-size: 6px; padding: 4px 7px; }
}

/* Landscape phones: keep canvas taller share, controls over bottom corners */
@media (max-height: 500px) and (orientation: landscape) {
  #top-bar, #obj-bar, #mod-bar { padding-top: 2px; padding-bottom: 2px; }
  #top-bar { min-height: 30px; }
  #obj-bar { min-height: 28px; }
  #mod-bar { min-height: 24px; }
  #mod-hint { display: none; }
  .title-block h1 { font-size: 9px; }
  #bottom-bar { display: none; }
  #stick-base { width: 88px; height: 88px; }
  #stick-zone { width: 150px; gap: 4px; }
  #action-zone { min-width: 210px; gap: 5px; }
  .touch-btn.fire { width: 78px; height: 78px; min-width: 78px; min-height: 78px; font-size: 10px; }
  .touch-btn.jump { width: 68px; height: 68px; min-width: 68px; min-height: 68px; font-size: 9px; }
  .touch-btn.util { min-height: 44px; min-width: 44px; padding: 6px 8px; }
  .dpad-fallback { display: none; }
  #touch-ui { padding: 0 max(10px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .touch-zone-label { display: none; }
  #menu .menu-info { display: none; }
  #menu .menu-sub { margin-bottom: 8px; }
  #menu .menu-mode-label { margin-top: 6px !important; }
  #menu .arcade-btn { padding: 10px 12px; margin-top: 6px !important; }
  .panel { padding: 10px 12px; }
}

@media (min-height: 501px) {
  .dpad-fallback { display: flex; }
}

.test-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 240, 255, 0.2);
}
.test-panel.hidden {
  display: none !important;
}
.test-panel .arcade-btn.secondary {
  width: 100%;
  max-width: 280px;
}
.playtest-badge {
  margin-top: 10px;
  color: #ffe566 !important;
  letter-spacing: 0.08em;
}
.mp-input {
  width: min(280px, 90%);
  margin: 6px auto 0;
  display: block;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(0, 240, 255, 0.45);
  color: #e8e6df;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  padding: 10px 12px;
  text-align: center;
  outline: none;
}
.mp-input:focus {
  border-color: #ff2bd6;
  box-shadow: 0 0 12px rgba(255, 43, 214, 0.35);
}
.mp-room-code {
  font-size: 14px !important;
  color: #00f0ff !important;
  letter-spacing: 0.25em;
  min-height: 1.4em;
}
.mp-reconnect-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(92vw, 520px);
  padding: 10px 14px;
  background: rgba(5, 5, 12, 0.92);
  border: 1px solid rgba(255, 43, 214, 0.65);
  box-shadow: 0 0 18px rgba(255, 43, 214, 0.35);
  color: #ffe566;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
}
.mp-reconnect-banner.hidden {
  display: none !important;
}
.mp-turn-help {
  border: 1px solid rgba(0, 240, 255, 0.25);
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.35);
}
.mp-turn-help summary {
  list-style: none;
}
.mp-turn-help summary::-webkit-details-marker {
  display: none;
}
#mp-turn-json {
  text-align: left;
  font-family: ui-monospace, monospace;
}
.settings-row {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin: 10px auto 0;
  max-width: 280px;
  text-align: left;
}
.mp-chat {
  position: fixed;
  right: 10px;
  bottom: 72px;
  z-index: 70;
  width: min(280px, 42vw);
  max-height: 160px;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background: rgba(5, 5, 12, 0.72);
  border: 1px solid rgba(0, 240, 255, 0.35);
  font-family: "Press Start 2P", monospace;
}
.mp-chat.hidden {
  display: none !important;
}
.mp-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  max-height: 110px;
  font-size: 7px;
  line-height: 1.45;
  color: #c8e8ff;
}
.mp-chat-line.self {
  color: #9dffb0;
}
.mp-chat-form {
  display: flex;
  border-top: 1px solid rgba(0, 240, 255, 0.25);
}
.mp-chat-form input {
  flex: 1;
  border: 0;
  background: transparent;
  color: #e8e6df;
  font-family: inherit;
  font-size: 7px;
  padding: 6px 8px;
  outline: none;
  min-width: 0;
}
.mp-chat-form button {
  border: 0;
  background: rgba(255, 43, 214, 0.25);
  color: #ff9ae8;
  font-family: inherit;
  font-size: 7px;
  padding: 6px 8px;
  cursor: pointer;
}
body.quality-low #scanlines,
body.quality-low #vignette {
  opacity: 0.35;
}
body.quality-low .mp-chat {
  display: none !important;
}
@media (max-width: 700px) {
  .mp-chat {
    width: min(96vw, 320px);
    right: 2vw;
    bottom: 88px;
    max-height: 120px;
  }
}
.ladder-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 12px 0 10px;
  flex-wrap: wrap;
}
.ladder-tab {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(0, 240, 255, 0.4);
  background: rgba(0, 0, 0, 0.5);
  color: #e8e6df;
  cursor: pointer;
}
.ladder-tab.active {
  border-color: #ff2bd6;
  color: #ffe566;
  box-shadow: 0 0 10px rgba(255, 43, 214, 0.35);
}
.ladder-list {
  list-style: none;
  margin: 0;
  padding: 0 4px;
  max-height: min(42vh, 280px);
  overflow-y: auto;
  text-align: left;
  width: min(340px, 94%);
  margin-inline: auto;
}
.ladder-list li {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: #e8e6df;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(0, 240, 255, 0.12);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.ladder-list li .rank {
  color: #00f0ff;
  min-width: 1.8em;
}
.ladder-list li .sc {
  color: #b8ff3c;
}

/* Fullscreen / mobile immersive */
html.fs-mode,
html.fs-mode body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #000;
}
html.fs-mode #crt {
  width: 100%;
  height: 100%;
  max-width: none;
  border: none;
  border-radius: 0;
}
html.fs-mode #game-wrap {
  flex: 1 1 auto;
  min-height: 0;
}
html.fs-mode #game {
  width: 100% !important;
  height: 100% !important;
  max-height: none;
  object-fit: contain;
}
/* Touch always on for small screens / online */
@media (max-width: 900px), (pointer: coarse) {
  #touch-ui {
    opacity: 1 !important;
    pointer-events: none !important;
  }
  #touch-ui.inactive {
    opacity: 0 !important;
    visibility: hidden;
    pointer-events: none !important;
  }
  .desktop-hint {
    display: none;
  }
  #top-bar h1 {
    font-size: 11px;
  }
  #bottom-bar {
    font-size: 8px;
  }
  .touch-btn.jump,
  .touch-btn.fire {
    min-width: 88px;
    min-height: 88px;
    font-size: 12px;
  }
  #stick-base {
    width: 120px;
    height: 120px;
  }

  body.state-play #mod-bar,
  body.state-play #mod-hint,
  body.state-play #bottom-bar {
    display: none;
  }

  body.state-play #top-bar,
  body.state-play #obj-bar {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 42;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.38));
    backdrop-filter: blur(3px);
  }

  body.state-play #top-bar {
    top: 0;
    min-height: 38px;
  }

  body.state-play #obj-bar {
    top: 38px;
    min-height: 34px;
  }

  body.state-play #game-wrap {
    width: 100%;
    height: 100%;
    flex: 1 1 100%;
    padding: 0;
  }

  body.state-play #game {
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    max-height: none;
    border: 0;
    object-fit: contain;
  }

  body.state-play #overlay {
    inset: 0;
  }
}

@media (max-width: 600px) {
  #stick-base { width: 104px; height: 104px; }
  .touch-btn.jump { width: 72px; height: 72px; min-width: 72px; min-height: 72px; }
  .touch-btn.fire { width: 82px; height: 82px; min-width: 82px; min-height: 82px; }
  .dpad-fallback { display: none !important; }
}

@media (max-width: 700px) and (orientation: portrait) {
  body.state-play #rotate-hint {
    display: flex;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  #stick-base { width: 88px; height: 88px; }
  .touch-btn.jump { width: 68px; height: 68px; min-width: 68px; min-height: 68px; }
  .touch-btn.fire { width: 78px; height: 78px; min-width: 78px; min-height: 78px; }
}
#god-chip {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: #b8ff3c;
  border: 1px solid #b8ff3c;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.65);
  letter-spacing: 0.1em;
  pointer-events: none;
  display: none;
}
#god-chip.on { display: block; }
