/* Snake Game Styles */

/* Container */
.snake-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  width: 100%;
}

/* HUD */
.snake-hud {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  box-sizing: border-box;
}

/* Target Score */
.snake-target {
  color: #888;
  font-size: 1rem;
}

.snake-target span {
  color: #f1c40f;
  font-weight: bold;
}

/* Obstacles Display */
.snake-obstacles {
  color: #888;
  font-size: 1rem;
}

.snake-obstacles span {
  color: #9b59b6;
  font-weight: bold;
}

/* Canvas Container */
.snake-canvas-container {
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

/* Canvas */
#snake-canvas {
  display: block;
  background: #1a1a2e;
}

/* Countdown Overlay */
.snake-countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 5rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 20px #667eea, 0 0 40px #667eea;
  animation: pulse-countdown 1s ease-in-out infinite;
  z-index: 10;
}

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

/* Scoreboard */
.snake-scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

/* Player Score */
.snake-player-score {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  min-width: 120px;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.snake-player-score.dead {
  opacity: 0.5;
}

.snake-player-score.me {
  border-color: #667eea;
}

/* Color Dot */
.snake-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Player Name */
.snake-player-name {
  font-size: 0.9rem;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

/* Player Points */
.snake-player-points {
  font-size: 1.2rem;
  font-weight: bold;
  color: #fff;
  margin-left: auto;
}

/* Controls */
.snake-controls {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  justify-content: center;
}

/* Message Overlay */
.snake-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1.5rem 2.5rem;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 12px;
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
  text-align: center;
  z-index: 10;
  border: 2px solid transparent;
}

.snake-message.win {
  color: #2ecc71;
  border-color: #2ecc71;
}

.snake-message.lose {
  color: #e74c3c;
  border-color: #e74c3c;
}

.snake-message.respawn {
  color: #f1c40f;
  border-color: #f1c40f;
  font-size: 1.2rem;
}

/* Mobile Controls */
.snake-mobile-controls {
  display: none;
  margin-top: 1rem;
}

.snake-dpad {
  display: grid;
  grid-template-columns: repeat(3, 70px);
  grid-template-rows: repeat(3, 70px);
  gap: 6px;
}

.snake-dpad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s ease, transform 0.1s ease;
}

.snake-dpad-btn:active,
.snake-dpad-btn:hover {
  background: rgba(102, 126, 234, 0.6);
  transform: scale(0.95);
}

.snake-dpad-btn:disabled {
  opacity: 0;
  cursor: default;
  border: none;
}

/* Instructions */
.snake-instructions {
  font-size: 0.85rem;
  color: #666;
  text-align: center;
  margin-top: 0.5rem;
}

.snake-instructions kbd {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.8rem;
  color: #ccc;
}

/* Responsive - Tablets */
@media (max-width: 900px) {
  .snake-mobile-controls {
    display: block;
  }
}

/* Responsive - Mobile */
@media (max-width: 600px) {
  .snake-mobile-controls {
    display: block;
  }

  .snake-instructions {
    display: none;
  }

  .snake-scoreboard {
    flex-direction: column;
    align-items: center;
  }

  .snake-player-score {
    width: 100%;
    max-width: 200px;
  }

  .snake-hud {
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
  }

  .snake-dpad {
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(3, 80px);
    gap: 8px;
  }

  .snake-dpad-btn {
    font-size: 2rem;
  }
}

/* Touch device detection */
@media (pointer: coarse) {
  .snake-mobile-controls {
    display: block;
  }
}
