* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
    font-size: 18px;
    color: #776e65;
    background: #faf8ef;
}

.container {
    width: 500px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 80px;
    font-weight: bold;
    margin: 0;
    color: #776e65;
}

.score-container {
    display: flex;
    gap: 10px;
}

.score-box {
    position: relative;
    background: #bbada0;
    padding: 15px 25px;
    border-radius: 3px;
    color: white;
    text-align: center;
    min-width: 70px;
}

.score-label {
    font-size: 13px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 5px;
}

#score, #best-score {
    font-size: 25px;
    font-weight: bold;
}

.game-intro {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#new-game-button, .retry-button {
    background: #8f7a66;
    border-radius: 3px;
    padding: 10px 20px;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

#new-game-button:hover, .retry-button:hover {
    background: #9f8b77;
}

.game-container {
    position: relative;
    background: #bbada0;
    border-radius: 6px;
    width: 500px;
    height: 500px;
    padding: 15px;
    margin-bottom: 20px;
}

.grid-container {
    position: absolute;
    z-index: 1;
}

.grid-row {
    display: flex;
    margin-bottom: 15px;
}

.grid-row:last-child {
    margin-bottom: 0;
}

.grid-cell {
    width: 107px;
    height: 107px;
    background: rgba(238, 228, 218, 0.35);
    border-radius: 3px;
    margin-right: 15px;
}

.grid-cell:last-child {
    margin-right: 0;
}

.tile-container {
    position: absolute;
    z-index: 2;
}

.tile {
    position: absolute;
    width: 107px;
    height: 107px;
    background: #eee4da;
    border-radius: 3px;
    font-weight: bold;
    font-size: 55px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.15s ease-in-out;
    line-height: 1;
}

.tile-2 {
    background: #eee4da;
    color: #776e65;
}

.tile-4 {
    background: #ede0c8;
    color: #776e65;
}

.tile-8 {
    background: #f2b179;
    color: #f9f6f2;
}

.tile-16 {
    background: #f59563;
    color: #f9f6f2;
}

.tile-32 {
    background: #f67c5f;
    color: #f9f6f2;
}

.tile-64 {
    background: #f65e3b;
    color: #f9f6f2;
}

.tile-128 {
    background: #edcf72;
    color: #f9f6f2;
    font-size: 45px;
}

.tile-256 {
    background: #edcc61;
    color: #f9f6f2;
    font-size: 45px;
}

.tile-512 {
    background: #edc850;
    color: #f9f6f2;
    font-size: 45px;
}

.tile-1024 {
    background: #edc53f;
    color: #f9f6f2;
    font-size: 35px;
}

.tile-2048 {
    background: #edc22e;
    color: #f9f6f2;
    font-size: 35px;
}

.tile-super {
    background: #3c3a32;
    color: #f9f6f2;
    font-size: 30px;
}

.game-message {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(238, 228, 218, 0.73);
    z-index: 100;
    text-align: center;
    border-radius: 6px;
}

.game-message p {
    font-size: 60px;
    font-weight: bold;
    height: 60px;
    line-height: 60px;
    margin-top: 150px;
}

.game-message.game-won {
    background: rgba(237, 194, 46, 0.5);
    color: #f9f6f2;
}

.game-message.game-over {
    background: rgba(238, 228, 218, 0.73);
    color: #776e65;
}

.game-message .lower {
    margin-top: 30px;
}

.game-explanation {
    margin-top: 30px;
    line-height: 1.5;
}

@media screen and (max-width: 520px) {
    .container {
        width: 100%;
        padding: 10px;
    }
    
    h1 {
        font-size: 50px;
    }
    
    .game-container {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }
    
    .grid-cell, .tile {
        width: calc(25% - 11.25px);
        height: calc(25% - 11.25px);
    }
    
    .tile {
        font-size: 35px;
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 30px;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 25px;
    }
    
    .tile-super {
        font-size: 20px;
    }
}