html, body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
    background-color: #faf8ef;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    text-align: center;
    padding: 0 10px;
    width: calc(100% - 20px);
    max-width: 500px;
    box-sizing: border-box;
}

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

h1 {
    color: #776e65;
    font-size: 60px;
    margin: 0;
    line-height: 1;
}

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

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

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

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 10px;
    background-color: #bbada0;
    border-radius: 5px;
    padding: 10px;
    width: 100%;
    aspect-ratio: 1;
    box-sizing: border-box;
}

.tile {
    background-color: #cdc1b4;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 35px;
    font-weight: bold;
    color: #776e65;
    transition: all 0.2s ease-in-out;
    position: relative;
    aspect-ratio: 1;
    width: 100%;
}

.tile-2 { background-color: #eee4da; }
.tile-4 { background-color: #ede0c8; }
.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: 30px;
}
.tile-256 {
    background-color: #edcc61;
    color: white;
    font-size: 30px;
}
.tile-512 {
    background-color: #edc850;
    color: white;
    font-size: 30px;
}
.tile-1024 {
    background-color: #edc53f;
    color: white;
    font-size: 25px;
}
.tile-2048 {
    background-color: #edc22e;
    color: white;
    font-size: 25px;
}

.instructions {
    margin-top: 20px;
    color: #776e65;
    font-size: 16px;
}

@media (max-width: 350px) {
    h1 {
        font-size: 40px;
    }

    .score-container {
        padding: 5px 10px;
        min-width: 60px;
    }

    .game-board {
        grid-gap: 5px;
        padding: 5px;
    }

    .tile {
        font-size: 25px;
    }

    .tile-128, .tile-256, .tile-512 {
        font-size: 20px;
    }

    .tile-1024, .tile-2048 {
        font-size: 16px;
    }
}

@media (max-width: 500px) {
    .container {
        width: calc(100% - 20px);
        padding: 10px;
    }

    .header {
        justify-content: center;
        gap: 15px;
    }

    h1 {
        font-size: 48px;
    }
    
    .tile {
        font-size: 30px;
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 25px;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 20px;
    }

    .instructions {
        font-size: 14px;
        margin-top: 15px;
    }
}

@keyframes appear {
    0% { opacity: 0; transform: scale(0); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes merge {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
