* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #1b1a1f;
    color: #ffffff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
}

.game-container-2048 {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.title-section h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

.subtitle {
    color: #b1b1b1;
    font-size: 1.1rem;
}

.score-section {
    display: flex;
    gap: 1rem;
}

.score-box {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    text-align: center;
    min-width: 100px;
}

.best-score-box {
    background: linear-gradient(135deg, rgba(255, 182, 65, 0.2) 0%, rgba(255, 182, 65, 0.1) 100%);
    border: 1px solid rgba(255, 182, 65, 0.3);
}

.score-label {
    font-size: 0.85rem;
    color: #b1b1b1;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

.score-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffffff;
}

.game-info {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-info p {
    color: #b1b1b1;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.btn-new-game {
    background: linear-gradient(135deg, #ffb641 0%, #ff8c00 100%);
    color: #1b1a1f;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-new-game:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 182, 65, 0.4);
}

.game-board {
    position: relative;
    width: 480px;
    height: 480px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px;
    margin: 0 auto;
}

.grid-container {
    position: absolute;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    padding: 10px;
}

.grid-cell {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.tiles-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.tile {
    position: absolute;
    width: 105px;
    height: 105px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    transition: all 0.15s ease;
    animation: tileAppear 0.2s ease;
}

@keyframes tileAppear {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

.tile-2 { background: #eee4da; color: #776e65; }
.tile-4 { background: #ede0c8; color: #776e65; }
.tile-8 { background: #f2b179; color: #f9f6f2; }
.tile-16 { background: #f59563; color: #f9f6f2; }
.tile-32 { background: #f67c5f; color: #f9f6f2; }
.tile-64 { background: #f65e3b; color: #f9f6f2; }
.tile-128 { background: #edcf72; color: #f9f6f2; font-size: 2rem; }
.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 2rem; }
.tile-512 { background: #edc850; color: #f9f6f2; font-size: 2rem; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 1.8rem; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 1.8rem; box-shadow: 0 0 30px rgba(237, 194, 46, 0.6); }
.tile-4096 { background: #3c3a32; color: #f9f6f2; font-size: 1.5rem; }
.tile-8192 { background: #3c3a32; color: #f9f6f2; font-size: 1.5rem; }

.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(27, 26, 31, 0.95);
    border-radius: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.game-over-overlay.show {
    display: flex;
}

.game-over-message {
    text-align: center;
    padding: 2rem;
}

.game-over-message h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #f56565;
}

#game-over-subtitle {
    color: #b1b1b1;
    margin-bottom: 1rem;
}

.final-score {
    font-size: 4rem;
    font-weight: 700;
    color: #ffb641;
    margin: 1rem 0;
}

.best-tile-info {
    color: #b1b1b1;
    margin-bottom: 2rem;
}

.best-tile-info span {
    color: #ffb641;
    font-weight: 700;
}

.btn-retry {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: #ffffff;
    border: none;
    padding: 1rem 3rem;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
}

.btn-retry:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(72, 187, 120, 0.4);
}

.save-info {
    color: #b1b1b1;
    font-size: 0.9rem;
    margin-top: 1rem;
}

.info-box {
    background: linear-gradient(135deg, rgba(255, 182, 65, 0.15) 0%, rgba(255, 182, 65, 0.05) 100%);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 182, 65, 0.3);
    margin-top: 2rem;
    text-align: center;
}

.info-box p {
    color: #b1b1b1;
    line-height: 1.6;
}

.info-box strong {
    color: #ffb641;
}

@media (max-width: 768px) {
    .game-container-2048 {
        padding: 1rem;
    }

    .title-section h1 {
        font-size: 2rem;
    }

    .game-board {
        width: 100%;
        max-width: 400px;
        height: auto;
        aspect-ratio: 1;
    }

    .tile {
        width: calc((100% - 50px) / 4);
        height: calc((100% - 50px) / 4);
        font-size: 1.5rem;
    }

    .tile-128, .tile-256, .tile-512 {
        font-size: 1.2rem;
    }

    .tile-1024, .tile-2048 {
        font-size: 1rem;
    }

    .game-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .score-section {
        width: 100%;
        justify-content: space-between;
    }
}
