<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dashboard</title>
    <style>
        /* Base Reset */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* Background and Container Styles */
        body {
            background: url('bg.jpg') no-repeat center center/cover;
            position: relative;
            height: 100vh;
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: 'Arial', sans-serif;
        }

        #particles-js {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 1;
        }

        .container {
            position: relative;
            z-index: 2;
            background: rgba(0, 0, 0, 0.7);
            padding: 30px 40px;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
            text-align: center;
        }

        .container h1 {
            font-size: 20px;
            margin-bottom: 20px;
            text-transform: uppercase;
            letter-spacing: 3px;
            color: #ffffff;
            animation: glowText 2s infinite;
        }

        @keyframes glowText {
            0%, 100% { text-shadow: 0 0 10px #ffffff, 0 0 20px #ffffff; }
            50% { text-shadow: 0 0 20px #ffffff, 0 0 40px #ffffff; }
        }

        /* Button Styling */
        .button, .join-tg {
            width: 100%;
            padding: 10px;
            border: none;
            border-radius: 8px;
            background: linear-gradient(90deg, #00f, #4db8ff);
            color: #ffffff;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            margin-top: 10px;
            transition: all 0.3s ease;
            text-shadow: 0 0 10px #00f, 0 0 20px #4db8ff;
        }

        .button:hover, .join-tg:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(0, 0, 255, 0.6);
        }

        .output p {
            color: white;
            font-size: 14px;
        }
    </style>
</head>
<body>
    <div id="particles-js"></div>

    <div class="container">
        <div class="auto-text" id="autoText"></div>
        <h1 style="font-size: 18px; margin-bottom: 10px;">2LEVEL CALCULATION</h1>
        <div class="output">
            <p><strong>Period Number:</strong> <span id="periodNumber"></span></p>
            <p><strong>Result:</strong> <span id="result">RESULT</span></p>
        </div>
        <button class="button" onclick="calculatePeriod()">PRESENT RESULT</button>
        <button class="join-tg" onclick="openTelegram()">JOIN TG</button>
    </div>

    <script>
        // Auto-type effect
        const autoText = document.getElementById('autoText');
        const text = "";
        let index = 0;

        function typeText() {
            if (index < text.length) {
                autoText.textContent += text.charAt(index);
                index++;
                setTimeout(typeText, 250);
            }
        }
        typeText();

        // Function to calculate the period
        function calculatePeriod() {
            const now = new Date();
            const hour = now.getHours();
            const minute = now.getMinutes();
            const totalMinutes = (hour * 60) + minute;

            const currentDate = now.toISOString().slice(0, 10).replace(/-/g, '');
            const offset = 330;
            const periodCalculation = 10001 + totalMinutes - offset;
            const periodNumber = `${currentDate}1000${periodCalculation}`;

            document.getElementById('periodNumber').textContent = periodNumber;

            let digitSum = String(periodCalculation)
                .split('')
                .reduce((sum, digit) => sum + parseInt(digit), 0);

            while (digitSum >= 10) {
                digitSum = String(digitSum)
                    .split('')
                    .reduce((sum, digit) => sum + parseInt(digit), 0);
            }

            let result;
            if (digitSum >= 0 && digitSum <= 4) {
                result = "BIG";
            } else if (digitSum >= 5 && digitSum <= 9) {
                result = "SMALL";
            } else {
                result = "ERROR";
            }

            document.getElementById('result').textContent = result;
        }

        // Open Telegram link
        function openTelegram() {
            window.open('https://t.me/TEAM_KBTRETURNS', '_blank');
        }
    </script>
</body>
</html>