* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  touch-action: none;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #0a0a0a;
  color: #fff;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* Login Screen */
#loginScreen {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  z-index: 100;
}

.login-box {
  text-align: center;
  padding: 40px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 90%;
  width: 400px;
}

.login-box h1 {
  font-size: 2rem;
  margin-bottom: 10px;
  background: linear-gradient(90deg, #00ff88, #00ccff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-box p {
  color: #888;
  margin-bottom: 20px;
}

#nameInput {
  width: 100%;
  padding: 15px 20px;
  font-size: 1.2rem;
  border: 2px solid #333;
  border-radius: 10px;
  background: #0a0a0a;
  color: #fff;
  text-align: center;
  margin-bottom: 15px;
  outline: none;
  transition: border-color 0.3s;
}

#nameInput:focus {
  border-color: #00ff88;
}

#joinBtn {
  width: 100%;
  padding: 15px;
  font-size: 1.2rem;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, #00ff88, #00ccff);
  color: #0a0a0a;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

#joinBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 255, 136, 0.3);
}

.instructions {
  margin-top: 30px;
  text-align: left;
  font-size: 0.9rem;
  color: #666;
}

.instructions p {
  margin: 8px 0;
}

/* Game Screen */
#gameScreen {
  background: #0a0a0a;
}

#gameCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* UI */
#ui {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#topBar {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 15px;
  font-size: 0.9rem;
  font-weight: bold;
}

#topBar > div {
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 15px;
  border-radius: 20px;
  backdrop-filter: blur(5px);
}

#score { color: #00ff88; }
#deaths { color: #ff4444; }
#kills { color: #ffaa00; }

#leaderboard {
  position: fixed;
  top: 60px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 15px;
  border-radius: 10px;
  backdrop-filter: blur(5px);
  min-width: 180px;
  max-width: 250px;
}

#leaderboard h3 {
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: #ffd700;
  border-bottom: 1px solid #333;
  padding-bottom: 5px;
}

#leaderboardList {
  font-size: 0.8rem;
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #222;
}

.leaderboard-item:last-child {
  border-bottom: none;
}

.leaderboard-item.crown {
  color: #ffd700;
  font-weight: bold;
}

.leaderboard-rank {
  margin-right: 8px;
  color: #666;
}

/* Toggle Button */
.ui-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  backdrop-filter: blur(5px);
  border: 2px solid #333;
  transition: all 0.2s;
  z-index: 30;
  pointer-events: auto;
}

.ui-btn:hover {
  background: rgba(50, 50, 50, 0.8);
  border-color: #555;
  transform: scale(1.1);
}

.ui-btn:active {
  transform: scale(0.95);
}

.ui-btn.hidden-map {
  opacity: 0.5;
  border-color: #ff4444;
}

/* Powerup Message */
.powerup-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, rgba(0,0,0,0.9), rgba(30,30,30,0.9));
  color: #fff;
  padding: 20px 40px;
  border-radius: 15px;
  font-size: 1.5rem;
  font-weight: bold;
  z-index: 100;
  animation: powerupPop 0.5s ease;
  border: 2px solid #00ff88;
  box-shadow: 0 0 30px rgba(0, 255, 136, 0.5);
}

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

/* Powerup indicators in UI */
#powerupBar {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 20;
}

.powerup-indicator {
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 5px;
  animation: pulse 1s infinite;
}

.powerup-indicator.speed { border: 2px solid #ff6600; color: #ff6600; }
.powerup-indicator.shield { border: 2px solid #4488ff; color: #4488ff; }
.powerup-indicator.ghost { border: 2px solid #888888; color: #888888; }

/* Messages */
#deathMessage, #killMessage {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.message-box {
  text-align: center;
  padding: 30px 50px;
  background: rgba(255, 68, 68, 0.2);
  border: 2px solid #ff4444;
  border-radius: 15px;
  animation: pulse 0.5s ease;
}

.message-box.success {
  background: rgba(0, 255, 136, 0.2);
  border-color: #00ff88;
}

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.message-box h2 {
  font-size: 2rem;
  margin-bottom: 10px;
}

/* Joystick Control */
#joystickZone {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  z-index: 25;
  touch-action: none;
  user-select: none;
  display: none; /* Hidden by default, shown on touch devices */
}

#joystickKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00ff88, #00ccff);
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 15px rgba(0, 255, 136, 0.4);
  pointer-events: none;
}

#joystickZone:active {
  background: rgba(255, 255, 255, 0.1);
}

/* Show joystick on touch devices */
@media (hover: none) and (pointer: coarse) {
  #joystickZone {
    display: block;
  }
  
  #leaderboard {
    top: 60px;
    right: 5px;
    min-width: 150px;
    padding: 10px;
  }
  
  #leaderboard h3 {
    font-size: 0.8rem;
  }
  
  #leaderboardList {
    font-size: 0.7rem;
  }
  
  #topBar {
    font-size: 0.8rem;
  }
  
  #topBar > div {
    padding: 6px 12px;
  }
}