<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Prediction Web</title>
    <link rel="stylesheet" href="styles.css">
    <style>
        body {
            background: linear-gradient(1350deg, #000000, #333333);
            color: #ffcc00;
            font-family: 'Courier New', Courier, monospace;
            text-align: center;
            padding: 160px;
        }

        .container {
            display: inline-block;
            border: 5px solid #ffcc00;
            padding: 20px;
            border-radius: 15px;
            background: radial-gradient(circle, #444444, #222222);
            box-shadow: 0 0 100px rgba(255, 200, 0, 0.5);
        }

        .header {
            font-size: 30px;
            margin-bottom: 20px;
            text-shadow: 0 0 15px #ffcc00;
        }

        .period {
            font-size: 28px;
            margin: 10px 0;
            border: 2px solid #ffcc00;
            padding: 10px;
            border-radius: 15px;
            background-color: #333;
            text-shadow: 0 0 10px #ffcc00;
        }

        .server {
            font-size: 20px;
            margin: 10px 0;
            padding: 10px;
            border: 2px solid #ffcc00;
            border-radius: 15px;
            background-color: #333;
            text-shadow: 0 0 10px #ffcc00;
        }

        .result-btn {
            font-size: 25px;
            background-color: black;
            color: #ffcc00;
            border: 2px solid #ffcc00;
            border-radius: 15px;
            padding: 10px 30px;
            margin: 20px 0;
            cursor: pointer;
        }

        .result {
            font-size: 40px;
            color: #00ff00;
            text-shadow: 0 0 20px #00ff00;
            margin-top: 20px;
        }

        .telegram-link {
            margin-top: 20px;
        }

        .telegram-btn {
            font-size: 20px;
            background-color: #0088cc; /* Telegram blue */
            color: white;
            padding: 10px 20px;
            border-radius: 10px;
            text-decoration: none;
            transition: background-color 0.3s;
        }

        .telegram-btn:hover {
            background-color: #0077b3; /* Darker blue on hover */
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">★ PREDICTION VIP ★</div>
        <div class="period" id="period">Loading...</div>
        <div class="server">SERVER STATUS: ACTIVE</div>
        <div id="result" class="result">Press the button for prediction</div>
        <button id="result-btn" class="result-btn">GET PREDICTION</button>
        <div class="telegram-link">
            <a href="https://t.me/HgzyGame_BDT" target="_blank" class="telegram-btn"> Telegram Channel </a>
        </div>
    </div>

<script>
let lastUpdateTime = 0; // Last update time in milliseconds
const resultBtn = document.getElementById('result-btn');
const resultElement = document.getElementById('result');
const periodElement = document.getElementById('period');

// Show random text
function showRandomText() {
    const texts = ['BIG', 'SMALL', 'SMALL', 'SKIP', 'BIG', 'BIG', 'SMALL', 'SKIP', 'SMALL', 'BIG']; 
    const randomIndex = Math.floor(Math.random() * texts.length); 
    const selectedText = texts[randomIndex];
    return selectedText;
}

// Function to update the prediction
function updatePrediction() {
    const currentPeriod = getCurrentPeriod(); // Get the current period
    periodElement.innerText = currentPeriod; // Display the period number

    const prediction = showRandomText(); // Generate random prediction
    resultElement.innerText = prediction; // Display the result
}

// Function to get the current period based on Bangladesh time (UTC+6)
function getCurrentPeriod() {
    const now = new Date();
    const bangladeshTime = new Date(now.getTime() + 24 * 60 * 60 * 1000); // Adjust to Bangladesh time
    const totalMinutes = bangladeshTime.getUTCHours() * 60 + bangladeshTime.getUTCMinutes() + 1; // Add 1 to total minutes
    const currentDate = bangladeshTime.getUTCFullYear().toString() +
        (bangladeshTime.getUTCMonth() + 1).toString().padStart(2, '0') +
        bangladeshTime.getUTCDate().toString().padStart(2, '0');
    return `${currentDate}0001${totalMinutes.toString().padStart(4, '0')}`; // Return formatted period number
}

// Add an event listener to the result button
resultBtn.addEventListener('click', function() {
    const now = new Date().getTime(); // Get the current time in milliseconds

    // Ensure at least 1 minute has passed since the last prediction
    if (now - lastUpdateTime >= 60000) {
        updatePrediction(); // Call the updatePrediction function
        lastUpdateTime = now; // Update the last time of prediction
    } else {
        resultElement.innerText = "Wait for the next period"; // Prevent multiple predictions in the same minute
    }
});

// Check for new minute every second and reset prediction time
setInterval(function() {
    const now = new Date();
    const bangladeshTime = new Date(now.getTime() + 24 * 60 * 60 * 1000); // Adjust to Bangladesh time
    const seconds = bangladeshTime.getUTCSeconds();

    // Check if a new minute has started
    if (seconds === 0) {
        lastUpdateTime = 0; // Allow new prediction when the next minute starts
    }
}, 1000); // Check every second
</script>
</body>
</html>