* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #faf8ef;
    color: #776e65;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

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

h1 {
    font-size: 48px;
    color: #776e65;
    margin-bottom: 10px;
}

.score-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.score-box {
    background-color: #bbada0;
    padding: 10px 20px;
    border-radius: 5px;
    color: white;
    font-weight: bold;
}

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

.score-box .score-value {
    font-size: 24px;
}

.game-container {
    position: relative;
    background-color: #bbada0;
    border-radius: 10px;
    width: 100%;
    max-width: 500px;
    height: 0;
    padding-bottom: 100%;
    margin-bottom: 20px;
}

.grid-container {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
}

.grid-cell {
    background-color: #cdc1b4;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    font-weight: bold;
    transition: all 0.15s ease-in-out;
}

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

.controls {
    margin-top: 20px;
}

.btn {
    background-color: #8f7a66;
    color: #f9f6f2;
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    font-size: 18px;
    cursor: pointer;
    margin: 0 5px;
}

.btn:hover {
    background-color: #9f8a76;
}

.game-message {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    font-size: 48px;
    font-weight: bold;
    color: #776e65;
    display: none;
}

.game-message.show {
    display: flex;
}

.instructions {
    margin-top: 20px;
    font-size: 14px;
    line-height: 1.5;
}

@media (max-width: 520px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 36px;
    }
    
    .grid-cell {
        font-size: 24px;
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 20px;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 18px;
    }
}