body {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(135deg, #974a7f, #974a7f);
  font-family: 'Press Start 2P', cursive;
  overflow: hidden;
  color: white;
  touch-action: none;
}  

#game-container {
  position: relative;
  width: 1100px;
  height: 500px;
  margin: auto;
}
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width:1100px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none; /* Permite disparar aunque la UI esté encima */
    z-index: 10;
    box-sizing: border-box;
}
#canvas {
  background-color: #4b3647;
  border: 2px solid #e177b6;
  display: block;
}

#controls {         
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  text-align: center;
  font-size: 14px;
  text-shadow: 0 0 5px #ad7799;
  opacity: 0.7;
  z-index: 5;
}

#puntos{
  position: absolute;
  top: 20px;
  left: 20px;
  font-size: 16px;
  color: #ff0;
  margin-left: 7%;
}

#level-display {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 16px;
  color: #0f0;
}

#twenty-levels{
  margin-left: 150px;
}

/* Efecto de neón para el título */
.game-title {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  color: #a5f1af;
  text-shadow: 0 0 10px #65ca6a, 0 0 20px #75ac7e, 0 0 30px #ff0080, 0 0 40px #ff0080;
  font-size: 24px;
}

/* Efectos de partículas para fondo (opcional) */
.particle {
  position: absolute;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  pointer-events: none;
}

/* Modal para game over/ganar */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 100;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.modal-content {
  background: linear-gradient(145deg, #1a1a2e, #16213e);
  padding: 30px;
  border-radius: 10px;
  border: 3px solid #ff0077;
  text-align: center;
  box-shadow: 0 0 30px rgba(255, 0, 162, 0.7);
}

.modal h2 {
  color: #00ffff;
  margin-bottom: 20px;
  font-size: 28px;
}

.modal button {
  background: #ff0077;
  border: none;
  padding: 10px 20px;
  font-family: 'Press Start 2P', cursive;
  cursor: pointer;
  font-size: 16px;
  border-radius: 5px;
  transition: all 0.3s;
}

.modal button:hover {
  background: rgb(210, 117, 165);
  transform: scale(1.1);
}
.modos {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 101;
  display: flex;
  gap: 300px;
}

.modos button {
  padding: 15px 30px;
  font-family: 'Press Start 2P', cursive;
  font-size: 16px;
  background-color: #ff0077;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s;
}

.modos button:hover {
  background-color: rgb(210, 117, 165);
  transform: scale(1.05);
}

.modos button:last-child {
  background-color: #844b65;
}

.modos button:last-child:hover {
  background-color: #823c64;
}

.game-controls {
  bottom: 50px;
  left: 80%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  z-index: 5;
  margin-left: 250px;
}

.game-controls button {
  padding: 12px 25px;
  font-size: 18px;
  font-weight: bold;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  border: 2px solid #00ffff;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.game-controls button:hover {
  background-color: rgba(0, 150, 255, 0.7);
  transform: scale(1.05);
}

.game-controls button:active {
  transform: scale(0.95);
}

#btn-shoot {
  background-color: rgba(160, 55, 111, 0.7);
}

#ui-layer {
    position: absolute;
    width: 100%;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

#energy-container {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #00ffff;
    font-size: 10px;
    margin-right: 50px;
}

#energy-bar {
    width: 100px;
    height: 15px;
    border: 2px solid #00ffff;
    background: #000;
}

#energy-fill {
    width: 100%;
    height: 100%;
    background: #00ffff; /* Color normal: Cian */
    transition: width 0.2s, background-color 0.3s;
}

/* Añade esta regla si quieres que parpadee o cambie al agotarse */
#energy-fill[style*="width: 0%"] {
    background: #ff0000; /* Rojo cuando está vacía */
}

#vivas-display {
    color: #d162a9;
    text-shadow: 0 0 5px #000;
    margin-left: 30px;
}

/* Ajuste para que el canvas se vea bien en móviles */
canvas {
    max-width: none;
    height: 500px;
    width: 1100px;
}

@media screen and (max-width: 400px) {
  /* 1. Ajuste del contenedor para que la UI no flote sobre el juego de forma caótica */
  #ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    display: grid; /* Cambiamos a GRID para control total */
    grid-template-columns: 1fr 1fr; /* Dos columnas */
    grid-template-rows: auto auto; /* Dos filas */
    gap: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.7); /* Fondo más oscuro para ver las letras */
    box-sizing: border-box;
    pointer-events: none;
    z-index: 100;
  }

  /* 2. Posicionamos cada elemento en su sitio sin que se toquen */
  #puntos {
    grid-column: 5;
    grid-row: 1;
    font-size: 1px;
    color: #ffff00;
    text-align: left;
    margin: 0;
  }

  #vivas-display {
    margin-left: 500px;
    grid-column: 2;
    grid-row: 1;
    font-size: 1px;
    color: #ff0077;
    text-align: right;
 
  }

  #energy-container {
    font-size: 5px;
    grid-column: 1 / span 2; /* Ocupa toda la fila de abajo */
    grid-row: 600;
    display: flex;
    gap: 10px;
    width: 100%;
    text-align: right;

  }

  #energy-container span {
    font-size: 5px;
    color: #00ffff;
  }

  #energy-bar {
    flex-grow: 1; /* La barra se estira para llenar el espacio */
    max-width: 150px;
    height: 12px;
    border: 1px solid #00ffff;
    font-size: 5px;
  }

  /* 3. Botones táctiles abajo del todo */
  .game-controls {
    position: fixed;
    bottom: 20px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 0;
    padding: 0 10px;
    box-sizing: border-box;
  }

  .game-controls button {
    width: 60px;
    height: 60px;
    font-size: 20px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(80, 40, 70, 0.9);
    border: 2px solid #ff0077;
    border-radius: 10px;
  }

  /* Ocultar texto innecesario en móvil para limpiar la pantalla */
  #controls, .game-title {
    display: none;
  }
}