/* ===== RESET Y CONFIGURACIÓN BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Arial", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Animación de fondo con estrellas */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(2px 2px at 20px 30px, #fff, transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1px 1px at 90px 40px, #fff, transparent),
    radial-gradient(
      1px 1px at 130px 80px,
      rgba(255, 255, 255, 0.6),
      transparent
    );
  background-repeat: repeat;
  background-size: 200px 100px;
  animation: sparkle 20s linear infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes sparkle {
  0% {
    transform: translateY(0px);
  }
  100% {
    transform: translateY(-100px);
  }
}

/* ===== SISTEMA DE PANTALLAS ===== */
.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease-in-out;
  z-index: 10;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

.screen.overlay {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 100;
}

/* ===== PANTALLA DE BIENVENIDA ===== */
.welcome-container {
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  padding: 3rem 2rem;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  animation: slideIn 0.6s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.game-title {
  font-size: 2.5rem;
  color: #4a5568;
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.star-icon {
  display: inline-block;
  animation: rotate 3s linear infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.game-subtitle {
  font-size: 1.2rem;
  color: #718096;
  margin-bottom: 2rem;
}

.input-container {
  margin-bottom: 2rem;
}

#player-name {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  border: 3px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 1rem;
  text-align: center;
  transition: all 0.3s ease;
  background: #f7fafc;
}

#player-name:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  transform: scale(1.02);
}

.instructions {
  background: #b8b9b9;
  padding: 1.5rem;
  border-radius: 10px;
  margin-top: 1.5rem;
}

.instructions h3 {
  color: #2d3748;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.instructions p {
  color: #4a5568;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

/* ===== BOTONES ===== */
.btn-primary,
.btn-secondary {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-secondary {
  background: #e2e8f0;
  color: #4a5568;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
  background: #cbd5e0;
  transform: translateY(-2px);
}

.btn-primary:active,
.btn-secondary:active {
  transform: translateY(0);
}

/* ===== PANTALLA DEL JUEGO ===== */
#game-screen {
  flex-direction: column;
  padding: 1rem;
  background: transparent;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 800px;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.9);
  padding: 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.player-info {
  font-weight: bold;
  color: #4a5568;
  font-size: 1.1rem;
}

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

.score-label {
  color: #718096;
  font-size: 0.9rem;
  display: block;
}

#score-display {
  font-size: 2rem;
  font-weight: bold;
  color: #667eea;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.controls-hint {
  font-size: 0.9rem;
  color: #718096;
  text-align: right;
}

#game-canvas {
  border: 4px solid rgba(255, 255, 255, 0.8);
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
}

.game-footer {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.game-footer button {
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
}

/* ===== PANTALLAS DE PAUSA Y GAME OVER ===== */
.pause-container,
.gameover-container {
  background: rgba(255, 255, 255, 0.95);
  padding: 3rem 2rem;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
}

.pause-container h2,
.gameover-container h2 {
  color: #4a5568;
  margin-bottom: 2rem;
  font-size: 2rem;
}

.final-score {
  font-size: 1.3rem;
  color: #667eea;
  font-weight: bold;
  margin-bottom: 1rem;
}

.encouragement {
  color: #718096;
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

.gameover-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .game-title {
    font-size: 2rem;
  }

  .game-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .controls-hint {
    text-align: center;
  }

  .welcome-container {
    padding: 2rem 1.5rem;
  }

  .game-footer {
    flex-direction: column;
    align-items: center;
  }

  .gameover-buttons {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 1.8rem;
  }

  .btn-primary,
  .btn-secondary {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
  }

  #score-display {
    font-size: 1.5rem;
  }
}

/* ===== EFECTOS ESPECIALES ===== */
.pulse {
  animation: pulse 0.3s ease-in-out;
}

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

.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}
