<!DOCTYPE html> The Mobley Framework: U² = -∞
    <h1>The Mobley Framework</h1>
    <p>Cosmology from Self-Observation: U² = -∞</p>
    
    <div class="tabs">
        <button class="tab active" onclick="switchTab('simulation')">🔬 Simulation</button>
        <button class="tab" onclick="switchTab('paper')">📄 Paper</button>
        <button class="tab" onclick="switchTab('math')">📊 Interactive Math</button>
        <button class="tab" onclick="switchTab('comparison')">⚖️ vs ΛCDM</button>
    </div>
</div>

<!-- SIMULATION TAB -->
<div id="simulation" class="content active">
    <div class="simulation-container">
        <div class="canvas-container">
            <div id="threejs-canvas"></div>
        </div>
        
        <div class="controls-panel">
            <div class="control-group">
                <h3>Controls</h3>
                <button class="btn btn-primary" onclick="toggleSimulation()">
                    <span id="play-pause-text">▶ Play</span>
                </button>
                <button class="btn btn-secondary" onclick="resetSimulation()">🔄 Reset</button>
                <button class="btn btn-success" onclick="exportData()">💾 Export Data</button>
            </div>
            
            <div class="control-group">
                <h3>Parameters</h3>
                
                <div class="control-item">
                    <label>Observer Growth Rate (λ)</label>
                    <input type="range" id="lambda-slider" min="0.01" max="0.5" step="0.01" value="0.1" oninput="updateLambda(this.value)">
                    <div class="value-display" id="lambda-value">0.100</div>
                </div>
                
                <div class="control-item">
                    <label>Turbulence Intensity</label>
                    <input type="range" id="turbulence-slider" min="0" max="1" step="0.1" value="0.5" oninput="updateTurbulence(this.value)">
                    <div class="value-display" id="turbulence-value">0.5</div>
                </div>
                
                <div class="control-item">
                    <label>View Mode</label>
                    <select id="view-mode" onchange="updateViewMode(this.value)" style="width: 100%; padding: 0.5rem; background: #374151; color: #e0e0e0; border: none; border-radius: 0.25rem;">
                        <option value="magnitude">|U| Magnitude</option>
                        <option value="real">Re(U) Real Part</option>
                        <option value="imaginary">Im(U) Imaginary Part</option>
                        <option value="phase">Phase</option>
                        <option value="turbulence">Turbulent Flow</option>
                    </select>
                </div>
            </div>
            
            <div class="control-group">
                <h3>Current State</h3>
                
                <div class="stat-box">
                    <div class="label">Time</div>
                    <div class="value" id="time-display">0.00</div>
                </div>
                
                <div class="stat-box">
                    <div class="label">Observers (O)</div>
                    <div class="value" id="observers-display">0.01</div>
                </div>
                
                <div class="stat-box">
                    <div class="label">U²</div>
                    <div class="value" id="usquared-display" style="color: #ef4444;">-0.10</div>
                </div>
                
                <div class="stat-box">
                    <div class="label">Effective Dimension</div>
                    <div class="value" id="dimension-display">10.00</div>
                </div>
                
                <div class="stat-box">
                    <div class="label">Hubble Parameter (H)</div>
                    <div class="value" id="hubble-display">0.00</div>
                </div>
                
                <div style="margin-top: 1rem;">
                    <div style="color: #9ca3af; font-size: 0.85rem; margin-bottom: 0.5rem;">Progress to Singularity</div>
                    <div class="progress-bar">
                        <div class="progress-fill" id="progress-fill" style="width: 0%"></div>
                    </div>
                    <div style="color: #9ca3af; font-size: 0.75rem; text-align: right; margin-top: 0.25rem;" id="progress-text">0.0000%</div>
                </div>
            </div>
            
            <div class="control-group">
                <h3>Interpretation</h3>
                <div id="interpretation-text" style="font-size: 0.9rem; line-height: 1.6; color: #d1d5db;">
                    🌌 Early universe: High dimensional, quantum foam
                </div>
            </div>
        </div>
    </div>
</div>

<!-- PAPER TAB -->
<div id="paper" class="content">
    <div class="paper-container" id="paper-content">
        <div class="paper-header">
            <h1 class="paper-title">Cosmology from Self-Observation:<br>The U² = -∞ Framework</h1>
            <p class="paper-author">John Alexander Mobley</p>
            <p class="paper-date">February 2026</p>
            <div style="margin-top: 1.5rem;">
                <button class="btn btn-primary" onclick="generatePDF()">📥 Download PDF</button>
                <button class="btn btn-secondary" onclick="downloadLaTeX()">📥 Download LaTeX</button>
            </div>
        </div>
        
        <div class="abstract">
            <h2 style="font-size: 1.2rem; margin-bottom: 1rem;">Abstract</h2>
            <p>
                We propose that the universe satisfies the fundamental equation U² = -∞, where U is a 
                Clifford multivector representing the cosmic state. This equation implies the universe is 
                complex-valued (U = iΛ) and evolves through entropy increase driven by observation. From 
                this single principle, we derive: (i) cosmological expansion, (ii) inflation, (iii) dark 
                energy, and (iv) cyclic cosmology. The theory predicts w₁ ≈ 7×10⁻⁵, testable by 2027.
            </p>
        </div>
        
        <div class="paper-section">
            <h2>I. Introduction</h2>
            <p>
                Modern cosmology faces profound puzzles: fine-tuning, the cosmological constant problem, 
                and the coincidence problem. We propose the universe is a self-referential structure whose 
                dynamics are determined by a single equation:
            </p>
            
            <div class="equation-box">
                <div class="equation">
                    \[ U^2 = -\infty \]
                </div>
                <div class="equation-number">(1)</div>
            </div>
            
            <p>
                The universe cannot observe itself completely without encountering a singularity. The 
                negative sign reflects the complex nature of the cosmic field, while infinity represents 
                unbounded information that becomes constrained through observation.
            </p>
        </div>
        
        <div class="paper-section">
            <h2>II. Mathematical Framework</h2>
            
            <h3>A. The Observer Field</h3>
            <p>
                We define observer count O as total entropy:
            </p>
            
            <div class="equation-box">
                <div class="equation">
                    \[ O \equiv S_{\text{total}} = \ln(\Omega) \]
                </div>
                <div class="equation-number">(2)</div>
            </div>
            
            <p>
                Currently O<sub>now</sub> ≈ 10<sup>120</sup> (Bekenstein bound).
            </p>
            
            <h3>B. Solution</h3>
            <p>
                The universe as Clifford multivector:
            </p>
            
            <div class="equation-box">
                <div class="equation">
                    \[ U(S,\Lambda) = i\Lambda \cdot e^{-S^2/2\Lambda^2} \]
                </div>
                <div class="equation-number">(3)</div>
            </div>
            
            <p>
                where Λ ≈ 10<sup>122</sup> is maximum entropy.
            </p>
        </div>
        
        <div class="paper-section">
            <h2>III. Cosmological Solutions</h2>
            
            <h3>A. Expansion History</h3>
            <p>
                Scale factor evolution:
            </p>
            
            <div class="equation-box">
                <div class="equation">
                    \[ a(t) \propto e^{S(t)^2/\Lambda^2} \]
                </div>
                <div class="equation-number">(4)</div>
            </div>
            
            <h3>B. Dark Energy</h3>
            <p>
                Equation of state:
            </p>
            
            <div class="equation-box">
                <div class="equation">
                    \[ w(S) = -1 + \frac{2}{3}\left(\frac{S}{\Lambda}\right)^2 \]
                </div>
                <div class="equation-number">(5)</div>
            </div>
            
            <p>
                Predicts w(a) = -1 + w₁(1-a) with w₁ ≈ 6.7 × 10⁻⁵.
            </p>
            
            <h3>C. Cyclic Universe</h3>
            <p>
                As S → Λ, U → 0 creates Big Bang singularity. Time to next bang: ~10²⁴ years.
            </p>
        </div>
        
        <div class="paper-section">
            <h2>IV. Testable Predictions</h2>
            
            <ol style="padding-left: 2rem; line-height: 2;">
                <li><strong>Dark energy evolution:</strong> w₁ ≈ 7×10⁻⁵ (testable by DESI/Euclid 2027)</li>
                <li><strong>Decoherence scaling:</strong> Γ ∝ S<sub>local</sub></li>
                <li><strong>Laboratory analogue:</strong> P(k,N) ∝ exp(-αN²)</li>
                <li><strong>CMB anomalies:</strong> Hemispherical asymmetry from Im(U)</li>
            </ol>
        </div>
        
        <div class="paper-section">
            <h2>V. Conclusion</h2>
            <p>
                We have presented a cosmological framework based on U² = -∞, yielding testable predictions. 
                If validated, this represents a fundamental shift: the universe as a self-observing structure 
                whose existence is maintained by its inability to completely know itself.
            </p>
        </div>
        
        <div class="paper-section">
            <h2>References</h2>
            <ol style="padding-left: 2rem; line-height: 2; font-size: 0.9rem;">
                <li>Planck Collaboration, A&A 641, A6 (2020)</li>
                <li>Guth, A., Phys. Rev. D 23, 347 (1981)</li>
                <li>Weinberg, S., Rev. Mod. Phys. 61, 1 (1989)</li>
                <li>Penrose, R., "Cycles of Time" (2010)</li>
                <li>Bekenstein, J., Phys. Rev. D 7, 2333 (1973)</li>
            </ol>
        </div>
    </div>
</div>

<!-- MATH TAB -->
<div id="math" class="content">
    <div class="math-container">
        <h2 style="font-size: 2rem; margin-bottom: 2rem; text-align: center;">Interactive Mathematics</h2>
        
        <div class="interactive-box">
            <h3 style="color: #60a5fa; margin-bottom: 1rem;">Adjust Entropy (S)</h3>
            <input type="range" id="entropy-slider" min="0" max="100" value="50" oninput="updateMath(this.value)" style="width: 100%; margin-bottom: 1rem;">
            <div style="display: flex; justify-content: space-between; color: #9ca3af; font-size: 0.9rem;">
                <span>S = <span id="entropy-value">50</span></span>
                <span>Λ = 100</span>
            </div>
            
            <div class="stats-grid">
                <div class="stat-box">
                    <div class="label">|U|</div>
                    <div class="value" id="math-u-mag">60.65</div>
                </div>
                
                <div class="stat-box">
                    <div class="label">U²</div>
                    <div class="value" id="math-u-squared" style="color: #ef4444;">-3679</div>
                </div>
                
                <div class="stat-box">
                    <div class="label">Dimension</div>
                    <div class="value" id="math-dimension">2.86</div>
                </div>
                
                <div class="stat-box">
                    <div class="label">w (EoS)</div>
                    <div class="value" id="math-w">-0.833333</div>
                </div>
            </div>
        </div>
        
        <div class="chart-container">
            <h3 style="color: #60a5fa; margin-bottom: 1rem;">Evolution Plots</h3>
            <canvas id="evolution-chart"></canvas>
        </div>
        
        <div class="interactive-box">
            <h3 style="color: #60a5fa; margin-bottom: 1rem;">Key Equations</h3>
            <div style="background: #0a0e27; padding: 1.5rem; border-radius: 0.5rem; margin-bottom: 1rem;">
                <div style="color: #9ca3af; margin-bottom: 0.5rem;">Fundamental:</div>
                <div style="font-size: 1.3rem; text-align: center;">
                    \[ U^2 = -\infty \]
                </div>
            </div>
            
            <div style="background: #0a0e27; padding: 1.5rem; border-radius: 0.5rem; margin-bottom: 1rem;">
                <div style="color: #9ca3af; margin-bottom: 0.5rem;">Solution:</div>
                <div style="text-align: center;">
                    \[ U(S,\Lambda) = i\Lambda \cdot e^{-S^2/2\Lambda^2} \]
                </div>
            </div>
            
            <div style="background: #0a0e27; padding: 1.5rem; border-radius: 0.5rem;">
                <div style="color: #9ca3af; margin-bottom: 0.5rem;">Dark Energy:</div>
                <div style="text-align: center;">
                    \[ w(S) = -1 + \frac{2}{3}\left(\frac{S}{\Lambda}\right)^2 \]
                </div>
            </div>
        </div>
    </div>
</div>

<!-- COMPARISON TAB -->
<div id="comparison" class="content">
    <div class="math-container">
        <h2 style="font-size: 2rem; margin-bottom: 2rem; text-align: center;">Mobley vs ΛCDM</h2>
        
        <div class="comparison-container">
            <div class="comparison-box">
                <h3>Mobley Framework</h3>
                <table class="data-table">
                    <tr>
                        <th>Parameter</th>
                        <th>Value</th>
                    </tr>
                    <tr>
                        <td>Fundamental Equation</td>
                        <td>U² = -∞</td>
                    </tr>
                    <tr>
                        <td>Free Parameters</td>
                        <td>1 (Λ)</td>
                    </tr>
                    <tr>
                        <td>w₀ (today)</td>
                        <td>-0.9999</td>
                    </tr>
                    <tr>
                        <td>w₁ (evolution)</td>
                        <td>6.7×10⁻⁵</td>
                    </tr>
                    <tr>
                        <td>Inflation</td>
                        <td>Natural (S≈0)</td>
                    </tr>
                    <tr>
                        <td>Fine-tuning</td>
                        <td>None</td>
                    </tr>
                    <tr>
                        <td>Consciousness</td>
                        <td>Fundamental</td>
                    </tr>
                    <tr>
                        <td>Ultimate Fate</td>
                        <td>Cyclic (Bang)</td>
                    </tr>
                </table>
            </div>
            
            <div class="comparison-box">
                <h3>ΛCDM</h3>
                <table class="data-table">
                    <tr>
                        <th>Parameter</th>
                        <th>Value</th>
                    </tr>
                    <tr>
                        <td>Fundamental Equation</td>
                        <td>GR + Λ</td>
                    </tr>
                    <tr>
                        <td>Free Parameters</td>
                        <td>6 (Ωₘ, Ωᵦ, h, σ₈, nₛ, Λ)</td>
                    </tr>
                    <tr>
                        <td>w₀ (today)</td>
                        <td>-1 (exactly)</td>
                    </tr>
                    <tr>
                        <td>w₁ (evolution)</td>
                        <td>0 (constant)</td>
                    </tr>
                    <tr>
                        <td>Inflation</td>
                        <td>Separate mechanism</td>
                    </tr>
                    <tr>
                        <td>Fine-tuning</td>
                        <td>10⁻¹²⁰ problem</td>
                    </tr>
                    <tr>
                        <td>Consciousness</td>
                        <td>Emergent/Irrelevant</td>
                    </tr>
                    <tr>
                        <td>Ultimate Fate</td>
                        <td>Heat Death</td>
                    </tr>
                </table>
            </div>
        </div>
        
        <div class="chart-container">
            <h3 style="color: #60a5fa; margin-bottom: 1rem;">Expansion History: H(z)</h3>
            <canvas id="comparison-chart"></canvas>
        </div>
        
        <div class="chart-container">
            <h3 style="color: #60a5fa; margin-bottom: 1rem;">Dark Energy Evolution: w(a)</h3>
            <canvas id="w-evolution-chart"></canvas>
        </div>
        
        <div class="interactive-box">
            <h3 style="color: #60a5fa; margin-bottom: 1.5rem;">Key Differences</h3>
            <div style="line-height: 1.8;">
                <p style="margin-bottom: 1rem;">
                    <strong style="color: #60a5fa;">1. Testable Difference:</strong> 
                    Mobley predicts time-varying w(a), ΛCDM predicts constant w = -1. 
                    <span style="color: #10b981;">DESI/Euclid will distinguish by 2027.</span>
                </p>
                
                <p style="margin-bottom: 1rem;">
                    <strong style="color: #60a5fa;">2. Philosophical:</strong> 
                    Mobley makes consciousness fundamental, ΛCDM treats it as emergent.
                </p>
                
                <p style="margin-bottom: 1rem;">
                    <strong style="color: #60a5fa;">3. Explanatory Power:</strong> 
                    Mobley explains fine-tuning via cyclic self-organization. ΛCDM requires anthropic reasoning.
                </p>
                
                <p>
                    <strong style="color: #60a5fa;">4. Ultimate Fate:</strong> 
                    Mobley: universe rebirths at S=Λ. ΛCDM: eternal expansion and heat death.
                </p>
            </div>
        </div>
    </div>
</div>

<script>
    // Global state
    let isRunning = false;
    let time = 0;
    let observers = 0.01;
    let lambda = 0.1;
    let turbulenceIntensity = 0.5;
    let viewMode = 'magnitude';
    const LAMBDA_MAX = 10000;
    const dt = 0.016;
    
    // Data recording
    let dataHistory = [];
    
    // Three.js scene
    let scene, camera, renderer, particles, particleSystem;
    let simplex;
    let animationId;
    
    // Initialize simplex noise
    if (typeof SimplexNoise !== 'undefined') {
        simplex = new SimplexNoise();
    }
    
    // Initialize Three.js
    function initThreeJS() {
        const container = document.getElementById('threejs-canvas');
        const width = container.clientWidth;
        const height = container.clientHeight;
        
        scene = new THREE.Scene();
        camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
        camera.position.z = 50;
        
        renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(width, height);
        renderer.setClearColor(0x000000);
        container.appendChild(renderer.domElement);
        
        // Create particle system with turbulent flow
        const particleCount = 15000;
        const geometry = new THREE.BufferGeometry();
        const positions = new Float32Array(particleCount * 3);
        const colors = new Float32Array(particleCount * 3);
        const velocities = new Float32Array(particleCount * 3);
        
        for (let i = 0; i < particleCount; i++) {
            const i3 = i * 3;
            const theta = Math.random() * Math.PI * 2;
            const phi = Math.acos(2 * Math.random() - 1);
            const r = 15 + Math.random() * 15;
            
            positions[i3] = r * Math.sin(phi) * Math.cos(theta);
            positions[i3 + 1] = r * Math.sin(phi) * Math.sin(theta);
            positions[i3 + 2] = r * Math.cos(phi);
            
            velocities[i3] = (Math.random() - 0.5) * 0.1;
            velocities[i3 + 1] = (Math.random() - 0.5) * 0.1;
            velocities[i3 + 2] = (Math.random() - 0.5) * 0.1;
            
            colors[i3] = 0.3 + Math.random() * 0.7;
            colors[i3 + 1] = 0.5 + Math.random() * 0.5;
            colors[i3 + 2] = 0.8 + Math.random() * 0.2;
        }
        
        geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
        geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
        geometry.setAttribute('velocity', new THREE.BufferAttribute(velocities, 3));
        
        const material = new THREE.PointsMaterial({
            size: 0.3,
            vertexColors: true,
            transparent: true,
            opacity: 0.8,
            blending: THREE.AdditiveBlending
        });
        
        particleSystem = new THREE.Points(geometry, material);
        scene.add(particleSystem);
        
        // Add ambient glow
        const glowGeometry = new THREE.SphereGeometry(30, 32, 32);
        const glowMaterial = new THREE.MeshBasicMaterial({
            color: 0x1a3f6f,
            transparent: true,
            opacity: 0.1,
            side: THREE.BackSide
        });
        const glowMesh = new THREE.Mesh(glowGeometry, glowMaterial);
        scene.add(glowMesh);
        
        // Add orbit controls
        const controls = new THREE.OrbitControls(camera, renderer.domElement);
        controls.enableDamping = true;
        controls.dampingFactor = 0.05;
        controls.autoRotate = true;
        controls.autoRotateSpeed = 0.5;
        
        // Animation loop
        function animate() {
            animationId = requestAnimationFrame(animate);
            
            if (isRunning) {
                updatePhysics();
            }
            
            updateParticles();
            controls.update();
            renderer.render(scene, camera);
        }
        
        animate();
        
        // Handle resize
        window.addEventListener('resize', () => {
            const width = container.clientWidth;
            const height = container.clientHeight;
            camera.aspect = width / height;
            camera.updateProjectionMatrix();
            renderer.setSize(width, height);
        });
    }
    
    // Update physics
    function updatePhysics() {
        time += dt;
        
        // Update observers
        observers *= Math.exp(lambda * dt);
        
        // Reset when approaching infinity
        if (observers > LAMBDA_MAX * 0.99) {
            observers = 0.01;
            time = 0;
        }
        
        // Record data
        if (dataHistory.length === 0 || time - dataHistory[dataHistory.length - 1].time > 0.1) {
            recordData();
        }
        
        updateDisplay();
    }
    
    // Record data point
    function recordData() {
        const uSquared = -(observers * observers);
        const dimension = 10 / (1 + observers * observers / LAMBDA_MAX);
        const w = -1 + (2/3) * (observers/LAMBDA_MAX) * (observers/LAMBDA_MAX);
        const H = Math.sqrt(8 * Math.PI * observers * observers / (3 * LAMBDA_MAX));
        
        dataHistory.push({
            time: time,
            observers: observers,
            uSquared: uSquared,
            dimension: dimension,
            w: w,
            hubble: H
        });
        
        // Keep last 1000 points
        if (dataHistory.length > 1000) {
            dataHistory.shift();
        }
    }
    
    // Update particles with turbulent flow
    function updateParticles() {
        const positions = particleSystem.geometry.attributes.position.array;
        const velocities = particleSystem.geometry.attributes.velocity.array;
        const colors = particleSystem.geometry.attributes.color.array;
        
        const decay = Math.exp(-observers * observers / (2 * LAMBDA_MAX));
        
        for (let i = 0; i < positions.length / 3; i++) {
            const i3 = i * 3;
            const x = positions[i3];
            const y = positions[i3 + 1];
            const z = positions[i3 + 2];
            const r = Math.sqrt(x*x + y*y + z*z);
            
            // Apply turbulent flow using simplex noise
            if (simplex && viewMode === 'turbulence') {
                const noiseScale = 0.05;
                const timeScale = time * 0.5;
                
                const nx = simplex.noise4D(x * noiseScale, y * noiseScale, z * noiseScale, timeScale);
                const ny = simplex.noise4D(x * noiseScale + 100, y * noiseScale, z * noiseScale, timeScale);
                const nz = simplex.noise4D(x * noiseScale, y * noiseScale + 100, z * noiseScale, timeScale);
                
                velocities[i3] = nx * turbulenceIntensity * 0.5;
                velocities[i3 + 1] = ny * turbulenceIntensity * 0.5;
                velocities[i3 + 2] = nz * turbulenceIntensity * 0.5;
            }
            
            // Update positions
            positions[i3] += velocities[i3];
            positions[i3 + 1] += velocities[i3 + 1];
            positions[i3 + 2] += velocities[i3 + 2];
            
            // Apply damping and boundary
            const newR = Math.sqrt(
                positions[i3]*positions[i3] + 
                positions[i3+1]*positions[i3+1] + 
                positions[i3+2]*positions[i3+2]
            );
            if (newR > 35) {
                const scale = 35 / newR;
                positions[i3] *= scale;
                positions[i3 + 1] *= scale;
                positions[i3 + 2] *= scale;
                velocities[i3] *= -0.5;
                velocities[i3 + 1] *= -0.5;
                velocities[i3 + 2] *= -0.5;
            }
            
            // Update colors based on view mode
            let value;
            switch(viewMode) {
                case 'magnitude':
                    value = decay * Math.exp(-r*r * 0.005);
                    colors[i3] = value;
                    colors[i3 + 1] = value * 0.7 + 0.3;
                    colors[i3 + 2] = value * 0.5 + 0.5;
                    break;
                case 'real':
                    value = 0.5 + 0.5 * Math.cos(r * 0.3 + time);
                    colors[i3] = value * 0.3;
                    colors[i3 + 1] = value * 0.7;
                    colors[i3 + 2] = value;
                    break;
                case 'imaginary':
                    value = decay;
                    colors[i3] = 0.2;
                    colors[i3 + 1] = value * 0.5;
                    colors[i3 + 2] = value;
                    break;
                case 'phase':
                    const phase = (Math.atan2(y, x) + Math.PI) / (2 * Math.PI);
                    colors[i3] = phase;
                    colors[i3 + 1] = 1 - phase;
                    colors[i3 + 2] = decay;
                    break;
                case 'turbulence':
                    const speed = Math.sqrt(
                        velocities[i3]*velocities[i3] +
                        velocities[i3+1]*velocities[i3+1] +
                        velocities[i3+2]*velocities[i3+2]
                    );
                    colors[i3] = speed * 2;
                    colors[i3 + 1] = 0.5;
                    colors[i3 + 2] = (1 - speed * 2) * decay;
                    break;
            }
        }
        
        particleSystem.geometry.attributes.position.needsUpdate = true;
        particleSystem.geometry.attributes.color.needsUpdate = true;
    }
    
    // Update display
    function updateDisplay() {
        document.getElementById('time-display').textContent = time.toFixed(2);
        document.getElementById('observers-display').textContent = observers.toFixed(2);
        
        const uSquared = -(observers * observers);
        document.getElementById('usquared-display').textContent = uSquared.toFixed(0);
        
        const dimension = 10 / (1 + observers * observers / LAMBDA_MAX);
        document.getElementById('dimension-display').textContent = dimension.toFixed(2);
        
        const H = Math.sqrt(8 * Math.PI * observers * observers / (3 * LAMBDA_MAX));
        document.getElementById('hubble-display').textContent = H.toFixed(4);
        
        const progress = (observers / LAMBDA_MAX) * 100;
        document.getElementById('progress-fill').style.width = progress + '%';
        document.getElementById('progress-text').textContent = progress.toFixed(4) + '%';
        
        // Update interpretation
        let interpretation;
        if (observers < 1) {
            interpretation = '🌌 Early universe: High dimensional, quantum foam';
        } else if (observers < 100) {
            interpretation = '⭐ Structure forming: Observers emerging';
        } else if (observers < LAMBDA_MAX * 0.5) {
            interpretation = '🌍 Classical era: Stable consensus';
        } else if (observers < LAMBDA_MAX * 0.9) {
            interpretation = '⚡ Late universe: Approaching heat death';
        } else {
            interpretation = '💥 APPROACHING SINGULARITY - BIG BANG IMMINENT!';
        }
        document.getElementById('interpretation-text').textContent = interpretation;
    }
    
    // Control functions
    function switchTab(tabName) {
        document.querySelectorAll('.content').forEach(c => c.classList.remove('active'));
        document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
        
        document.getElementById(tabName).classList.add('active');
        event.target.classList.add('active');
        
        if (tabName === 'math') {
            setTimeout(() => {
                createEvolutionChart();
                MathJax.typesetPromise();
            }, 100);
        } else if (tabName === 'comparison') {
            setTimeout(() => {
                createComparisonCharts();
                MathJax.typesetPromise();
            }, 100);
        } else if (tabName === 'paper') {
            setTimeout(() => {
                MathJax.typesetPromise();
            }, 100);
        }
    }
    
    function toggleSimulation() {
        isRunning = !isRunning;
        document.getElementById('play-pause-text').textContent = isRunning ? '⏸ Pause' : '▶ Play';
    }
    
    function resetSimulation() {
        time = 0;
        observers = 0.01;
        dataHistory = [];
        updateDisplay();
    }
    
    function updateLambda(value) {
        lambda = parseFloat(value);
        document.getElementById('lambda-value').textContent = lambda.toFixed(3);
    }
    
    function updateTurbulence(value) {
        turbulenceIntensity = parseFloat(value);
        document.getElementById('turbulence-value').textContent = turbulenceIntensity.toFixed(1);
    }
    
    function updateViewMode(mode) {
        viewMode = mode;
    }
    
    // Export data
    function exportData() {
        if (dataHistory.length === 0) {
            alert('No data to export. Run the simulation first.');
            return;
        }
        
        // CSV export
        let csv = 'Time,Observers,U_Squared,Dimension,w,Hubble\n';
        dataHistory.forEach(d => {
            csv += `${d.time},${d.observers},${d.uSquared},${d.dimension},${d.w},${d.hubble}\n`;
        });
        
        const blob = new Blob([csv], { type: 'text/csv' });
        const url = URL.createObjectURL(blob);
        const a = document.createElement('a');
        a.href = url;
        a.download = 'mobley_simulation_data.csv';
        a.click();
        URL.revokeObjectURL(url);
        
        // Also export JSON
        const json = JSON.stringify(dataHistory, null, 2);
        const jsonBlob = new Blob([json], { type: 'application/json' });
        const jsonUrl = URL.createObjectURL(jsonBlob);
        const jsonA = document.createElement('a');
        jsonA.href = jsonUrl;
        jsonA.download = 'mobley_simulation_data.json';
        jsonA.click();
        URL.revokeObjectURL(jsonUrl);
    }
    
    // PDF generation
    async function generatePDF() {
        const { jsPDF } = window.jspdf;
        const pdf = new jsPDF('p', 'mm', 'a4');
        
        const element = document.getElementById('paper-content');
        
        // Show loading
        const originalText = event.target.textContent;
        event.target.textContent = '⏳ Generating...';
        event.target.disabled = true;
        
        try {
            const canvas = await html2canvas(element, {
                scale: 2,
                useCORS: true,
                logging: false
            });
            
            const imgData = canvas.toDataURL('image/png');
            const imgWidth = 210; // A4 width in mm
            const pageHeight = 297; // A4 height in mm
            const imgHeight = (canvas.height * imgWidth) / canvas.width;
            let heightLeft = imgHeight;
            let position = 0;
            
            pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
            heightLeft -= pageHeight;
            
            while (heightLeft >= 0) {
                position = heightLeft - imgHeight;
                pdf.addPage();
                pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
                heightLeft -= pageHeight;
            }
            
            pdf.save('Mobley_Framework.pdf');
        } catch (error) {
            console.error('PDF generation error:', error);
            alert('Error generating PDF. Please try again.');
        } finally {
            event.target.textContent = originalText;
            event.target.disabled = false;
        }
    }
    
    // LaTeX download
    function downloadLaTeX() {
        const latex = `\\documentclass{article}

\usepackage{amsmath} \usepackage{amssymb} \usepackage{graphicx}

\title{Cosmology from Self-Observation: The \(U^2 = -\\infty\) Framework} \author{John Alexander Mobley} \date{February 2026}

\begin{document}

\maketitle

\begin{abstract} We propose that the universe satisfies the fundamental equation \(U^2 = -\\infty\), where \(U\) is a Clifford multivector representing the cosmic state. This equation implies the universe is complex-valued (\(U = i\\Lambda\)) and evolves through entropy increase driven by observation. From this single principle, we derive: (i) cosmological expansion, (ii) inflation, (iii) dark energy, and (iv) cyclic cosmology. The theory predicts \(w_1 \\approx 7\\times10^{-5}\), testable by 2027. \end{abstract}

\section{Introduction} Modern cosmology faces profound puzzles: fine-tuning, the cosmological constant problem, and the coincidence problem. We propose the universe is a self-referential structure whose dynamics are determined by a single equation:

\begin{equation} U^2 = -\infty \end{equation}

\section{Mathematical Framework}

\subsection{The Observer Field} We define observer count \(O\) as total entropy:

\begin{equation} O \equiv S_{\text{total}} = \ln(\Omega) \end{equation}

\subsection{Solution} The universe as Clifford multivector:

\begin{equation} U(S,\Lambda) = i\Lambda \cdot e{-S2/2\Lambda^2} \end{equation}

\section{Cosmological Solutions}

\subsection{Expansion History} Scale factor evolution:

\begin{equation} a(t) \propto e{S(t)2/\Lambda^2} \end{equation}

\subsection{Dark Energy} Equation of state:

\begin{equation} w(S) = -1 + \frac{2}{3}\left(\frac{S}{\Lambda}\right)^2 \end{equation}

\section{Testable Predictions} \begin{enumerate} \item Dark energy evolution: \(w_1 \\approx 7\\times10^{-5}\) \item Decoherence scaling: \(\\Gamma \\propto S_{\\text{local}}\) \item Laboratory analogue: \(P(k,N) \\propto e^{-\\alpha N^2}\) \end{enumerate}

\section{Conclusion} We have presented a cosmological framework based on \(U^2 = -\\infty\), yielding testable predictions. If validated, this represents a fundamental shift: the universe as a self-observing structure whose existence is maintained by its inability to completely know itself.

\end{document}`;

        const blob = new Blob([latex], { type: 'text/plain' });
        const url = URL.createObjectURL(blob);
        const a = document.createElement('a');
        a.href = url;
        a.download = 'Mobley_Framework.tex';
        a.click();
        URL.revokeObjectURL(url);
    }
    
    // Math tab functions
    function updateMath(value) {
        const S = parseFloat(value);
        const LAMBDA = 100;
        
        document.getElementById('entropy-value').textContent = S;
        
        const U_mag = LAMBDA * Math.exp(-S*S / (2*LAMBDA*LAMBDA));
        const U_squared = -LAMBDA * LAMBDA * Math.exp(-S*S / (LAMBDA*LAMBDA));
        const dimension = 10 / (1 + S*S / (LAMBDA*LAMBDA));
        const w = -1 + (2/3) * (S/LAMBDA) * (S/LAMBDA);
        
        document.getElementById('math-u-mag').textContent = U_mag.toFixed(2);
        document.getElementById('math-u-squared').textContent = U_squared.toFixed(0);
        document.getElementById('math-dimension').textContent = dimension.toFixed(2);
        document.getElementById('math-w').textContent = w.toFixed(6);
    }
    
    let evolutionChart = null;
    
    function createEvolutionChart() {
        const ctx = document.getElementById('evolution-chart');
        if (!ctx) return;
        
        const LAMBDA = 100;
        const sValues = [];
        const uMagValues = [];
        const dimensionValues = [];
        const wValues = [];
        
        for (let s = 0; s <= LAMBDA; s += 1) {
            sValues.push(s);
            uMagValues.push(LAMBDA * Math.exp(-s*s / (2*LAMBDA*LAMBDA)));
            dimensionValues.push(10 / (1 + s*s / (LAMBDA*LAMBDA)));
            wValues.push(-1 + (2/3) * (s/LAMBDA) * (s/LAMBDA));
        }
        
        if (evolutionChart) {
            evolutionChart.destroy();
        }
        
        evolutionChart = new Chart(ctx, {
            type: 'line',
            data: {
                labels: sValues,
                datasets: [
                    {
                        label: '|U| (scaled ×0.1)',
                        data: uMagValues.map(v => v * 0.1),
                        borderColor: '#60a5fa',
                        backgroundColor: 'rgba(96, 165, 250, 0.1)',
                        tension: 0.4
                    },
                    {
                        label: 'Dimension',
                        data: dimensionValues,
                        borderColor: '#a78bfa',
                        backgroundColor: 'rgba(167, 139, 250, 0.1)',
                        tension: 0.4
                    },
                    {
                        label: 'w + 1 (×10)',
                        data: wValues.map(v => (v + 1) * 10),
                        borderColor: '#f87171',
                        backgroundColor: 'rgba(248, 113, 113, 0.1)',
                        tension: 0.4
                    }
                ]
            },
            options: {
                responsive: true,
                maintainAspectRatio: true,
                plugins: {
                    legend: {
                        labels: {
                            color: '#e0e0e0'
                        }
                    }
                },
                scales: {
                    x: {
                        title: {
                            display: true,
                            text: 'Entropy (S)',
                            color: '#e0e0e0'
                        },
                        ticks: {
                            color: '#9ca3af'
                        },
                        grid: {
                            color: '#374151'
                        }
                    },
                    y: {
                        title: {
                            display: true,
                            text: 'Value',
                            color: '#e0e0e0'
                        },
                        ticks: {
                            color: '#9ca3af'
                        },
                        grid: {
                            color: '#374151'
                        }
                    }
                }
            }
        });
    }
    
    // Comparison charts
    let comparisonChart = null;
    let wEvolutionChart = null;
    
    function createComparisonCharts() {
        // H(z) comparison
        const ctx1 = document.getElementById('comparison-chart');
        if (ctx1 && !comparisonChart) {
            const zValues = [];
            const mobleyH = [];
            const lcdmH = [];
            
            for (let z = 0; z <= 5; z += 0.1) {
                zValues.push(z.toFixed(1));
                const a = 1 / (1 + z);
                
                // Mobley: H(z) depends on S(a)
                const S = 50 * a; // Simplified
                const H_mob = Math.sqrt(0.3 * Math.pow(1+z, 3) + 0.7 * Math.exp(S*S/10000));
                mobleyH.push(H_mob);
                
                // ΛCDM
                const H_lcdm = Math.sqrt(0.3 * Math.pow(1+z, 3) + 0.7);
                lcdmH.push(H_lcdm);
            }
            
            comparisonChart = new Chart(ctx1, {
                type: 'line',
                data: {
                    labels: zValues,
                    datasets: [
                        {
                            label: 'Mobley',
                            data: mobleyH,
                            borderColor: '#60a5fa',
                            backgroundColor: 'rgba(96, 165, 250, 0.1)',
                            tension: 0.4
                        },
                        {
                            label: 'ΛCDM',
                            data: lcdmH,
                            borderColor: '#f87171',
                            backgroundColor: 'rgba(248, 113, 113, 0.1)',
                            tension: 0.4,
                            borderDash: [5, 5]
                        }
                    ]
                },
                options: {
                    responsive: true,
                    plugins: {
                        legend: {
                            labels: { color: '#e0e0e0' }
                        }
                    },
                    scales: {
                        x: {
                            title: { display: true, text: 'Redshift (z)', color: '#e0e0e0' },
                            ticks: { color: '#9ca3af' },
                            grid: { color: '#374151' }
                        },
                        y: {
                            title: { display: true, text: 'H(z) (normalized)', color: '#e0e0e0' },
                            ticks: { color: '#9ca3af' },
                            grid: { color: '#374151' }
                        }
                    }
                }
            });
        }
        
        // w(a) evolution
        const ctx2 = document.getElementById('w-evolution-chart');
        if (ctx2 && !wEvolutionChart) {
            const aValues = [];
            const mobleyW = [];
            const lcdmW = [];
            
            const w1 = 0.000067;
            
            for (let a = 0.2; a <= 1; a += 0.01) {
                aValues.push(a.toFixed(2));
                mobleyW.push(-1 + w1 * (1 - a));
                lcdmW.push(-1.0);
            }
            
            wEvolutionChart = new Chart(ctx2, {
                type: 'line',
                data: {
                    labels: aValues,
                    datasets: [
                        {
                            label: 'Mobley',
                            data: mobleyW,
                            borderColor: '#60a5fa',
                            backgroundColor: 'rgba(96, 165, 250, 0.1)',
                            tension: 0.4
                        },
                        {
                            label: 'ΛCDM (w = -1)',
                            data: lcdmW,
                            borderColor: '#f87171',
                            backgroundColor: 'rgba(248, 113, 113, 0.1)',
                            tension: 0,
                            borderDash: [5, 5]
                        }
                    ]
                },
                options: {
                    responsive: true,
                    plugins: {
                        legend: {
                            labels: { color: '#e0e0e0' }
                        }
                    },
                    scales: {
                        x: {
                            title: { display: true, text: 'Scale Factor (a)', color: '#e0e0e0' },
                            ticks: { color: '#9ca3af' },
                            grid: { color: '#374151' }
                        },
                        y: {
                            title: { display: true, text: 'w(a)', color: '#e0e0e0' },
                            ticks: { color: '#9ca3af' },
                            grid: { color: '#374151' },
                            min: -1.001,
                            max: -0.999
                        }
                    }
                }
            });
        }
    }
    
    // Initialize on load
    window.addEventListener('load', () => {
        initThreeJS();
        updateDisplay();
        updateMath(50);
        
        // Trigger MathJax rendering
        if (typeof MathJax !== 'undefined') {
            MathJax.typesetPromise();
        }
    });
</script>