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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #faf8ef 0%, #ede4da 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

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

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 60px;
    font-weight: bold;
    color: #776e65;
}

.version {
    font-size: 16px;
    color: #bbada0;
    vertical-align: super;
}

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

.score-box {
    background: #bbada0;
    padding: 10px 20px;
    border-radius: 6px;
    text-align: center;
    color: white;
}

.score-box span:first-child {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    color: #eee4da;
}

.score-box span:last-child {
    display: block;
    font-size: 20px;
    font-weight: bold;
}

.controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

button {
    background: #8f7a66;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: #7f6a56;
}

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

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.cell {
    background: #cdc1b4;
    border-radius: 6px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30px;
    font-weight: bold;
    color: #776e65;
    position: relative;
}

.tile {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    animation: appear 0.2s ease;
    transition: transform 0.15s ease-in-out;
}

.tile.new {
    animation: appear 0.2s ease;
}

.tile.merged {
    animation: pop 0.2s ease;
}

@keyframes appear {
    0% { opacity: 0; transform: scale(0); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes pop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { 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: 28px; }
.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 28px; }
.tile-512 { background: #edc850; color: #f9f6f2; font-size: 28px; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 24px; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 24px; }

.tile-super {
    background: #3c3a32;
    color: #f9f6f2;
    font-size: 20px;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(238, 228, 218, 0.73);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.overlay.show {
    opacity: 1;
    pointer-events: auto;
}

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

.instructions {
    text-align: center;
    color: #776e65;
    margin-top: 20px;
    font-size: 14px;
}

@media (max-width: 500px) {
    .cell {
        height: 65px;
        font-size: 24px;
    }
    
    h1 {
        font-size: 40px;
    }
}
