/* Reset generale */

html, body {
    margin: 0;
    padding: 0;
    /* forza tutto a 100% */
    width: 100%;
    height: 100%;
  
    /* Usa -webkit-fill-available per iOS Safari */
    min-height: -webkit-fill-available;
  
    /* Solo se vuoi sfondo nero (o un altro colore) */
    background: black;
    overflow: hidden;
    
    /* Disabilita tutte le gesture del browser */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: none;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
  }

  .full-viewport {
    height: 100svh; /* Safari 16+ e browser moderni */
    touch-action: none;
  }


  body {
    overscroll-behavior: none;          /* Chrome/Firefox/Edge */
    -webkit-overflow-scrolling: none;   /* iOS Safari */
    touch-action: none;                 /* disabilita pinch/zoom */
    position: fixed;                    /* Impedisce lo scroll inerziale su iOS */
    width: 100%;
    height: 100%;
  }


  html, body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }


/* Slideshow Container */

#slideshow-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: black;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Evita scroll */
    z-index: 9999;
    /* Alto per essere sopra tutto */
    cursor: auto !important;
    /* Assicura che il cursore standard sia visibile nelle slide */
}

#slideshow-container * {
    cursor: auto !important;
    /* Assicura che tutti gli elementi dentro le slide abbiano il cursore standard */
}


/* Slide */

.slide {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}


/* Le immagini coprono l'intera finestra */

.slide img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Copre la finestra tagliando l'eccesso */
    pointer-events: none;
    /* Evita interazioni con il clic */
}


/* Slide attiva */

.slide.active {
    opacity: 1;
}


/* ===== SPLASH (stile 3D Gallery) ===== */

#slideshow-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: #ffff00;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
}

#slideshow-container.hidden {
    display: none;
}

#logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 28px;
}

#logo {
    width: 200px;
    height: auto;
    animation: fadeInLogo 2s ease-out forwards;
}

@keyframes fadeInLogo {
    from { opacity: 0; }
    to   { opacity: 1; }
}

#progress-bar {
    position: relative;
    width: 260px;
    height: 3px;
    background: #00aa00;
}

#loading-bar-fill {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    width: 0%;
    background: #ff00ff;
    transition: width 0.15s linear;
}

#tap-hint {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    color: #ff00ff;
    letter-spacing: 0.15em;
    animation: blink 1s step-start infinite;
    margin-top: 20px;
}

@keyframes blink {
    50% { opacity: 0; }
}

@media (max-width: 900px) {
    #logo { width: 150px; }
    #progress-bar { width: 200px; }
}


/* Contenitore del gioco */

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: black;
    z-index: 2;
    /* Sopra lo slideshow */
}


/* Canvas */

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}


/* Barra della vita */


/* Barra della vita del personaggio */

#health-bar {
    position: relative;
    width: 200px;
    height: 20px;
    background: red;
    border: 3px solid black;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 10;
    margin-right: auto;
}


/* Colore dinamico della barra (facoltativo per future animazioni) */

#health-bar .fill {
    width: 100%;
    height: 100%;
    background: #00ff00;
    border-radius: 5px;
    transition: width 0.2s ease;
    /* Transizione fluida */
}


/* Classe per nascondere elementi */

.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
}


/* Barra della vita del boss */

#boss-health-bar {
    position: relative;
    width: 200px;
    height: 20px;
    background: transparent; /* Sfondo trasparente */
    border: none; /* Nessun bordo */
    border-radius: 10px;
    overflow: hidden;
    z-index: 10;
    margin-left: auto;
    padding: 3px; /* Spazio per il bordo */
    box-sizing: content-box;
    --damage-width: 0%; /* Variabile CSS per la larghezza dell'overlay rosso */
    display: none; /* Nascosto di default, verrà mostrato dal JavaScript */
}

/* Contenitore interno verde */
#boss-health-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #00ff00; /* Verde */
    border-radius: 7px;
    z-index: 1;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.7), inset 0 0 0 3px #009900; /* Ombra verde e bordo interno */
}

/* Overlay rosso per il danno */
#boss-health-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--damage-width);
    background: red;
    border-radius: 7px;
    z-index: 2; /* Sopra il verde */
    display: none; /* Nascosto di default */
    transition: width 0.2s ease; /* Transizione fluida */
}

/* Quando il boss è danneggiato */
#boss-health-bar.damaged::before {
    display: block;
}

#boss-health-bar.damaged::after {
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.7), inset 0 0 0 3px #990000; /* Ombra rossa e bordo interno rosso */
}

#boss-health-bar .fill {
    /* Non necessario, usiamo l'elemento pseudo ::before */
    display: none;
}


/* HUD */

#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Evita interferenze con clic */
    z-index: 10000 !important; /* Sempre visibile sopra tutto */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    justify-content: space-between;
    padding: 20px;
    box-sizing: border-box;
}

/* Messaggio di istruzione per il lanciafiamme */
#flamethrower-instruction {
    position: fixed;
    top: 50px; /* Stessa posizione del movement-instruction */
    left: 50%;
    transform: translateX(-50%);
    color: #39ff14;
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    text-align: center;
    z-index: 2; /* Stesso z-index del movement-instruction */
    display: none;
    text-shadow: 0 0 5px rgba(57, 255, 20, 0.7);
    white-space: nowrap;
}

#three-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5; /* Valore inferiore a quello dei controls */
}


/* Controlli per il bivio */

#controls {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: space-between;
    width: 300px; /* Aumento larghezza per frecce più grandi */
    z-index: 9999; /* Valore molto alto per essere sicuri che sia sopra ogni altro elemento */
    opacity: 0; /* Inizialmente nascosto */
    pointer-events: auto !important; /* Garantisco che siano sempre cliccabili */
    transition: opacity 0.3s ease;
}


/* Frecce */

#controls img {
    width: 65px; /* Rimpicciolite rispetto agli 80px precedenti */
    height: 65px; /* Rimpicciolite rispetto agli 80px precedenti */
    cursor: none !important;
    transition: transform 0.2s ease;
    filter: brightness(0) invert(1); /* Rende le frecce bianche */
    pointer-events: auto !important; /* Garantisco che siano sempre cliccabili */
}

#controls img:hover {
    transform: scale(1.2); /* Effetto hover più contenuto */
    filter: brightness(0) invert(1); /* Mantiene le frecce bianche anche in hover */
    cursor: none !important;
}


/* Classe per mostrare i controlli */

#controls.visible {
    opacity: 1;
    pointer-events: auto;
    /* Abilita interazione */
}


/* Effetto occhi che si aprono e chiudono */
#eyelid-top {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background-color: #000;
    z-index: 30000; /* Aumentato enormemente per essere sicuri che sia sopra tutto */
    transform: translateY(0);
    transition: transform 0.5s ease-in-out;
}

#eyelid-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background-color: #000;
    z-index: 30000; /* Aumentato enormemente per essere sicuri che sia sopra tutto */
    transform: translateY(0);
    transition: transform 0.5s ease-in-out;
}

.eyelid-close {
    animation: none;
}

.eyelid-animate {
    animation: blinkEyes 3s ease-in-out forwards;
}

@keyframes blinkEyes {
    0% {
        transform: translateY(0);
    }
    20% {
        transform: translateY(-100%);
    }
    40% {
        transform: translateY(0);
    }
    60% {
        transform: translateY(-100%);
    }
    100% {
        transform: translateY(-100%);
    }
}

/* Inverti l'animazione per il rettangolo inferiore */
#eyelid-bottom.eyelid-animate {
    animation: blinkEyesBottom 3s ease-in-out forwards;
}

@keyframes blinkEyesBottom {
    0% {
        transform: translateY(0);
    }
    20% {
        transform: translateY(100%);
    }
    40% {
        transform: translateY(0);
    }
    60% {
        transform: translateY(100%);
    }
    100% {
        transform: translateY(100%);
    }
}

/* Effetto sfocatura */
.blur-effect {
    filter: blur(10px);
    transition: filter 2s ease-out;
}

.blur-effect.removing {
    filter: blur(0);
}

#movement-instruction {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    color: #39ff14;
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    text-align: center;
    z-index: 2; /* Abbassato ulteriormente per essere sicuri che sia dietro l'animazione degli occhi */
    display: none;
    text-shadow: 0 0 5px rgba(57, 255, 20, 0.7);
    white-space: nowrap;
}

#movement-instruction.visible {
    display: block; /* Rimosso !important */
    visibility: visible; /* Rimosso !important */
    opacity: 1; /* Rimosso !important */
}

#flamethrower-instruction.visible {
    display: block; /* Rimosso !important */
    visibility: visible; /* Rimosso !important */
    opacity: 1; /* Rimosso !important */
}

/* Regole per i container principali */
#slideshow-container.hidden {
    display: none !important;
    z-index: -1 !important;
}

#game-container {
    z-index: 999;
}

#game-container.hidden {
    display: none !important;
}

/* Assicurati che l'HUD non sia nascosto dalla classe hidden */
#hud.hidden {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}