* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #776e65;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 48px;
    font-weight: bold;
    color: #776e65;
}

.scores-container {
    display: flex;
    gap: 10px;
}

.score-container, .best-container {
    background: #bbada0;
    padding: 10px 15px;
    border-radius: 5px;
    text-align: center;
    min-width: 80px;
}

.score-title {
    font-size: 14px;
    color: #eee4da;
    text-transform: uppercase;
}

.score {
    font-size: 20px;
    font-weight: bold;
    color: white;
}

.game-intro {
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.5;
}

.game-intro p {
    margin-bottom: 10px;
}

.game-container {
    position: relative;
    background: #bbada0;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
}

.grid-container {
    display: grid;
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
}

.grid-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.grid-cell {
    width: 100px;
    height: 100px;
    background: rgba(238, 228, 218, 0.35);
    border-radius: 3px;
}

.tile-container {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
}

.tile {
    position: absolute;
    width: 100px;
    height: 100px;
    background: #eee4da;
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 35px;
    font-weight: bold;
    transition: all 0.1s ease-in-out;
    z-index: 10;
}

.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 {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(238, 228, 218, 0.73);
    border-radius: 10px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 100;
}

.game-message.game-won,
.game-message.game-over {
    display: flex;
}

.game-message p {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 20px;
}

.message-buttons {
    display: flex;
    gap: 10px;
}

.restart-button, .btn {
    background: #8f7a66;
    color: #f9f6f2;
    border: none;
    border-radius: 3px;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.restart-button:hover, .btn:hover {
    background: #7c6b5a;
}

.controls {
    text-align: center;
}

.btn {
    margin-top: 10px;
}

@media (max-width: 520px) {
    .container {
        margin: 10px;
        padding: 15px;
    }
    
    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;
    }
}