/* ============================================================================
           SECTION 1 — VARIABLES & DESIGN SYSTEM IMMERSIF
           ============================================================================ */
        :root {
            /* Palette néon minimaliste */
            --quantum-blue: #00f3ff;
            --void-purple: #8a2be2;
            --starlight: #ffffff;
            --deep-space: #0a0a0f;
            --nebula-gray: #1a1a25;
            
            /* Effets immersifs */
            --hologram-glow: 0 0 30px var(--quantum-blue), 0 0 60px rgba(0, 243, 255, 0.3);
            --quantum-pulse: 0 0 20px currentColor;
            --depth-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            
            /* Animations */
            --pulse-slow: pulse 4s ease-in-out infinite;
            --pulse-fast: pulse 2s ease-in-out infinite;
            --float-animation: float 6s ease-in-out infinite;
            --scan-line: scan 8s linear infinite;
            
            /* Dimensions minimales */
            --border-thin: 1px;
            --border-thick: 2px;
            --radius-sm: 4px;
            --radius-md: 8px;
            
            /* Z-index immersion */
            --z-bg: -10;
            --z-grid: 1;
            --z-machines: 2;
            --z-ui: 10;
            --z-overlay: 20;
            --z-universe: 30;
        }

        /* ============================================================================
           SECTION 2 — RESET & BASE IMMERSIVE
           ============================================================================ */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
            -webkit-user-drag: none;
            user-select: none;
        }

        html, body {
            width: 100%;
            height: 100%;
            overflow: hidden;
            font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
            background: var(--deep-space);
            color: var(--starlight);
            position: fixed;
            touch-action: manipulation;
        }

        /* ============================================================================
           SECTION 3 — UNIVERS COSMIQUE (Background Immersif)
           ============================================================================ */
        .universe {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: var(--z-bg);
            overflow: hidden;
        }

        .stars {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: 
                radial-gradient(circle at 20% 30%, rgba(0, 243, 255, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 70%, rgba(138, 43, 226, 0.1) 0%, transparent 50%);
            animation: universeRotate 120s linear infinite;
        }

        .star {
            position: absolute;
            background: var(--starlight);
            border-radius: 50%;
            opacity: 0;
            animation: starTwinkle 5s infinite;
        }

        .quantum-field {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: 
                repeating-linear-gradient(
                    0deg,
                    transparent,
                    transparent 2px,
                    rgba(0, 243, 255, 0.03) 2px,
                    rgba(0, 243, 255, 0.03) 4px
                ),
                repeating-linear-gradient(
                    90deg,
                    transparent,
                    transparent 2px,
                    rgba(138, 43, 226, 0.03) 2px,
                    rgba(138, 43, 226, 0.03) 4px
                );
            opacity: 0.3;
            animation: var(--scan-line);
        }

        /* ============================================================================
           SECTION 4 — INTERFACE HOLOGRAPHIQUE MINIMALISTE
           ============================================================================ */
        .hud {
            position: fixed;
            z-index: var(--z-ui);
            padding: 20px;
            pointer-events: none;
        }

        /* Stats en haut à gauche - Ultra minimal */
        .stats-hud {
            top: 20px;
            left: 20px;
            display: flex;
            flex-direction: column;
            gap: 12px;
            min-width: 200px;
        }

        .quantum-stat {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 8px 16px;
            background: rgba(26, 26, 37, 0.7);
            backdrop-filter: blur(20px);
            border: var(--border-thin) solid rgba(0, 243, 255, 0.3);
            border-radius: var(--radius-md);
            position: relative;
            overflow: hidden;
            transition: all 0.3s ease;
        }

        .quantum-stat::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, 
                transparent, 
                rgba(0, 243, 255, 0.1), 
                transparent);
            transition: left 0.6s ease;
        }

        .quantum-stat:hover::before {
            left: 100%;
        }

        .stat-icon {
            font-size: 20px;
            color: var(--quantum-blue);
            text-shadow: var(--quantum-pulse);
        }

        .stat-info {
            flex: 1;
            min-width: 0;
        }

        .stat-label {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 2px;
            color: rgba(255, 255, 255, 0.7);
            margin-bottom: 2px;
        }

        .stat-value {
            font-size: 18px;
            font-weight: 600;
            color: var(--starlight);
            text-shadow: 0 0 10px currentColor;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .stat-change {
            font-size: 11px;
            color: #00ff88;
            opacity: 0.8;
        }

        /* Contrôles en bas à droite - Icônes seulement */
        .controls-hud {
            bottom: 20px;
            right: 20px;
            display: flex;
            gap: 8px;
        }

        .quantum-button {
            width: 44px;
            height: 44px;
            border-radius: 50%;
            background: rgba(26, 26, 37, 0.8);
            backdrop-filter: blur(20px);
            border: var(--border-thin) solid rgba(0, 243, 255, 0.3);
            color: var(--quantum-blue);
            font-size: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            pointer-events: auto;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .quantum-button::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0;
            height: 0;
            border-radius: 50%;
            background: rgba(0, 243, 255, 0.2);
            transform: translate(-50%, -50%);
            transition: width 0.3s, height 0.3s;
        }

        .quantum-button:hover {
            transform: scale(1.1);
            border-color: var(--quantum-blue);
            box-shadow: var(--hologram-glow);
        }

        .quantum-button:hover::after {
            width: 100%;
            height: 100%;
        }

        .quantum-button:active {
            transform: scale(0.95);
        }

        .button-badge {
            position: absolute;
            top: -4px;
            right: -4px;
            background: #ff0055;
            color: white;
            font-size: 10px;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            animation: var(--pulse-fast);
        }

        /* ============================================================================
           SECTION 5 — ZONE DE JEU IMMERSIVE
           ============================================================================ */
        .factory-universe {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: grid;
            place-items: center;
            z-index: var(--z-grid);
            perspective: 1000px;
            pointer-events: none; /* Important pour les interactions */
        }

        .quantum-grid {
    position: relative;
    transform-style: preserve-3d;
    animation: var(--float-animation);
    pointer-events: auto; /* Réactive les interactions sur la grille */
}

        .grid-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
}

        .grid-bg {
    width: 600px;
    height: 600px;
    background: 
        radial-gradient(circle at center, rgba(0, 243, 255, 0.05) 0%, transparent 70%),
        conic-gradient(
            from 0deg at 50% 50%,
            transparent 0deg,
            rgba(138, 43, 226, 0.1) 90deg,
            transparent 180deg,
            rgba(0, 243, 255, 0.1) 270deg,
            transparent 360deg
        );
    border-radius: 50%;
    filter: blur(20px);
    opacity: 0.5;
    transform: translateZ(-100px);
}

        .grid-main {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 30px;
    width: 500px;
    height: 500px;
    transform: translateZ(0);
}

        /* ============================================================================
           SECTION 6 — CELLULES & MACHINES QUANTIQUES
           ============================================================================ */
        .quantum-cell {
            position: relative;
            background: rgba(26, 26, 37, 0.3);
            border: var(--border-thin) solid rgba(0, 243, 255, 0.1);
            border-radius: 12px;
            transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
            cursor: pointer;
            overflow: hidden;
        }

        .quantum-cell::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: 
                radial-gradient(circle at 30% 30%, rgba(0, 243, 255, 0.1) 0%, transparent 70%),
                radial-gradient(circle at 70% 70%, rgba(138, 43, 226, 0.1) 0%, transparent 70%);
            opacity: 0;
            transition: opacity 0.5s ease;
        }

        .quantum-cell:hover {
            border-color: var(--quantum-blue);
            box-shadow: 0 0 30px rgba(0, 243, 255, 0.3);
            transform: translateZ(20px);
        }

        .quantum-cell:hover::before {
            opacity: 1;
        }

        .quantum-cell.active {
            background: rgba(0, 243, 255, 0.1);
            border-color: var(--quantum-blue);
            box-shadow: var(--hologram-glow);
            animation: cellPulse 2s infinite;
        }

        .quantum-machine {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    z-index: var(--z-machines);
}


        .machine-core {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--quantum-blue), var(--void-purple));
    display: grid;
    place-items: center;
    font-size: 20px;
    color: white;
    position: relative;
    animation: corePulse 3s infinite;
    box-shadow: 
        0 0 20px var(--quantum-blue),
        0 0 40px rgba(0, 243, 255, 0.3);
    transform-origin: center;
}

        .machine-rings {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--quantum-blue);
    border-right-color: var(--void-purple);
    animation: ringRotate 4s linear infinite;
    top: 0;
    left: 0;
}

        .machine-info {
            position: absolute;
            bottom: -25px;
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: rgba(255, 255, 255, 0.8);
            white-space: nowrap;
            text-shadow: 0 0 10px currentColor;
            left: 50%;
            transform: translateX(-50%);
        }

        .machine-level {
            position: absolute;
            top: -10px;
            right: -10px;
            background: var(--void-purple);
            color: white;
            font-size: 10px;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            display: grid;
            place-items: center;
            font-weight: bold;
        }

        /* Garantir le centrage parfait sur tous les écrans */
        @media (max-width: 768px) {
            .grid-main {
                width: 350px;
                height: 350px;
                gap: 20px;
                transform: translateZ(0) scale(1);
            }
            
            .grid-bg {
                width: 400px;
                height: 400px;
                transform: translateZ(-100px) scale(1);
            }
        }

        @media (max-width: 480px) {
            .grid-main {
                width: 300px;
                height: 300px;
                gap: 15px;
                transform: translateZ(0) scale(1);
            }
            
            .grid-bg {
                width: 350px;
                height: 350px;
                transform: translateZ(-100px) scale(1);
            }
        }

        /* ============================================================================
           SECTION 7 — OVERLAYS & MODAUX IMMERSIFS
           ============================================================================ */
        .quantum-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(10, 10, 15, 0.95);
            backdrop-filter: blur(30px);
            z-index: var(--z-overlay);
            display: none;
            opacity: 0;
            transition: opacity 0.5s ease;
        }

        .quantum-overlay.active {
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 1;
        }

        .holo-modal {
            width: 90%;
            max-width: 500px;
            background: rgba(26, 26, 37, 0.9);
            backdrop-filter: blur(40px);
            border: var(--border-thin) solid rgba(0, 243, 255, 0.3);
            border-radius: var(--radius-md);
            padding: 30px;
            position: relative;
            transform: translateY(20px);
            transition: transform 0.5s ease;
            box-shadow: 
                var(--hologram-glow),
                inset 0 0 50px rgba(0, 243, 255, 0.1);
        }

        .quantum-overlay.active .holo-modal {
            transform: translateY(0);
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: var(--border-thin) solid rgba(0, 243, 255, 0.2);
        }

        .modal-title {
            font-size: 24px;
            color: var(--quantum-blue);
            text-transform: uppercase;
            letter-spacing: 3px;
            text-shadow: var(--quantum-pulse);
        }

        .modal-close {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.1);
            border: none;
            color: var(--quantum-blue);
            font-size: 20px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
        }

        .modal-close:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: rotate(90deg);
        }

        /* ============================================================================
           SECTION 8 — UPGRADES & EVOLUTION IDLE
           ============================================================================ */
        .upgrade-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
            gap: 12px;
            max-height: 400px;
            overflow-y: auto;
            padding-right: 10px;
        }

        .upgrade-grid::-webkit-scrollbar {
            width: 4px;
        }

        .upgrade-grid::-webkit-scrollbar-track {
            background: rgba(0, 243, 255, 0.1);
            border-radius: 2px;
        }

        .upgrade-grid::-webkit-scrollbar-thumb {
            background: var(--quantum-blue);
            border-radius: 2px;
        }

        .quantum-upgrade {
            background: rgba(26, 26, 37, 0.6);
            border: var(--border-thin) solid rgba(0, 243, 255, 0.2);
            border-radius: var(--radius-sm);
            padding: 15px;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .quantum-upgrade::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, 
                rgba(0, 243, 255, 0.1) 0%, 
                rgba(138, 43, 226, 0.1) 100%);
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .quantum-upgrade:hover {
            border-color: var(--quantum-blue);
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
        }

        .quantum-upgrade:hover::before {
            opacity: 1;
        }

        .quantum-upgrade.purchased {
            border-color: #00ff88;
            background: rgba(0, 255, 136, 0.05);
        }

        .quantum-upgrade.locked {
            opacity: 0.5;
            cursor: not-allowed;
            filter: grayscale(1);
        }

        .upgrade-icon {
            font-size: 24px;
            margin-bottom: 10px;
            color: var(--quantum-blue);
            text-align: center;
        }

        .upgrade-name {
            font-size: 14px;
            font-weight: 600;
            margin-bottom: 5px;
            color: var(--starlight);
        }

        .upgrade-desc {
            font-size: 11px;
            color: rgba(255, 255, 255, 0.7);
            margin-bottom: 10px;
            line-height: 1.4;
        }

        .upgrade-cost {
            font-size: 12px;
            color: #00ff88;
            font-weight: 600;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .upgrade-level {
            color: var(--quantum-blue);
            font-size: 11px;
        }

        /* ============================================================================
           SECTION 9 — PROGRESSION & PRESTIGE IDLE
           ============================================================================ */
        .prestige-system {
            position: fixed;
            bottom: 80px;
            right: 20px;
            z-index: var(--z-ui);
        }

        .quantum-singularity {
            background: linear-gradient(135deg, #ff0055, #8a2be2);
            border: none;
            border-radius: 50%;
            width: 60px;
            height: 60px;
            color: white;
            font-size: 24px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 
                0 0 30px #ff0055,
                0 0 60px rgba(255, 0, 85, 0.3);
            animation: singularityPulse 3s infinite;
            position: relative;
            transition: all 0.3s ease;
        }

        .quantum-singularity:hover {
            transform: scale(1.1);
            box-shadow: 
                0 0 40px #ff0055,
                0 0 80px rgba(255, 0, 85, 0.4);
        }

        .singularity-energy {
            position: absolute;
            top: -30px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 2px;
            color: #ff0055;
            text-shadow: 0 0 10px #ff0055;
            white-space: nowrap;
        }

        .progress-ring {
            position: fixed;
            bottom: 20px;
            left: 20px;
            width: 50px;
            height: 50px;
            z-index: var(--z-ui);
        }

        .ring-bg, .ring-fill {
            fill: none;
            stroke-width: 4;
            stroke-linecap: round;
            transform: rotate(-90deg);
            transform-origin: 50% 50%;
        }

        .ring-bg {
            stroke: rgba(255, 255, 255, 0.1);
        }

        .ring-fill {
            stroke: var(--quantum-blue);
            stroke-dasharray: 283;
            stroke-dashoffset: 283;
            transition: stroke-dashoffset 1s ease;
        }

        .progress-percent {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 12px;
            font-weight: 600;
            color: var(--quantum-blue);
        }

        /* ============================================================================
           SECTION 10 — ANIMATIONS IMMERSIVES
           ============================================================================ */
        @keyframes universeRotate {
            from { transform: rotate(0deg); }
            to { transform: rotate(360deg); }
        }

        @keyframes starTwinkle {
            0%, 100% { opacity: 0.3; transform: scale(1); }
            50% { opacity: 1; transform: scale(1.2); }
        }

        @keyframes float {
            0%, 100% { transform: rotateX(5deg) rotateY(0deg) scale(1); }
            33% { transform: rotateX(0deg) rotateY(5deg) scale(1); }
            66% { transform: rotateX(-5deg) rotateY(-5deg) scale(1); }
        }

        @keyframes scan {
            0% { transform: translateY(-100%); }
            100% { transform: translateY(100%); }
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.7; }
        }

        @keyframes cellPulse {
            0%, 100% { box-shadow: 0 0 30px rgba(0, 243, 255, 0.3); }
            50% { box-shadow: 0 0 50px rgba(0, 243, 255, 0.6); }
        }

        @keyframes corePulse {
            0%, 100% { transform: translate(-50%, -50%) scale(1); }
            50% { transform: translate(-50%, -50%) scale(1.1); }
        }

        @keyframes ringRotate {
            from { transform: rotate(0deg); }
            to { transform: rotate(360deg); }
        }

        @keyframes singularityPulse {
            0%, 100% { box-shadow: 0 0 30px #ff0055, 0 0 60px rgba(255, 0, 85, 0.3); }
            50% { box-shadow: 0 0 50px #ff0055, 0 0 100px rgba(255, 0, 85, 0.5); }
        }

        /* ============================================================================
           SECTION 11 — RESPONSIVE & MOBILE IMMERSIF
           ============================================================================ */
        @media (max-width: 768px) {
            .stats-hud {
                top: 10px;
                left: 10px;
                min-width: 160px;
            }
            
            .quantum-stat {
                padding: 6px 12px;
                gap: 8px;
            }
            
            .stat-value {
                font-size: 16px;
            }
            
            .grid-main {
                width: 350px;
                height: 350px;
                gap: 20px;
            }
            
            .grid-bg {
                width: 400px;
                height: 400px;
            }
            
            .controls-hud {
                bottom: 10px;
                right: 10px;
            }
            
            .prestige-system {
                bottom: 70px;
                right: 10px;
            }
            
            .progress-ring {
                bottom: 10px;
                left: 10px;
            }
            
            .holo-modal {
                width: 95%;
                padding: 20px;
            }
            
            .upgrade-grid {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        @media (max-width: 480px) {
            .grid-main {
                width: 300px;
                height: 300px;
                gap: 15px;
            }
            
            .grid-bg {
                width: 350px;
                height: 350px;
            }
            
            .stats-hud {
                min-width: 140px;
            }
            
            .stat-value {
                font-size: 14px;
            }
            
            .upgrade-grid {
                grid-template-columns: 1fr;
            }
        }

        /* ============================================================================
           SECTION 12 — UTILS & ACCESSIBILITY
           ============================================================================ */
        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            border: 0;
        }

        .hidden {
            display: none !important;
        }

        .fade-in {
            animation: fadeIn 0.5s ease forwards;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* Touch optimization */
        .touch-target {
            min-width: 44px;
            min-height: 44px;
        }

        /* High contrast mode */
        @media (prefers-contrast: high) {
            :root {
                --quantum-blue: #00ffff;
                --void-purple: #ff00ff;
            }
            
            .quantum-cell {
                border-width: 2px;
            }
        }

        /* Reduced motion */
        @media (prefers-reduced-motion: reduce) {
            * {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
            }
        }
