*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:      #14142c;
  --panel:   #1a1a32;
  --border:  #2a2a4e;
  --cyan:    #00ffff;
  --magenta: #ff00ff;
  --text:    #e0e0f4;
  --dim:     #4a4a70;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url('/neonvs-bg.svg') center/cover no-repeat;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ──────────────────────────────────────────────── */

#lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

#game {
  display: none;
  position: relative;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}

#canvas {
  display: block;
  margin: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ── Lobby panel ─────────────────────────────────────────── */

.lobby-panel {
  background: rgba(20, 20, 44, 0.98);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.4rem 2.5rem 2rem;
  min-width: 360px;
  max-width: 520px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lobby-logo {
  display: block;
  max-width: 416px;
  width: 90%;
  margin: 0 auto 0.2rem;
  object-fit: contain;
}

/* ── Forms ───────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

input[type="text"] {
  flex: 1;
  background: #1d1d38;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]::placeholder {
  color: #7a7aa0;
}

input[type="text"]:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}

select {
  background: #1d1d38;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

button {
  background: transparent;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  color: var(--cyan);
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: rgba(0, 255, 255, 0.08);
  box-shadow: 0 0 8px var(--cyan);
}

/* VS-mode tint — applied to Create Room + Play vs CPU when NEON VS is selected */
button.btn-vs {
  border-color: var(--magenta);
  color: var(--magenta);
}

button.btn-vs:hover:not(:disabled) {
  background: rgba(255, 0, 255, 0.08);
  box-shadow: 0 0 8px var(--magenta);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Room list ───────────────────────────────────────────── */

.room-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 200px;
  overflow-y: auto;
}

.room-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #181830;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.75rem;
}

.room-name { flex: 1; font-weight: bold; }

.room-info {
  font-size: 0.8rem;
  color: var(--dim);
  white-space: nowrap;
}

.no-rooms {
  color: var(--dim);
  font-size: 0.85rem;
  text-align: center;
  padding: 0.5rem;
}

/* ── Open lobby bar ──────────────────────────────────────── */

.open-lobby-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 255, 255, 0.06);
  border: 1px solid var(--cyan);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.open-lobby-label {
  flex: 1;
  font-weight: bold;
  color: var(--cyan);
}

/* VS open lobby bar gets a pink/magenta tint */
.open-lobby-bar.ol-vs {
  background: rgba(255, 0, 200, 0.06);
  border-color: rgba(255, 0, 200, 0.55);
}

.open-lobby-bar.ol-vs .open-lobby-label {
  color: var(--magenta);
}

/* ── Mode selection cards ────────────────────────────────── */

.mode-cards {
  display: flex;
  gap: 0.5rem;
}

.mode-card {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.mode-card:hover {
  border-color: var(--cyan);
}

.mode-card.active {
  border-color: var(--cyan);
  background: rgba(0, 255, 255, 0.07);
  box-shadow: 0 0 8px var(--cyan);
}

.mode-card strong {
  display: block;
  color: var(--cyan);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

.mode-card span {
  font-size: 0.72rem;
  color: var(--dim);
}

.mode-card.active[data-mode="neonvs"] {
  border-color: var(--magenta);
  background: rgba(255, 0, 255, 0.07);
  box-shadow: 0 0 8px var(--magenta);
}

.mode-card.active[data-mode="neonvs"] strong {
  color: var(--magenta);
}

.mode-card:hover[data-mode="neonvs"]:not(.active) {
  border-color: var(--magenta);
}

/* ── Room mode tag ───────────────────────────────────────── */

.room-mode-tag {
  font-size: 0.65rem;
  padding: 0 0.3rem;
  border-radius: 3px;
}

.room-mode-tag.mode-neonvs {
  color: var(--magenta);
  border: 1px solid var(--magenta);
  text-shadow: 0 0 6px var(--magenta);
}

/* ── Create form ─────────────────────────────────────────── */

.create-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.create-form input { flex: 1; min-width: 120px; }

/* ── Practice bar ────────────────────────────────────────── */

.practice-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

#practice-btn {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 1rem;
  letter-spacing: 0.1em;
}

.practice-options {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* ── Player list (lobby + HUD) ───────────────────────────── */

.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.player-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.ready-tag {
  background: rgba(0,255,0,0.15);
  border: 1px solid #00ff00;
  color: #00ff00;
  font-size: 0.7rem;
  padding: 0 0.4rem;
  border-radius: 3px;
}

.player-list li.dead { opacity: 0.4; text-decoration: line-through; }

/* ── HUD overlay ─────────────────────────────────────────── */

#hud {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(20, 20, 44, 0.7);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  min-width: 140px;
  pointer-events: none;
  z-index: 10;
}

/* ── Countdown ───────────────────────────────────────────── */

.countdown {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 8rem;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 40px var(--cyan), 0 0 80px var(--cyan);
  animation: pulse 0.8s ease-out;
  pointer-events: none;
  z-index: 20;
}

@keyframes pulse {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1.4); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ── Audio control ───────────────────────────────────────── */

#audio-ctrl {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  background: rgba(20, 20, 44, 0.88);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  z-index: 100;
  backdrop-filter: blur(4px);
}

#audio-icon {
  display: none; /* hidden; track buttons replace it */
}

#track-btns {
  display: flex;
  gap: 0.3rem;
}

.track-btn {
  border: 1px solid var(--border);
  color: var(--dim);
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
  border-radius: 4px;
  min-width: 0;
  transition: all 0.15s;
}

.track-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0,255,255,0.06);
  box-shadow: none;
}

.track-btn.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0, 255, 255, 0.1);
  box-shadow: 0 0 6px var(--cyan);
}

#vol-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#vol-label {
  font-size: 0.7rem;
  color: var(--dim);
  user-select: none;
}

#vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
  cursor: pointer;
}

#vol-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
  cursor: pointer;
  border: none;
}

/* ── SFX toggles ─────────────────────────────────────────── */

#sfx-row {
  display: flex;
  gap: 0.3rem;
}

.sfx-toggle {
  border: 1px solid rgba(255, 60, 60, 0.7);
  color: rgba(255, 80, 80, 0.9);
  background: rgba(255, 60, 60, 0.08);
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  border-radius: 4px;
  min-width: 0;
  transition: all 0.15s;
}

.sfx-toggle:hover:not(.active) {
  background: rgba(255, 60, 60, 0.15);
  box-shadow: 0 0 6px rgba(255, 60, 60, 0.3);
}

.sfx-toggle.active {
  border-color: rgba(0, 210, 80, 0.8);
  color: rgba(0, 230, 80, 0.95);
  background: rgba(0, 210, 80, 0.1);
  box-shadow: 0 0 6px rgba(0, 210, 80, 0.4);
}

.sfx-toggle.active:hover {
  background: rgba(0, 210, 80, 0.18);
}

/* ── Mobile joystick ──────────────────────────────────────── */

#dpad {
  display: none;
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  pointer-events: auto;
}

#joystick-base {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(0, 255, 255, 0.07);
  border: 2px solid rgba(0, 255, 255, 0.35);
  box-shadow: 0 0 18px rgba(0, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

#joystick-knob {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(0, 255, 255, 0.25);
  border: 2px solid rgba(0, 255, 255, 0.8);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.5);
  pointer-events: none;
  transition: transform 0.05s ease-out;
  will-change: transform;
}

/* ── Mobile overrides (touch devices) ───────────────────── */

@media (hover: none) and (pointer: coarse) {
  :root {
    --text:   #e8e8ff;
    --dim:    #9090b8;
    --border: #5050a0;
  }

  /* Larger tap targets */
  button {
    padding: 0.65rem 1.1rem;
    font-size: 1rem;
  }

  input[type="text"], select {
    font-size: 1rem;
    padding: 0.65rem 0.75rem;
  }

  /* Move audio ctrl to top-right so it doesn't clash with D-pad */
  #audio-ctrl {
    bottom: auto;
    top: 0.5rem;
  }

  /* Exit button: small, top-left corner */
  #exit-btn {
    bottom: auto;
    top: 0.75rem;
    left: 0.75rem;
    font-size: 0.75rem;
    padding: 0.3rem 0.65rem;
    width: max-content;
    height: auto;
  }

  /* HUD moves to top-left below exit btn */
  #hud {
    top: 3.5rem;
    right: auto;
    left: 0.5rem;
  }

}

/* ── In-game exit button ─────────────────────────────────── */

#exit-btn {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  border-color: rgba(255, 0, 255, 0.5);
  color: rgba(255, 0, 255, 0.7);
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  width: max-content;
  height: auto;
  z-index: 15;
}

body.mobile #exit-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
}

#exit-btn:hover {
  border-color: var(--magenta);
  color: var(--magenta);
  background: rgba(255, 0, 255, 0.08);
  box-shadow: 0 0 8px var(--magenta);
}

/* ── Swap slot button (practice lobby) ──────────────────── */

.swap-btn {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  margin-left: 0.5rem;
  border: 1px solid var(--dim);
  color: var(--dim);
  background: transparent;
  border-radius: 3px;
  cursor: pointer;
  vertical-align: middle;
  transition: border-color 0.15s, color 0.15s;
}

.swap-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ── Lobby footer ───────────────────────────────────────── */

.lobby-footer {
  text-align: center;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.lobby-footer a {
  color: var(--dim);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  transition: color 0.15s;
}

.lobby-footer a:hover {
  color: var(--cyan);
}

/* ── Ping indicator ─────────────────────────────────────── */

#ping-display {
  display: none;
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  opacity: 0.65;
  z-index: 15;
  pointer-events: none;
}

/* ── Game over ───────────────────────────────────────────── */

.game-over {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 20;
  pointer-events: none;
}

.game-over h2 {
  font-size: 3.5rem;
  color: var(--cyan);
  text-shadow: 0 0 30px var(--cyan);
  margin-bottom: 0.5rem;
}

.game-over p { font-size: 1.2rem; margin: 0.25rem 0; }
.game-over .subtext { color: var(--dim); font-size: 0.9rem; margin-top: 1rem; }

.results-table {
  border-collapse: collapse;
  margin: 0.75rem auto;
  font-size: 1.05rem;
  min-width: 220px;
}
.results-table td {
  padding: 0.2rem 0.6rem;
  text-align: left;
}
.results-table td:first-child { text-align: right; opacity: 0.6; }
.results-table td:last-child  { text-align: right; opacity: 0.7; font-size: 0.9rem; }

/* ── Kill feed ───────────────────────────────────────────── */

#kill-feed {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 25;
  pointer-events: none;
  width: 260px;
}

#kill-feed ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kill-entry {
  background: rgba(10, 10, 30, 0.75);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.8rem;
  font-family: 'Courier New', monospace;
  opacity: 1;
  transition: opacity 0.6s ease;
}

.kill-entry.kf-fade { opacity: 0; }

.kf-arrow { color: #aaa; margin: 0 3px; }
.kf-eliminated { color: #888; font-style: italic; }

