* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  background: #0a0a1a;
  color: #eee;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ─── Animations ─── */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

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

@keyframes bombPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

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

@keyframes glitch {
  0% { text-shadow: 2px 0 #ff0040, -2px 0 #00ff88; }
  25% { text-shadow: -2px 0 #ff0040, 2px 0 #00ff88; }
  50% { text-shadow: 2px 2px #ff0040, -2px -2px #00ff88; }
  75% { text-shadow: -2px 2px #ff0040, 2px -2px #00ff88; }
  100% { text-shadow: 2px 0 #ff0040, -2px 0 #00ff88; }
}

@keyframes screenShake {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, -3px); }
  80% { transform: translate(2px, 3px); }
}

@keyframes countPop {
  0% { transform: scale(2); opacity: 0; }
  50% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes titleGlow {
  0%, 100% { text-shadow: 0 0 20px rgba(255,107,53,0.5), 0 0 40px rgba(255,107,53,0.3); }
  50% { text-shadow: 0 0 40px rgba(255,107,53,0.8), 0 0 80px rgba(255,107,53,0.4), 0 0 120px rgba(255,107,53,0.2); }
}

@keyframes ringPulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.8); opacity: 0; }
}

@keyframes dotPulse {
  0%, 33% { content: '.'; }
  34%, 66% { content: '..'; }
  67%, 100% { content: '...'; }
}

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

@keyframes victoryGlow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(34,197,94,0.5)); }
  50% { filter: drop-shadow(0 0 20px rgba(34,197,94,0.8)); }
}

/* ─── Scanlines Overlay ─── */
.scanlines {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0.08;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255,255,255,0.03) 2px,
    rgba(255,255,255,0.03) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* ─── Screens ─── */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background: linear-gradient(180deg, #0a0a1a 0%, #1a0a2e 50%, #0a0a1a 100%);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}
.screen.fade-out {
  opacity: 0;
}
.screen.fade-in {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

/* ─── LOBBY ─── */
.lobby-container {
  text-align: center;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  position: relative;
  z-index: 2;
  animation: slideUp 0.6s ease-out;
}

.bomb-float {
  font-size: 56px;
  animation: float 3s ease-in-out infinite;
  margin-bottom: 8px;
  filter: drop-shadow(0 8px 20px rgba(255,107,53,0.3));
}

.game-title {
  font-size: clamp(18px, 6vw, 32px);
  font-weight: 700;
  letter-spacing: 3px;
  color: #ff6b35;
  margin-bottom: 4px;
  animation: glitch 4s ease-in-out infinite, titleGlow 3s ease-in-out infinite;
}

.game-subtitle {
  font-size: clamp(6px, 2vw, 9px);
  letter-spacing: 4px;
  color: #5555aa;
  margin-bottom: 32px;
  text-transform: uppercase;
}

.input-group {
  margin-bottom: 14px;
}

input[type="text"] {
  width: 100%;
  padding: 14px 18px;
  font-size: 12px;
  font-family: 'Press Start 2P', monospace;
  border: 2px solid #1e1e3a;
  border-radius: 12px;
  background: #0e0e22;
  color: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-align: center;
  letter-spacing: 2px;
}
input[type="text"]:focus {
  border-color: #ff6b35;
  box-shadow: 0 0 24px rgba(255,107,53,0.15), 0 0 2px rgba(255,107,53,0.3);
}
input[type="text"]::placeholder {
  color: #333;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
}

.button-group {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.btn {
  padding: 14px 16px;
  font-size: 11px;
  font-family: 'Press Start 2P', monospace;
  font-weight: 400;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s;
  letter-spacing: 1px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.btn:active {
  transform: scale(0.94);
}

.btn-icon {
  font-size: 10px;
}

.btn-primary {
  background: linear-gradient(145deg, #ff6b35, #e63946);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255,107,53,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-primary:active {
  box-shadow: 0 2px 12px rgba(255,107,53,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
}

.btn-secondary {
  background: linear-gradient(145deg, #1a1a35, #12122a);
  color: #7777aa;
  border: 2px solid #252550;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.03);
}
.btn-secondary:active {
  background: linear-gradient(145deg, #252550, #1a1a35);
  color: #9999cc;
}

.btn-accent {
  background: linear-gradient(145deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 4px 16px rgba(59,130,246,0.3);
}

.btn-small {
  padding: 12px 16px;
  font-size: 9px;
  flex: none;
  border-radius: 10px;
}

.btn-copy {
  background: #0e0e22;
  color: #5555aa;
  border: 1px solid #252550;
  padding: 8px 14px;
  font-size: 8px;
  flex: none;
  border-radius: 8px;
  letter-spacing: 2px;
}
.btn-copy:active {
  background: #1a1a35;
  color: #8888cc;
}

.room-join {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.room-join input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 6px;
  font-size: 13px;
}

.error-msg {
  color: #e63946;
  margin-top: 14px;
  font-size: 9px;
  min-height: 16px;
  letter-spacing: 1px;
}

.lobby-footer {
  margin-top: 28px;
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 8px;
  color: #333;
  letter-spacing: 1px;
}

/* ─── WAITING ─── */
.waiting-container {
  text-align: center;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  position: relative;
  z-index: 2;
  animation: slideUp 0.4s ease-out;
}

.waiting-header {
  margin-bottom: 24px;
}

.room-label {
  font-size: 10px;
  color: #5555aa;
  letter-spacing: 6px;
  margin-bottom: 4px;
}

.room-code {
  color: #ff6b35;
  font-size: clamp(24px, 8vw, 40px);
  letter-spacing: 10px;
  text-shadow: 0 0 30px rgba(255,107,53,0.4);
  animation: titleGlow 2s ease-in-out infinite;
}

.player-list {
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #0e0e22, #12122a);
  border-radius: 12px;
  border-left: 4px solid;
  animation: fadeSlideIn 0.3s ease-out;
  transition: background 0.2s;
}
.player-item:hover {
  background: linear-gradient(135deg, #141430, #18183a);
}
.player-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 10px currentColor;
  animation: bombPulse 2s ease-in-out infinite;
}
.player-name {
  font-size: 11px;
  letter-spacing: 1px;
}
.player-you {
  margin-left: auto;
  font-size: 7px;
  color: #ff6b35;
  background: rgba(255,107,53,0.1);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,107,53,0.2);
  letter-spacing: 2px;
}

.btn-start-game {
  margin: 12px auto;
  max-width: 260px;
  padding: 16px 24px;
  font-size: 12px;
  justify-content: center;
}

.waiting-text {
  color: #3a3a6a;
  font-size: 9px;
  letter-spacing: 2px;
  animation: pulse 2s ease-in-out infinite;
}

.countdown-display {
  font-size: clamp(48px, 15vw, 80px);
  color: #ff6b35;
  text-shadow: 0 0 60px rgba(255,107,53,0.6), 0 0 120px rgba(255,107,53,0.3);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: countPop 0.8s ease-out;
}

/* ─── GAME ─── */
#game.active {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #060610 0%, #0a0820 100%);
}

.game-hud {
  padding: 8px 12px;
  background: linear-gradient(180deg, #0a0a20 0%, #080818 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  z-index: 10;
  border-bottom: 2px solid #1a1a3a;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.hud-players {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.hud-player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 8px;
  background: linear-gradient(145deg, #0e0e28, #0a0a1e);
  border: 2px solid;
  transition: opacity 0.4s, transform 0.3s, box-shadow 0.3s;
  white-space: nowrap;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}
.hud-player::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}
.hud-player.dead {
  opacity: 0.2;
  transform: scale(0.9);
  text-decoration: line-through;
  filter: grayscale(1);
}
.hud-player .hud-name {
  font-size: 8px;
  letter-spacing: 1px;
}
.hud-player .hud-stats {
  display: flex;
  gap: 5px;
  font-size: 10px;
  opacity: 0.9;
}
.hud-stat {
  display: flex;
  align-items: center;
  gap: 1px;
}
.hud-stat-val {
  font-size: 8px;
  color: #ccc;
}

.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-height: 0;
}
.canvas-wrapper.shake {
  animation: screenShake 0.3s ease-out;
}

#gameCanvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 6px;
  box-shadow: 0 0 30px rgba(255,107,53,0.1), 0 0 60px rgba(100,50,200,0.06);
}

/* ─── MOBILE CONTROLS ─── */
.mobile-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px 20px;
  background: linear-gradient(180deg, #060610, #08081a);
  flex-shrink: 0;
  border-top: 1px solid #151530;
  gap: 30px;
}

/* ─── VIRTUAL JOYSTICK ─── */
.joystick-area {
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: none;
}

.joystick-base {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #1a1a3a, #0a0a1e);
  border: 3px solid #252550;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.joystick-base::before {
  content: '';
  position: absolute;
  width: 40%;
  height: 40%;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.04);
}

.joystick-base::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px dashed rgba(85,85,170,0.15);
}

.joystick-knob {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #3a3a6a, #252550);
  border: 2px solid #4a4a80;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
  position: absolute;
  transition: transform 0.06s ease-out;
  cursor: pointer;
  z-index: 2;
}

.joystick-knob.active {
  background: radial-gradient(circle at 35% 35%, #ff8c50, #ff6b35);
  border-color: rgba(255,140,80,0.6);
  box-shadow: 0 0 20px rgba(255,107,53,0.4), 0 2px 10px rgba(0,0,0,0.4);
}

.bomb-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid #ff6b35;
  background: radial-gradient(circle at 35% 35%, #ff6b35, #cc3300);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow:
    0 0 30px rgba(255,107,53,0.4),
    0 6px 20px rgba(0,0,0,0.5),
    inset 0 -4px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  animation: bombPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
.bomb-btn:active {
  transform: scale(0.85);
  background: radial-gradient(circle at 35% 35%, #ff8c50, #e63946);
  box-shadow:
    0 0 50px rgba(255,107,53,0.7),
    0 0 80px rgba(255,200,50,0.3),
    inset 0 -2px 4px rgba(0,0,0,0.4);
  animation: none;
}

.bomb-icon {
  font-size: 30px;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}

.bomb-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(255,107,53,0.4);
  animation: ringPulse 1.5s ease-out infinite;
}

@media (min-width: 769px) {
  .mobile-controls { display: none; }
}

@media (min-width: 400px) and (max-width: 768px) {
  .joystick-area { width: 160px; height: 160px; }
  .joystick-base { width: 140px; height: 140px; }
  .joystick-knob { width: 56px; height: 56px; }
  .bomb-btn { width: 78px; height: 78px; }
  .bomb-icon { font-size: 32px; }
  .mobile-controls { padding: 12px 32px 20px; gap: 24px; }
}

/* ─── GAME OVER ─── */
.overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.9);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.overlay.active { display: flex; }

.overlay-content {
  text-align: center;
  padding: 32px;
  background: linear-gradient(145deg, #141430, #0e0e22);
  border-radius: 20px;
  border: 1px solid #252550;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 20px 80px rgba(0,0,0,0.6), 0 0 40px rgba(255,107,53,0.05);
  animation: fadeSlideIn 0.4s ease-out;
}

.overlay-icon {
  font-size: 48px;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

.overlay-content h2 {
  font-size: clamp(16px, 5vw, 24px);
  margin-bottom: 6px;
  letter-spacing: 4px;
}
.overlay-content p {
  color: #5555aa;
  margin-bottom: 20px;
  font-size: 10px;
  letter-spacing: 1px;
}

.overlay-buttons {
  display: flex;
  gap: 10px;
}

.btn-rematch {
  font-size: 11px;
  padding: 16px 24px;
}

.btn-back {
  font-size: 9px;
  padding: 16px 18px;
  flex: 0;
  white-space: nowrap;
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.game-over-stats {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  border: 1px solid #252550;
  min-width: 60px;
}
.stat-value {
  font-size: 16px;
  color: #ff6b35;
}
.stat-label {
  font-size: 6px;
  color: #5555aa;
  letter-spacing: 1px;
}

.overlay-content {
  position: relative;
  z-index: 1;
}

.rematch-info {
  margin-top: 12px;
  color: #3a3a6a;
  font-size: 8px;
  letter-spacing: 1px;
}

/* Desktop keyboard hint */
.keyboard-hint {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  color: #222;
  font-size: 7px;
  pointer-events: none;
  letter-spacing: 2px;
  font-family: 'Press Start 2P', monospace;
  white-space: nowrap;
}
@media (max-width: 768px) { .keyboard-hint { display: none; } }

/* ─── Game Timer ─── */
.game-timer {
  font-size: 10px;
  color: #8888aa;
  letter-spacing: 2px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  border: 1px solid #252550;
  min-width: 60px;
  text-align: center;
  flex-shrink: 0;
}

/* ─── Kill Feed ─── */
.kill-feed {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
  pointer-events: none;
  max-width: 200px;
}
.kill-item {
  padding: 5px 10px;
  background: rgba(10, 10, 26, 0.85);
  border-radius: 6px;
  border-left: 3px solid #ff6b35;
  font-size: 7px;
  color: #ccc;
  letter-spacing: 0.5px;
  backdrop-filter: blur(4px);
  animation: fadeSlideIn 0.3s ease-out;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── HUD Kills Counter ─── */
.hud-kills {
  color: #e63946;
  margin-left: 2px;
}

/* ─── VOICE CHAT UI ─── */
.mic-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #252550;
  background: #0a0a1e;
  color: #5555aa;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.mic-btn:active { transform: scale(0.9); }
.mic-btn.mic-on {
  border-color: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}
.mic-btn.mic-off {
  border-color: #e63946;
  background: rgba(230, 57, 70, 0.15);
}
.mic-btn.mic-denied {
  border-color: #333;
  opacity: 0.4;
  cursor: not-allowed;
}

.mic-btn-mobile {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #252550;
  background: linear-gradient(145deg, #1a1a38, #12122a);
  color: #5555aa;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.mic-btn-mobile:active { transform: scale(0.9); }
.mic-btn-mobile.mic-on {
  border-color: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.3);
}
.mic-btn-mobile.mic-off {
  border-color: #e63946;
  background: rgba(230, 57, 70, 0.15);
}
.mic-btn-mobile.mic-denied {
  border-color: #333;
  opacity: 0.4;
  cursor: not-allowed;
}

@keyframes speakingPulse {
  0%, 100% { box-shadow: 0 0 6px currentColor; }
  50% { box-shadow: 0 0 16px currentColor, 0 0 24px currentColor; }
}
.hud-player.speaking {
  animation: speakingPulse 0.6s ease-in-out infinite;
  background: rgba(34, 197, 94, 0.08);
}

@media (min-width: 769px) {
  .mic-btn-mobile { display: none; }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #0a0a1a; }
::-webkit-scrollbar-thumb { background: #252550; border-radius: 4px; }
