/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0a0a1a;
  --surface:  rgba(10, 10, 30, 0.88);
  --border:   rgba(0, 255, 255, 0.25);
  --cyan:     #00ffff;
  --violet:   #8b00ff;
  --text:     #e0e0ff;
  --muted:    rgba(224, 224, 255, 0.5);
  --danger:   #ff4466;
  --success:  #00ff88;
  --font:     'Rajdhani', sans-serif;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Screens ──────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  transition: opacity 0.25s ease;
}
.screen.hidden { opacity: 0; pointer-events: none; }

/* Animated star/particle background for menus */
.screen::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(139,0,255,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(0,255,255,0.07) 0%, transparent 60%);
  pointer-events: none;
}

/* ── Card / Panel ─────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 40px;
  width: 420px;
  max-width: calc(100vw - 32px);
  backdrop-filter: blur(16px);
  box-shadow: 0 0 40px rgba(0, 255, 255, 0.08), 0 0 80px rgba(139,0,255,0.06);
}

.card-wide {
  width: 520px;
  max-width: calc(100vw - 32px);
}

/* ── Logo ─────────────────────────────────────────────────── */
.logo {
  text-align: center;
  margin-bottom: 28px;
}
.logo h1 {
  font-size: 3.2rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 18px rgba(0,255,255,0.45));
}
.logo p {
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* ── Form elements ────────────────────────────────────────── */
.field {
  margin-bottom: 18px;
}
.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0,255,255,0.2);
}
.field input::placeholder { color: rgba(255,255,255,0.2); }

/* Code input — large centered */
.field input.code-input {
  text-align: center;
  font-size: 1.8rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
}

/* ── Color picker ─────────────────────────────────────────── */
.color-section label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.color-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}
.color-dot {
  width: 100%; aspect-ratio: 1;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.selected {
  border-color: #fff;
  box-shadow: 0 0 10px currentColor;
  transform: scale(1.2);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  padding: 12px 20px;
  border-radius: 7px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  outline: none;
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #0088cc);
  color: #0a0a1a;
  box-shadow: 0 0 16px rgba(0,255,255,0.3);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 28px rgba(0,255,255,0.55); }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #aa0033);
  color: #fff;
  box-shadow: 0 0 16px rgba(255,68,102,0.3);
}
.btn-danger:hover:not(:disabled) { box-shadow: 0 0 28px rgba(255,68,102,0.55); }

.btn-violet {
  background: linear-gradient(135deg, var(--violet), #5500cc);
  color: #fff;
  box-shadow: 0 0 16px rgba(139,0,255,0.3);
}
.btn-violet:hover:not(:disabled) { box-shadow: 0 0 28px rgba(139,0,255,0.55); }

.btn-sm {
  width: auto;
  display: inline-block;
  padding: 7px 16px;
  font-size: 0.85rem;
}

.btn-group {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 8px;
}

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 0.8rem; margin: 18px 0;
}
.divider::before, .divider::after {
  content: ''; flex: 1;
  height: 1px; background: var(--border);
}

/* ── Error message ────────────────────────────────────────── */
.error-msg {
  background: rgba(255,68,102,0.12);
  border: 1px solid rgba(255,68,102,0.35);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--danger);
  margin-bottom: 14px;
  display: none;
}
.error-msg.visible { display: block; }

/* ── Lobby screen ─────────────────────────────────────────── */
.lobby-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.lobby-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
}

.room-code-box {
  background: rgba(0,255,255,0.06);
  border: 1px solid rgba(0,255,255,0.2);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.room-code-label {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.room-code-value {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan);
}

.player-list {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 18px;
}
.player-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  transition: background 0.15s;
}
.player-item:hover { background: rgba(255,255,255,0.04); }
.player-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.player-name {
  font-size: 1rem; font-weight: 600;
  flex: 1;
}
.player-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge-host { color: var(--cyan); border-color: var(--cyan); }
.badge-you  { color: var(--violet); border-color: var(--violet); }

.lobby-status {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 14px;
  animation: pulse-text 2s infinite;
}

/* ── Game HUD ─────────────────────────────────────────────── */
#hud {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 5;
  display: none;
}
#hud.visible { display: block; }

/* Score */
#score-display {
  position: absolute;
  top: 18px; left: 18px;
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  backdrop-filter: blur(8px);
}
#score-display .score-label {
  font-size: 0.7rem; color: var(--muted);
  letter-spacing: 0.12em; text-transform: uppercase;
}
#score-display .score-value {
  font-size: 1.8rem; font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan);
}

/* Leaderboard */
#leaderboard {
  position: absolute;
  top: 18px; right: 18px;
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 200px;
  backdrop-filter: blur(8px);
}
#leaderboard h3 {
  font-size: 0.72rem; font-weight: 700;
  color: var(--muted); letter-spacing: 0.12em;
  text-transform: uppercase; margin-bottom: 8px;
  text-align: center;
}
.lb-row {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0; font-size: 0.88rem;
}
.lb-rank  { width: 18px; color: var(--muted); font-size: 0.75rem; text-align: right; }
.lb-dot   { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.lb-name  { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { color: var(--cyan); font-weight: 700; font-size: 0.8rem; }
.lb-row.lb-me .lb-name { color: var(--cyan); }

/* Minimap */
#minimap-canvas {
  position: absolute;
  bottom: 18px; right: 18px;
  width: 130px; height: 130px;
  border-radius: 50%;
  border: 1px solid var(--border);
  box-shadow: 0 0 14px rgba(0,255,255,0.12);
}

/* ── Joystick (mobile) ────────────────────────────────────── */
#joystick {
  position: fixed;
  width: 124px; height: 124px;
  display: none;
  pointer-events: none;
  touch-action: none;
  transform: translate(-50%, -50%); /* centered on touch point */
}
#joystick.active { display: block; }

#joystick-base {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(0,255,255,0.18);
  background: rgba(0,255,255,0.04);
}

#joystick-knob {
  position: absolute;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(0,255,255,0.15);
  border: 2px solid rgba(0,255,255,0.35);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 10px rgba(0,255,255,0.15);
}

/* Boost indicator */
#boost-btn {
  position: absolute;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  pointer-events: all;
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  background: rgba(0,255,255,0.08);
  color: var(--cyan);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  text-align: center;
  line-height: 1.2;
  box-shadow: 0 0 16px rgba(0,255,255,0.2);
  transition: background 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#boost-btn.touch-visible { display: flex; }
#boost-btn.active {
  background: rgba(0,255,255,0.25);
  box-shadow: 0 0 28px rgba(0,255,255,0.5);
}

/* Kill notification */
#kill-notif {
  position: absolute;
  top: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(0,255,136,0.15);
  border: 1px solid var(--success);
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 0.9rem; font-weight: 600;
  color: var(--success);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}
#kill-notif.show { opacity: 1; }

/* ── Death overlay ────────────────────────────────────────── */
#death-screen {
  position: fixed; inset: 0;
  background: rgba(5, 5, 20, 0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
  backdrop-filter: blur(6px);
  display: none;
}
#death-screen.visible { display: flex; }
.death-card {
  background: var(--surface);
  border: 1px solid rgba(255,68,102,0.4);
  border-radius: 14px;
  padding: 40px 44px;
  text-align: center;
  box-shadow: 0 0 40px rgba(255,68,102,0.15);
  max-width: 360px; width: calc(100vw - 32px);
}
.death-title {
  font-size: 2.4rem; font-weight: 700;
  color: var(--danger);
  text-shadow: 0 0 20px var(--danger);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.death-killed-by {
  font-size: 0.9rem; color: var(--muted);
  margin-bottom: 20px;
}
.death-killed-by span { color: #fff; font-weight: 600; }
.death-score {
  font-size: 1rem; color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.death-score-value {
  font-size: 2.8rem; font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 16px var(--cyan);
  margin-bottom: 24px;
  display: block;
}
.death-leaderboard {
  text-align: left;
  margin-bottom: 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.death-leaderboard h4 {
  font-size: 0.72rem; color: var(--muted);
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 8px;
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card { animation: fade-in 0.3s ease; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,255,255,0.2); border-radius: 2px; }

/* ── Canvas (PixiJS) ──────────────────────────────────────── */
#game-canvas {
  position: fixed; inset: 0;
  display: none;
}
#game-canvas.visible { display: block; }
