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

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

.game-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    font-size: 3rem;
    color: #f39c12;
    text-shadow: 0 0 20px rgba(243, 156, 18, 0.5);
}

.game-header .subtitle {
    color: #ecf0f1;
    font-size: 1rem;
    margin-top: 10px;
}

.score-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.score-box {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 10px 25px;
    text-align: center;
    min-width: 100px;
}

.score-label {
    display: block;
    color: #95a5a6;
    font-size: 0.8rem;
    font-weight: bold;
}

.score-value {
    display: block;
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 10px;
    aspect-ratio: 1;
    touch-action: none;
}

.tile {
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transition: all 0.15s ease;
}

.tile[data-value="2"] {
    background: #eee4da;
    color: #776e65;
}

.tile[data-value="4"] {
    background: #ede0c8;
    color: #776e65;
}

.tile[data-value="8"] {
    background: #f2b179;
    color: #fff;
}

.tile[data-value="16"] {
    background: #f59563;
    color: #fff;
}

.tile[data-value="32"] {
    background: #f67c5f;
    color: #fff;
}

.tile[data-value="64"] {
    background: #f65e3b;
    color: #fff;
}

.tile[data-value="128"] {
    background: #edcf72;
    color: #fff;
    font-size: 1.8rem;
}

.tile[data-value="256"] {
    background: #edcc61;
    color: #fff;
    font-size: 1.8rem;
}

.tile[data-value="512"] {
    background: #edc850;
    color: #fff;
    font-size: 1.8rem;
}

.tile[data-value="1024"] {
    background: #edc53f;
    color: #fff;
    font-size: 1.5rem;
}

.tile[data-value="2048"] {
    background: #edc22e;
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 0 30px rgba(237, 194, 46, 0.8);
}

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

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

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

@keyframes pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.controls {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.control-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.instructions {
    margin-top: 20px;
    text-align: center;
    color: #95a5a6;
}

.instructions h3 {
    color: #ecf0f1;
    margin-bottom: 10px;
}

.instructions p {
    font-size: 0.9rem;
    margin: 5px 0;
}

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

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
}

.overlay-content h2 {
    color: #f39c12;
    font-size: 2.5rem;
    margin-bottom: 20px;
}

.overlay-content p {
    color: #ecf0f1;
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.overlay-content button {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1rem;
    border-radius: 25px;
    cursor: pointer;
    margin: 5px;
    transition: all 0.3s ease;
}

.overlay-content button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.4);
}

@media (max-width: 500px) {
    .game-container {
        padding: 15px;
    }

    .game-header h1 {
        font-size: 2rem;
    }

    .tile {
        font-size: 1.5rem;
    }

    .tile[data-value="128"],
    .tile[data-value="256"],
    .tile[data-value="512"] {
        font-size: 1.3rem;
    }

    .tile[data-value="1024"],
    .tile[data-value="2048"] {
        font-size: 1.1rem;
    }
}
