/* Importa il font */
body {
    font-family: 'Fredoka One', cursive;
}

#game-container {
    width: 100vw;
    height: 100vh;
    background: linear-gradient(180deg, #3a6ea5 0%, #213970 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* MODIFICATO: Corretto il glitch del "flash" */
.screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.5); backdrop-filter: blur(5px); color: white;
    display: flex; /* Manteniamo flex per centrare il contenuto */
    flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 1rem;
    
    /* Inizialmente le schermate sono invisibili e non interagibili */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out; /* Aggiunge una transizione fluida */
    z-index: 100; /* Assicura che le schermate overlay siano sempre sopra */
}

.screen.active {
    /* La schermata attiva diventa visibile e interagibile */
    opacity: 1;
    pointer-events: auto;
}

.screen-content {
    background: rgba(255, 255, 255, 0.2); padding: 2rem; border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5); box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
}

.rules { font-size: 1.2rem; color: #eee; max-width: 400px; margin: 0 auto 1.5rem; }

#game-screen {
    background-color: transparent;
    backdrop-filter: none;
    justify-content: center;
    padding: 1rem;
    gap: 15px;
    position: relative;
    z-index: 1; /* Schermata di gioco sta sotto le altre */
}

/* Logo del gioco */
#game-logo {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 150px;
    height: auto;
    z-index: 10;
    filter: drop-shadow(3px 3px 5px rgba(0,0,0,0.7));
}

#start-screen {
    background-color: white;
    backdrop-filter: none;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

#start-screen .screen-content {
    background: none;
    box-shadow: none;
    border: none;
    backdrop-filter: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 600px;
}

#start-screen .rules {
    color: #555;
    margin-bottom: 2.5rem;
}

#start-screen img {
    max-width: 80%;
    height: auto;
    margin-bottom: 2rem;
}

.game-panel {
    background-color: #2c5282;
    color: white;
    border-radius: 12px;
    padding: 10px 20px;
    width: 100%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    border: 2px solid #5a8fcf;
}

#composed-word {
    font-size: 2.5rem; letter-spacing: 0.5em; font-weight: bold;
    min-height: 50px; display: flex; align-items: center; justify-content: center;
}

#info-line { font-size: 1.2rem; }

/* --- NUOVA REGOLA AGGIUNTA QUI --- */
.info-label {
    color: #FFC300; /* Un colore giallo per evidenziare le etichette */
    margin-right: 5px; /* Aggiunge un piccolo spazio tra l'etichetta e il valore */
}

.game-main {
    width: 100%; max-width: 600px; margin: 0 auto;
}

#syllable-grid {
    display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px;
}

.syllable-cell {
    background: linear-gradient(145deg, #ff8c0a, #c96a0d);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px; aspect-ratio: 1 / 1;
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(0.8rem, 2.8vw, 1.8rem); font-weight: bold;
    color: white; text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
    cursor: pointer; transition: transform 0.2s, background-color 0.2s; user-select: none;
}
.syllable-cell:hover {
    background: linear-gradient(145deg, #ffa500, #d4780f); transform: scale(1.1);
}

.image-placeholder {
    grid-column: span 3; grid-row: span 3; padding: 5px; background: white;
    border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
}
.image-placeholder img {
    width: 100%; height: 100%; object-fit: contain; border-radius: 6px;
}

.btn-wood {
    background-color: #2c5282; color: white; padding: 10px 25px;
    border-radius: 10px; border: 2px solid #5a8fcf; font-size: 1.2rem;
    font-weight: bold; cursor: pointer; transition: background-color 0.3s;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
.btn-wood:hover { background-color: #3b6fa5; }
.btn-wood:active { transform: translateY(2px); }

/* Animazioni e Roulette */
.shake { animation: shake 0.5s; }
@keyframes shake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 40%, 60% { transform: translate3d(4px, 0, 0); } }
.victory-bounce { animation: bounce 0.6s ease; }
@keyframes bounce { 0%, 20%, 50%, 80%, 100% {transform: translateY(0);} 40% {transform: translateY(-20px);} 60% {transform: translateY(-10px);} }
#roulette-spinner { width: 50px; height: 50px; border-radius: 50%; border: 4px solid #fff; border-top-color: #f3ec78; animation: spin 1s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive Design */
@media (max-width: 768px) {
    #game-logo { width: 100px; top: 10px; right: 10px; }
    .game-panel { max-width: 90%; }
    #composed-word { font-size: 2rem; }
    #info-line { font-size: 1rem; }
    .syllable-cell { font-size: clamp(0.7rem, 3.5vw, 1.5rem); }
    #start-screen .rules { font-size: 1rem; }
}
@media (max-width: 480px) {
    #game-logo { width: 80px; top: 5px; right: 5px; }
    #composed-word { font-size: 1.8rem; letter-spacing: 0.3em; }
    #info-line { font-size: 0.9rem; }
    .syllable-cell { font-size: clamp(0.6rem, 4vw, 1.2rem); }
    #start-screen .rules { font-size: 0.9rem; }
}