<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TANMAY AI SERVER</title>
    <script src="https://cdn.jsdelivr.net/npm/particles.js@2.0.0/particles.min.js"></script>
    <style>
        /* General Reset */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background-image: url('images/wolf-background.jpg'); /* Replace with your background */
            background-size: cover;
            background-position: center;
            font-family: 'Arial', sans-serif;
            color: #FFFFFF;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
        }

        /* Particles.js container */
        #particles-js {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: -1; /* Keep particles behind the content */
        }

        .container {
            width: 90%;
            max-width: 400px;
            background: rgba(0, 0, 0, 0.8); /* Black transparent */
            border: 2px solid red;
            border-radius: 10px;
            padding: 20px;
            position: relative;
            text-align: center;
            animation: fadeIn 1.5s ease;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: scale(0.9);
            }
            to {
                opacity: 1;
                transform: scale(1);
            }
        }

        .header {
            font-size: 28px;
            font-weight: bold;
            color: red;
            text-align: center;
            margin-bottom: 20px;
        }

        .buttons {
            display: flex;
            justify-content: space-between;
            margin-bottom: 20px;
        }

        .buttons button {
            flex: 1;
            margin: 0 10px;
            padding: 10px;
            font-size: 16px;
            background: black;
            color: white;
            border: 2px solid red;
            border-radius: 5px;
            cursor: pointer;
            transition: 0.3s ease;
        }

        .buttons button:hover {
            background: red;
            color: black;
        }

        .selection {
            text-align: center;
            font-size: 16px;
            font-weight: bold;
            margin-bottom: 10px;
            color: red;
            animation: bounce 2s infinite;
        }

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

        .period {
            font-size: 14px;
            color: #FFF;
            margin-bottom: 20px;
        }

        .result-box {
            height: 150px;
            border: 2px solid red;
            border-radius: 10px;
            display: flex;
            justify-content: center;
            align-items: center;
            color: red;
            font-size: 20px;
            font-weight: bold;
            overflow: hidden;
            position: relative;
        }

        .result-animation {
            font-size: 30px;
            font-weight: bold;
            animation: resultAnimation 2s ease forwards;
            opacity: 0;
        }

        @keyframes resultAnimation {
            0% {
                transform: scale(0.5) rotateX(-90deg);
                opacity: 0;
            }
            50% {
                transform: scale(1.2) rotateX(0deg);
                opacity: 0.7;
            }
            100% {
                transform: scale(1) rotateX(0deg);
                opacity: 1;
            }
        }

        .get-result {
            margin-top: 20px;
            text-align: center;
        }

        .get-result button {
            width: 100%;
            padding: 10px;
            font-size: 16px;
            background: black;
            color: white;
            border: 2px solid red;
            border-radius: 5px;
            cursor: pointer;
            transition: 0.3s ease;
        }

        .get-result button:hover {
            background: red;
            color: black;
        }
    </style>
</head>
<body>
    <!-- Particles.js Container -->
    <div id="particles-js"></div>

    <div class="container">
        <div class="header">TANMAY AI SERVER</div>
        <div class="buttons">
            <button onclick="selectServer('Server 1')">SERVER 1</button>
            <button onclick="selectServer('Server 2')">SERVER 2</button>
        </div>
        <div class="selection" id="serverSelection">SERVER SELECT 👉</div>
        <div class="period" id="periodNumber">PERIOD: Loading...</div>
        <div class="result-box" id="resultBox">RESULT</div>
        <div class="get-result">
            <button onclick="showResult()">GET RESULT</button>
        </div>
    </div>
    <script>
        let selectedServer = "";
        let lastPeriod = "";
        let lastResultPeriod = "";

        // Update period number every second
        function updatePeriodNumber() {
    const periodElement = document.getElementById('periodNumber');
    const now = new Date();

    const seconds = now.getUTCSeconds();
    const remainingSeconds = 60 - seconds;
    const minutes = now.getUTCMinutes();
    const hours = now.getUTCHours();
    const totalMinutes = hours * 60 + minutes;

    // Period format: yyyyMMdd1000XXXXX (where XXXXX = total minutes + 10001)
    const period = `${now.getUTCFullYear()}${(now.getUTCMonth() + 1).toString().padStart(2, '0')}${now.getUTCDate().toString().padStart(2, '0')}1000${10001 + totalMinutes}`;
    
    periodElement.textContent = `PERIOD: ${period}`;

    // Optional: Display countdown timer
    const timerElement = document.getElementById('timer');
    if (timerElement) {
        timerElement.textContent = `Next in: ${remainingSeconds}s`;
    }

    lastPeriod = period;
}

// Update every second
setInterval(updatePeriodNumber, 1000);

        // Server Selection
        function selectServer(server) {
            selectedServer = server;
            document.getElementById('serverSelection').textContent = `SERVER SELECT ➡️ ${server}`;
            document.getElementById('resultBox').textContent = "RESULT"; // Clear result box
        }

        // Show result for selected server
        function showResult() {
            const resultBox = document.getElementById('resultBox');
            if (!selectedServer) {
                alert("Please select a server first!");
                return;
            }

            if (lastResultPeriod === lastPeriod) {
                resultBox.innerHTML = "<div class='result-animation'>WAIT FOR NEXT PERIOD 🫷</div>";
                return;
            }

            const bigNumbers = [5, 6, 7, 8, 9];
            const smallNumbers = [0, 1, 2, 3, 4];
            let result = "";

            if (selectedServer === "Server 1") {
                result = Math.random() > 0.5 ? "BIG" : "SMALL";
            } else if (selectedServer === "Server 2") {
                const isBig = Math.random() > 0.5;
                result = isBig
                    ? `BIG ${bigNumbers[Math.floor(Math.random() * bigNumbers.length)]}`
                    : `SMALL ${smallNumbers[Math.floor(Math.random() * smallNumbers.length)]}`;
            }

            lastResultPeriod = lastPeriod; // Store the period for which result was shown

            // Add animated result
            resultBox.innerHTML = `<div class="result-animation">${result}</div>`;
        }

        // Load particles.js
        particlesJS.load('particles-js', 'particles-config.json', function() {
            console.log('Particles.js loaded');
        });
    </script>
</body>
</html>