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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #121212;
  font-family: 'Outfit', sans-serif;
  color: white;
  user-select: none;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

.hidden {
  display: none !important;
}

/* MAIN MENU */
#main-menu {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #2c3e50, #1a252f);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  z-index: 100;
}

.logo {
  font-size: 5rem;
  font-weight: 900;
  font-style: italic;
  text-shadow: 4px 4px 0 #000;
  margin-bottom: 2rem;
  color: #f1c40f;
  transform: skewX(-10deg);
}

.logo span {
  color: #e74c3c;
}

.menu-content {
  display: flex;
  gap: 3rem;
  width: 100%;
  max-width: 1000px;
}

.kart-preview {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border-radius: 20px;
  border: 4px solid rgba(255,255,255,0.1);
  min-height: 400px;
}

.menu-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

input[type="text"] {
  width: 100%;
  padding: 1rem;
  font-size: 1.5rem;
  border: none;
  border-radius: 10px;
  background: rgba(255,255,255,0.9);
  color: #333;
  font-family: 'Outfit', sans-serif;
  font-weight: bold;
}

.color-picker {
  display: flex;
  gap: 10px;
}

.color-btn {
  padding: 8px 15px;
  border-radius: 10px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.2s;
}

.color-btn:hover {
  transform: scale(1.1);
}

.color-btn.selected {
  border-color: white;
  transform: scale(1.1);
}

.primary-btn {
  width: 100%;
  padding: 1.2rem;
  font-size: 1.8rem;
  font-weight: 900;
  background: #2ecc71;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 6px 0 #27ae60;
  transition: transform 0.1s, box-shadow 0.1s;
  text-transform: uppercase;
}

.primary-btn:active {
  transform: translateY(6px);
  box-shadow: 0 0 0 #27ae60;
}

.room-list {
  background: rgba(0,0,0,0.4);
  border-radius: 10px;
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
}

.room-item {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  background: rgba(255,255,255,0.1);
  margin-bottom: 5px;
  border-radius: 5px;
  cursor: pointer;
}

.room-item:hover {
  background: rgba(255,255,255,0.2);
}

/* GAME UI */
#game-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: auto;
}

#hud-top {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
}

#leaderboard {
  background: rgba(0,0,0,0.5);
  padding: 10px;
  border-radius: 10px;
  min-width: 150px;
}

.lb-item {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 5px;
}

#match-timer {
  font-size: 2.5rem;
  font-weight: 900;
  background: rgba(0,0,0,0.5);
  padding: 5px 20px;
  border-radius: 20px;
  height: fit-content;
}

#killfeed {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
}

.kill-msg {
  background: rgba(0,0,0,0.6);
  padding: 5px 15px;
  border-radius: 5px;
  font-weight: bold;
  animation: fadeOut 3s forwards;
}

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

#hud-bottom {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  align-items: flex-end;
}

.health-container {
  text-align: center;
}

.health-bar-bg {
  width: 300px;
  height: 30px;
  background: rgba(0,0,0,0.6);
  border-radius: 15px;
  overflow: hidden;
  border: 3px solid #333;
}

#health-bar-fill {
  width: 100%;
  height: 100%;
  background: #2ecc71;
  transition: width 0.2s;
}

#health-text {
  font-size: 1.5rem;
  font-weight: 900;
  margin-top: 5px;
}

.level-container {
  text-align: center;
}

#player-level {
  font-size: 2rem;
  font-weight: 900;
  color: #f1c40f;
  text-shadow: 2px 2px 0 #000;
}

.xp-bar-bg {
  width: 150px;
  height: 15px;
  background: rgba(0,0,0,0.6);
  border-radius: 8px;
  margin-top: 5px;
}

#xp-bar-fill {
  width: 0%;
  height: 100%;
  background: #f1c40f;
  border-radius: 8px;
}

.powerup-container {
  width: 80px;
  height: 80px;
  background: rgba(0,0,0,0.5);
  border: 4px solid #fff;
  border-radius: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 0.8rem;
  text-align: center;
}

#announcer-message {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 4rem;
  font-weight: 900;
  color: #f1c40f;
  text-shadow: 0 5px 15px rgba(0,0,0,0.8);
  text-transform: uppercase;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: translate(-50%, -50%) scale(0); }
  to { transform: translate(-50%, -50%) scale(1); }
}

#end-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 200;
  pointer-events: auto;
}

#end-screen h1 {
  font-size: 5rem;
  color: #e74c3c;
  margin-bottom: 2rem;
}

#end-leaderboard {
  font-size: 2rem;
  background: rgba(255,255,255,0.1);
  padding: 2rem;
  border-radius: 10px;
  margin-bottom: 2rem;
}

/* Mobile Controls */
#mobile-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#joystick-base {
  position: absolute;
  bottom: 40px;
  left: 40px;
  width: 120px;
  height: 120px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  pointer-events: auto;
  touch-action: none;
}

#joystick-stick {
  position: absolute;
  top: 30px;
  left: 30px;
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,0.5);
  border-radius: 50%;
  pointer-events: none;
}

#btn-fire-mobile {
  position: absolute;
  bottom: 40px;
  right: 40px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(231, 76, 60, 0.6);
  border: 4px solid rgba(231, 76, 60, 0.9);
  color: white;
  font-weight: 900;
  font-size: 1.2rem;
  pointer-events: auto;
  touch-action: none;
}

@media (max-width: 768px) {
  .menu-content {
    flex-direction: column;
  }
  .kart-preview {
    min-height: 200px;
  }
  .logo {
    font-size: 3rem;
  }
  #mobile-controls {
    display: block !important;
  }
  #hud-bottom {
    transform: scale(0.6) translateX(-50%);
    bottom: 0px;
    transform-origin: bottom center;
  }
}
