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

body {
    font-family: "Arial", sans-serif;
    background: #faf8ef;
    color: #776e65;
    margin: 0;
    padding: 0;
}

.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;
    color: #776e65;
    margin: 0;
}

.scores-container {
    display: flex;
    gap: 10px;
}

.score-container {
    background: #bbada0;
    padding: 10px 20px;
    border-radius: 3px;
    color: white;
    text-align: center;
    min-width: 70px;
}

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

.score {
    font-size: 25px;
    font-weight: bold;
}

.game-intro {
    margin-bottom: 20px;
    text-align: center;
}

.game-intro p {
    font-size: 18px;
    line-height: 1.65;
    margin-bottom: 10px;
}

.restart-button, .retry-button {
    background: #8f7a66;
    border-radius: 3px;
    padding: 10px 20px;
    color: white;
    border: none;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.restart-button:hover, .retry-button:hover {
    background: #9f8b77;
}

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

.grid-container {
    position: absolute;
    z-index: 1;
}

.grid-row {
    display: flex;
    margin-bottom: 10px;
}

.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: 10px;
}

.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-size: 55px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.15s ease-in-out;
    animation: appear 0.2s ease-in-out;
}

@keyframes appear {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    100% {
        opacity: 1;
        transform: scale(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;
}

.tile-merged {
    animation: merge 0.2s ease-in-out;
}

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

.game-message {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    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;
}

.lower {
    margin-top: 30px;
}

.instructions {
    margin-top: 20px;
    line-height: 1.65;
}

.instructions strong {
    font-weight: bold;
}

@media (max-width: 520px) {
    .container {
        width: 100%;
        padding: 10px;
    }
    
    h1 {
        font-size: 50px;
    }
    
    .game-container {
        width: 310px;
        height: 310px;
        padding: 10px;
        margin: 0 auto;
    }
    
    .grid-cell, .tile {
        width: 67.5px;
        height: 67.5px;
        font-size: 35px;
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 25px;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 20px;
    }
    
    .tile-super {
        font-size: 15px;
    }
    
    .grid-cell {
        margin-right: 2.5px;
        margin-bottom: 2.5px;
    }
    
    .grid-row {
        margin-bottom: 2.5px;
    }
    
    .tile-container {
        top: 10px;
        left: 10px;
    }
}
