<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Period Calculation</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f0f0f0;
        }
        .container {
            width: 250px;
            height: auto;
            background-color: #fff;
            border: 2px solid #FF0045; /* Neon sky blue border */
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            padding: 20px;
            text-align: center;
            box-sizing: border-box;
        }
        .output {
            margin: 10px 0;
            padding: 10px;
            background-color: #f9f9f9;
            border-radius: 5px;
            font-size: 14px;
        }
        button {
            margin-top: 10px;
            padding: 10px;
            width: 70%;
            font-size: 14px;
            background-color: #007BFF;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        .join-tg {
            width: 70%;
            height: 40px;
            margin-top: 20px;
            background-color: #00bfff; /* Neon blue background */
            color: white;
            font-size: 16px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        .join-tg:hover {
            background-color: #4682b4; /* Slightly darker blue on hover */
        }
        .auto-text {
            font-size: 20px;
            color: #00FF00; /* Neon sky blue text */
            text-shadow: 1px 1px 2px black;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="auto-text" id="autoText"></div>
        <h1 style="font-size: 18px; margin-bottom: 10px;">Period Calculation</h1>
        <div class="output">
            <p><strong>Period Number:</strong> <span id="periodNumber">N/A</span></p>
            <p><strong>Result:</strong> <span id="result">N/A</span></p>
        </div>
        <button onclick="calculatePeriod()">Calculate</button>
        <button class="join-tg" onclick="openTelegram()">JOIN TG</button>
    </div>

    <script>
        // Auto-type effect for "MADE BY TEAM KBT"
        const autoText = document.getElementById('autoText');
        const text = "MADE BY TEAM KBT";
        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>