/* --- RESET E VARIABILI --- */
:root {
    /* TODO: aggiornare se si cambia URL */
    --sfondo: url('https://cacciatesoro.gigini.it/img/paper.jpg');
}

/* ============================================================
   CONFIGURAZIONI BASE E LAYOUT
   ============================================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #000;
    color: #eee;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    text-align: center;
}

a {
    color: darkred;
    text-decoration: none;
}

.container {
    width: 90%;
    max-width: 850px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

hr {
    border: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, darkred, transparent);
    margin: 20px auto;
    width: 100%;
}

h1 {
    color: darkred;
    /*text-transform: uppercase;*/
    letter-spacing: 3px;
    font-size: 2.2rem;
    margin: 10px 0;
}

/* ============================================================
   COMPONENTI UI (Bottoni, Input, Card)
   ============================================================ */
.game-main {
    background: black;
    background-image: var(--sfondo);
    background-repeat: no-repeat;

    /* 1. Forza l'immagine a occupare il 100% di larghezza e altezza del box */
    background-size: 100% 100%;

    /* 2. Rendi la larghezza fluida rispetto alla finestra */
    width: 90%;
    /* Usa una percentuale per il resize orizzontale */
    max-width: 600px;
    /* Opzionale: un limite massimo per non sgranare troppo */

    /* 3. Gestione altezza */
    min-height: 220px;
    /* Altezza minima di partenza */
    height: auto;
    /* Permette al box di allungarsi se il testo aumenta */

    color: black;
    margin: auto;
    padding: 40px 65px 55px;
    /* Consigliato: evita che il testo tocchi i bordi dell'immagine */
    box-sizing: border-box;
    /* Assicura che il padding non rompa le dimensioni del box */
}

.key {
    color: white;
    letter-spacing: 2px;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 10px 0;
}

.game-card {
    background: #111;
    border: 1px solid #333;
    padding: 25px;
    border-radius: 12px;
    margin: 20px 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.cover-img,
.clue-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #222;
}

textarea,
input[type="number"],
input[type="text"] {
    width: 100%;
    max-width: 350px;
    padding: 14px;
    background: #222;
    border: 1px solid #444;
    color: #fff;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 10px;
    transition: border 0.3s;
}

input[type="number"]:focus {
    border-color: darkred;
    outline: none;
}

input[type="text"]:focus {
    border-color: darkred;
    outline: none;
}

.btn-main {
    background: darkred;
    color: white;
    border: none;
    padding: 14px 35px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    transition: all 0.3s ease;
    display: inline-block;
    text-decoration: none;
}

.btn-main:hover {
    background: #ff0000;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 0, 0, 0.3);
}

.btn-dwl {
    background: #444;
    margin-top: 10px;
    padding: 10px 20px;
}

.sel-main {
    background: gray;
    color: white;
    border: none;
    padding: 14px 35px;
    border-radius: 6px;
    cursor: pointer;
    /*font-weight: bold;
    text-transform: uppercase;*/
    transition: all 0.3s ease;
    display: inline-block;
    text-decoration: none;
}

.sel-main:hover {
    background: darkgray transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.3);
}

.info-bar,
.step-bar {
    padding: 10px 20px;
}

.msg {
    background: #111;
    border: 1px solid #333;
    padding: 15px;
    border-radius: 12px;
    margin: 10px 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}


.error {
    color: red;
    font-weight: bold;
    font-size: 1.2rem;
    display: block;
}

.warning {
    color: yellow;
    font-size: 1.2rem;
    display: block;
    margin-bottom: 15px;
}

.info {
    color: gray;
    font-size: 1.2rem;
    font-style: italic;
    display: block;
    margin-bottom: 15px;
}

.approfondimenti {
    background: #111;
    border: 1px solid #333;
    padding: 25px;
    border-radius: 12px;
    margin: 20px 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.approfondimenti a {
    color: darkred;
    text-decoration: none;
    margin: 0 10px;
}

/* ============================================================
   ANIMAZIONI E FEEDBACK (Successo ed Errore)
   ============================================================ */

/* --- SUCCESSO (Bounce + Shimmer) --- */
@keyframes successBounce {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    70% {
        transform: scale(1.05);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% center;
    }

    100% {
        background-position: 200% center;
    }
}

.success-banner {
    animation: successBounce 0.6s ease-out, shimmer 3s linear infinite;
    /*background: linear-gradient(90deg, #1e7e34, #28a745, #1e7e34); verde*/
    /*background: linear-gradient(90deg, #721c24, #dc3545, #721c24); Rosso Classico (Equilibrato)*/
    background: linear-gradient(90deg, #5a0001, #900c3f, #5a0001);
    /*Rosso Profondo (Elegante)*/
    background-size: 200% auto;
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

/* --- ERRORE (Shake) --- */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-10px);
    }

    40%,
    80% {
        transform: translateX(10px);
    }
}

.error-container {
    animation: shake 0.4s ease-in-out;
}

.input-error {
    border: 2px solid #ff4d4d !important;
    background: rgba(255, 0, 0, 0.1) !important;
}

/* ============================================================
   SEZIONI SPECIFICHE (Vittoria e Footer)
   ============================================================ */
.victory-card {
    background: darkred;
    color: white;
    padding: 20px 10px;
    border-radius: 15px;
    border: 3px solid #b8860b;
    margin: 20px 0;
}

.victory-card h2 {
    color: #b8860b;
}

.victory-card hr {
    background: linear-gradient(to right, transparent, #b8860b, transparent);
}

.hint-box {
    background: #1a1a1a;
    color: darkgray;
    border-left: 4px solid darkred;
    padding: 20px;
    border-radius: 0 8px 8px 0;
    margin: 25px auto;
    text-align: center;
    width: 90%;
    max-width: 600px;
}

footer {
    color: darkred;
    margin-top: auto;
    padding: 10px 0 10px;
    font-size: 0.9rem;
}

footer a {
    color: gray;
    text-decoration: none;
    margin: 0 10px;
}

/* Responsive */
@media (max-width: 600px) {
    h1 {
        font-size: 1.6rem;
    }

    .btn-main {
        width: 100%;
    }
}

/* Stile del Dialog */
dialog {
    border: 2px solid #333;
    border-radius: 15px;
    /* Angoli arrotondati */
    padding: 20px;
    max-width: 90vw;
    max-height: 90vh;
    outline: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    /* Centratura magica (se non già centrato dal browser) */
    margin: auto;
    overflow: hidden;
    /* Impedisce la scrollbar fastidiosa */
}

/* Animazione Fade-In quando si apre */
dialog[open] {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Sfondo oscurato (Backdrop) */
dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    /* Effetto sfocatura molto moderno */
    animation: fadeIn 0.3s ease-out forwards;
}

/* Definizione dell'animazione */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
        /* Parte leggermente più piccolo */
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.dialog-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    /* Occupa tutto lo spazio del dialog */
}

.dialog-content img {
    display: block;
    max-width: 100%;
    /* Calcoliamo l'altezza massima: 
       90vh (altezza dialog) - 40px (padding dialog) - 60px (spazio per tasto e margini) */
    max-height: calc(90vh - 110px);
    height: auto;
    width: auto;
    /* Mantiene le proporzioni corrette */
    object-fit: contain;
    /* Assicura che l'immagine sia contenuta senza tagli */
    border-radius: 8px;
    margin-bottom: 15px;
}

.btn-close {
    flex-shrink: 0;
    /* Impedisce al bottone di rimpicciolirsi se l'immagine è grande */
    padding: 8px 16px;
    cursor: pointer;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 5px;
}