:root {
    --bg-color: #faf8ef;
    --text-color: #776e65;
    --board-bg: #bbada0;
    --tile-empty: #cdc1b4;
    --tile-2: #eee4da;
    --tile-4: #ede0c8;
    --tile-8: #f2b179;
    --tile-16: #f59563;
    --tile-32: #f67c5f;
    --tile-64: #f65e3b;
    --tile-128: #edcf72;
    --tile-256: #edcc61;
    --tile-512: #edc850;
    --tile-1024: #edc53f;
    --tile-2048: #edc22e;
    --font-family: 'Outfit', sans-serif;
}

/* Dark mode override for consistency with other games if preferred, 
   but 2048 usually has this specific color scheme. 
   Let's adapt it to be dark-ish or keep classic? 
   Let's keep classic colors but dark background for the page to match the suite. */

body {
    background-color: #121212;
    color: #ffffff;
    font-family: var(--font-family);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

.game-container {
    width: 100%;
    max-width: 500px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.back-btn {
    color: #ffffff;
    text-decoration: none;
    font-size: 1.2rem;
}

h1 {
    font-size: 3rem;
    margin: 0;
    color: #ffffff;
}

.scores {
    display: flex;
    gap: 0.5rem;
}

.score-box {
    background-color: #bbada0;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    color: #f9f6f2;
}

.score-box span:first-child {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #eee4da;
}

.score-box span:last-child {
    font-size: 1.5rem;
    font-weight: bold;
}

#new-game-btn {
    background-color: #8f7a66;
    color: #f9f6f2;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: bold;
}

.game-board {
    background-color: #bbada0;
    border-radius: 6px;
    width: 100%;
    aspect-ratio: 1;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    position: relative;
}

.tile {
    background-color: var(--tile-empty);
    border-radius: 3px;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    color: #776e65;
    transition: transform 0.1s ease-in-out, background-color 0.1s;
    animation: appear 0.2s ease-in-out;
}

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

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.tile[data-value="2"] {
    background-color: var(--tile-2);
}

.tile[data-value="4"] {
    background-color: var(--tile-4);
}

.tile[data-value="8"] {
    background-color: var(--tile-8);
    color: #f9f6f2;
}

.tile[data-value="16"] {
    background-color: var(--tile-16);
    color: #f9f6f2;
}

.tile[data-value="32"] {
    background-color: var(--tile-32);
    color: #f9f6f2;
}

.tile[data-value="64"] {
    background-color: var(--tile-64);
    color: #f9f6f2;
}

.tile[data-value="128"] {
    background-color: var(--tile-128);
    color: #f9f6f2;
    font-size: 1.8rem;
}

.tile[data-value="256"] {
    background-color: var(--tile-256);
    color: #f9f6f2;
    font-size: 1.8rem;
}

.tile[data-value="512"] {
    background-color: var(--tile-512);
    color: #f9f6f2;
    font-size: 1.8rem;
}

.tile[data-value="1024"] {
    background-color: var(--tile-1024);
    color: #f9f6f2;
    font-size: 1.5rem;
}

.tile[data-value="2048"] {
    background-color: var(--tile-2048);
    color: #f9f6f2;
    font-size: 1.5rem;
}

.instructions {
    margin-top: 2rem;
    color: #aaaaaa;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: #faf8ef;
    padding: 3rem;
    border-radius: 6px;
    text-align: center;
    color: #776e65;
}

.modal-content h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.modal-content button {
    background-color: #8f7a66;
    color: #f9f6f2;
    border: none;
    padding: 1rem 2rem;
    border-radius: 6px;
    font-size: 1.2rem;
    cursor: pointer;
    margin-top: 1rem;
}