:root {
    --bg-color: #0d0914;
    --primary: #9d4edd;
    --secondary: #7b2cbf;
    --black: #0d0914;
    --text: #f8f9fa;
    --border-width: 1px;
    --radius: 4px;
    --grid-gap: 10px;
    --cell-size: 100px;
}

body {
    background-color: var(--bg-color);
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    color: var(--text);
}

.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    padding: 10px 20px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    transition: 0.2s;
    z-index: 100;
}
.back-btn:hover {
    background: var(--primary);
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 500px;
}

.header-panel {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
}

h1 {
    font-size: 4rem;
    font-weight: 900;
    margin: 0;
    color: var(--primary);
    letter-spacing: 2px;
}

.score-container {
    display: flex;
    gap: 15px;
}

.score-box {
    background: #1a1525;
    border: 1px solid var(--secondary);
    border-radius: var(--radius);
    padding: 10px 20px;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    min-width: 80px;
}
.score-box div:first-child {
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 5px;
}

.instructions {
    font-size: 1.1rem;
    font-weight: 400;
    margin: 0;
    color: #ccc;
}

#game-board {
    position: relative;
    background: #1a1525;
    border: 1px solid var(--secondary);
    border-radius: var(--radius);
    padding: var(--grid-gap);
    display: grid;
    grid-template-columns: repeat(4, var(--cell-size));
    grid-template-rows: repeat(4, var(--cell-size));
    gap: var(--grid-gap);
    width: fit-content;
}

.grid-cell {
    background: #110d1a;
    border: 1px solid var(--secondary);
    border-radius: 4px;
    width: var(--cell-size);
    height: var(--cell-size);
}

#tile-container {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 2;
}

.tile {
    position: absolute;
    width: var(--cell-size);
    height: var(--cell-size);
    border: 1px solid var(--primary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    transition: transform 0.15s ease-in-out;
}

.tile.new {
    animation: pop 0.2s ease;
}
.tile.merged {
    animation: pulse 0.2s ease;
    z-index: 3;
}

@keyframes pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Tile Colors */
.tile-2 { background: #1a1525; color: #fff; }
.tile-4 { background: #2a223a; color: #fff; }
.tile-8 { background: #3a2e4f; color: #fff; }
.tile-16 { background: #4a3a64; color: #fff; }
.tile-32 { background: #5a4779; color: #fff; }
.tile-64 { background: #6a538f; color: #fff; }
.tile-128 { background: #7b2cbf; color: #fff; }
.tile-256 { background: #9d4edd; color: #fff; font-size: 2rem;}
.tile-512 { background: #c77dff; color: #fff; font-size: 2rem;}
.tile-1024 { background: #e0aaff; color: #0d0914; font-size: 1.8rem;}
.tile-2048 { background: #f8f9fa; color: #0d0914; font-size: 1.8rem;}
.tile-super { background: #fff; color: #0d0914; font-size: 1.5rem;}

.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(13, 9, 20, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: var(--radius);
}

.overlay h2 {
    font-size: 2.5rem;
    color: var(--primary);
    margin: 0 0 20px 0;
}

#restart-btn {
    background: transparent;
    color: var(--text);


.virtual-controls { display: none; flex-direction: column; align-items: center; gap: 10px; margin-top: 20px; }
.v-row { display: flex; gap: 10px; }
.v-btn { width: 50px; height: 50px; background: rgba(157, 78, 221, 0.2); border: 2px solid #9d4edd; color: #fff; font-size: 20px; border-radius: 8px; user-select: none; }
.v-btn:active { background: rgba(157, 78, 221, 0.6); }
@media (max-width: 768px) { 
    .virtual-controls { display: flex; } 
    #game-board { transform: scale(0.8); }
}
