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

body {
    background: #faf8ef;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 20px;
}

.game-wrapper {
    display: flex;
    gap: 30px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.board-section {
    background: #bbada0;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, 100px);
    grid-template-rows: repeat(4, 100px);
    gap: 12px;
}

.cell {
    background: #cdc1b4;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 38px;
    font-weight: bold;
    color: #776e65;
    transition: all 0.15s ease;
    user-select: none;
}

.cell[data-value="2"]    { background: #eee4da; }
.cell[data-value="4"]    { background: #ede0c8; }
.cell[data-value="8"]    { background: #f2b179; color: #f9f6f2; }
.cell[data-value="16"]   { background: #f59563; color: #f9f6f2; }
.cell[data-value="32"]   { background: #f67c5f; color: #f9f6f2; }
.cell[data-value="64"]   { background: #f65e3b; color: #f9f6f2; }
.cell[data-value="128"]  { background: #edcf72; color: #f9f6f2; font-size: 32px; }
.cell[data-value="256"]  { background: #edcc61; color: #f9f6f2; font-size: 32px; }
.cell[data-value="512"]  { background: #edc850; color: #f9f6f2; font-size: 32px; }
.cell[data-value="1024"] { background: #edc53f; color: #f9f6f2; font-size: 28px; }
.cell[data-value="2048"] { background: #edc22e; color: #f9f6f2; font-size: 28px; }
.cell[data-value="4096"] { background: #3c3a32; color: #f9f6f2; font-size: 28px; }
.cell[data-value="8192"] { background: #2c2a24; color: #f9f6f2; font-size: 26px; }
.cell[data-value="16384"] { background: #1e1c18; color: #f9f6f2; font-size: 24px; }

.cell.animate {
    transform: scale(1.08);
    transition: transform 0.08s ease;
}

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.dpad {
    display: grid;
    grid-template-areas:
        ". up ."
        "left . right"
        ". down .";
    gap: 12px;
}

.btn {
    width: 70px;
    height: 70px;
    border: none;
    border-radius: 14px;
    background: #8f7a66;
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    user-select: none;
}

.btn:active {
    transform: scale(0.92);
    background: #9e8b77;
}

.btn-up    { grid-area: up; }
.btn-down  { grid-area: down; }
.btn-left  { grid-area: left; }
.btn-right { grid-area: right; }

.reset-btn {
    background: #8f7a66;
    color: white;
    padding: 12px 28px;
    border: none;
    border-radius: 30px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: background 0.2s, transform 0.1s;
}

.reset-btn:active {
    transform: scale(0.95);
    background: #9e8b77;
}

.score-box {
    background: #bbada0;
    color: white;
    padding: 10px 30px;
    border-radius: 30px;
    font-size: 22px;
    font-weight: bold;
    text-align: center;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: #faf8ef;
    border-radius: 24px;
    padding: 30px 40px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    font-size: 28px;
    font-weight: bold;
    color: #776e65;
    min-width: 300px;
}

.modal-buttons {
    margin-top: 30px;
    display: flex;
    gap: 20px;
    justify-content: center;
}

.modal-btn {
    background: #8f7a66;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-btn:hover {
    background: #9e8b77;
}

@media (max-width: 600px) {
    .grid {
        grid-template-columns: repeat(4, 70px);
        grid-template-rows: repeat(4, 70px);
        gap: 8px;
    }
    .cell {
        font-size: 24px;
    }
    .btn {
        width: 55px;
        height: 55px;
        font-size: 24px;
    }
    .modal-content {
        padding: 20px 25px;
        font-size: 22px;
        min-width: 260px;
    }
    .modal-btn {
        padding: 8px 18px;
        font-size: 16px;
    }
}