-<html lang="en"><head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>𝐖𝐈𝐍𝐆𝐎 𝟏 𝐌𝐈𝐍 𝐏𝐑𝐄𝐃𝐈𝐂𝐓𝐈𝐎𝐍</title>

    <script src="js/chart.js"></script>

    <style>

        body {

            font-family: 'Arial', sans-serif;

            background-color: #1201FD;

            margin: 0;

            padding: 0;

            color: #12E200;

        }

        h1, h2 {

            color: #FFFF00;

            text-align: center;

            margin-top: 20px;

        }

        body {
            font-family: Arial, sans-serif;
            background-color: #f4f7fc;
            margin: 0;
            padding: 0;
        }

        .mainContent {
            max-width: 400px;
            margin: 100px auto;
            padding: 40px;
            background: #fff;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
        }

        h2 {
            text-align: center;
            color: #333;
            margin-bottom: 30px;
        }

        label {
            font-size: 14px;
            color: #555;
        }

        input[type="email"], input[type="password"] {
            width: 100%;
            padding: 15px;
            margin: 10px 0;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 16px;
            box-sizing: border-box;
        }

        button {
            width: 100%;
            padding: 15px;
            background-color: #4CAF50;
            border: none;
            border-radius: 4px;
            font-size: 16px;
            color: white;
            cursor: pointer;
        }

        button:hover {
            background-color: #45a049;
        }

        .error-message {
            color: red;
            text-align: center;
            margin-top: 10px;
        }

        .success-message {
            color: green;
            text-align: center;
            margin-top: 10px;

        }
                #mainContent {
            display: none;
        }

        .card {

            max-width: 90%;

            margin: 20px auto;

            padding: 20px;

            border-radius: 8px;

            background-color: #1201FD;

            box-shadow: 3 4px 8px rgba(0, 0, 0, 0.1);

        }

        #dataTable, #predictionHistoryTable {

            width: 100%;

            border-radius: 8px;

            overflow: hidden;

            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);

            background-color: #FFFFFF;

        }

        table {

            width: 100%;

            border-collapse: collapse;

        }

        th, td {

            padding: 12px;

            text-align: center;

            border-bottom: 1px solid #FFFFFF;

        }

        th {

            background-color: #FFFF00;

            color: black;

            font-weight: bold;

        }

        td {

            background-color: #FFFFFF;

        }

        tr:nth-child(even) td {

            background-color: #FFFFFF;

        }

        tr:hover td {

            background-color: #FFFFFF;

        }

        #predictionChart {

            width: 100%;

            height: 250px; /* Fixed height */

            border: 2px solid #FFFF00;

            border-radius: 8px;

            background-color: #FFFFFF;

        }

        .pagination {

            display: flex;

            justify-content: center;

            margin-top: 20px;

        }

        .pagination button {

            padding: 10px 20px;

            margin: 0 5px;

            border: none;

            border-radius: 5px;

            background-color: #FFFF00;

            color: black;

            cursor: pointer;

            transition: background-color 0.3s ease, transform 0.2s ease;

        }

        .pagination button:hover {

            background-color: #FF0000;

            transform: scale(1.05);

        }

        .pagination button:disabled {

            background-color: #DDDDDD;

            cursor: not-allowed;

        }

        #timeRemaining {

            font-size: 24px;

            font-weight: bold;

            text-align: center;

        }

        #predictedNumber, #predictedPremium {

            font-size: 18px;

            text-align: center;

            margin: 10px 0;

        }

        .button-group {

            display: flex;

            justify-content: center;

            margin: 20px 0;

        }

        .button-group a {

            padding: 10px 20px;

            margin: 0 10px;

            border-radius: 5px;

            cursor: pointer;

            text-decoration: none; /* Remove underline */

            color: white; /* Text color */

            display: inline-block; /* Make anchor behave like a button */

            transition: background-color 0.3s ease, transform 0.2s ease;

        }

        #registerButton {

            background-color: #FFFF00; /* Blue for Register */

        }

        #telegramButton {

            background-color: #FF0000; /* Red for Telegram */

        }

        .button-group a:hover {

            transform: scale(1.05);

        }

        @media (max-width: 768px) {

            .card {

                padding: 15px;

            }

            th, td {

                padding: 8px;

                font-size: 14px;

            }

            #timeRemaining {

                font-size: 20px;

            }

            #predictedNumber, #predictedPremium {

                font-size: 16px;

            }

            #predictionChart {

                height: 200px; /* Adjusted height for mobile */

            }

        }

        @media (max-width: 480px) {

            th, td {

                font-size: 12px;

            }

            #timeRemaining {

                font-size: 18px;

            }

            #predictedNumber, #predictedPremium {

                font-size: 14px;

            }

            #predictionChart {

                height: 180px; /* Further adjustment for very small screens */

            }

        }

    </style>

</head>

<body>

    <!-- Main Content Section -->
    <div class="mainContent">
        <h2>Login</h2>
        <form id="login-form">
            <label for="email">Email:</label>
            <input type="email" id="email" placeholder="Enter your email" required>
            
            <label for="password">Password:</label>
            <input type="password" id="password" placeholder="Enter your password" required>
            
            <button type="submit">Login</button>
        </form>
        
        <div id="error-message" class="error-message"></div>
        <div id="success-message" class="success-message"></div>
    </div>
    
    <div id="mainContent">
    

    <h1>𝐖𝐈𝐍𝐆𝐎 𝟏 𝐌𝐈𝐍 𝐏𝐑𝐄𝐃𝐈𝐂𝐓𝐈𝐎𝐍</h1>

    <div class="card">

        <h2>©ColorTraderPro™</h2>

        <p id="predictedNumber">Prediction :--</p>

        <p id="predictedPremium">Enjoy: --</p>

    </div>

    <div class="card">

        <h2>Timer</h2>

        <p id="timeRemaining">--:--</p>

        

    <div class="button-group">

        <a href= "t.me/ColorTraderPro" id="registerButton" target="_blank">Register</a>

        <a href="https://t.me/ColorTraderPro" id="telegramButton" target="_blank">Telegram</a>

    </div>

    </div>

    <div class="card">

        <h2>Collected Data</h2>

        <table id="dataTable">

            <thead>

                <tr>

                    <th>Issue Number</th>

                    <th>Number</th>

                    <th>Colour</th>

                    <th>Premium</th>

                </tr>

            </thead>

            <tbody>

                <!-- Data rows will be inserted here -->

            </tbody>

        </table>

    </div>

    <div class="card">

        <h2>Prediction History</h2>

        <table id="predictionHistoryTable">

            <thead>

                <tr>

                    <th>Issue Number</th>

                    <th>Predicted Number</th>

                    <th>Actual Number</th>

                    <th>Result</th>

                </tr>

            </thead>

            <tbody></tbody>

        </table>

        <div class="pagination">

            <button id="prevPage" disabled="">Previous</button>

            <button id="nextPage" disabled="">Next</button>

        </div>

    </div>

    <div class="card">

        <h2>Devloper  @ColorTraderPro™</h2>

        <div class="button-group">

        <a href="https://www.in978.com/#/register?invitationCode=885723619234" id="registerButton" target="_blank">Telegram Join Now!!</a>

    </div>

<script>

document.addEventListener('DOMContentLoaded', function() {

    const tableBody = document.querySelector('#dataTable tbody');

    const predictedNumberElement = document.getElementById('predictedNumber');

    const predictedPremiumElement = document.getElementById('predictedPremium');

    const timerElement = document.getElementById('timeRemaining');

    const historyTableBody = document.querySelector('#predictionHistoryTable tbody');

    const prevPageButton = document.getElementById('prevPage');

    const nextPageButton = document.getElementById('nextPage');

    let predictionHistory = JSON.parse(localStorage.getItem('predictionHistory')) || [];

    let lastPrediction = JSON.parse(localStorage.getItem('lastPrediction'));

    let currentPrediction = JSON.parse(localStorage.getItem('currentPrediction'));

    let currentPage = 0;

    const itemsPerPage = 10;

    let timerInterval;

    const fetchNoAverageEmerdList = () => {

        const requestData = {

            pageSize: 10,

            pageNo: 1,

            typeId: 1,

            language: 0,

            random: "ded40537a2ce416e96c00e5218f6859a",

            signature: "69306982EEEB19FA940D72EC93C62552",

            timestamp: Math.floor(Date.now() / 1000)

        };

        return fetch('https://api.bdg88zf.com/api/webapi/GetNoaverageEmerdList', {

            method: 'POST',

            headers: {

                'Content-Type': 'application/json;charset=UTF-8',

                'Accept': 'application/json, text/plain, */*'

            },

            body: JSON.stringify(requestData)

        })

        .then(response => response.json())

        .catch(error => console.error('Error fetching no average EMERD list data:', error));

    };

    const fetchGameIssue = () => {

        const requestData = {

            typeId: 1,

            language: 0,

            random: "f8dcb5c527814db68800e3946a2b60e8",

            signature: "08CF7FF3339ED58D4743F4B650FCBEA9",

            timestamp: Math.floor(Date.now() / 1000)

        };

        return fetch('https://api.bdg88zf.com/api/webapi/GetGameIssue', {

            method: 'POST',

            headers: {

                'Content-Type': 'application/json;charset=UTF-8',

                'Accept': 'application/json, text/plain, */*'

            },

            body: JSON.stringify(requestData)

        })

        .then(response => response.json())

        .catch(error => console.error('Error fetching game issue:', error));

    };
  
          const predictedNumber = (number) => {

        if (number >= 0 && number <= 0) return 'RED';

        

        if (number >= 1 && number <= 1) return 'GREEN';

      

        if (number >= 2 && number <= 2) return 'RED';

      

        if (number >= 3 && number <= 3) return 'GREEN';

      

        if (number >= 4 && number <= 4) return 'RED';

      

        if (number >= 5 && number <= 5) return 'GREEN';

      

        if (number >= 6 && number <= 6) return 'RED';

        

        if (number >= 7 && number <= 7) return 'GREEN';

      

        if (number >= 8 && number <= 8) return 'RED';

      

        if (number >= 9 && number <= 9) return 'GREEN';

        return 'Unknown';

    };

    const categorizeNumber = (number) => {




      
        if (number >= 0 && number <= 0) return 'GREEN & VIOLET';

        

        if (number >= 1 && number <= 1) return 'GREEN';

      

        if (number >= 2 && number <= 2) return 'RED';

      

        if (number >= 3 && number <= 3) return 'RED';

      

        if (number >= 4 && number <= 4) return 'GREEN';

      

        if (number >= 5 && number <= 5) return 'GREEN & VIOLET';

      

        if (number >= 6 && number <= 6) return 'RED';

        

        if (number >= 7 && number <= 7) return 'RED';

      

        if (number >= 8 && number <= 8) return 'GREEN';

      

        if (number >= 9 && number <= 9) return 'GREEN';
        
    };

    const generateRandomPrediction = () => {

        const randomNumber = Math.floor(Math.random() * 10);

        const randomCategory = categorizeNumber(randomNumber);

        return { number: randomNumber, category: randomCategory };

    };

    const updateDataAndPrediction = () => {

        fetchNoAverageEmerdList()

            .then(data => {

                const list = data.data.list;

                tableBody.innerHTML = '';

                list.forEach(item => {

                    const numberCategory = categorizeNumber(Number(item.number));

                    const row = document.createElement('tr');

                    row.innerHTML = `

                        <td>${item.issueNumber}</td>

                        <td>${item.number} (${numberCategory})</td>

                        <td>${item.colour}</td>

                        <td>${item.premium}</td>

                    `;

                    tableBody.appendChild(row);

                });

                const latestIssue = list[0].issueNumber;

                const latestActual = Number(list[0].number);

                const actualCategory = predictedNumber(latestActual);

                if (!lastPrediction || lastPrediction.issueNumber !== latestIssue) {

                    if (lastPrediction) {

                        const result = (lastPrediction.category === actualCategory) ? 'Win' : 'Loss';

                        predictionHistory.unshift({

                            issueNumber: latestIssue,

                            predictedNumber: lastPrediction.number,

                            actualNumber: latestActual,

                            result: result

                        });

                        localStorage.setItem('predictionHistory', JSON.stringify(predictionHistory));

                    }

                    currentPrediction = generateRandomPrediction();

                    currentPrediction.issueNumber = latestIssue;

                    localStorage.setItem('currentPrediction', JSON.stringify(currentPrediction));

                }

                predictedNumberElement.textContent = `Prediction: ${currentPrediction.number} (${currentPrediction.category})`;

                predictedPremiumElement.textContent = `:`;

                lastPrediction = {

                    issueNumber: latestIssue,

                    number: currentPrediction.number,

                    category: currentPrediction.category

                };

                localStorage.setItem('lastPrediction', JSON.stringify(lastPrediction));

                updatePredictionHistoryTable();

            })

            .catch(error => console.error('Error updating data and prediction:', error));

    };

    const updatePredictionHistoryTable = () => {

        historyTableBody.innerHTML = '';

        const start = currentPage * itemsPerPage;

        const end = start + itemsPerPage;

        const paginatedHistory = predictionHistory.slice(start, end);

        paginatedHistory.forEach(entry => {

            const row = document.createElement('tr');

            row.innerHTML = `

                <td>${entry.issueNumber}</td>

                <td>${entry.predictedNumber}</td>

                <td>${entry.actualNumber}</td>

                <td>${entry.result}</td>

            `;

            historyTableBody.appendChild(row);

        });

        prevPageButton.disabled = currentPage === 0;

        nextPageButton.disabled = end >= predictionHistory.length;

    };

    const updateTimer = () => {

        fetchGameIssue()

            .then(data => {

                const { endTime } = data.data;

                const endDate = new Date(endTime);

                const now = new Date();

                const remainingTimeMs = endDate - now;

                if (remainingTimeMs <= 0) {

                    timerElement.textContent = "Time Remaining: 00:00:00";

                    clearInterval(timerInterval);

                    updateDataAndPrediction();

                    updateTimer();

                } else {

                    const hours = String(Math.floor(remainingTimeMs / (1000 * 60 * 60))).padStart(2, '0');

                    const minutes = String(Math.floor((remainingTimeMs % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0');

                    const seconds = String(Math.floor((remainingTimeMs % (1000 * 60)) / 1000)).padStart(2, '0');

                    timerElement.textContent = `Time Remaining: ${hours}:${minutes}:${seconds}`;

                }

            })

            .catch(error => console.error('Error fetching game issue for timer:', error));

    };

    // Pagination controls

    prevPageButton.addEventListener('click', () => {

        if (currentPage > 0) {

            currentPage--;

            updatePredictionHistoryTable();

        }

    });

    nextPageButton.addEventListener('click', () => {

        if ((currentPage + 1) * itemsPerPage < predictionHistory.length) {

            currentPage++;

            updatePredictionHistoryTable();

        }

    });

    // Initialize data and start the timer

    updateDataAndPrediction();

    updateTimer();

    timerInterval = setInterval(() => {

        updateTimer();

        updateDataAndPrediction();

    }, 1000); // Update every 10 seconds

    // Load initial prediction history table

    updatePredictionHistoryTable();

});

</script>

    <!-- Firebase Integration and Login Handling -->

    <script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-database.js"></script>

    <script>
        // Firebase configuration (replace with your Firebase project config)
        const firebaseConfig = {
            apiKey: "AIzaSyBL1KlVtPLoGgkhsH1QnkrEkV_s9x7-Mws",
            authDomain: "colortraderpro-panel.firebaseapp.com",
            databaseURL: "https://colortraderpro-panel-default-rtdb.firebaseio.com",
            projectId: "colortraderpro-panel",
            storageBucket: "colortraderpro-panel.firebasestorage.app",
            messagingSenderId: "612198052901",
            appId: "1:612198052901:android:26b24e8056ca9f26953bcc"
        };

        // Initialize Firebase
        const app = firebase.initializeApp(firebaseConfig);
        const database = firebase.database();

        // Handle form submission
        document.getElementById('login-form').addEventListener('submit', function(event) {
            event.preventDefault();

            const email = document.getElementById('email').value;
            const password = document.getElementById('password').value;

            // Check if email and password exist in the Firebase Realtime Database
            const usersRef = database.ref('users');  // Assuming 'users' node in Realtime Database
            usersRef.orderByChild('email').equalTo(email).once('value')
                .then(snapshot => {
                    if (snapshot.exists()) {
                        const user = snapshot.val();
                        let validPassword = false;

                        // Loop through users to check password
                        for (const userId in user) {
                            if (user[userId].password === password) {
                                validPassword = true;
                                break;
                            }
                        }

                        if (validPassword) {
                            document.getElementById('success-message').innerText = 'Login successful!';
        document.getElementById('login-form').style.display = 'none';
        document.getElementById('mainContent').style.display = 'block';
                        }
                    } else {
                        document.getElementById('error-message').innerText = 'No user found with this email';
                    }
                })
                .catch(error => {
                    document.getElementById('error-message').innerText = 'Error: ' + error.message;
                });
        });
    </script>


</div></body></html>