body {
    font-family: 'Arial', sans-serif;
    background-color: #faf8ef;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
}

.container {
    text-align: center;
    width: 100%;
    max-width: 500px;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    color: #776e65;
    margin: 0;
    font-size: 80px;
    font-weight: bold;
}

.score-container {
    background-color: #bbada0;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    min-width: 100px;
}

.score-label {
    font-size: 13px;
    text-transform: uppercase;
}

#score {
    font-size: 24px;
    font-weight: bold;
}

.game-container {
    background-color: #bbada0;
    border-radius: 6px;
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    box-sizing: border-box;
}

#grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 10px;
    width: 100%;
    height: 100%;
    max-width: 400px;
    max-height: 400px;
}

.tile {
    background-color: #cdc1b4;
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    transition: all 0.2s ease-in-out;
    color: #776e65;
}

.tile:empty {
    background-color: rgba(238, 228, 218, 0.35);
}

.tile-2 { background-color: #eee4da; color: #776e65; }
.tile-4 { background-color: #ede0c8; color: #776e65; }
.tile-8 { background-color: #f2b179; color: white; }
.tile-16 { background-color: #f59563; color: white; }
.tile-32 { background-color: #f67c5f; color: white; }
.tile-64 { background-color: #f65e3b; color: white; }
.tile-128 { 
    background-color: #edcf72; 
    color: white;
    font-size: 20px;
}
.tile-256 { 
    background-color: #edcc61; 
    color: white;
    font-size: 20px;
}
.tile-512 { 
    background-color: #edc850; 
    color: white;
    font-size: 20px;
}
.tile-1024 { 
    background-color: #edc53f; 
    color: white;
    font-size: 16px;
}
.tile-2048 { 
    background-color: #edc22e; 
    color: white;
    font-size: 16px;
}

.instructions {
    margin-top: 20px;
    font-size: 14px;
    color: #776e65;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

#fireworks-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.firework {
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: #fff;
    border-radius: 50%;
    animation: firework-animation 1s ease-out;
}

@keyframes firework-animation {
    0% {
        transform: translate(var(--x, 0), var(--y, 0)) scale(0);
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--x, 0), var(--y, 0)) scale(2);
        opacity: 0;
    }
}

.encouragement-section {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#get-encouragement {
    background-color: #8f7a66;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

#get-encouragement:hover {
    background-color: #9f8a76;
}

.encouragement-result {
    margin-top: 15px;
    text-align: center;
    font-style: italic;
    color: #776e65;
    max-width: 300px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 480px) {
    h1 {
        font-size: 50px;
    }

    .game-container {
        padding: 10px;
    }

    .tile {
        font-size: 18px;
    }
}
