:root {
    --bg-color: #8ce1fc;
    --board-bg: #ffffff;
    --text-color: #2b1f66;
    --green-bg: #67e849;
    --green-shadow: #4abd32;
    --yellow-bg: #FEF041;
    --yellow-mid1: #F9C537;
    --yellow-mid2: #FBA93F;
    --yellow-shadow: #FD6E34;
    --yellow-shadow: #FD6E34;
    --grey-bg: #dcdcdc;
    /* Colore schiarito per lettera non presente */
    --grey-shadow: #b3b3b3;
    --empty-bg: #f0f0f5;
    --row-bg: #f9f9fb;
    /* Sfondo del contenitore righe */
    --font-family: 'Nunito', sans-serif;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Nuvole vettoriali CSS */
.clouds {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.cloud {
    position: absolute;
    background: white;
    border-radius: 100px;
}

.cloud::before,
.cloud::after {
    content: '';
    position: absolute;
    background: white;
    border-radius: 50%;
}

.cloud-1 {
    width: 200px;
    height: 60px;
    top: 25%;
    left: 5%;
}

.cloud-1::before {
    width: 90px;
    height: 90px;
    top: -45px;
    left: 30px;
}

.cloud-1::after {
    width: 110px;
    height: 110px;
    top: -65px;
    right: 30px;
}

.cloud-2 {
    width: 280px;
    height: 80px;
    top: 15%;
    right: -5%;
}

.cloud-2::before {
    width: 120px;
    height: 120px;
    top: -60px;
    left: 40px;
}

.cloud-2::after {
    width: 150px;
    height: 150px;
    top: -80px;
    right: 50px;
}

.cloud-3 {
    width: 250px;
    height: 75px;
    bottom: 25%;
    left: -8%;
}

.cloud-3::before {
    width: 110px;
    height: 110px;
    top: -55px;
    left: 40px;
}

.cloud-3::after {
    width: 130px;
    height: 130px;
    top: -75px;
    right: 40px;
}

.cloud-4 {
    width: 180px;
    height: 55px;
    bottom: 15%;
    right: 5%;
}

.cloud-4::before {
    width: 80px;
    height: 80px;
    top: -40px;
    left: 25px;
}

.cloud-4::after {
    width: 90px;
    height: 90px;
    top: -45px;
    right: 25px;
}

.cloud-5 {
    width: 300px;
    height: 90px;
    bottom: -40px;
    left: 30%;
}

.cloud-5::before {
    width: 130px;
    height: 130px;
    top: -65px;
    left: 60px;
}

.cloud-5::after {
    width: 160px;
    height: 160px;
    top: -80px;
    right: 50px;
}

.logo-img {
    max-width: 350px;
    margin-bottom: 25px;
    margin-top: 20px;
    z-index: 1;
}

/* Leaderboard e Timer in alto */
.leaderboard,
.timer {
    position: absolute;
    top: 20px;
    background: white;
    padding: 10px 20px;
    border-radius: 15px;
    font-weight: 800;
    color: var(--text-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.leaderboard {
    right: 20px;
    cursor: pointer;
}

.timer {
    left: 20px;
}

.leaderboard .score-title,
.timer .score-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    opacity: 0.8;
}

.leaderboard .score-value,
.timer .score-value {
    font-size: 1.5rem;
    color: var(--green-shadow);
}

.board-container {
    background: var(--board-bg);
    padding: 30px 35px;
    border-radius: 35px;
    box-shadow: 0 12px 0px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 1;
}

.board-container::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 40px;
    background: var(--board-bg);
    border-radius: 30px 30px 0 0;
    z-index: -1;
}

.board {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--row-bg);
    padding: 22px;
    border-radius: 30px;
    box-shadow: inset 0 4px 6px rgba(0, 0, 0, 0.04);
}

.row {
    display: flex;
    gap: 12px;
}

.tile {
    width: 65px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.2rem;
    font-weight: 900;
    position: relative;
    overflow: hidden;
    user-select: none;
    box-sizing: border-box;
    text-transform: uppercase;
}

.tile span {
    z-index: 2;
    color: var(--text-color);
}

.tile::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 12px;
    right: 12px;
    height: 18px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.30);
    z-index: 1;
}

.tile.empty::before {
    display: none;
}

.tile.empty {
    background-color: var(--empty-bg);
    border: 3px solid #e1e1e8;
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.05);
}

@keyframes pulse-border {

    0%,
    100% {
        border-color: #e1e1e8;
    }

    50% {
        border-color: #2b1f66;
    }
}

.tile.blinking {
    animation: pulse-border 1.2s infinite ease-in-out;
}

.tile.correct {
    background-color: var(--green-bg);
    border: none;
    box-shadow: 0 6px 0 var(--green-shadow), inset 0 -6px 0 rgba(0, 0, 0, 0.1);
}

.tile.present {
    background-color: var(--yellow-bg);
    border: none;
    box-shadow: 0 6px 0 var(--yellow-shadow), inset 0 -6px 0 var(--yellow-mid2);
}

.tile.absent {
    background-color: var(--grey-bg);
    border: none;
    box-shadow: 0 6px 0 var(--grey-shadow), inset 0 -6px 0 rgba(0, 0, 0, 0.1);
}

@keyframes pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

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

.tile.filled {
    animation: pop 0.1s ease-in-out;
}

@keyframes flip {
    0% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(0);
    }

    100% {
        transform: scaleY(1);
    }
}

.tile.flip {
    animation: flip 0.5s ease-in-out;
}

.message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px 40px;
    border-radius: 25px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    transition: opacity 0.3s;
    opacity: 0;
    pointer-events: none;
    /* Prevents clicks when hidden */
}

.message.show {
    pointer-events: auto;
}

.message-text {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-color);
    text-transform: uppercase;
    text-align: center;
}

.replay-btn {
    background-color: var(--green-bg);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 900;
    font-family: var(--font-family);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 7px 0 var(--green-shadow), inset 0 -6px 0 rgba(0, 0, 0, 0.1);
    transition: transform 0.1s, box-shadow 0.1s;
    text-transform: uppercase;
}

.replay-btn:hover {
    transform: translateY(2px);
    box-shadow: 0 4px 0 var(--green-shadow), inset 0 -6px 0 rgba(0, 0, 0, 0.1);
}

.replay-btn:active {
    transform: translateY(7px);
    box-shadow: 0 0px 0 var(--green-shadow), inset 0 -6px 0 rgba(0, 0, 0, 0.1);
}

.replay-btn.grey {
    background-color: var(--grey-bg);
    color: var(--text-color);
    box-shadow: 0 7px 0 var(--grey-shadow), inset 0 -6px 0 rgba(0, 0, 0, 0.1);
}

.replay-btn.grey:hover {
    box-shadow: 0 4px 0 var(--grey-shadow), inset 0 -6px 0 rgba(0, 0, 0, 0.1);
}

.replay-btn.grey:active {
    box-shadow: 0 0px 0 var(--grey-shadow), inset 0 -6px 0 rgba(0, 0, 0, 0.1);
}

.footer-credit {
    position: fixed;
    bottom: 12px;
    left: 16px;
    font-family: var(--font-family);
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-color);
    z-index: 10;
    margin: 0;
}

@media (max-width: 500px) {
    .tile {
        width: 14vw;
        height: 14vw;
        font-size: 8vw;
        border-radius: 8px;
    }

    .board-container {
        padding: 20px;
        border-radius: 20px;
    }

    .logo {
        font-size: 3rem;
    }

    .tile::before {
        top: 2px;
        height: 8px;
    }
}