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

:root {
  --bg-dark: #0d0d0d;
  --panel-bg: rgba(20, 15, 10, 0.85);
  --panel-border: rgba(255, 120, 40, 0.25);
  --lava-glow: #ff5500;
  --lava-orange: #ff8a00;
  --lava-red: #ff3300;
  --text-primary: #fff5e6;
  --text-muted: #aa9080;
  --accent: #ffaa44;
  --accent-hover: #ffcc66;
  --danger: #ff4444;
  --success: #44ffaa;
  --font: 'Outfit', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

canvas#gameCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

/* ─── Overlays ────────────────────────────────────────────── */
.overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at bottom, rgba(255,60,0,0.15) 0%, rgba(0,0,0,0.9) 70%);
  backdrop-filter: blur(6px);
}

.overlay.hidden { display: none; }

/* ─── Panel ───────────────────────────────────────────────── */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  min-width: 340px;
  max-width: 420px;
  text-align: center;
  box-shadow:
    0 0 60px rgba(255, 80, 0, 0.15),
    0 20px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 200, 100, 0.08);
  animation: panelAppear 0.4s ease-out;
}

@keyframes panelAppear {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Title ───────────────────────────────────────────────── */
.game-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 2px;
  margin-bottom: 2rem;
  color: var(--text-primary);
}

.game-title span {
  font-size: 2.8rem;
  background: linear-gradient(135deg, var(--lava-orange), var(--lava-red));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 16px rgba(255, 80, 0, 0.5));
}

/* ─── Inputs ──────────────────────────────────────────────── */
input[type="text"] {
  width: 100%;
  padding: 0.8rem 1rem;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 0.8rem;
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(255, 170, 68, 0.2);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

#roomCode {
  text-transform: uppercase;
  letter-spacing: 6px;
  text-align: center;
  font-size: 1.2rem;
  flex: 1;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--lava-orange), var(--lava-red));
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 80, 0, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(255, 80, 0, 0.5);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--accent);
}

/* ─── Divider ─────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.2rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

/* ─── Join Row ────────────────────────────────────────────── */
.join-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.join-row .btn { flex-shrink: 0; }
.join-row input { margin-bottom: 0; }

/* ─── Room ────────────────────────────────────────────────── */
.room-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.room-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.room-code {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(255, 170, 68, 0.4);
}

.player-list {
  list-style: none;
  margin-bottom: 1.5rem;
}

.player-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.3rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
}

.player-list li .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-list li .host-badge {
  margin-left: auto;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  background: rgba(255, 170, 68, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
}

.waiting-msg {
  color: var(--text-muted);
  font-size: 0.9rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ─── Lobby Sections ──────────────────────────────────────── */
.lobby-section { transition: opacity 0.3s; }
.lobby-section.hidden { display: none; }

/* ─── HUD ─────────────────────────────────────────────────── */
#hud {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  gap: 1.5rem;
}

#hud.hidden { display: none; }

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 1.2rem;
  background: rgba(20, 15, 10, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 120, 40, 0.2);
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(255, 80, 0, 0.1);
}

.hud-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.hud-item span:last-child {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
}

/* ─── Death Screen ────────────────────────────────────────── */
.death-panel h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  color: var(--danger);
}

.spectate-msg {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  animation: pulse 2s ease-in-out infinite;
}

/* ─── Game Over ───────────────────────────────────────────── */
.gameover-panel h2 {
  font-size: 1.8rem;
  margin-bottom: 0.8rem;
}

.gameover-panel p {
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.gameover-panel .btn {
  margin-top: 0.5rem;
  width: 100%;
}

/* ─── Hidden utility ──────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .panel { min-width: 0; margin: 1rem; padding: 1.5rem 1.2rem; }
  .game-title { font-size: 1.5rem; }
  .game-title span { font-size: 2rem; }
}
