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

:root {
  --ct: #4a9eff;
  --ct-dark: #1a3a6e;
  --t: #e8a838;
  --t-dark: #6e4a1a;
  --bg: #0a0e14;
  --panel: rgba(12, 18, 28, 0.92);
  --text: #c8d6e5;
  --accent: #00ff88;
  --danger: #ff4757;
  --mono: 'Share Tech Mono', monospace;
  --display: 'Rajdhani', sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--display);
  cursor: crosshair;
  user-select: none;
}

.hidden { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lobby-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(74, 158, 255, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(232, 168, 56, 0.08) 0%, transparent 60%),
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,0.02) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,0.02) 40px),
    var(--bg);
}

.lobby-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem;
  max-width: 560px;
  width: 100%;
}

.logo {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.logo-duel {
  font-size: 4rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--ct);
  text-shadow: 0 0 40px rgba(74, 158, 255, 0.5);
}

.logo-shooter {
  font-size: 4rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--t);
  text-shadow: 0 0 40px rgba(232, 168, 56, 0.5);
}

.tagline {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: rgba(200, 214, 229, 0.5);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 2.5rem;
}

.join-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

#playerName {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  letter-spacing: 0.05em;
  outline: none;
  transition: border-color 0.2s;
}

#playerName:focus {
  border-color: var(--accent);
}

#joinBtn {
  background: var(--accent);
  color: #0a0e14;
  border: none;
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

#joinBtn:hover { opacity: 0.85; }
#joinBtn:active { transform: scale(0.97); }
#joinBtn:disabled { opacity: 0.4; cursor: not-allowed; }

.lobby-status {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: rgba(200, 214, 229, 0.45);
  margin-bottom: 2rem;
  min-height: 1.2em;
}

.controls-info {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.25rem;
  text-align: left;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 1.25rem 1.5rem;
}

.control-col h3 {
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(200, 214, 229, 0.4);
  margin-bottom: 0.75rem;
}

.control-col p {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: rgba(200, 214, 229, 0.65);
  margin-bottom: 0.35rem;
}

kbd {
  display: inline-block;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-family: var(--mono);
  font-size: 0.72rem;
  margin-right: 0.25rem;
  color: var(--text);
}

.pu-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
  box-shadow: 0 0 8px currentColor;
}

.pu-dot.rapid { background: #ff4757; color: #ff4757; }
.pu-dot.power { background: #b44dff; color: #b44dff; }

.buff-indicator {
  position: absolute;
  bottom: 5.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.65);
  font-family: var(--mono);
  animation: buffPulse 1s infinite;
}

.buff-indicator.rapid { border-color: #ff4757; color: #ff6b7a; }
.buff-indicator.power { border-color: #b44dff; color: #d080ff; }

#buffLabel {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  font-weight: 700;
}

#buffTimer {
  font-size: 1.1rem;
  font-weight: 700;
}

@keyframes buffPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

#gameScreen {
  display: block;
}

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  position: fixed;
  inset: 0;
  z-index: 1;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.5rem;
}

.scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 0.5rem 2rem;
  max-width: 420px;
  margin: 0 auto;
}

.team-score {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.team-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.ct-score .team-label { color: var(--ct); }
.t-score .team-label { color: var(--t); }

.score-num {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--mono);
  line-height: 1;
}

.ct-score .score-num { color: var(--ct); }
.t-score .score-num { color: var(--t); }

.round-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 80px;
}

#roundNum {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: rgba(200,214,229,0.45);
}

.timer {
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--text);
}

.timer.warning { color: var(--danger); }

.kill-feed {
  position: absolute;
  top: 4.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-end;
}

.kill-entry {
  background: rgba(0,0,0,0.6);
  border-left: 2px solid var(--danger);
  padding: 0.25rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  animation: fadeIn 0.2s ease;
}

.kill-entry.headshot { border-left-color: #ffd700; }
.kill-entry .killer { color: var(--accent); }
.kill-entry .victim { color: var(--danger); }

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

.hud-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

.player-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.team-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  padding: 0.2rem 0.5rem;
  border: 1px solid;
}

.team-badge.ct { color: var(--ct); border-color: var(--ct); }
.team-badge.t { color: var(--t); border-color: var(--t); }

#playerNameHud {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.hud-bottom.fps-hud {
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
}

.health-armor {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 280px;
}

#healthText {
  position: absolute;
  top: -1.2rem;
  left: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.health-bar-wrap {
  position: relative;
  width: 100%;
  height: 10px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
}

.focus-hint {
  z-index: 5;
}

.health-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.15s, background 0.3s;
  width: 100%;
}

.health-bar.low { background: var(--danger); }
.health-bar.mid { background: var(--t); }

.ammo {
  text-align: right;
  font-family: var(--mono);
}

.ammo-mag {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.ammo-sep {
  color: rgba(200,214,229,0.3);
  margin: 0 0.2rem;
}

#ammoReserve {
  font-size: 1rem;
  color: rgba(200,214,229,0.45);
}

.reload {
  display: block;
  font-size: 0.7rem;
  color: var(--t);
  letter-spacing: 0.15em;
  margin-top: 0.2rem;
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.phase-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  pointer-events: none;
  animation: fadeOut 2s forwards;
}

.phase-overlay h2 {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-shadow: 0 0 30px rgba(0,255,136,0.4);
}

.phase-overlay p {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: rgba(200,214,229,0.6);
  margin-top: 0.5rem;
}

@keyframes fadeOut {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

.match-end {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.8);
  gap: 1.5rem;
  pointer-events: all;
}

.match-end h1 {
  font-size: 4rem;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.match-end h1.ct-win { color: var(--ct); text-shadow: 0 0 50px rgba(74,158,255,0.6); }
.match-end h1.t-win { color: var(--t); text-shadow: 0 0 50px rgba(232,168,56,0.6); }

#rematchBtn {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  padding: 0.75rem 2rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#rematchBtn:hover {
  background: var(--accent);
  color: #0a0e14;
}

.chat-box {
  position: fixed;
  bottom: 5rem;
  left: 1.5rem;
  width: 280px;
  pointer-events: all;
  z-index: 4;
}

#chatMessages {
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.chat-msg {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: rgba(200,214,229,0.55);
  line-height: 1.4;
}

#chatInput {
  width: 100%;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.4rem 0.6rem;
  outline: none;
  opacity: 0;
  transition: opacity 0.2s;
}

#chatInput:focus,
.chat-box:hover #chatInput {
  opacity: 1;
}

#chatInput:focus {
  border-color: rgba(255,255,255,0.25);
}

.focus-hint {
  position: fixed;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(0, 255, 136, 0.35);
  color: rgba(200, 214, 229, 0.85);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  padding: 0.5rem 1rem;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 20;
}

.focus-hint.hidden {
  opacity: 0;
}

.dead-overlay {
  position: fixed;
  inset: 0;
  background: rgba(180, 0, 0, 0.25);
  pointer-events: none;
  animation: deathFlash 0.4s ease;
}

@keyframes deathFlash {
  0% { background: rgba(255,0,0,0.5); }
  100% { background: rgba(180,0,0,0.25); }
}
