/* ==========================================================================
   2048 Game - Background
   Warm brown tones (light) → dark slate tones (dark mode)
   ========================================================================== */

/* ---- CSS variables for background gradients ---- */
:root {
    --bg-2048-grad1: rgba(237, 194, 46, 0.1);
    --bg-2048-grad2: rgba(242, 177, 121, 0.12);
    --bg-2048-grad3: rgba(149, 213, 178, 0.08);
    --bg-2048-grad4: rgba(187, 173, 160, 0.05);
    --bg-2048-base1: #FFF8F0;
    --bg-2048-base2: #FFF5EB;
    --bg-2048-dot: rgba(237, 194, 46, 0.08);
}
[data-theme="dark"] {
    --bg-2048-grad1: rgba(237, 194, 46, 0.04);
    --bg-2048-grad2: rgba(242, 177, 121, 0.05);
    --bg-2048-grad3: rgba(125, 184, 159, 0.04);
    --bg-2048-grad4: rgba(100, 100, 120, 0.06);
    --bg-2048-base1: #1A1A2E;
    --bg-2048-base2: #16213E;
    --bg-2048-dot: rgba(255, 255, 255, 0.04);
}

/* Main background layer */
.game-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

/* Multi-layer gradient background */
.game-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 50% 40%,
            var(--bg-2048-grad1) 0%,
            transparent 50%
        ),
        radial-gradient(ellipse at 20% 20%,
            var(--bg-2048-grad2) 0%,
            transparent 40%
        ),
        radial-gradient(ellipse at 80% 80%,
            var(--bg-2048-grad3) 0%,
            transparent 40%
        ),
        linear-gradient(180deg,
            rgba(237, 194, 46, 0.05) 0%,
            transparent 40%,
            var(--bg-2048-grad4) 100%
        ),
        linear-gradient(135deg, var(--bg-2048-base1) 0%, var(--bg-2048-base2) 100%);
    animation: bgPulse2048 10s ease-in-out infinite;
}

/* Floating number tile decorations */
.bg-tiles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.bg-tile {
    position: absolute;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    opacity: 0.06;
    animation: tileFloat linear infinite;
    user-select: none;
}

.bg-tile:nth-child(1) { top: 8%;  left: 5%;  width: 60px; height: 60px; background: #EDC22E; color: #776E65; font-size: 18px; animation-duration: 18s; }
.bg-tile:nth-child(2) { top: 65%; left: 8%;  width: 50px; height: 50px; background: #F2B179; color: #F9F6F2; font-size: 16px; animation-duration: 22s; animation-delay: -5s; }
.bg-tile:nth-child(3) { top: 20%; right: 8%; width: 70px; height: 70px; background: #F59563; color: #F9F6F2; font-size: 22px; animation-duration: 25s; animation-delay: -10s; }
.bg-tile:nth-child(4) { top: 75%; right: 12%; width: 55px; height: 55px; background: #95D5B2; color: #2B2D42; font-size: 17px; animation-duration: 20s; animation-delay: -3s; }
.bg-tile:nth-child(5) { top: 40%; left: 85%; width: 45px; height: 45px; background: #FF8FA3; color: #F9F6F2; font-size: 14px; animation-duration: 16s; animation-delay: -8s; }
.bg-tile:nth-child(6) { top: 45%; left: 2%;  width: 40px; height: 40px; background: #EDCF72; color: #776E65; font-size: 13px; animation-duration: 19s; animation-delay: -12s; }

/* Dot grid decoration */
.bg-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, var(--bg-2048-dot) 1px, transparent 1px);
    background-size: 45px 45px;
    opacity: 0.4;
}

/* Animations */
@keyframes bgPulse2048 {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.96; }
}

@keyframes tileFloat {
    0%   { transform: translateY(0) rotate(0deg); }
    25%  { transform: translateY(-25px) rotate(3deg); }
    50%  { transform: translateY(-15px) rotate(0deg); }
    75%  { transform: translateY(-30px) rotate(-3deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

/* Mobile */
@media (max-width: 768px) {
    .bg-tile { transform: scale(0.7); }
    .bg-grid  { background-size: 35px 35px; }
}
