:root { --primary-font: 'Fredoka One', cursive; }

@keyframes rainbow-border {
    0% { border-color: #ff0000; box-shadow: 0 0 10px #ff0000; }
    33% { border-color: #00ff00; box-shadow: 0 0 10px #00ff00; }
    66% { border-color: #0000ff; box-shadow: 0 0 10px #0000ff; }
    100% { border-color: #ff0000; box-shadow: 0 0 10px #ff0000; }
}

#preloader {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #1a1a1a; display: flex; align-items: center; justify-content: center; z-index: 9999;
}
#loader-percentage { font-family: var(--primary-font); font-size: 6rem; color: #ff9f43; font-weight: bold; }

body, html {
    margin: 0; padding: 0; background: #000; overflow: hidden;
    font-family: var(--primary-font); height: 100vh; width: 100vw;
    display: flex; align-items: center; justify-content: center;
}

#game-container {
    position: relative; width: 100vw; height: 56.25vw; 
    max-height: 100vh; max-width: 177.78vh;
    background: url('images/sfondo.png') no-repeat center center;
    background-size: 100% 100%; visibility: hidden;
}

.rainbow-frame {
    border: 4px solid #fff; border-radius: 15px;
    background: rgba(0, 0, 0, 0.5); padding: 8px 15px;
    animation: rainbow-border 4s linear infinite;
    display: flex; align-items: center;
    box-sizing: border-box;
}

#music-control {
    position: absolute; top: 2%; left: 2%; width: 60px; height: 60px;
    cursor: pointer; z-index: 100;
}
#music-icon-img { width: 100%; height: 100%; object-fit: contain; }

.screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: none; z-index: 10; }
.screen.active { display: block; }

.central-content {
    position: absolute; left: 21%; top: 20%; width: 28%; height: 60%;
    display: flex; flex-direction: column; justify-content: space-between;
}

/* CORREZIONE: Box Parola Centrato */
.word-box { 
    min-height: 70px; 
    justify-content: center; /* Centra orizzontalmente */
}

#composed-word-display { 
    font-size: 2rem; 
    color: #fff; 
    letter-spacing: 0.3rem; 
    white-space: nowrap;
    text-align: center;
    width: 100%;
}

.label { font-size: 1rem; color: #ffd700; width: 90px; }
.value { font-size: 1.4rem; color: #fff; }
.hint-box { flex-direction: column; align-items: center; text-align: center; min-height: 80px; }
#hint-display { font-size: 1.2rem; color: #fff; opacity: 0; transition: opacity 0.5s; margin-top: 5px; }

#animal-container {
    position: absolute; left: 4%; bottom: 11.5%; width: 20%; height: 48%;
    display: flex; align-items: flex-end; justify-content: center;
}
#current-animal-img { max-width: 110%; max-height: 110%; object-fit: contain; }

.grid-area {
    position: absolute; right: 4.5%; top: 26%; width: 44%; height: 60%;
    display: flex; align-items: center; justify-content: center;
}
#syllable-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
    width: 95%; height: 95%;
}
.syllable-cell {
    background: url('images/tessera.png') no-repeat center center; background-size: 85% 85%;
    display: flex; align-items: center; justify-content: center;
    color: #4a2c00; font-size: 1.4rem; cursor: pointer; font-weight: bold;
}

.overlay-content { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(0,0,0,0.7); }
.main-title { font-size: 4rem; color: #ff9f43; text-shadow: 3px 3px 0 #000; margin-bottom: 20px; }
.victory-text { font-size: 8rem; color: #ff9f43; text-shadow: 4px 4px 0 #000; margin-bottom: 30px; }
.btn-start { background: #e67e22; color: #fff; padding: 15px 40px; border-radius: 40px; font-size: 2rem; border: none; border-bottom: 6px solid #d35400; cursor: pointer; font-family: var(--primary-font); }