/* ===== 2048 Game Styles ===== */

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

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark, #050505);
    color: var(--text-main, #ffffff);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow-x: hidden;
}

/* ===== Header ===== */
.g4f-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-card, rgba(20, 20, 25, 0.7));
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main, #fff);
    font-size: 1.2rem;
    font-weight: 600;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-neon, #6366f1), var(--secondary-neon, #ec4899));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.highlight-4 {
    color: var(--secondary-neon, #ec4899);
    font-weight: 700;
}

.lang-switch {
    display: flex;
    gap: 6px;
}

.lang-btn {
    padding: 6px 14px;
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    background: transparent;
    color: var(--text-dim, #94a3b8);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.lang-btn.active {
    background: var(--primary-neon, #6366f1);
    color: #fff;
    border-color: var(--primary-neon, #6366f1);
}

.lang-btn:hover {
    border-color: var(--primary-neon, #6366f1);
}

/* ===== Game Container ===== */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
}

/* ===== Game Header ===== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 16px;
}

.game-title {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-neon, #6366f1), var(--accent-cyan, #06b6d4));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -1px;
}

.scores {
    display: flex;
    gap: 10px;
}

.score-box {
    position: relative;
    background: var(--bg-card, rgba(20, 20, 25, 0.7));
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-lg, 16px);
    padding: 10px 20px;
    text-align: center;
    min-width: 80px;
    backdrop-filter: blur(8px);
}

.score-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-dim, #94a3b8);
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.score-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main, #fff);
}

.score-add {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-cyan, #06b6d4);
    opacity: 0;
    pointer-events: none;
}

.score-add.active {
    animation: scoreFloat 0.8s ease-out forwards;
}

@keyframes scoreFloat {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-24px); }
}

/* ===== Controls ===== */
.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 16px;
}

.btn-new-game {
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--primary-neon, #6366f1), var(--secondary-neon, #ec4899));
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    font-family: inherit;
}

.btn-new-game:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.4);
}

.btn-new-game:active {
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
    margin-top: 8px;
}

.btn-secondary:hover {
    border-color: var(--primary-neon, #6366f1);
    box-shadow: none;
}

.game-hint {
    font-size: 0.85rem;
    color: var(--text-dim, #94a3b8);
}

/* ===== Board ===== */
.board-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 460px;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 10px;
    background: var(--bg-card, rgba(20, 20, 25, 0.7));
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-xl, 24px);
    backdrop-filter: blur(12px);
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.grid-cell {
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-lg, 16px);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.tile-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 10px;
    pointer-events: none;
}

/* ===== Tiles ===== */
.tile {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    border-radius: var(--radius-lg, 16px);
    transition: top 0.15s ease, left 0.15s ease;
    z-index: 10;
    user-select: none;
}

.tile.tile-new {
    animation: tileAppear 0.2s ease-out;
}

.tile.tile-merged {
    animation: tilePop 0.25s ease-out;
    z-index: 20;
}

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

@keyframes tilePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Tile colors - neon themed */
.tile-2 {
    background: linear-gradient(135deg, #1e293b, #334155);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tile-4 {
    background: linear-gradient(135deg, #1e3a5f, #2563eb33);
    color: #93c5fd;
    border: 1px solid rgba(147, 197, 253, 0.15);
}

.tile-8 {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.tile-16 {
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    color: #fff;
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.3);
}

.tile-32 {
    background: linear-gradient(135deg, #ec4899, #f472b6);
    color: #fff;
    box-shadow: 0 0 24px rgba(236, 72, 153, 0.35);
}

.tile-64 {
    background: linear-gradient(135deg, #e11d48, #f43f5e);
    color: #fff;
    box-shadow: 0 0 24px rgba(225, 29, 72, 0.35);
}

.tile-128 {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: #1a1a2e;
    box-shadow: 0 0 28px rgba(245, 158, 11, 0.35);
}

.tile-256 {
    background: linear-gradient(135deg, #f97316, #fb923c);
    color: #1a1a2e;
    box-shadow: 0 0 28px rgba(249, 115, 22, 0.4);
}

.tile-512 {
    background: linear-gradient(135deg, #06b6d4, #22d3ee);
    color: #1a1a2e;
    box-shadow: 0 0 32px rgba(6, 182, 212, 0.4);
}

.tile-1024 {
    background: linear-gradient(135deg, #10b981, #34d399);
    color: #1a1a2e;
    box-shadow: 0 0 36px rgba(16, 185, 129, 0.45);
}

.tile-2048 {
    background: linear-gradient(135deg, #eab308, #facc15, #fde047);
    color: #1a1a2e;
    box-shadow: 0 0 40px rgba(234, 179, 8, 0.5), 0 0 80px rgba(234, 179, 8, 0.2);
    animation: tileGlow 2s ease-in-out infinite alternate;
}

.tile-super {
    background: linear-gradient(135deg, #f43f5e, #ec4899, #a855f7, #6366f1);
    color: #fff;
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.5);
    background-size: 200% 200%;
    animation: superGradient 3s ease infinite;
}

@keyframes tileGlow {
    0% { box-shadow: 0 0 40px rgba(234, 179, 8, 0.5), 0 0 80px rgba(234, 179, 8, 0.2); }
    100% { box-shadow: 0 0 50px rgba(234, 179, 8, 0.7), 0 0 100px rgba(234, 179, 8, 0.3); }
}

@keyframes superGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ===== Overlays ===== */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 5, 0.75);
    backdrop-filter: blur(6px);
    border-radius: var(--radius-xl, 24px);
    z-index: 50;
    animation: overlayIn 0.4s ease;
}

.game-overlay.active {
    display: flex;
}

@keyframes overlayIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.overlay-content {
    text-align: center;
    padding: 32px;
}

.overlay-content h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary-neon, #6366f1), var(--secondary-neon, #ec4899));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.win-overlay .overlay-content h2 {
    background: linear-gradient(135deg, #eab308, #fde047);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overlay-score {
    font-size: 1.2rem;
    color: var(--text-dim, #94a3b8);
    margin-bottom: 20px;
}

/* ===== Ad Container ===== */
.g4f-ad-container {
    width: 100%;
    max-width: 460px;
    margin-top: 24px;
    padding: 24px;
    background: var(--bg-card, rgba(20, 20, 25, 0.7));
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-lg, 16px);
    text-align: center;
    backdrop-filter: blur(8px);
}

.ad-placeholder-content {
    color: var(--text-dim, #94a3b8);
    font-size: 0.85rem;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-dim, #94a3b8);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-glass, rgba(255, 255, 255, 0.1));
}

/* ===== Responsive ===== */
@media (max-width: 520px) {
    .game-container {
        padding: 16px 12px;
    }

    .game-title {
        font-size: 2.2rem;
    }

    .score-box {
        padding: 8px 14px;
        min-width: 64px;
    }

    .score-value {
        font-size: 1.1rem;
    }

    .game-controls {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .game-hint {
        text-align: center;
    }

    .grid-container {
        gap: 8px;
        padding: 8px;
        border-radius: var(--radius-lg, 16px);
    }

    .tile-container {
        padding: 8px;
    }

    .tile {
        border-radius: 12px;
    }

    .grid-cell {
        border-radius: 12px;
    }
}

@media (max-width: 360px) {
    .grid-container {
        gap: 6px;
        padding: 6px;
    }

    .tile-container {
        padding: 6px;
    }

    .game-title {
        font-size: 1.8rem;
    }
}
