@import url('https://fonts.googleapis.com/css2?family=Bitcount+Grid+Double:wght@100..900&family=Bitcount+Prop+Double:wght@100..900&display=swap');

*{
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      /* ✅ Añadimos más directivas para forzar el renderizado pixelado en todos los navegadores */
      image-rendering: -moz-crisp-edges;
      image-rendering: pixelated;
      image-rendering: crisp-edges;
}

body{
      width: 100vw;
      height: 100vh;
      overflow: hidden;
      font-family: "Bitcount Grid Double", system-ui;
      font-weight: 400;
      background-color: #242739;
      -webkit-user-select: none; /* 📱 Evita selección de texto */
      -moz-user-select: none;
      -webkit-tap-highlight-color: transparent; /* Quita el flash azul en iOS */
      touch-action: manipulation;               /* Permite detectar toques */
      -ms-user-select: none;
      user-select: none;
}

.game{
      position: relative;
      color: white;
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
}
.menu{
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      display: flex;
      justify-content: center;
      align-items: center;
      text-align: center;
      flex-direction: column;
      animation: menu-animation 7s infinite;

}

@keyframes menu-animation{
      0%{
            transform: translateY(-1%);
      }
      50%{
            transform: translateY(1%);
      }
      100%{
            transform: translateY(-1%);
      }
}
h2{
      font-size: 50px;
}

#reward-menu {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    flex-direction: column;
    background: linear-gradient(to bottom, #222121, #010122);
    z-index: 1003; /* Por encima de todo */
}

.reward-content {
    background: rgba(0, 0, 0, 0.5);
    padding: 30px 50px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.button-reward, .button-close {
    font-family: "Bitcount Grid Double", system-ui;
    border: 2px solid #00ff88;
    background: transparent;
    color: #00ff88;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 18px;
}

.button-reward:disabled {
    border-color: #555;
    color: #777;
    cursor: not-allowed;
}

.hud-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1001;
    color: white;
    font-size: 20px;
}

.hud-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ✅ Estilo para el botón de regalo cuando está deshabilitado */
.hud-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(100, 100, 100, 0.1);
}

.gift-button {
    right: 60px; /* Ajusta la posición para que no se solape con el botón de sonido */
}

.score-container{
      position: absolute;
      left: 0;
      top: 0;
      margin: 5px;
      font-size: 18px;
      font-weight: 500;
      opacity: 0.7;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      padding: 1px 10px;
      
}

/* Botón de disparo */
.button{
      width: 80px;  /* ✅ Reducido el tamaño base para que sea más manejable */
      height: 80px;
      border: 2px solid rgba(255, 255, 255, 0.3);
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.1);
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      z-index: 1002; /* ✅ Aumentado para que esté sobre la zona del joystick (1000) y otros elementos */
      transition: all 0.2s ease;
      backdrop-filter: blur(10px);
}

/* ✅ Posicionamiento específico para cada botón */
#shoot-button {
    position: absolute;
    /* bottom: 200px;
    right: 20px; */
}

#super-button {
    position: absolute;
    /* bottom: 20px;
    right: 120px;  */
}

/* ✨ Botón de esquive (dash) */
#dash-button {
    position: absolute;

}


.button:active {
      background: rgba(255, 255, 255, 0.2);
      border-color: rgba(255, 255, 255, 0.5);
      transform: rotate(-45deg) scale(1.1);
      border-bottom: 25px solid rgba(255, 255, 255, 0.3);
}

.button ion-icon {
      font-size: 32px;
      color: white;
}
.nipple{
      position: absolute;
      background: rgba(255, 255, 255, 0.5);
      border-radius: 50%;
      pointer-events: none;
  
}
.score, .high-score{
      font-size: 24px;
      font-weight: 700;
}

.high-score-container{
       position: absolute;
       width: 150px;
       left: 43%;
       top: 0;
       margin: 5px;
       font-size: 18px;
       font-weight: 500;
       opacity: 0.7;
       display: flex;
       justify-content: center;
       align-items: center;
       flex-direction: column;
}

/* 📱 Estilos responsivos para móviles */
#canvas {
    display: block;
    background: transparent;
    /* ✅ Asegura que el canvas se renderice con estilo pixelado al ser escalado por CSS */
    image-rendering: pixelated;
    touch-action: none; /* Evita gestos del navegador como zoom */
}
/* Contenedor del botón de recompensa */

/* Estilo del botón de recompensa */
.menuElement {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #444;/* Añadimos padding para que no se vea apretado */
    max-width: 220px;   /* Un ancho máximo para que no sea demasiado grande */
    cursor: pointer;
    transition: 0.5s;
    max-height: 40px;
    margin-bottom: 5px;
    padding: 35px;
}



.play-game2:hover, .hangar-button:hover, .play-game:hover {
      transform: scale(1.2);
    background: rgba(255, 255, 255, 0.1);
}
/* Media queries para móviles */
@media (max-width: 768px) {
    .game {
        width: 100vw;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        margin: 0;
        padding: 0;
    }
    
    #canvas {
        width: 100vw !important;
        height: 100vh !important;
        position: fixed;
        top: 0;
        left: 0;
        object-fit: cover;
    }
    
    .score-container {
        font-size: 16px;
        z-index: 1001;
        left: 10% !important;
        top: 5px !important;
    }
    
    .high-score-container {
        font-size: 16px;
        z-index: 1001;
        left: 35% !important;
        top: 5px !important;
        width: 130px !important;
    }
    
    #hud {
        font-size: 16px !important;
        z-index: 1001;
        left: 65% !important;
        top: 5px !important;
        width: 150px !important;
    }
    
    h2 {
        font-size: 8vw;
    }
    
    .menu ion-icon {
        font-size: 8vw;
    }
 
    .button ion-icon {
        font-size: 28px !important;
    }

    /* ✅ Posicionamiento de botones para vista vertical (portrait) */
    #shoot-button {
        position: absolute;
        bottom: 20px;
        right: 20px;
    }

    #super-button {
        position: absolute;
        bottom: 110px; /* Lo colocamos encima del botón de disparo */
        right: 20px;
    }

    /* ✨ Botón de dash para móvil (portrait) */
    #dash-button {
        position: absolute;
        bottom: 200px; /* Lo colocamos encima del botón de super */
        right: 20px;
    }


    /* --- Menú de Selección de Nave Responsivo --- */
    .ship-selection-menu h2 {
        font-size: 8vw;
        margin-bottom: 10px;
        padding: 0 10px; /* Evita que el texto toque los bordes */
    }
    .ship-options {
        flex-wrap: wrap; /* Permite que los elementos se ajusten */
        justify-content: center; /* Centra las naves */
    }
    .ship-option {
        padding: 10px;
        width: 80vw;
        max-width: 300px;
    }
    .ship-option h3 {
        font-size: 20px;
    }
    .ship-option p {
        font-size: 12px;
    }
    .back-to-menu-button { margin-top: 20px; }

    .ship-preview {
        height: 80px; /* Altura fija para alinear mejor */
        display: flex;
        justify-content: center;
        align-items: center;
    }
}
.upgrade-button{
    font-family: "Bitcount Grid Double", system-ui;
    border: 2px solid rgba(255, 255, 255, 0.3);
    opacity: 0.8;
    background: transparent;
    color: white;
    padding: 2px 5px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;

}

.upgrade-button:hover{
    background: rgba(255, 255, 255, 0.1);
}
.upgrade-section{
    display: flex;
    flex-direction: column;
    gap: 5px; /* Espacio entre botones de mejora */
}

.unlock-button {
    font-family: "Bitcount Grid Double", system-ui;
    border: 2px solid #ffd700; /* Borde dorado */
    background: transparent;
    color: #ffd700;
    padding: 8px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 16px;
}
.unlock-button:hover {
    background: rgba(255, 215, 0, 0.2);
}

/* Para pantallas muy pequeñas */
@media (max-width: 480px) {
    .score-container {
        font-size: 14px;
    }
    
    .high-score-container {
        font-size: 14px;
        width: 120px;
    }
    
    #hud {
        font-size: 14px !important;
        width: 150px !important;
    }
}


@media screen and (orientation: landscape) and (max-height: 768px) {
    #joystick-zone {
        width: 35% !important;
        height: 100% !important;
        bottom: 0px !important;
        left: 0px !important;
        overflow: visible !important;
        max-width: none !important;
        max-height: none !important;
    }


    #shoot-button {
        width: 90px;   /* ✅ Ajustamos el tamaño para landscape */
        height: 90px;
        bottom: 100px;
        right: 25px;
    }
    #super-button {
        width: 90px;
        height: 90px;
        bottom: 25px;
        right: 125px; /* Ajustado para el nuevo tamaño */
    }

    /* ✨ Botón de dash para landscape */
    #dash-button {
        width: 90px;
        height: 90px;
        bottom: 125px; /* Encima del botón de disparo */
        right: 125px;
    }
    
    .button ion-icon {
        font-size: 40px !important;
    }

    #health-container {
        top: 5px !important; /* ✅ Posición correcta para el HUD de vida */
        left: 5px !important;
        font-size: 16px !important;
        width: auto !important; /* Ancho automático */
    }
    
    .score-container {
        font-size: 14px;
        top: 5px !important;
        left: 5px !important;
    }
    
    #hud {
        font-size: 14px !important;
        left: 45% !important; /* ✅ Ajustado para que no se solape */
        top: 5px !important;
        width: 150px !important;
    }
    
    .high-score-container {
        font-size: 14px;
        width: 120px;
        left: 28% !important; /* ✅ Ajustado para mejor alineación */
        top: 5px !important;
    }

    h2 {
        font-size: 6vw !important;
        margin-bottom: 15px !important;
    }
    
    .menu ion-icon {
        font-size: 6vw !important;
        margin-bottom: 15px !important;
    }

    /* --- Menú de Selección de Nave en Landscape --- */
    .ship-selection-menu h2 {
        font-size: 5vw;
        margin-bottom: 15px;
    }
    .ship-options {
        flex-wrap: nowrap; /* Evita que se rompa la línea en landscape */
    }
    .ship-option {
        padding: 10px;
        max-width: 200px; /* Limita el ancho en pantallas horizontales */
    }
}

/* --- Banner Slot Styling --- */

/* Desktop */
#banner-slot { width: 728px; height: 90px; }

/* Tablet / narrow desktop fallback */
@media (max-width: 1024px) {
  #banner-slot { width: 300px; height: 250px; }
}

/* Mobile */
@media (max-width: 768px) {
  #banner-slot { width: 320px; height: 50px; }
}

/* opcional: ocultar visual placeholder mientras no haya banner real */
#banner-slot { background: transparent; pointer-events: auto; }

#loading-screen {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-color: #111111; /* Mismo color que el fondo del juego */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: white;
    font-size: 24px;
}

/* Estilos para la información del usuario en el HUD */
.hud-text {
    position: absolute;
    font-size: 14px;
    opacity: 0.7;
    color: white;
    z-index: 1001;
    display: none; /* Oculto por defecto */
}

#user-info {
    top: 18px;
    right: 60px; /* Al lado del botón de mute */
    text-align: right;
}

/* Ajustes para móviles */
@media (max-width: 768px) {
    #user-info {
        font-size: 12px;
        top: 18px;
        right: 60px; /* Ajustado para móviles */
        max-width: 100px; /* Evita que se desborde */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* --- Animación de Pantalla de Carga --- */
.container {
    display: flex;
    justify-content: center;
    align-items: center;
    animation: space 3.5s infinite alternate;
    position: relative;
}

.planet {
    margin: 0 20px;
    width: 100px;
    height: 100px;
    animation: rotate 20s linear infinite;
}

.nave {
    position: absolute;
    width: 50px;
    z-index: 10;
    bottom: 0;
    left: 0;
    transition: all;
    animation: moveNave 5s infinite alternate;
}

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

@keyframes moveNave {
    0% {
        transform: scale(0.3);
    }
    10% {
        bottom: 17px;
        left: 19px;
        transform: scale(0.5);
    }
    20% {
        bottom: 36px;
        left: 38px;
        transform: scale(0.7);
    }
    30% {
        bottom: 49px;
        left: 53px;
        transform: scale(0.8);
    }
    40% {
        bottom: 60px;
        left: 66px;
        transform: scale(0.9);
    }
    50% {
        bottom: 75px;
        left: 90px;
        transform: scale(1);
    }
    60% {
        bottom: 52px;
        left: 52px;
        transform: scale(0.8);
    }
    70% {
        bottom: 39px;
        left: 39px;
        transform: scale(0.7);
    }
    80% {
        bottom: 26px;
        left: 26px;
        transform: scale(0.5);
    }
    90% {
        z-index: -1;
        bottom: 13px;
        left: 13px;
        transform: scale(0.4);
    }
    100% {
        z-index: -1;
        bottom: 0px;
        left: 0px;
        transform: scale(0.3);
    }
}

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

/* --- Estilos para el Menú de Selección de Nave --- */
.ship-selection-menu {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex; /* Cambiado para mejor control */
    flex-direction: column; /* Cambiado para mejor control */
    justify-content: flex-start; /* ✅ Alinea el contenido arriba */
    align-items: center;
    text-align: center;
    background: linear-gradient(to bottom, #222121, #010122);
    opacity: 0.95; /* Ligera tranparencia */
    z-index: 1002; /* Por encima del menú principal */
    color: white;
    padding: 10px 0; /* Añadimos padding vertical */
    overflow: auto; /* Permite scroll si el contenido es muy alto */
}

.ship-options {
    display: flex;
    flex-wrap: wrap; /* ✅ Permitir que los elementos se envuelvan a la siguiente línea */
    justify-content: center; /* ✅ Centrar las naves en el contenedor */
    gap: 20px;
    margin-top: 30px;
    padding: 0 15px; /* Espaciado lateral */
    max-width: 750px; /* ✅ Ancho máximo para forzar 3 columnas (220px * 3 + gaps) */
}

.ship-option {
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.05);
    width: 100%; /* Ocupa el espacio disponible */
    max-width: 220px; /* Pero no más de esto */
    /* ✅ Usamos flexbox para alinear el contenido verticalmente */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 250px; /* Asegura una altura mínima para todas las tarjetas */
}

.ship-option:hover, .ship-option.selected {
    background: rgba(0, 255, 136, 0.2);
    border-color: #00ff88;
    transform: translateY(-10px);
}

.ship-text-content {
    /* ✅ Este contenedor empujará la descripción hacia abajo */
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-top: 15px; /* ✅ Añadimos un espacio superior consistente */
}

.ship-option h3 {
    font-size: 24px;
}

.ship-option p {
    font-size: 14px;
    opacity: 0.7;
}

.ship-preview {
    width: 100px;
    height: 120px; /* Aumentamos la altura para dar espacio */
    background-repeat: no-repeat;
    display: flex; /* Para centrar la imagen interna */
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    image-rendering: pixelated; /* Para mantener el estilo pixel art */
}

/* Coordenadas de cada nave en el spritesheet */
/* ✅ Hacemos la regla más específica para que solo afecte a la nave azul */
.ship-option[data-ship-type="blue"] .ship-blue {
    background-image: url('spaceShooter2_spritesheet.png');
    background-position: -278px 0px;
    width: 170px; height: 151px;
    transform: scale(0.6); /* Ajustamos con transform para no afectar el layout */
}

.ship-green {
    background-image: url('spaceShooter2_spritesheet.png');
    background-position: -448px -58px; 
    width: 114px; height: 82px;
    transform: scale(1);
    margin-bottom: 37px;
    margin-top: 30px;
}

.ship-red {
    background-image: url('spaceShooter2_spritesheet.png');
    background-position: -562px -58px; 
    width: 100px; height: 82px;
    transform: scale(1);
    margin-bottom: 37px;
    margin-top: 30px;
}

.ship-locked {
    background-repeat: no-repeat;
    background-position: center;
    border: 3px dashed rgba(255, 255, 255, 0.4);
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.question-mark {
    font-size: 60px;
    color: rgba(255, 255, 255, 0.6);
}

/* ✅ Estilos para la imagen de la nave dorada que se añadirá con JS */
.ship-preview.ship-gold img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    transform: scale(1.2);
    margin-top: 10px;
}

/* Estilos para la imagen de la nave mariposa */
.ship-preview.ship-butterfly img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    transform: scale(1.2);
    margin-top: 10px;
}

/* Estilos para la nueva nave pixel */
.ship-preview.ship-pixel img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    transform: scale(1.2);
    margin-top: 10px;
}

.back-to-menu-button {
    margin-top: 20px; /* Reducimos el margen superior */
    font-size: 40px;
    cursor: pointer;
    transition: transform 0.3s;
}
.back-to-menu-button:hover {
    transform: scale(1.2);
}

/* --- Estilos para el Tutorial Interactivo --- */
#tutorial-overlay {
    position: absolute;
    bottom: 15%; /* Posicionado en la parte inferior de la pantalla */
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 600px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-align: center;
    z-index: 2000;
    font-size: 18px;
}

#tutorial-prompt {
    display: block;
    margin-top: 10px;
    font-size: 16px;
    color: #00ff88;
    opacity: 0.8;
}

/* --- Estilos para Estadísticas Post-Partida --- */
#post-game-stats {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2500; /* Por encima de todo */
    color: white;
    font-family: "Bitcount Grid Double", system-ui;
}

.stats-content {
    background: rgba(10, 10, 20, 0.9);
    padding: 30px 40px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    min-width: 350px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px 20px;
    margin: 25px 0;
    text-align: left;
    font-size: 18px;
}

.stats-grid span:nth-child(even) {
    text-align: right;
    font-weight: bold;
    color: #00ff88;
}

#stats-continue-button {
    font-family: "Bitcount Grid Double", system-ui;
    border: 2px solid #00ff88;
    background: transparent;
    color: #00ff88;
    padding: 10px 25px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 18px;
}

#stats-continue-button:hover {
    background: rgba(0, 255, 136, 0.2);
}
