<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Play Minute Mania, an addictive arcade-style number game where you race against time to reach 1 million points. Match falling numbers through 5 challenging levels and become a high-score champion.">
    <title>Home - Minute Mania</title>
    <link rel="icon" type="image/x-icon" href="mmfavicon.png">
    <link href="https://fonts.googleapis.com/css2?family=Bungee&family=Montserrat:wght@600&display=swap" rel="stylesheet">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
    <style>
        /* Original CSS */
        :root {
            --primary-purple: #6a1b9a;
            --accent-gold: #ffd700;
            --glow-purple: rgba(106, 27, 154, 0.4);
        }

        html, body {
            margin: 0;
            padding: 0;
            height: 100vh;
            overflow: hidden;
            background: radial-gradient(circle at center, #4a148c 0%, #2c0058 100%);
            font-family: 'Bungee', cursive;
        }

        #time-portal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
        }

        .clock-bg {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: min(90vh, 90vw);
            height: min(90vh, 90vw);
            border: 4px solid rgba(255, 255, 255, 0.1);
            border-radius: 50%;
            box-shadow: 0 0 100px rgba(106, 27, 154, 0.3);
            animation: rotate 60s infinite linear;
            z-index: 1;
        }

        @keyframes rotate {
            from { transform: translate(-50%, -50%) rotate(0deg); }
            to { transform: translate(-50%, -50%) rotate(360deg); }
        }

        .content-wrapper {
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            z-index: 2;
            gap: 30px;
            padding: 20px;
            transform-origin: top center;
            transition: transform 0.3s ease;
        }

        .logo-container {
            position: relative;
            width: min(80vw, 500px);
            animation: float-logo 4s ease-in-out infinite;
        }

        @keyframes float-logo {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-10px); }
        }

        .logo {
            width: 100%;
            filter: drop-shadow(0 10px 20px rgba(0,0,0,0.4));
        }

        .buttons-container {
            display: flex;
            flex-direction: column;
            gap: 20px;
            width: 100%;
            max-width: 400px;
            animation: fade-up 1s ease-out;
        }

        @keyframes fade-up {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .game-button {
            position: relative;
            width: 100%;
            padding: 15px 30px;
            border: none;
            border-radius: 15px;
            background: linear-gradient(135deg, #ffd700 0%, #ffa000 100%);
            cursor: pointer;
            overflow: hidden;
            transform-style: preserve-3d;
            transform: perspective(1000px);
            transition: transform 0.3s, filter 0.3s;
        }

        .game-button.play-button {
            padding: 30px;
            font-size: 3.5em;
            border-radius: 25px;
            background: linear-gradient(135deg, #ffd700 0%, #ff8f00 100%);
        }

        .button-face {
            position: relative;
            z-index: 1;
            font-family: 'Montserrat', sans-serif;
            font-weight: 600;
            color: var(--primary-purple);
            text-transform: uppercase;
            text-shadow: 
                0 1px 0 rgba(255,255,255,0.4),
                0 -1px 0 rgba(0,0,0,0.4);
        }

        .play-button .button-face {
            font-family: 'Bungee', cursive;
            font-weight: normal;
        }

        .button-shine {
            position: absolute;
            inset: 0;
            background: linear-gradient(
                135deg,
                rgba(255,255,255,0.4) 0%,
                transparent 50%,
                rgba(255,255,255,0.1) 100%
            );
            transition: opacity 0.3s;
        }

        @keyframes pulse {
            0% {
                transform: perspective(1000px) translateZ(10px) scale(1);
                filter: brightness(1.1) drop-shadow(0 10px 20px rgba(0,0,0,0.4));
            }
            50% {
                transform: perspective(1000px) translateZ(10px) scale(1.02);
                filter: brightness(1.2) drop-shadow(0 15px 25px rgba(0,0,0,0.5));
            }
            100% {
                transform: perspective(1000px) translateZ(10px) scale(1);
                filter: brightness(1.1) drop-shadow(0 10px 20px rgba(0,0,0,0.4));
            }
        }

        .game-button:hover {
            animation: pulse 1s ease-in-out infinite;
        }

        .game-button:hover .button-shine {
            opacity: 0.8;
        }

        .game-button:active {
            animation: none;
            transform: perspective(1000px) translateZ(-5px);
            filter: brightness(0.95) drop-shadow(0 5px 10px rgba(0,0,0,0.3));
        }

        .time-markers {
            position: absolute;
            inset: 0;
            pointer-events: none;
        }

        .marker {
            position: absolute;
            width: 2px;
            height: 20px;
            background: rgba(255, 255, 255, 0.1);
            transform-origin: 50% 50%;
        }

        @media (max-width: 768px) {
            .buttons-container {
                max-width: 300px;
            }

            .game-button.play-button {
                padding: 25px;
                font-size: 3em;
            }
        }

        /* Laptop screens (typically 1366x768) */
        @media screen and (max-height: 800px) {
            .content-wrapper {
                transform: scale(0.97);
                padding-top: max(20px, 4vh);
            }

            .clock-bg {
                width: min(85vh, 85vw);
                height: min(85vh, 85vw);
            }

            .logo-container {
                width: min(75vw, 450px);
                margin-bottom: -15px; /* Reduce space between logo and buttons */
            }

            .buttons-container {
                gap: 15px; /* Reduce gap between buttons */
                max-width: 380px;
            }

            .game-button.play-button {
                padding: 25px; /* Slightly smaller padding */
                font-size: 3.2em;
            }

            .game-button {
                padding: 15px 28px;
            }

            /* Adjust marker sizes */
            .marker {
                height: 15px; /* Slightly smaller markers */
            }
        }

        /* Even smaller screens */
        @media screen and (max-height: 700px) {
            .content-wrapper {
                transform: scale(0.89);
            }

            .clock-bg {
                width: min(80vh, 80vw);
                height: min(80vh, 80vw);
            }

            .logo-container {
                width: min(70vw, 380px);
                margin-bottom: -25px;
            }

            .buttons-container {
                gap: 12px;
            }

            .game-button.play-button {
                padding: 15px;
                font-size: 2.8em;
            }

            .game-button {
                padding: 10px 20px;
            }
        }

        /* Very small heights */
        @media screen and (max-height: 600px) {
            .content-wrapper {
                transform: scale(0.82);
            }

            .clock-bg {
                width: min(70vh, 70vw);
                height: min(70vh, 70vw);
            }

            .logo-container {
                width: min(60vw, 300px);
                margin-bottom: -30px;
            }
        }

        /* Handle landscape specifically */
        @media screen and (max-height: 800px) and (orientation: landscape) {
            .content-wrapper {
                transform: scale(0.82);
                padding-top: max(10px, 2vh);
            }

            .clock-bg {
                width: min(65vh, 65vw);
                height: min(65vh, 65vw);
            }

            .logo-container {
                width: min(50vw, 350px);
            }

            .buttons-container {
                max-width: 300px;
            }
        }

        /* Preserve the vortex effect */
        #time-portal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100% !important;
            height: 100% !important;
            z-index: 0;
        }


    </style>
</head>
<body>
    <canvas id="time-portal"></canvas>
    <div class="clock-bg">
        <div class="time-markers" id="timeMarkers"></div>
    </div>
    
    <div class="content-wrapper">
        <div class="logo-container">
            <img src="mmlogomainmenu.webp" alt="Minute Mania" class="logo">
        </div>
        
        <div class="buttons-container">
            <button class="game-button play-button" onclick="window.location.href='maingameplay.html'">
                <div class="button-shine"></div>
                <div class="button-face">Play</div>
            </button>
            
            <button class="game-button" onclick="window.location.href='howtoplay.html'">
                <div class="button-shine"></div>
                <div class="button-face">How to Play</div>
            </button>
            
            <button class="game-button" onclick="window.location.href='settings.html'">
                <div class="button-shine"></div>
                <div class="button-face">Settings</div>
            </button>
        </div>
    </div>

    <script>
        // Initialize Three.js Scene
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer({ 
            canvas: document.getElementById('time-portal'),
            alpha: true,
            antialias: true
        });
        renderer.setSize(window.innerWidth, window.innerHeight);
        camera.position.z = 50;

        // Create Time Vortex
        const vortexGeometry = new THREE.TorusGeometry(20, 5, 32, 100);
        const vortexMaterial = new THREE.MeshPhongMaterial({
            color: 0xffd700,
            transparent: true,
            opacity: 0.3,
            emissive: 0xffd700,
            emissiveIntensity: 0.5
        });
        const vortex = new THREE.Mesh(vortexGeometry, vortexMaterial);
        scene.add(vortex);

        // Add Lighting
        const ambientLight = new THREE.AmbientLight(0x404040);
        scene.add(ambientLight);
        const directionalLight = new THREE.DirectionalLight(0xffd700, 1);
        directionalLight.position.set(5, 5, 5);
        scene.add(directionalLight);

        // Time Particles
        const particlesGeometry = new THREE.BufferGeometry();
        const particleCount = 1000;
        const posArray = new Float32Array(particleCount * 3);
        
        for(let i = 0; i < particleCount * 3; i++) {
            posArray[i] = (Math.random() - 0.5) * 100;
        }
        particlesGeometry.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
        
        const particlesMaterial = new THREE.PointsMaterial({
            size: 0.2,
            color: 0xffd700,
            transparent: true,
            opacity: 0.8,
            blending: THREE.AdditiveBlending
        });
        
        const particlesMesh = new THREE.Points(particlesGeometry, particlesMaterial);
        scene.add(particlesMesh);

        // Mouse and Touch Movement Effects
        let mouseX = 0;
        let mouseY = 0;
        let targetX = 0;
        let targetY = 0;
        const windowHalfX = window.innerWidth / 2;
        const windowHalfY = window.innerHeight / 2;

        // Mouse events
        document.addEventListener('mousemove', (event) => {
            event.preventDefault();
            handleMovement(event.clientX, event.clientY);
        });

        // Touch events
        document.addEventListener('touchstart', (event) => {
            event.preventDefault();
            handleMovement(event.touches[0].clientX, event.touches[0].clientY);
        });

        document.addEventListener('touchmove', (event) => {
            event.preventDefault();
            handleMovement(event.touches[0].clientX, event.touches[0].clientY);
        });

        // Unified movement handler
        function handleMovement(x, y) {
            mouseX = (x - windowHalfX);
            mouseY = (y - windowHalfY);
        }

        // Animation Loop
        function animate() {
            requestAnimationFrame(animate);

            // Rotate vortex
            vortex.rotation.z += 0.005;
            vortex.rotation.x = mouseY * 0.0001;
            vortex.rotation.y = mouseX * 0.0001;

            // Animate particles
            particlesMesh.rotation.y += 0.001;
            particlesMesh.rotation.x += 0.001;

            // Smooth camera movement
            targetX = mouseX * 0.001;
            targetY = mouseY * 0.001;
            camera.rotation.y += 0.05 * (targetX - camera.rotation.y);
            camera.rotation.x += 0.05 * (targetY - camera.rotation.x);

            renderer.render(scene, camera);
        }
        animate();

        // Create clock markers
        const timeMarkers = document.getElementById('timeMarkers');
        for (let i = 0; i < 60; i++) {
            const marker = document.createElement('div');
            marker.className = 'marker';
            marker.style.transform = `rotate(${i * 6}deg) translateY(-50vh)`;
            timeMarkers.appendChild(marker);
        }

        // Handle Window Resize and Device Orientation
        window.addEventListener('resize', onWindowResize);
        window.addEventListener('orientationchange', onWindowResize);

        function onWindowResize() {
            // Update camera and renderer
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);

            // Update center points for calculations
            windowHalfX = window.innerWidth / 2;
            windowHalfY = window.innerHeight / 2;

            // Scale vortex and adjust camera based on screen height
            if (window.innerHeight <= 800) {
                vortex.scale.set(0.92, 0.92, 0.92);  // Increased from 0.85
                camera.position.z = 47;  // Adjusted for better view
                particlesMesh.scale.set(0.92, 0.92, 0.92);
            } else if (window.innerHeight <= 700) {
                vortex.scale.set(0.82, 0.82, 0.82);  // Increased from 0.75
                camera.position.z = 42;
                particlesMesh.scale.set(0.82, 0.82, 0.82);
            } else if (window.innerHeight <= 600) {
                vortex.scale.set(0.72, 0.72, 0.72);  // Increased from 0.65
                camera.position.z = 37;
                particlesMesh.scale.set(0.72, 0.72, 0.72);
            } else {
                vortex.scale.set(1, 1, 1);
                camera.position.z = 50;
                particlesMesh.scale.set(1, 1, 1);
            }
        }
    </script>
</body>
</html>