/* === GLOBALI E SFONDO === */
html, body {
    margin:0; padding:0; width:100%; height:100%;
    background: radial-gradient(circle at center, #202030 0%, #0a0a0f 100%);
    overflow:hidden; font-family: "Segoe UI", sans-serif;
}
select { 
    /* Nascondiamo i selettori nativi */
    display:none; 
}

.hint {
    position:fixed; left:10px; bottom:10px;
    background: rgba(0,0,0,0.5); color:white;
    padding:8px 12px; border-radius:8px; font-size:13px;
    z-index: 10;
}

/* === TITOLO E COPYRIGHT === */
#siteTitleContainer {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1001;
    text-align: right;
    color: #FFFFFF;
    max-width: 450px;
}

#mainTitle {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.2vw; /* Responsive font size - Si adatta alla larghezza */
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    color: #FFD700; /* Oro */
    text-shadow: 1px 1px 3px #000000;
    width: 25%; /* Largo quanto il contenitore dei gruppi */
    text-align: center; /* Centrato */
    white-space: nowrap; /* Evita il wrap del testo */
}

#subTitle {
    font-family: Georgia, serif;
    font-size: 0.9em;
    display: block;
    font-weight: 400;
    opacity: 0.8;
    color: #FFD700; /* Oro */
    text-shadow: 1px 1px 3px #000000;
}

#copyright {
    position: fixed;
    bottom: 10px;
    right: 10px;
    color: #888;
    font-size: 10px;
    font-family: sans-serif;
    z-index: 9999;
    padding: 2px;
}

/* === NODI E GRUPPI (FISICA) === */
.node, .group-block {
    position:absolute; transform:translate(-50%, -50%);
    padding:6px 10px; border-radius:10px;
    background: rgba(255,255,255,0.06);
    color:white; cursor:pointer;
    white-space:nowrap; transition: background 0.2s;
    user-select:none;
    z-index: 5;
    opacity: 0.3;
}

.group-block {
    width: 12%; /* Responsive */
    height: 8vh; /* Responsive - usa viewport height */
    text-align: center;
    /* 🔑 NUOVA REGOLA: Ritorna al comportamento originale (fluttuante) */
    position: relative; 
    transform: none;
    margin: 0.5%; /* Responsive - Spazio tra i blocchi quando fluttuano */
    float: left; /* Flottaggio per l'allineamento iniziale */
    z-index: 100; /* Z-index più alto per evitare conflitti con hover */
    font-size: 1.2vw; /* Responsive font size */
    line-height: 0.1; /* Interlinea quasi zero per blocchi gruppo */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.node {
    min-width: 8.16%; /* Responsive - Ridotto del 15% ulteriore (9.6% * 0.85) */
    width: max-content;
    text-align: center;
    opacity: 0.6;
    background-color: rgba(255, 255, 255, 0.05);
    transition: opacity 0.2s, background 0.2s, filter 0.2s;
    z-index: 5;
    font-size: 1.1vw; /* Responsive font size */
}

.node .book { display:block; font-size:0.6vw; opacity:0.8; } /* Responsive */
.node strong { font-size: 0.9vw; } /* Responsive */

.node:hover {
    opacity: 1 !important;
    z-index: 100 !important;
    background-color: rgba(10, 10, 10, 1.0) !important;
    filter: none !important;
    color: white;
    transition: background 0.2s, filter 0.2s;
}

/* === STATO DIMMERATO === */
.dimmed-group {
    opacity: 0.3 !important;
    filter: grayscale(98%);
    transition: opacity 0.3s, filter 0.3s;
}

.group-block:hover {
    background: rgba(255,255,255,0.15) !important;
    opacity: 1 !important;
    filter: none !important;
}
.group-block:not(.dimmed-group) {
    opacity: 1;
    filter: grayscale(0%);
}

/* 🔑 CLASSE PER IL GRUPPO SELEZIONATO - POSIZIONE FISSA */
.group-block.selected {
    border: 3px solid #FFD700; /* Evidenziazione */
    background: rgba(113, 242, 128, 0.46) !important;
    /* Rimuove order per mantenere la posizione fissa */
}

/* === MENU CONTAINER E LAYOUT LATERALE === */
.menu-section-container {
    position: fixed;
    left: 1%;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    padding: 0.8% 1.5%; 
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 23%; /* Responsive - Ridotto del 2% (25% * 0.98) */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 900;
}

/* 🔑 Adattate le posizioni TOP - RESPONSIVE */
#groupMenuContainer { top: 10%; } /* Rialzato del 3% */
#characterMenuContainer { top: 20%; } /* Rialzato del 3% */

/* 🔑 NUOVO CONTAINER PER I BLOCCHI DEI GRUPPI MBTI (PER L'ALLINEAMENTO A DESTRA) */
#groupBlockContainer {
    position: fixed;
    top: 8%; /* 🔑 Mantiene la stessa posizione in alto */
    height: 60vh; /* Responsive height - Aumentato del 20% per contenitore più alto */
    right: 1%; /* Allineato a destra */
    width: 25%; /* Responsive - Abbastanza largo per 2 colonne */
    padding: 0.5%;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 900;
    
    /* 🔑 Contenitore Flex per due colonne a destra - CONFIGURAZIONE STABILE */
    display: flex;
    flex-wrap: wrap; /* Permette il wrapping a 2 colonne */
    justify-content: flex-start; /* Mantiene l'ordine naturale dei blocchi */
    align-content: flex-start; /* Allinea le righe in alto */
}
/* Reimposta i gruppi per la disposizione su due colonne - RESPONSIVE */
#groupBlockContainer .group-block {
    position: relative; 
    transform: none;
    float: none;
    width: 45%; /* Due colonne larghe */
    height: 7vh; /* Responsive height - Aumentato per contenitore più alto */
    margin: 0.4% 2%; /* Spazio tra i blocchi - Aumentato per contenitore più alto */
    box-sizing: border-box; /* Include padding e border nella larghezza */
    font-size: 1.1vw; /* Responsive font size */
    line-height: 0.8; /* Interlinea quasi zero per blocchi gruppo */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}


/* ========================================================= */
/* MODIFICHE PER ALLINEARE I BOTTONI MBTI INFO E RANDOM */
/* ========================================================= */

/* Contenitore MBTI Info (Originale) - RESPONSIVE */
#infoMenuContainer {
    top: 32%; /* Rialzato del 3% */
    width: 12%;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
    z-index: 900;
    
    /* 🔑 ESSENZIALE per l'allineamento orizzontale */
    display: inline-block; 
    vertical-align: top;
    margin-right: 2%; /* Spazio dal bottone Random - Responsive */
    position: fixed; /* Mantenuto per non rompere il layout */
}

/* Nuovo Contenitore Random: Stesse proprietà di allineamento del suo vicino - RESPONSIVE */
#randomCharContainer {
    /* 🔑 ESSENZIALE per l'allineamento orizzontale */
    display: inline-block; 
    vertical-align: top;
    position: fixed; 
    left: 15%; /* Responsive - Posizionato dopo il bottone MBTI */
    top: 32%; /* Rialzato del 3% */
    
    /* Rimuoviamo gli stili del menu-section-container che non servono qui */
    width: 8%;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
    z-index: 900; 
}


/* Stile per il pulsante INFO (Originale) */
#mbtiInfoButton {
    background-color: rgba(30, 30, 40, 0.9);
    color: #FFD700;
    border: 1px solid #FFD700;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    width: 100%;
    text-align: left;
    transition: background-color 0.2s;
}
#mbtiInfoButton:hover {
    background-color: rgba(50, 50, 65, 0.9);
}

/* Stile per il NUOVO pulsante Random */
#randomCharButton {
    background-color: rgba(30, 30, 40, 0.9);
    color: #66CDAA; /* Verde acqua per distinguerlo */
    border: 1px solid #66CDAA; 
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    width: 100%;
    text-align: center;
    transition: background-color 0.2s;
}
#randomCharButton:hover {
    background-color: rgba(50, 50, 65, 0.9);
    color: #ADFF2F; 
    border-color: #ADFF2F;
}

/* ========================================================= */
/* FINE BOTTONI - INIZIO ALTRI STILI */
/* ========================================================= */

.menu-section-container label {
    margin-right: 15px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    text-align: right;
    flex-shrink: 0;
    width: 80px; 
}

/* Priorità massima quando un menu è aperto */
.menu-section-container.active-dropdown {
    z-index: 9999 !important;
}

/* === STILI CUSTOM SELECT === */

.custom-select-container {
    width: 200px; 
    position: relative;
    font-family: "Segoe UI", sans-serif;
    z-index: 990;
}

/* L'ELEMENTO CHE MOSTRA IL VALORE SELEZIONATO */
.select-display {
    min-height: 48px; 
    line-height: 1.3; 
    padding: 5px 10px;
    border: 1px solid #ccc;
    background-color: rgba(255,255,255,0.95);
    color: #111;
    cursor: pointer;
    font-weight: 500;
    border-radius: 4px;
    user-select: none;
    box-sizing: border-box;
    width: 100%; 
    display: block;
    transition: background-color 0.2s;
    overflow: hidden;

    /* REGOLE PER LA FRECCIA */
    position: relative; 
    padding-right: 30px; 
}

.select-display:hover {
    background-color: #fff;
}

/* 💥 REGOLE DELLA FRECCIA (TRIANGOLO) */
.select-display::after {
    content: "\25BC"; 
    position: absolute;
    top: 50%; 
    right: 10px; 
    transform: translateY(-50%); 
    font-size: 10px; 
    color: #333; 
    pointer-events: none;
    transition: transform 0.2s;
}

/* 💥 ROTAZIONE DELLA FRECCIA QUANDO IL MENU È APERTO */
.active-dropdown .select-display::after {
    transform: translateY(-50%) rotate(180deg); 
}

/* === LISTA OPZIONI E RISULTATI RICERCA === */
.options-list, #searchResultsList {
    position: absolute;
    width: 100%; /* Responsive - Si adatta al contenitore */
    left: 0;
    top: 100%;
    max-height: 40vh; /* Responsive height */
    overflow-y: auto;
    border: 1px solid #ccc;
    border-top: none;
    background-color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border-radius: 0 0 4px 4px;
    z-index: 10000;
}

.options-list.hidden {
    display: none;
}

/* === SEARCH BAR E CONTAINER === */
#searchContainer {
    position: fixed;
    top: 1%; /* Responsive */
    left: 1%; /* Responsive */
    background: rgba(0, 0, 0, 0.5);
    padding: 1%; /* Responsive */
    border-radius: 8px;
    width: 25%; /* Largo quanto il contenitore dei gruppi */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 5000;
}

#searchBar {
    width: 100%;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid #ccc;
    box-sizing: border-box;
    font-size: 14px;
    outline: none;
}

#searchResultsList {
    top: 100%; /* Responsive - Si posiziona sotto il contenitore */
    left: 0; /* Responsive - Allineato al contenitore */
}

/* === OPZIONI E RISULTATI COMUNI === */
.custom-option {
    padding: 4px 6px; /* Padding aumentato per spazio tra bordo e testo */
    cursor: pointer;
    border-bottom: 1px solid #eee;
    white-space: normal;
    word-break: break-word;
    line-height: 0.7; /* Interlinea molto ridotta */
    color: black;
    margin: 0; /* Rimuove margini */
    text-align: left; /* Forza l'allineamento a sinistra */
}

/* Forza l'allineamento a sinistra per tutti gli elementi interni */
.custom-option strong {
    text-align: left !important;
    display: inline; /* Cambiato da block a inline */
}

/* Gestisce il gruppo MBTI inline */
.custom-option span[style*="font-size: 0.7em"] {
    display: inline;
    text-align: left !important;
}

/* Forza l'allineamento a sinistra per tutti gli elementi della barra di ricerca */
#searchResultsList {
    text-align: left !important;
}

#searchResultsList .custom-option {
    text-align: left !important;
}

#searchResultsList .custom-option strong {
    text-align: left !important;
    display: inline !important;
}

#searchResultsList .custom-option span[style*="font-size: 0.7em"] {
    text-align: left !important;
    display: inline !important;
}

#searchResultsList .custom-option-book {
    text-align: left !important;
    display: block !important;
}
.custom-option:hover {
    background-color: #e0e0e0;
}
.custom-option-book {
    display: block; 
    font-size: 0.65em; /* Font ancora più piccolo */
    color: #666;
    font-weight: normal;
    margin: 8px 0 0 0; /* Aggiunge margine superiore per separare le righe */
    padding: 0; /* Rimuove padding */
    line-height: 1.0; /* Interlinea normale per quando va a capo */
}

/* === BOX DESCRIZIONI === */

/* 🔑 MODIFICA: CENTRATO E ALLARGATO */
#groupDescriptionBox {
    position: fixed;
    top: 46%; /* 🔑 Ancorato in alto alla stessa altezza del blocco descrizione personaggio */
    left: 2%; /* 🔑 Responsive - Posizionato a sinistra */
    transform: none; /* 🔑 Rimuove il centramento */
    width: 20%; /* 🔑 Responsive - 10% più stretto */
    height: auto; /* Responsive height - Dipende dal contenuto */
    max-height: 40vh; /* Altezza massima per evitare overflow */
    background: rgba(0, 0, 0, 0.9); /* Sfondo più scuro per risalto */
    color: white;
    border-radius: 10px;
    padding: 1.5% 2%; /* Responsive */
    font-size: 0.9vw; /* Responsive font size - Ridotto */
    line-height: 1.6; /* Responsive interlinea */
    display: none;
    z-index: 999; /* Z-index più alto per essere sopra i nodi */
    border: 1px solid rgba(255,255,255,0.5);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.8);
}
#groupDescriptionBox strong { color: #FFD700; font-size: 1.1vw; } /* Responsive - Ridotto */


/* 🔑 MODIFICA: CENTRATO E ALLARGATO */
#characterDescriptionBox {
    position: fixed;
    top: 46%; /* 🔑 Alzato del 4% il box di visualizzazione dei personaggi (50% - 4% = 46%) */
    left: 50%; /* Posizionamento iniziale al 50% da sinistra */
    transform: translateX(-50%); /* Centra solo orizzontalmente */
    width: 42.5%; /* Responsive - Ridotto del 15% (50% * 0.85) */
    height: auto; /* Responsive height - Dipende dal contenuto */
    max-height: 40vh; /* Altezza massima per evitare overflow */
    background: rgba(0, 0, 0, 0.9); /* Sfondo più scuro per risalto */
    color: white;
    border-radius: 10px;
    padding: 1.5% 2%; /* Responsive */
    font-size: 0.9vw; /* Responsive font size - Appena più piccolo */
    line-height: 1.6; /* Responsive interlinea */
    display: none;
    z-index: 999; /* Z-index più alto per essere sopra i nodi */
    border: 1px solid rgba(255,255,255,0.5);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.8);
}
#characterDescriptionBox strong { color: #66CDAA; font-size: 1.0vw; } /* Responsive - Appena più piccolo */


/* === RIQUADRO INFORMAZIONI MBTI === */
#mbtiInfoBox {
    position: fixed;
    top: 40%; /* Responsive - Più in basso del bottone MBTI Info (32%) */
    left: 2%; /* Responsive */
    width: 25%; /* Responsive */
    height: 50vh; /* Responsive height - Aumentata ulteriormente */
    background: rgba(0, 0, 0, 0.95);
    color: white;
    border-radius: 8px;
    padding: 1.5%; /* Responsive */
    font-size: 0.7vw; /* Responsive font size - Più piccolo per adattarsi al box */
    line-height: 1.4; /* Responsive interlinea - Ridotta per più testo */
    z-index: 1000; /* Alzato sopra il blocco della descrizione dei tipi */
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.7);
    overflow-y: auto; /* Scroll se il testo esce */
}

#mbtiInfoBox strong { color: #FFD700; font-size: 0.8vw; } /* Responsive - Più piccolo per adattarsi al box */
#mbtiInfoBox p { margin: 0.5vh 0; } /* Responsive */

/* === BOTTONI DISPLAY CONTROLS E NUOVO POSIZIONAMENTO === */

/* 🔑 MODIFICA: Contenitore per i bottoni al centro-sotto i nodi */
#displayControls {
    position: fixed;
    top: 38% !important; /* 🔑 Alzato del 4% (era -3.3%, ora 0.7%) - Forzato con !important */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; 
}

.nav-display-btn {
    padding: 1.95% 3.9%; /* Responsive - Aumentato del 30% (1.5% * 1.3 e 3% * 1.3) */
    margin: 0 1.95%; /* Responsive - Aumentato del 30% (1.5% * 1.3) */
    border: 1px solid #4CAF50; 
    background-color: #333; 
    color: #fff;
    cursor: pointer;
    font-size: 1em;
    border-radius: 5px;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.nav-display-btn:hover:not(:disabled) {
    background-color: #4CAF50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.nav-display-btn:disabled {
    border-color: #555;
    background-color: #222; 
    color: #555;
    cursor: not-allowed;
}


#updatesInfo {
    position: fixed;
    bottom: 25px; /* Sposta 25px sopra il bottom di copyright (che è 10px) */
    right: 10px;
    color: #888; /* Stesso colore del copyright */
    font-size: 16px; /* Stesso font size del copyright */
    font-family: sans-serif;
    z-index: 9999;
    padding: 2px;
}

/* === COOKIE BANNER STYLES === */
#cookieBanner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 450px;
    width: 90%;
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    z-index: 100000;
}

#cookieBanner p { margin: 0; flex-grow: 1; padding-right: 15px; }

#cookieBanner button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 0;
    flex-shrink: 0;
    transition: background-color 0.2s;
}
#cookieBanner button:hover { background-color: #0056b3; }

/* ========================================================= */
/* MEDIA QUERIES PER DISPOSITIVI MOBILE */
/* ========================================================= */

@media screen and (max-width: 768px) {
    /* Layout generale - Stack verticale */
    html, body {
        overflow-y: auto; /* Permette scroll verticale su mobile */
        overflow-x: hidden;
    }

    /* Titolo - Più piccolo e centrato */
    #siteTitleContainer {
        position: relative;
        top: 0;
        right: 0;
        left: 0;
        max-width: 100%;
        text-align: center;
        padding: 10px;
        margin-bottom: 10px;
    }

    #mainTitle {
        font-size: 18px !important; /* Fisso invece di vw */
        width: 100%;
        white-space: normal;
    }

    #subTitle {
        font-size: 12px;
    }

    /* Barra di ricerca - Full width in alto */
    #searchContainer {
        position: relative;
        top: 0;
        left: 0;
        width: 95%;
        margin: 10px auto;
        padding: 10px;
    }

    /* Menu laterali - Stack verticale */
    .menu-section-container {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        width: 95% !important;
        margin: 5px auto;
        padding: 10px;
        font-size: 14px;
    }

    #groupMenuContainer,
    #characterMenuContainer {
        margin-top: 10px;
    }

    /* Bottoni MBTI Info e Random - Affiancati usando float */
    #infoMenuContainer {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        float: left;
        width: 48% !important;
        margin: 5px 1% 5px 0;
        clear: none;
    }

    #randomCharContainer {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        float: left;
        width: 48% !important;
        margin: 5px 0 5px 1%;
        clear: none;
    }

    /* Assicura che i bottoni interni siano della stessa altezza e ben formattati */
    #mbtiInfoButton,
    #randomCharButton {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px !important;
        padding: 12px 15px !important;
        width: 100%;
        box-sizing: border-box;
    }

    #mbtiInfoButton {
        text-align: center !important; /* Centrato anche su mobile */
    }

    /* Blocchi gruppi MBTI - Scroll orizzontale invece di 2 colonne */
    #groupBlockContainer {
        position: relative;
        top: 0;
        right: 0;
        width: 95%;
        height: auto;
        max-height: 200px;
        margin: 10px auto;
        padding: 10px;
        overflow-x: auto;
        overflow-y: hidden;
        display: flex;
        flex-wrap: nowrap; /* Una riga orizzontale */
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch; /* Smooth scroll su iOS */
        clear: both; /* Clearfix per i bottoni float sopra */
    }

    #groupBlockContainer .group-block {
        width: 120px !important; /* Larghezza fissa per mobile */
        height: 60px !important;
        min-width: 120px;
        flex-shrink: 0; /* Non si restringono */
        margin: 5px;
        font-size: 14px !important;
    }

    /* Box descrizioni - Nel flusso del documento su mobile */
    /* Box descrizione gruppo: appare dopo i 16 gruppi, nel flusso normale */
    #groupDescriptionBox {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 92% !important; /* Ridotto da 95% per far vedere i bordi */
        max-width: 92%;
        margin: 20px auto !important;
        max-height: none;
        font-size: 14px !important;
        padding: 15px;
        z-index: auto;
        display: none; /* Nascosto di default, mostrato dal JavaScript quando necessario */
        background: rgba(0, 0, 0, 0.9) !important; /* Sfondo scuro */
        color: white !important;
        border-radius: 10px;
        border: 1px solid rgba(255, 255, 255, 0.5) !important;
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.8) !important;
        line-height: 1.6;
        box-sizing: border-box; /* Include border e padding nella larghezza */
    }

    /* Box descrizione personaggio: su mobile appare dopo i nodi nel flusso del documento */
    #characterDescriptionBox {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 92% !important; /* Ridotto da 95% per far vedere i bordi */
        max-width: 92%;
        margin: 20px auto !important;
        transform: none;
        max-height: none;
        font-size: 14px !important;
        padding: 15px;
        z-index: auto;
        background: rgba(0, 0, 0, 0.9) !important;
        color: white !important;
        border-radius: 10px;
        border: 1px solid rgba(255, 255, 255, 0.5) !important;
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.8) !important;
        line-height: 1.6;
        display: none; /* Nascosto di default, mostrato dal JavaScript quando necessario */
        box-sizing: border-box; /* Include border e padding nella larghezza */
    }

    #groupDescriptionBox strong,
    #characterDescriptionBox strong {
        font-size: 16px !important;
    }

    /* Box informazioni MBTI - Full width */
    #mbtiInfoBox {
        position: fixed;
        top: 5% !important;
        left: 5% !important; /* Aumentato per centrare meglio */
        width: 90% !important; /* Ridotto ulteriormente da 92% */
        max-width: 90%;
        height: 90vh !important;
        max-height: 90vh;
        font-size: 14px !important;
        padding: 15px;
        z-index: 10001;
        box-sizing: border-box; /* Include border e padding nella larghezza */
    }

    #mbtiInfoBox strong {
        font-size: 16px !important;
    }

    /* Bottoni navigazione - Nel flusso del documento, dopo il box descrizione */
    #displayControls {
        position: relative !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
        width: 100%;
        margin: 20px auto !important;
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: auto;
    }

    .nav-display-btn {
        padding: 12px 20px !important;
        margin: 0 5px;
        font-size: 16px !important;
        min-height: 44px; /* Dimensione minima per touch target */
    }

    /* Contenitore per i nodi su mobile - nel flusso del documento */
    #nodesContainerMobile {
        display: none; /* Nascosto di default, mostrato solo su mobile quando necessario */
        width: 98%;
        margin: 15px auto;
        padding: 0 3%; /* Padding laterale FISSO per spaziatura dai bordi (sempre presente) */
        box-sizing: border-box;
    }

    /* Quando visibile, usa grid layout - 2 colonne × 6 righe */
    /* Blocchi ancorati ai bordi, sovrapposizione solo al centro */
    #nodesContainerMobile:not([style*="display: none"]) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); /* Colonne che possono sovrapporsi */
        gap: 0; /* Nessun gap, useremo margin negativo per sovrapposizione */
        justify-items: stretch;
    }

    /* Nodi - Su mobile sono nel flusso del documento */
    .node {
        font-size: 12px !important; /* Ridotto da 14px */
        min-width: auto;
        padding: 6px 8px !important; /* Ridotto da 8px 12px */
    }

    /* Su mobile, i nodi nel contenitore sono relativi */
    #nodesContainerMobile .node {
        position: relative !important;
        transform: none !important;
        left: auto !important;
        top: auto !important;
        width: 100%;
        max-width: 100%;
        margin: 0;
        box-sizing: border-box; /* Include padding e border nella larghezza */
    }

    /* Blocchi ancorati ai bordi, sovrapposizione solo al centro */
    #nodesContainerMobile .node:nth-child(odd) {
        /* Blocchi colonna sinistra: ancorati a sinistra */
        margin-left: 0; /* Spaziatura garantita dal padding del contenitore (3%) */
        margin-right: -20px; /* Sovrapposizione al centro quando lo schermo è stretto */
        justify-self: start; /* Ancorati a sinistra */
    }

    #nodesContainerMobile .node:nth-child(even) {
        /* Blocchi colonna destra: ancorati a destra */
        margin-right: 0; /* Spaziatura garantita dal padding del contenitore (3%) */
        margin-left: -20px; /* Sovrapposizione al centro quando lo schermo è stretto */
        justify-self: end; /* Ancorati a destra */
    }

    .node .book {
        font-size: 10px !important; /* Ridotto da 11px */
    }

    .node strong {
        font-size: 11px !important; /* Ridotto da 13px */
    }

    /* La griglia 4x3 dei nodi sarà più compatta su mobile */
    /* (Il JavaScript calcola già posizioni responsive, ma qui forziamo dimensioni minime) */

    /* Custom select - Più grande */
    .custom-select-container {
        width: 100%;
    }

    .select-display {
        min-height: 44px; /* Touch target minimo */
        font-size: 16px;
        padding: 10px 40px 10px 10px;
    }

    .options-list {
        max-height: 50vh;
        font-size: 16px;
    }

    .custom-option {
        padding: 12px;
        min-height: 44px;
        line-height: 1.4;
    }

    /* Hint - Nel flusso del documento su mobile */
    .hint {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        width: 95% !important;
        margin: 20px auto !important;
        text-align: center;
        font-size: 12px;
        padding: 10px;
    }

    /* Copyright - Nel flusso del documento su mobile */
    #copyright {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        transform: none !important;
        width: 100%;
        text-align: center;
        font-size: 10px;
        padding: 15px 0;
        margin: 0;
    }

    /* Aggiunge padding-bottom al body per evitare che il contenuto vada sotto il footer */
    body {
        padding-bottom: 20px;
    }

    /* Cookie banner - Full width */
    #cookieBanner {
        width: 95%;
        left: 2.5%;
        transform: none;
        font-size: 12px;
        padding: 12px;
    }
}

/* Media query per schermi molto piccoli (smartphone piccoli) */
@media screen and (max-width: 480px) {
    #mainTitle {
        font-size: 16px !important;
    }

    #subTitle {
        font-size: 11px;
    }

    .menu-section-container {
        font-size: 12px;
        padding: 8px;
    }

    #groupBlockContainer .group-block {
        width: 100px !important;
        height: 50px !important;
        min-width: 100px;
        font-size: 12px !important;
    }

    .nav-display-btn {
        padding: 10px 15px !important;
        font-size: 14px !important;
    }

    #groupDescriptionBox,
    #characterDescriptionBox {
        font-size: 13px !important;
        padding: 12px;
    }

    #mbtiInfoBox {
        font-size: 13px !important;
        padding: 12px;
    }
}