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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0a0a0f;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #fff;
  user-select: none;
}

canvas#game {
  display: block;
  position: fixed;
  inset: 0;
  cursor: crosshair;
}

/* ── Top HUD ───────────────────────────────────────────── */
#hud-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 16px;
  pointer-events: none;
  z-index: 10;
}

#hud-title {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: #ff3355;
  text-shadow: 0 0 20px #ff335577;
}

#hud-left, #hud-right {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
#hud-right { align-items: flex-end; }

#timer {
  font-size: 1.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
#timer.urgent {
  color: #ef4444;
  animation: pulse 0.5s infinite alternate;
}

#alive-count {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

#my-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}
#kills-count {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
}

/* ── Bottom HUD: health bar ────────────────────────────── */
#hud-bottom {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(280px, 60vw);
  pointer-events: none;
  z-index: 10;
}

#hp-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  overflow: hidden;
}
#hp-fill {
  height: 100%;
  width: 100%;
  background: #4ade80;
  border-radius: 5px;
  transition: width 0.1s linear, background 0.3s;
}

/* ── Leaderboard ───────────────────────────────────────── */
#leaderboard {
  position: fixed;
  top: 68px;
  right: 12px;
  width: 185px;
  pointer-events: none;
  z-index: 10;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.38);
  margin-bottom: 2px;
}
.lb-row.me   { background: rgba(255, 255, 255, 0.13); font-weight: 700; }
.lb-row.dead { opacity: 0.4; }

.lb-rank  { width: 16px; color: rgba(255,255,255,0.4); font-size: 0.7rem; }
.lb-name  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-kills { min-width: 24px; text-align: right; color: rgba(255,255,255,0.6); }

/* ── Overlays ──────────────────────────────────────────── */
#connecting {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.88);
  font-size: 1.4rem;
  letter-spacing: 1px;
  z-index: 50;
}

#banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 10, 15, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 18px 44px;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  z-index: 40;
  animation: pop 0.25s ease;
}

#death-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.55);
  pointer-events: none;
  z-index: 30;
}
#death-box {
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(255, 50, 80, 0.35);
  border-radius: 14px;
  padding: 30px 52px;
  text-align: center;
}
#death-title {
  font-size: 2.1rem;
  font-weight: 800;
  color: #ef4444;
  margin-bottom: 10px;
}
#death-by {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 8px;
}
#death-hint {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.38);
}

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

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