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

body {
    font-family: 'Arial', sans-serif;
    background: #faf8ef;
    color: #776e65;
    text-align: center;
    padding: 20px;
}

.container {
    max-width: 500px;
    margin: 0 auto;
}

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

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

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

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

#score, #best {
    font-size: 25px;
}

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

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

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

.grid-row:last-child {
    margin-bottom: 0;
}

.grid-cell {
    width: 100px;
    height: 100px;
    background: rgba(238, 228, 218, 0.35);
    border-radius: 6px;
}

.tile-container {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 2;
}

.tile {
    position: absolute;
    width: 100px;
    height: 100px;
    background: #eee4da;
    border-radius: 6px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 35px;
    transition: all 0.15s ease-in-out;
}

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

.game-message {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

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

.message-content {
    text-align: center;
}

.message-text {
    font-size: 30px;
    font-weight: bold;
    color: #776e65;
    margin-bottom: 20px;
}

.restart-button {
    background: #8f7a66;
    color: #f9f6f2;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.restart-button:hover {
    background: #9f8a76;
}

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

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