/* --- RESET Y BASE --- */
body,
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #111; /* Fondo oscuro detrás del marco del celular */
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100svh;
  max-width: 450px; /* Forzamos el ancho máximo típico de un móvil grande */
  max-height: 900px; /* Limitamos la altura en PC para que no sea infinito */
  background-color: #000;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(0, 255, 200, 0.2); /* Un resplandor temático 3DX */
}

/* En PC, le damos un poco de borde redondeado para simular un dispositivo */
@media (min-width: 451px) {
  #game-container {
    height: 90vh;
    border-radius: 20px;
    border: 2px solid #333;
  }
}

canvas {
  display: block;
  image-rendering: auto;
}

/* --- CAPA DE INTERFAZ --- */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* --- VENTANAS (OVERLAYS) --- */
.overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 85%;
  max-width: 320px;
  max-height: 90vh;
  overflow-y: auto;

  /* Fondo oscuro puro */
  background: rgba(0, 0, 0, 0.95);
  /* Bordes y líneas en blanco puro */
  border: 2px solid #ffffff;
  border-radius: 15px;
  padding: 20px 15px;

  /* Textos en blanco */
  color: #ffffff;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  pointer-events: auto;
  box-sizing: border-box;

  /* Layout */
  display: flex; /* El JS lo alterna con display: none */
  flex-direction: column;
  justify-content: space-between;
  min-height: 400px;

  /* --- LA SOLUCIÓN AQUÍ --- */
  z-index: 1000; /* Obliga a la tarjeta a mostrarse SIEMPRE por encima del juego */

  scrollbar-width: none; /* Oculta en Firefox */
  -ms-overflow-style: none; /* Oculta en IE/Edge */

  .overlay::-webkit-scrollbar {
    display: none; /* Oculta en Chrome, Safari y Opera */
  }
}

/* Ajuste de imágenes dentro de menús */
.overlay img {
  max-width: 100%;
  height: auto;
  max-height: 120px; /* Limita el tamaño del banner para dejar espacio a botones */
  margin-bottom: 10px;
  object-fit: contain;
}

h1 {
  font-size: 1.4rem;
  margin: 5px 0;
  color: #00ffc8;
  text-transform: uppercase;
}
h2 {
  font-size: 1.2rem;
  margin: 5px 0;
  color: #fff;
}
p {
  font-size: 0.9rem;
  margin: 5px 0 15px;
  color: #ccc;
  line-height: 1.3;
}

button {
  width: 100%;
  padding: 12px;

  /* CAMBIO 1: Empujamos el botón 35px hacia abajo */
  /* Orden: Arriba | Derecha | Abajo | Izquierda */
  margin: 35px 0 5px 0;

  font-size: 1rem;
  font-weight: bold;
  color: #000;
  background-color: #00ffc8;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-transform: uppercase;

  /* CAMBIO 2: Lo mandamos a la capa inferior para que no tape el texto */
  position: relative;
  z-index: 1;
}

input[type="text"] {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 6px;
  border: none;
  background: #222;
  color: #fff;
  text-align: center;
  box-sizing: border-box;
}

/* Variantes */
#victory-screen {
  border-color: #ffd700;
}
#victory-screen h2 {
  color: #ffd700;
}
#victory-screen button {
  background-color: #ffd700;
}

#secret-ending {
  border-color: #00ffff;
}
#secret-ending h2 {
  color: #00ffff;
}

.main-banner {
  width: 100%;
  max-height: 80px !important;
  margin-bottom: 10px;
}

/* Título en blanco brillante */
.light-title {
  font-size: 1.6rem;
  letter-spacing: 2px;
  margin: 0;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* --- GLOSARIO (Caja sutil para separar jerarquía) --- */
.powerup-glossary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 15px 10px;
  margin: 15px 0 10px 0; /* Margen estándar */

  /* ESTO ES LO CRÍTICO */
  position: relative;
  z-index: 20; /* Fuerza a que el texto siempre esté POR ENCIMA del neón */
}

.section-title {
  font-size: 0.7rem;
  color: #ffffff;
  margin-bottom: 15px !important;
  font-weight: bold;
  letter-spacing: 1px;
  opacity: 0.9;
}

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.glossary-grid .item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.glossary-grid img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  margin-bottom: 8px !important;
  position: relative;
  z-index: 2; /* Mantiene la imagen sobre las partículas */
}

.glossary-grid span {
  font-size: 0.6rem;
  font-weight: bold;
  color: #ffffff; /* Texto de los poderes en blanco */
}

/* Contenedor del efecto visual */
.orb-visual {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}

.orb-visual img {
  width: 40px; /* Tamaño idéntico al 'size' del juego */
  height: 40px;
  z-index: 3;
}

/* Capa 1: Resplandor Pulsante (Simula el globalAlpha y shadowBlur) */
.orb-visual .glow {
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  z-index: 1;
  animation: cssOrbPulse 2s ease-in-out infinite;
}

/* Capa 2: Anillo Giratorio (Simula el arc de Math.PI * 1.5 y ctx.rotate) */
.orb-visual .ring {
  position: absolute;
  width: 52px; /* Radio de 26px como en el juego */
  height: 52px;
  border: 3px solid transparent;
  border-radius: 50%;
  z-index: 2;
  /* Creamos el anillo incompleto (270 grados) */
  border-top-color: inherit;
  border-left-color: inherit;
  border-right-color: inherit;
  animation: cssOrbRotate 4s linear infinite;
}

/* Colores específicos según el poder */
.escudo-fx {
  --orb-color: #00ffc8;
  border-color: #00ffc8;
  color: #00ffc8;
}
.pulso-fx {
  --orb-color: #ff00ff;
  border-color: #ff00ff;
  color: #ff00ff;
}
.turbo-fx {
  --orb-color: #ffd700;
  border-color: #ffd700;
  color: #ffd700;
}

.item .glow {
  background: var(--orb-color);
  box-shadow: 0 0 20px var(--orb-color);
}

/* ANIMACIONES: Espejo matemático del código JS */

@keyframes cssOrbPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.25; /* globalAlpha 0.4 - 0.15 */
  }
  50% {
    transform: scale(1.15); /* Crecimiento proporcional al pulse * 3 */
    opacity: 0.55; /* globalAlpha 0.4 + 0.15 */
  }
}

@keyframes cssOrbRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* --- BOTÓN PRINCIPAL VERSIÓN "POWER-ENGINE" --- */
.btn-main {
  position: relative;
  background-color: #ffffff; /* Botón Blanco Sólido */
  color: #000000;
  border: none;
  padding: 18px 30px;
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
  overflow: visible; /* Permitimos que el brillo salga del botón */
  transition: transform 0.1s;
  z-index: 10;
}

/* El texto del botón para que resalte */
.btn-main-text {
  position: relative;
  z-index: 5;
  letter-spacing: 1px;
}

/* EFECTO DE AURA TRIPLE (Cian, Magenta, Oro) */
/* Usamos sombras dinámicas para crear la energía de los poderes */
.btn-main::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 12px;
  z-index: -1;
  /* Tres capas de sombras que rotan y pulsan */
  box-shadow:
    0 0 15px #00ffc8,
    /* Escudo */ 0 0 30px #ff00ff,
    /* Pulso */ 0 0 45px #ffd700; /* Turbo */
  animation: engineGlow 3s ease-in-out infinite;
  opacity: 0.8;
}

/* EFECTO DE PARTÍCULAS ORBITALES ALREDEDOR DEL BOTÓN */
/* Simula la energía de los orbes pero en el botón */
.btn-main::after {
  content: "";
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  border-radius: 16px;
  z-index: -2;
  background: linear-gradient(45deg, #00ffc8, #ff00ff, #ffd700, #00ffc8);
  background-size: 400%;
  filter: blur(8px);
  animation: rainbowFlow 6s linear infinite;
  opacity: 0.5;
}

/* ANIMACIONES */

/* Animación de pulsación de energía */
@keyframes engineGlow {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 0 10px #ff00ff,
      0 0 20px #ffd700,
      0 0 30px #00ffc8;
  }
  50% {
    transform: scale(1.02, 1.05);
    box-shadow:
      0 0 20px #ff00ff,
      0 0 40px #ffd700,
      0 0 60px #00ffc8;
    opacity: 1;
  }
}

/* Movimiento circular de los colores de los poderes */
@keyframes rainbowFlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Feedback al tocarlo */
.btn-main:active {
  transform: scale(0.95);
}

/* --- FOOTER BLANCO --- */
.menu-footer {
  margin-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.3); /* Línea divisoria en blanco tenue */
  padding-top: 10px;
}

.menu-footer p {
  font-size: 0.75rem;
  margin-bottom: 5px;
  color: #cccccc;
}

.contact-link {
  color: #ffffff; /* Link en blanco para máxima limpieza visual */
  font-size: 0.8rem;
  text-decoration: none;
  font-weight: bold;
}

.contact-link:hover {
  text-decoration: underline;
  color: #00ffc8; /* Brilla en cyan al tocarlo */
}

/* --- DISEÑO DEL BANNER PUBLICITARIO B2B --- */
.b2b-banner {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 255, 200, 0.3);
  border-radius: 10px;
  padding: 15px;
  margin: 15px 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 90%;
  max-width: 320px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.b2b-banner img {
  width: 100%;
  max-height: 80px;
  object-fit: contain;
  border-radius: 5px;
}

.b2b-link {
  color: #00ffc8;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: bold;
  text-shadow: 0 0 5px rgba(0, 255, 200, 0.5);
  transition: all 0.3s ease;
}

.b2b-link:hover {
  color: #fff;
  text-shadow: 0 0 15px #00ffc8;
}

/* --- BOTONES DE GAME OVER MEJORADOS --- */
.buttons-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-top: 10px;
}

/* Botón Principal (Blanco Premium) */
.btn-primary {
  background-color: #ffffff !important;
  color: #000000 !important;
  border: none;
  box-shadow: 0 0 15px rgba(0, 255, 200, 0.4); /* Un toque de brillo cian sutil */
  font-weight: 900;
  transition: transform 0.2s;
}

/* Botón Secundario (Estilo Fantasma Blanco) */
.btn-secondary {
  background-color: transparent !important;
  border: 2px solid #ffffff !important;
  color: #ffffff !important;
  opacity: 0.8;
}

.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.95);
}
