:root {
    --teal: #00796b;
    --teal-dark: #004d40;
    --teal-light: #b2dfdb;
    --orange: #e65100;
    --white: #ffffff;
}

html, body {
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#screen-game {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 10px;
    padding-bottom: 10px;
}

#presplash-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('presplash.webp');
    background-size: cover;
    background-position: center;
    z-index: -1;
}

#waiting-overlay {
    background: rgba(0, 77, 64, 0.9);
    backdrop-filter: blur(5px);
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1040 !important; /* Meno del modal (1050) */
}

/* 2. Forziamo il Modal di autenticazione e avvisi a stare sopra a tutto */
#authModal {
    z-index: 1100 !important;
}

/* 3. Forziamo il 'velo' scuro del modal (backdrop) a stare sopra l'overlay di attesa */
.modal-backdrop {
    z-index: 1080 !important;
}

#waiting-overlay .card {
    border-radius: 20px;
    border: none;
    min-width: 280px;
}

#gallery-grid .card {
    transition: transform 0.2s;
    background: #f9f9f9;
}

#gallery-grid .card:hover {
    transform: scale(1.05);
    background: var(--teal-light);
}

/* Rende scorrevole il contenuto della bio se il testo eccede lo schermo */
#bioModal .modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

#bio-body p {
    line-height: 1.5;
    margin-top: 10px;
    text-align: justify; /* Forza l'allineamento a sinistra */
    hyphens: auto;    /* Aggiunge il trattino per andare a capo (sillabazione) */
}

#btn-speech {
    border-radius: 20px;
    font-weight: bold;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

#btn-speech:hover {
    background-color: #004d40;
    color: white;
    transform: scale(1.02);
}

.text-teal { color: var(--teal); }
.bg-teal { background-color: var(--teal); }

.btn-teal { 
    background-color: var(--teal); 
    color: white; 
    border: none; 
    transition: all 0.3s ease;
}

.btn-teal:hover { 
    background-color: var(--teal-dark); 
    color: white; 
    transform: translateY(-2px);
}

.btn-orange { 
    background-color: var(--orange); 
    color: white; 
    border: none; 
    transition: all 0.3s ease;
}

.btn-orange:hover { 
    background-color: #bf4500; 
    color: white; 
    transform: translateY(-2px);
}

.btn-outline-teal { 
    color: var(--teal); 
    border: 2px solid var(--teal); 
    font-weight: bold;
    background: white;
}

.btn-outline-teal:hover { 
    background-color: var(--teal); 
    color: white; 
}

.card-game { 
    background-color: white !important; /* Forza il bianco solido */
    width: 100%;
    max-width: 400px;
    min-width: 300px;
    max-height: 75vh;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 5px auto;
}

#card-img { 
    width: 100%;
    height: auto;
    max-height: 30vh; /* L'immagine si restringe se lo schermo è basso */
    min-height: 150px;
    object-fit: cover; 
    flex-shrink: 1;   /* Permette all'immagine di ridursi per far spazio ai tasti */
}

/* --- CONTENITORE PULSANTI STATISTICHE --- */
#stats-container {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly; 
    flex-grow: 1;
}

#card-name {
    text-align: center;
    width: 100%;
    margin-bottom: 15px;
    font-weight: 800;
    color: var(--teal-dark);
}

/* --- 3. STILE ICONA INFO 'i' --- */
.info-icon-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: white;
    border: 2px solid var(--teal);
    border-radius: 50%;
    color: var(--teal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Georgia", serif;
    font-style: italic;
    font-weight: bold;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    z-index: 10;
    transition: transform 0.2s ease;
}

.info-icon-btn:hover {
    transform: scale(1.1);
    background: var(--teal);
    color: white;
}

/* --- AREA INFORMAZIONI SUPERIORE --- */
#screen-game > .mb-2, 
#screen-game > .mb-3 {
    width: 100%;
    max-width: 400px; /* Allineato alla larghezza della carta */
    flex-shrink: 0;   /* Impedisce alla barra di schiacciarsi */
    margin-bottom: 8px !important;
}

.card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 10px !important;
    overflow: hidden; /* Evita la comparsa della barra di scorrimento interna */
}

.stat-btn {
    text-align: left;
    padding: 8px 12px !important; 
    font-size: 0.9rem;
    margin-bottom: 4px !important;
    display: flex;
    justify-content: space-between;
    flex: 1; /* Forza i pulsanti a dividersi l'altezza disponibile */
}

/* --- BARRA GIOCATORI ELASTICA --- */
#multi-player-status {
    display: flex;
    justify-content: space-around;
    width: 100%;
    overflow: hidden;
}

.player-badge {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
}

.player-name {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* --- PULSANTE ABBANDONA --- */
#screen-game .btn-danger {
    flex-shrink: 0;
    margin-top: 10px;
}

.badge {
    padding: 8px 12px;
    font-size: 0.8rem;
    border-radius: 50px;
}

/* Badge Veterano Classifica */
.bg-veteran { 
    background-color: #FFD700; 
    color: #000; 
    font-weight: bold; 
    border: 1px solid #b8860b; 
}

.text-orange { 
    color: var(--orange); 
    font-weight: bold; 
}

.modal-content {
    border-radius: 20px;
    border: none;
}

#end-icon {
    line-height: 1;
}

.pointer { cursor: pointer; }

.spinner-border.text-teal {
    color: var(--teal) !important;
}

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-height: 750px) {
    /* Regole più equilibrate per laptop o finestre ridotte */
    #card-img { 
        max-height: 30vh; /* Comunque generoso anche su schermi bassi */
    }
    .stat-btn { 
        padding: 8px 12px !important; 
        font-size: 0.9rem; 
        margin-bottom: 3px !important;
    }
    .card-body { 
        padding: 12px !important; 
    }
    h5 { 
        font-size: 1.2rem !important; 
    }
}

/* Forza i modal in primo piano */
.modal { z-index: 1060 !important; }
.modal-backdrop { z-index: 1050 !important; }

/* Compressione per schermi "corti" */
@media (max-height: 600px) {
    #card-img {
        max-height: 140px !important; /* Riduce l'immagine */
        min-height: 100px;
    }
    .card-game {
        max-height: 85vh; /* Usa più spazio verticale */
    }
    .stat-btn {
        padding: 5px 10px !important; /* Pulsanti più sottili */
        font-size: 0.8rem;
    }
    #card-name {
        margin-bottom: 5px;
        font-size: 1rem;
    }
}