* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

:root {
  --p1-color: #ff2e63;
  --p2-color: #08d9d6;
  --p3-color: #39ff14;
  --p4-color: #ffe66d;
  --bg-dark: #0a0a0f;
  --bg-arena: #1a1a2e;
}

@font-face {
  font-family: "GameFont";
  src: local("Impact"), local("Arial Black");
}

body {
  overflow: hidden;
  touch-action: none;
  background: var(--bg-dark);
  font-family: "Segoe UI", system-ui, sans-serif;
}

#gameCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

/* Scoreboard */
.scoreboard {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(10, 10, 15, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 15px;
  padding: 15px 20px;
  z-index: 50;
  min-width: 200px;
  backdrop-filter: blur(10px);
}

.scoreboard.hidden {
  display: none;
}

.scoreboard-title {
  font-size: 1.2rem;
  font-weight: bold;
  letter-spacing: 2px;
  margin-bottom: 10px;
  color: white;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 8px;
}

.score-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 1rem;
}

.score-item-name {
  font-weight: bold;
}

.score-item-value {
  font-weight: 900;
  font-size: 1.2rem;
}

/* Overlays */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 10, 15, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Menu */
.menu-content {
  text-align: center;
  color: white;
  max-width: 600px;
  padding: 20px;
}

.menu-content h1 {
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: 10px;
  margin-bottom: 20px;
  background: linear-gradient(
    135deg,
    var(--p1-color),
    var(--p2-color),
    var(--p3-color),
    var(--p4-color)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 50px rgba(255, 46, 99, 0.5);
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    filter: drop-shadow(0 0 20px rgba(255, 46, 99, 0.5));
  }
  to {
    filter: drop-shadow(0 0 40px rgba(8, 217, 214, 0.5));
  }
}

.menu-content p {
  font-size: 1.5rem;
  opacity: 0.7;
  margin-bottom: 30px;
}

.qr-container {
  margin: 30px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.join-qr {
  width: 300px;
  height: 300px;
  border-radius: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  padding: 10px;
  background: white;
  box-shadow: 0 0 50px rgba(255, 255, 255, 0.3);
}

.qr-status {
  font-size: 1rem;
  opacity: 0.7;
}

.players-info {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.cpu-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.cpu-label {
  font-size: 1.2rem;
  font-weight: bold;
  color: white;
}

.cpu-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.cpu-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

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

.cpu-count {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--p3-color);
  min-width: 30px;
  text-align: center;
}

.winner-cpu-controls {
  margin: 20px 0;
}

.players-count {
  font-size: 1.5rem;
  font-weight: bold;
}

.players-count span {
  color: var(--p2-color);
  font-size: 2rem;
}

.start-hint {
  font-size: 1.2rem;
  padding: 15px 30px;
  border-radius: 50px;
  background: rgba(57, 255, 20, 0.2);
  border: 2px solid var(--p3-color);
  color: var(--p3-color);
  font-weight: bold;
  letter-spacing: 2px;
  transition: all 0.3s ease;
}

.start-hint.ready {
  background: rgba(57, 255, 20, 0.4);
  box-shadow: 0 0 30px rgba(57, 255, 20, 0.5);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 30px rgba(57, 255, 20, 0.5);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 50px rgba(57, 255, 20, 0.8);
  }
}

.start-btn {
  padding: 20px 60px;
  font-size: 1.8rem;
  font-weight: bold;
  letter-spacing: 3px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--p1-color), var(--p2-color));
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 30px rgba(255, 46, 99, 0.5);
}

.start-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 50px rgba(255, 46, 99, 0.7);
}

.start-btn:active {
  transform: scale(0.98);
}

/* Countdown */
.countdown-number {
  font-size: 20rem;
  font-weight: 900;
  color: white;
  text-shadow: 0 0 50px rgba(255, 255, 255, 0.5);
  animation: countPulse 1s ease-in-out;
}

@keyframes countPulse {
  0% {
    transform: scale(2);
    opacity: 0;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
}

/* Winner */
.winner-content {
  text-align: center;
  color: white;
}

.winner-content h1 {
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: 10px;
  margin-bottom: 20px;
  animation: winnerGlow 0.5s ease-in-out infinite alternate;
}

@keyframes winnerGlow {
  from {
    text-shadow: 0 0 20px rgba(255, 230, 109, 0.5);
  }
  to {
    text-shadow: 0 0 50px rgba(255, 230, 109, 1);
  }
}

.winner-player {
  font-size: 3rem;
  font-weight: bold;
  margin-bottom: 20px;
  padding: 20px 40px;
  border-radius: 20px;
  display: inline-block;
}

.winner-player.p1 {
  color: var(--p1-color);
  background: rgba(255, 46, 99, 0.2);
  border: 3px solid var(--p1-color);
}

.winner-player.p2 {
  color: var(--p2-color);
  background: rgba(8, 217, 214, 0.2);
  border: 3px solid var(--p2-color);
}

.winner-player.p3 {
  color: var(--p3-color);
  background: rgba(57, 255, 20, 0.2);
  border: 3px solid var(--p3-color);
}

.winner-player.p4 {
  color: var(--p4-color);
  background: rgba(255, 230, 109, 0.2);
  border: 3px solid var(--p4-color);
}

.winner-score {
  font-size: 2rem;
  margin-bottom: 30px;
  opacity: 0.9;
}

.winner-score span {
  font-weight: bold;
  font-size: 2.5rem;
}

.winner-buttons {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
}

.reset-btn {
  padding: 20px 60px;
  font-size: 1.8rem;
  font-weight: bold;
  letter-spacing: 3px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--p3-color), var(--p4-color));
  color: #1a1a2e;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 30px rgba(57, 255, 20, 0.5);
}

.reset-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 50px rgba(57, 255, 20, 0.7);
}

.reset-btn:active {
  transform: scale(0.98);
}

.next-round-hint {
  font-size: 1.2rem;
  padding: 15px 30px;
  border-radius: 50px;
  background: rgba(57, 255, 20, 0.2);
  border: 2px solid var(--p3-color);
  color: var(--p3-color);
  font-weight: bold;
  letter-spacing: 2px;
  transition: all 0.3s ease;
}

.next-round-hint.ready {
  background: rgba(57, 255, 20, 0.4);
  box-shadow: 0 0 30px rgba(57, 255, 20, 0.5);
  animation: pulse 1.5s ease-in-out infinite;
}

/* Winner QR Code */
.winner-qr-container {
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.winner-qr-container .qr-container {
  margin: 0;
}

.winner-qr-container .join-qr {
  width: 200px;
  height: 200px;
  border-radius: 15px;
}

/* Confetti container */
#confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99;
}
