* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #faf8ef;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: "Segoe UI", Arial, sans-serif;
}

.game-container {
    text-align: center;
}

h1 {
    font-size: 64px;
    margin-bottom: 10px;
    color: #776e65;
}

.top-bar {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.score-box {
    background: #bbada0;
    padding: 10px 20px;
    border-radius: 8px;
    color: white;
}

.score-box .label {
    font-size: 14px;
    opacity: 0.8;
}

#score {
    font-size: 26px;
    font-weight: bold;
}

.board-wrapper {
    position: relative;
}

#board {
    width: 420px;
    height: 420px;
    padding: 10px;
    background: #bbada0;
    border-radius: 12px;

    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 10px;
}

.tile {
    background: #cdc1b4;
    border-radius: 8px;

    display: flex;
    justify-content: center;
    align-items: center;

    font-size: 42px;
    font-weight: bold;
    color: #776e65;

    transition: transform 0.15s ease;
}

.tile:not(:empty) {
    animation: pop 0.15s ease;
}

@keyframes pop {
    0% { transform: scale(0.8); }
    100% { transform: scale(1); }
}

/* Tile colors */
.x2    { background: #eee4da; }
.x4    { background: #ede0c8; }
.x8    { background: #f2b179; color: #f9f6f2; }
.x16   { background: #f59563; color: #f9f6f2; }
.x32   { background: #f67c5f; color: #f9f6f2; }
.x64   { background: #f65e3b; color: #f9f6f2; }
.x128  { background: #edcf72; color: #f9f6f2; font-size: 36px; }
.x256  { background: #edcc61; color: #f9f6f2; font-size: 36px; }
.x512  { background: #edc850; color: #f9f6f2; font-size: 36px; }
.x1024 { background: #edc53f; color: #f9f6f2; font-size: 28px; }
.x2048 { background: #edc22e; color: #f9f6f2; font-size: 28px; }
.x4096 { background: #3c3a32; color: #f9f6f2; font-size: 28px; }
.x8192 { background: #1c1b17; color: #f9f6f2; font-size: 26px; }

/* Overlay */
#overlay {
    position: absolute;
    inset: 0;
    background: rgba(238, 228, 218, 0.85);
    border-radius: 12px;

    display: flex;
    justify-content: center;
    align-items: center;
}

/* 🔑 FIX: correct specificity */
#overlay.hidden {
    display: none;
}

.overlay-content {
    background: #faf8ef;
    padding: 30px 40px;
    border-radius: 12px;
}

.overlay-content h2 {
    margin-bottom: 20px;
    color: #776e65;
}

.overlay-content button {
    padding: 10px 20px;
    font-size: 16px;
    background: #8f7a66;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.overlay-content button:hover {
    background: #7c6a58;
}
