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

:root {
  --color-bg: #18110b;
  --color-bg-deep: #0d0906;
  --color-surface: rgba(36, 26, 18, 0.82);
  --color-surface-strong: rgba(22, 16, 11, 0.92);
  --color-panel: rgba(58, 42, 30, 0.72);
  --color-panel-soft: rgba(78, 57, 42, 0.48);
  --color-border: rgba(219, 184, 131, 0.18);
  --color-accent: #d8b36f;
  --color-accent-strong: #bb7a3f;
  --color-accent-cool: #cbb594;
  --color-danger: #ff7b6e;
  --color-text: #f3eadf;
  --color-muted: #b09d89;
  --color-muted-strong: #d7c5af;
  --font-display: 'Rajdhani', sans-serif;
  --font-main: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 10px;
  --radius-lg: 18px;
  --shadow-soft: 0 20px 60px rgba(0, 0, 0, 0.28);
  --shadow-strong: 0 30px 80px rgba(0, 0, 0, 0.42);
}

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

body {
  letter-spacing: 0.01em;
}

button,
input {
  font: inherit;
}

/* ============================================================
   Screens
   ============================================================ */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}

.screen.active {
  display: flex;
}

.screen-noise,
.screen-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.screen-noise {
  opacity: 0.07;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.25) 0 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px),
    radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px);
  background-size: 120px 120px, 160px 160px, 180px 180px;
  mix-blend-mode: screen;
}

.screen-grid {
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(216, 179, 111, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(216, 179, 111, 0.08) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 1), transparent 82%);
}

.screen-kicker {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--color-accent-cool);
}

.screen-copy {
  max-width: 32rem;
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--color-muted-strong);
  text-align: center;
}

/* ============================================================
   Auth & Lobby
   ============================================================ */
#auth-screen,
#lobby-screen {
  background:
    radial-gradient(circle at 20% 20%, rgba(216, 179, 111, 0.2), transparent 28%),
    radial-gradient(circle at 80% 18%, rgba(143, 114, 83, 0.18), transparent 26%),
    radial-gradient(circle at 50% 100%, rgba(187, 122, 63, 0.16), transparent 34%),
    linear-gradient(180deg, #1a130d 0%, #20160f 45%, #0d0906 100%);
}

.auth-container,
.lobby-container {
  position: relative;
  z-index: 1;
  width: min(100%, 540px);
  padding: 2.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(55, 40, 28, 0.9) 0%, rgba(25, 18, 13, 0.94) 100%);
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(16px);
}

.game-title {
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 700;
  letter-spacing: 0.24em;
  line-height: 0.95;
  text-transform: uppercase;
  color: var(--color-accent);
  text-shadow:
    0 0 24px rgba(216, 179, 111, 0.22),
    0 0 48px rgba(187, 122, 63, 0.12);
}

.auth-tabs {
  width: 100%;
  display: flex;
  padding: 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: rgba(17, 12, 8, 0.58);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.tab-btn {
  flex: 1;
  padding: 0.72rem 1rem;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--color-muted);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-strong) 100%);
  color: #10202a;
  box-shadow: 0 10px 24px rgba(248, 157, 77, 0.22);
}

.tab-btn:hover:not(.active) {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.04);
}

.auth-form {
  width: 100%;
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.auth-form.active {
  display: flex;
}

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

.form-group label {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.form-group input {
  padding: 0.92rem 1rem;
  background: rgba(3, 10, 16, 0.72);
  border: 1px solid rgba(126, 224, 213, 0.14);
  border-radius: 14px;
  color: var(--color-text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.form-group input:focus {
  border-color: rgba(248, 201, 92, 0.68);
  box-shadow: 0 0 0 4px rgba(248, 201, 92, 0.1);
  background: rgba(6, 14, 21, 0.84);
}

.form-error,
.lobby-error {
  min-height: 1.3em;
  font-size: 0.9rem;
  color: var(--color-danger);
  text-align: center;
}

.btn-primary,
.btn-secondary {
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.16s ease, border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.btn-primary {
  padding: 0.88rem 1.6rem;
  border: none;
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-strong) 100%);
  color: #11212a;
  box-shadow: 0 14px 30px rgba(248, 157, 77, 0.22);
}

.btn-primary:hover {
  opacity: 0.94;
  transform: translateY(-1px);
}

.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.985);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 0.72rem 1.35rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--color-border);
  color: var(--color-muted-strong);
}

.btn-secondary:hover {
  border-color: rgba(248, 201, 92, 0.42);
  color: var(--color-accent);
}

.player-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1.3rem;
  padding: 1.4rem;
  border: 1px solid var(--color-border);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(13, 27, 39, 0.9), rgba(7, 16, 24, 0.88));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.player-avatar {
  flex-shrink: 0;
  width: 78px;
  height: 78px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 30% 30%, rgba(126, 224, 213, 0.25), transparent 60%),
    linear-gradient(180deg, rgba(248, 201, 92, 0.18), rgba(248, 157, 77, 0.06));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.player-info {
  flex: 1;
  min-width: 0;
}

.player-info h2 {
  margin-bottom: 0.75rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.stat {
  padding: 0.75rem 0.8rem;
  border: 1px solid rgba(126, 224, 213, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.stat-label {
  display: block;
  margin-bottom: 0.22rem;
  font-family: var(--font-display);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-muted);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--color-text);
}

.btn-large {
  width: 100%;
  padding: 1rem 1.2rem;
  font-size: 1.1rem;
  letter-spacing: 0.22em;
}

/* ============================================================
   Game Screen
   ============================================================ */
#game-screen {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 204, 128, 0.16), transparent 35%),
    linear-gradient(180deg, #b8dff2 0%, #7499b3 100%);
  touch-action: none;
  overscroll-behavior: none;
}

#game-screen::before,
#game-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#game-screen::before {
  z-index: 1;
  background:
    radial-gradient(circle at 76% 18%, rgba(255, 218, 144, 0.22), transparent 18%),
    linear-gradient(180deg, rgba(255, 214, 148, 0.08), transparent 34%),
    radial-gradient(ellipse at center, transparent 44%, rgba(36, 21, 10, 0.2) 100%);
  mix-blend-mode: soft-light;
}

#game-screen::after {
  z-index: 2;
  opacity: 0.18;
  background-image:
    linear-gradient(115deg, transparent 0 34%, rgba(255, 235, 175, 0.12) 42%, transparent 52%),
    linear-gradient(103deg, transparent 0 48%, rgba(255, 235, 175, 0.08) 54%, transparent 62%);
  transform: translateX(-18%);
  animation: sunshaft-drift 12s ease-in-out infinite alternate;
}

@keyframes sunshaft-drift {
  from { transform: translateX(-20%) skewX(-3deg); opacity: 0.12; }
  to   { transform: translateX(-8%) skewX(2deg); opacity: 0.22; }
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#asset-loading {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(4, 10, 14, 0.62);
  backdrop-filter: blur(4px);
}

#asset-loading.hidden {
  display: none;
}

.asset-loading-card {
  width: min(92vw, 420px);
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid rgba(126, 224, 213, 0.24);
  background: linear-gradient(180deg, rgba(8, 19, 26, 0.94), rgba(5, 13, 19, 0.95));
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
}

.asset-loading-title {
  margin-bottom: 0.55rem;
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted-strong);
}

.asset-loading-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(126, 224, 213, 0.18);
  background: rgba(255, 255, 255, 0.05);
}

.asset-loading-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent-cool), var(--color-accent));
  transition: width 120ms ease;
}

.asset-loading-text {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--color-text);
}

/* ============================================================
   HUD
   ============================================================ */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
  z-index: 3;
}

.hud-vignette,
.hud-noise,
#hud-hit-flash {
  position: absolute;
  inset: 0;
}

.hud-vignette {
  background:
    radial-gradient(circle at center, transparent 34%, rgba(4, 8, 13, 0.28) 100%),
    radial-gradient(circle at 78% 16%, rgba(255, 208, 124, 0.14), transparent 18%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.3), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.22));
}

.hud-noise {
  opacity: 0.05;
  mix-blend-mode: soft-light;
  background-image:
    linear-gradient(transparent 50%, rgba(255, 255, 255, 0.16) 50%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 22%, rgba(255, 255, 255, 0.06));
  background-size: 100% 3px, 240px 100%;
}

#hud-hit-flash {
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 30%, rgba(180, 0, 0, 0.55) 80%, rgba(120, 0, 0, 0.7) 100%);
  transition: opacity 0.08s ease-out;
}

#hud-hit-flash.active {
  opacity: 1;
  animation: damage-pulse 0.22s ease-out;
}

@keyframes damage-pulse {
  0%   { opacity: 1; transform: scale(1.02); }
  40%  { opacity: 0.85; }
  100% { opacity: 0; transform: scale(1); }
}

#hud-lives {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  gap: 0.45rem;
}

.life-pip {
  width: 18px;
  height: 18px;
  clip-path: polygon(50% 100%, 0 50%, 18% 14%, 50% 30%, 82% 14%, 100% 50%);
  background: linear-gradient(180deg, #ffe6a8 0%, #ff8f70 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 0 12px rgba(255, 123, 110, 0.38);
}

.life-pip.empty {
  opacity: 0.2;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

#hud-players,
#hud-ping {
  position: absolute;
  top: 66px;
  padding: 0.42rem 0.76rem;
  border: 1px solid rgba(126, 224, 213, 0.14);
  border-radius: 999px;
  background: rgba(5, 14, 20, 0.48);
  backdrop-filter: blur(8px);
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted-strong);
}

#hud-players {
  left: 20px;
}

#hud-ping {
  right: 20px;
}

#hud-ping.ping-good {
  color: var(--color-accent-cool);
}

#hud-ping.ping-warn {
  color: var(--color-accent);
}

#hud-ping.ping-bad {
  color: var(--color-danger);
}

#scoreboard {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 280px;
  max-width: min(92vw, 700px);
  padding: 0.72rem 0.9rem;
  border: 1px solid rgba(126, 224, 213, 0.14);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(9, 18, 25, 0.84), rgba(8, 14, 20, 0.72));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  display: none;
}

#scoreboard.visible {
  display: block;
}

#scoreboard .sb-list {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 0.18rem;
}

#scoreboard .sb-header,
#scoreboard .sb-row {
  display: grid;
  grid-template-columns: 1fr 52px 52px;
  gap: 0.45rem;
  align-items: center;
}

#scoreboard .sb-header {
  padding-bottom: 0.35rem;
  margin-bottom: 0.18rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#scoreboard .sb-header span {
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-muted);
  text-align: center;
}

#scoreboard .sb-header span:first-child,
#scoreboard .sb-name {
  text-align: left;
}

#scoreboard .sb-row {
  padding: 0.24rem 0.12rem;
  border-radius: 10px;
}

#scoreboard .sb-row.local {
  background: rgba(248, 201, 92, 0.1);
  color: var(--color-accent);
}

#scoreboard .sb-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#scoreboard .sb-val {
  font-size: 0.86rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-align: center;
}

#kill-feed {
  position: absolute;
  top: 74px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: flex-end;
  min-width: 250px;
  max-width: 340px;
}

.kill-entry {
  padding: 0.46rem 0.82rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--color-accent);
  border-radius: 14px;
  background: rgba(8, 17, 25, 0.74);
  backdrop-filter: blur(10px);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--color-text);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
  animation: fadeInRight 0.22s ease;
  white-space: nowrap;
}

.kill-entry .killer { color: var(--color-accent); }
.kill-entry .victim { color: var(--color-danger); }

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  transform: translate(-50%, -50%);
  transition: transform 0.12s ease;
}

#crosshair.pulse {
  transform: translate(-50%, -50%) scale(1.5);
}

/* Muzzle flash overlay */
#muzzle-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 220px;
  height: 220px;
  transform: translate(-50%, -50%) scale(0);
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 249, 208, 0.88) 0%,
    rgba(255, 198, 82, 0.48) 20%,
    rgba(255, 104, 38, 0.2) 44%,
    transparent 70%
  );
  filter: blur(0.5px);
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}

#muzzle-flash.active {
  animation: muzzle-burst 0.1s ease-out forwards;
}

@keyframes muzzle-burst {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.3); }
  50%  { opacity: 0.8; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); }
}

/* Screen shake on shoot */
#hud.shooting {
  animation: screen-shake 0.08s ease-out;
}

@keyframes screen-shake {
  0%   { transform: translateY(0); }
  25%  { transform: translateY(-3px); }
  50%  { transform: translateY(1px); }
  100% { transform: translateY(0); }
}

#crosshair.confirm {
  transform: translate(-50%, -50%) scale(0.94);
}

.ch-ring,
.ch-dot,
.ch-h,
.ch-v {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.ch-ring {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 230, 168, 0.34);
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(45, 25, 10, 0.35),
    0 0 18px rgba(255, 180, 90, 0.18);
}

.ch-h,
.ch-v {
  background: rgba(255, 243, 210, 0.9);
  box-shadow:
    0 0 1px rgba(40, 20, 8, 0.8),
    0 0 8px rgba(255, 186, 80, 0.24);
}

.ch-h {
  width: 16px;
  height: 2px;
}

.ch-v {
  width: 2px;
  height: 16px;
}

.ch-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
}

#crosshair.confirm .ch-ring {
  border-color: rgba(248, 201, 92, 0.75);
  box-shadow: 0 0 22px rgba(248, 201, 92, 0.32);
}

#frozen-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(120, 210, 255, 0.1), rgba(20, 54, 90, 0.76) 45%, rgba(4, 14, 22, 0.9) 100%);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}

#frozen-overlay.hidden {
  display: none;
}

.frozen-content {
  min-width: min(88vw, 420px);
  padding: 2rem 2.3rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid rgba(126, 224, 213, 0.18);
  border-radius: 26px;
  background: rgba(5, 18, 28, 0.72);
  box-shadow: var(--shadow-strong);
}

.frozen-icon {
  font-size: 4rem;
  animation: pulse 1.5s ease-in-out infinite;
}

.frozen-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.26em;
  color: var(--color-accent-cool);
  text-shadow: 0 0 30px rgba(126, 224, 213, 0.35);
}

.frozen-sub {
  font-family: var(--font-display);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-muted);
}

.frozen-timer {
  font-size: 3rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #fff;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.84; }
}

/* ── Radar ── */
#radar {
  position: absolute;
  bottom: 22px;
  right: 20px;
  width: 120px;
  height: 120px;
  pointer-events: none;
  z-index: 10;
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(126, 224, 213, 0.12),
    0 4px 18px rgba(0, 0, 0, 0.45);
}

#radar canvas {
  display: block;
  border-radius: 50%;
}

#chat-container {
  position: absolute;
  left: 20px;
  bottom: 22px;
  z-index: 4;
  width: min(420px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

#chat-feed {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: none;
}

#chat-feed::-webkit-scrollbar {
  display: none;
}

.chat-entry {
  padding: 0.5rem 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(7, 17, 24, 0.68);
  backdrop-filter: blur(8px);
  font-size: 0.94rem;
  line-height: 1.4;
  animation: fadeInChat 0.16s ease;
}

.chat-sender {
  font-weight: 700;
  color: var(--color-accent-cool);
}

.chat-text {
  color: var(--color-text);
  word-break: break-word;
}

#chat-input {
  padding: 0.82rem 1rem;
  background: rgba(5, 14, 20, 0.8);
  border: 1px solid rgba(126, 224, 213, 0.18);
  border-radius: 16px;
  color: var(--color-text);
  font-size: 0.96rem;
  outline: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

#chat-input.visible {
  opacity: 1;
  pointer-events: auto;
}

#chat-input:focus {
  border-color: rgba(248, 201, 92, 0.52);
  box-shadow: 0 0 0 4px rgba(248, 201, 92, 0.08);
}

@keyframes fadeInChat {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

#pointer-lock-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at center, rgba(255, 194, 112, 0.1), transparent 26%),
    rgba(2, 8, 12, 0.7);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  z-index: 10;
  animation: fadeInPrompt 0.22s ease;
}

#pointer-lock-prompt.hidden {
  display: none;
}

@keyframes fadeInPrompt {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.prompt-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.15rem;
  width: min(92vw, 680px);
  padding: 2.3rem;
  border: 1px solid rgba(248, 201, 92, 0.14);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(11, 23, 34, 0.9), rgba(7, 14, 21, 0.94));
  box-shadow: var(--shadow-strong);
}

.prompt-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.9rem);
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--color-accent);
  text-shadow: 0 0 28px rgba(248, 201, 92, 0.16);
}

.prompt-subtitle {
  font-size: 0.96rem;
  color: var(--color-muted-strong);
  letter-spacing: 0.04em;
  margin-top: -0.6rem;
}

.controls-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.4rem;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 48px;
  padding: 0.72rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
}

.control-label {
  font-size: 0.92rem;
  color: var(--color-text);
  font-weight: 500;
}

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom-width: 3px;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(51, 76, 92, 0.45), rgba(16, 31, 42, 0.92));
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.key.wide {
  min-width: 64px;
}

.key-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.key-row {
  display: flex;
  gap: 4px;
}

.key-icon {
  font-size: 1.75rem;
  line-height: 1;
  filter: saturate(0) brightness(1.65);
}

.controls-section-label {
  align-self: flex-start;
  margin-top: 0.25rem;
  margin-bottom: -0.45rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-accent-cool);
}

/* ============================================================
   Username labels
   ============================================================ */
.player-label {
  position: absolute;
  pointer-events: none;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff9e8;
  background:
    linear-gradient(180deg, rgba(8, 18, 26, 0.82), rgba(8, 18, 26, 0.58));
  border: 1px solid rgba(248, 201, 92, 0.16);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  transform: translateX(-50%);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  display: none;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }

  #scoreboard {
    top: 88px;
  }
}

@media (max-width: 640px) {
  .auth-container,
  .lobby-container {
    width: calc(100% - 24px);
    padding: 1.4rem;
    border-radius: 22px;
  }

  .screen-copy {
    font-size: 0.9rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  #hud-lives {
    top: 14px;
    left: 14px;
  }

  #hud-players,
  #hud-ping {
    top: 52px;
    font-size: 0.74rem;
  }

  #hud-players {
    left: 14px;
  }

  #hud-ping {
    right: 14px;
  }

  #scoreboard {
    top: 86px;
    width: calc(100vw - 28px);
    min-width: 0;
  }

  #kill-feed {
    top: auto;
    right: 14px;
    bottom: 150px;
    max-width: calc(100vw - 28px);
  }

  #chat-container {
    left: 14px;
    bottom: 14px;
    width: calc(100vw - 28px);
  }

  .prompt-card {
    padding: 1.4rem;
  }
}

/* ============================================================
   Mobile Controls
   ============================================================ */

/* Hide mobile elements by default */
#mobile-joystick,
#mobile-look-area,
#mobile-shoot-btn,
#mobile-jump-btn,
#mobile-chat-btn,
#mobile-pause-btn {
  display: none;
}

/* Only show on mobile */
.is-mobile #mobile-joystick,
.is-mobile #mobile-look-area,
.is-mobile #mobile-shoot-btn,
.is-mobile #mobile-jump-btn,
.is-mobile #mobile-chat-btn,
.is-mobile #mobile-pause-btn {
  display: block;
}

/* Hide desktop-only elements on mobile */
.is-mobile #pointer-lock-prompt .controls-grid,
.is-mobile #pointer-lock-prompt .controls-section-label {
  display: none;
}

.is-mobile #pointer-lock-prompt .prompt-subtitle {
  content: '';
}

.is-mobile #pointer-lock-prompt .prompt-subtitle::after {
  content: 'Tap anywhere to resume';
}

/* Joystick */
#mobile-joystick {
  position: absolute;
  left: 20px;
  bottom: 100px;
  width: 140px;
  height: 140px;
  z-index: 20;
  pointer-events: auto;
  touch-action: none;
}

.joy-base {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(126, 224, 213, 0.08), rgba(8, 17, 24, 0.5));
  border: 2px solid rgba(126, 224, 213, 0.25);
  box-shadow: 0 0 20px rgba(126, 224, 213, 0.1);
}

.joy-stick {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(248, 201, 92, 0.6), rgba(248, 157, 77, 0.4));
  border: 2px solid rgba(248, 201, 92, 0.5);
  box-shadow:
    0 0 16px rgba(248, 201, 92, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Look area */
#mobile-look-area {
  position: absolute;
  top: 0;
  right: 0;
  width: 55%;
  height: 60%;
  z-index: 15;
  pointer-events: auto;
  touch-action: none;
}

/* Shoot button */
#mobile-shoot-btn {
  position: absolute;
  right: 24px;
  bottom: 100px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 2px solid rgba(255, 123, 110, 0.5);
  background: radial-gradient(circle at 35% 35%, rgba(255, 123, 110, 0.45), rgba(200, 60, 50, 0.35));
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  pointer-events: auto;
  touch-action: none;
  z-index: 20;
  box-shadow:
    0 0 24px rgba(255, 123, 110, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

#mobile-shoot-btn:active {
  background: radial-gradient(circle at 35% 35%, rgba(255, 123, 110, 0.7), rgba(200, 60, 50, 0.6));
  transform: scale(0.93);
}

/* Jump button */
#mobile-jump-btn {
  position: absolute;
  right: 130px;
  bottom: 110px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(126, 224, 213, 0.4);
  background: radial-gradient(circle at 35% 35%, rgba(126, 224, 213, 0.35), rgba(80, 180, 170, 0.25));
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: auto;
  touch-action: none;
  z-index: 20;
  box-shadow:
    0 0 16px rgba(126, 224, 213, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

#mobile-jump-btn:active {
  background: radial-gradient(circle at 35% 35%, rgba(126, 224, 213, 0.6), rgba(80, 180, 170, 0.5));
  transform: scale(0.93);
}

/* Chat button */
#mobile-chat-btn {
  position: absolute;
  left: 20px;
  bottom: 54px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(126, 224, 213, 0.25);
  background: rgba(8, 17, 24, 0.6);
  color: var(--color-muted-strong);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: auto;
  touch-action: none;
  z-index: 20;
  backdrop-filter: blur(6px);
}

/* Pause button */
#mobile-pause-btn {
  position: absolute;
  top: 16px;
  right: 60px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(126, 224, 213, 0.2);
  background: rgba(8, 17, 24, 0.55);
  color: var(--color-muted-strong);
  font-size: 1.2rem;
  line-height: 1;
  pointer-events: auto;
  touch-action: none;
  z-index: 20;
  backdrop-filter: blur(6px);
}

/* Adjust HUD layout on mobile to avoid control overlap */
.is-mobile #kill-feed {
  top: auto;
  right: 14px;
  bottom: 210px;
  max-width: 220px;
}

.is-mobile #chat-container {
  left: 14px;
  bottom: 250px;
  width: calc(100vw - 28px);
}

.is-mobile #hud-lives {
  top: 14px;
  left: 14px;
}

.is-mobile #scoreboard {
  top: 4px;
  max-width: min(50vw, 240px);
  padding: 0.2rem 0.4rem;
  border-radius: 8px;
  opacity: 0.85;
}

.is-mobile #scoreboard .sb-header,
.is-mobile #scoreboard .sb-row {
  grid-template-columns: 1fr 26px 26px;
  gap: 0.15rem;
}

.is-mobile #scoreboard .sb-header span {
  font-size: 0.46rem;
  letter-spacing: 0.05em;
}

.is-mobile #scoreboard .sb-name {
  font-size: 0.52rem;
}

.is-mobile #scoreboard .sb-val {
  font-size: 0.48rem;
}

.is-mobile #scoreboard .sb-row {
  padding: 0.08rem 0.05rem;
  border-radius: 4px;
}

.is-mobile #scoreboard .sb-header {
  padding-bottom: 0.15rem;
  margin-bottom: 0.08rem;
}

.is-mobile #scoreboard .sb-list {
  gap: 0.05rem;
}

.is-mobile #hud-players,
.is-mobile #hud-ping {
  top: 4px;
  padding: 0.15rem 0.35rem;
  font-size: 0.5rem;
  letter-spacing: 0.04em;
}

.is-mobile #hud-players {
  left: 6px;
}

.is-mobile #hud-ping {
  right: 6px;
}

.is-mobile #radar {
  width: 80px;
  height: 80px;
  bottom: 10px;
  right: 10px;
}

.is-mobile #crosshair {
  /* Keep crosshair visible on mobile */
  pointer-events: none;
}

/* Prevent text selection and callout on mobile controls */
.is-mobile #game-screen {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
