<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>FREE BY SATYAM {RAJ MODS}</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      text-align: center;
      background-image: url('bg.png'); /* Added background image */
      background-size: cover;
      background-position: center;
      color: #333;
      padding: 20px;
      position: relative;
    }

    h1 {
      color: #000;
      text-shadow: 3px 3px 9px rgba(0, 0, 0, 3.0);
      font-size: 2.0rem;
      background: linear-gradient(45deg, red, pink);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
   
    .circle-image {
      width: 120px;
      height: 120px;
      border-radius: 50%;
      margin-top: 30px;
      border: 5px solid #fff;
      box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    }

    .container {
      margin-top: 50px;
      background-image: url('bg.png'); /* Added background image */
      background-size: cover;
      background-position: center;
      padding: 40px;
      border-radius: 10px;
      box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.3);
      color: white;
    }

    .big, .small {
      font-size: 2.5rem;
      font-weight: bold;
      text-shadow: 3px 3px 20px rgba(0, 0, 0, 0.8);
      display: inline-block;
      padding: 10px;
      border-radius: 8px;
      background: linear-gradient(45deg, red, violet);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    .big {
      font-size: 3rem;
    }

    .red-violet {
      color: red;
      background: linear-gradient(45deg, red, violet);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    .green-violet {
      color: green;
      background: linear-gradient(45deg, green, violet);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    button {
      margin-top: 20px;
      padding: 10px 20px;
      font-size: 1rem;
      background-color: #333;
      color: #fff;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
    }

    button:hover {
      background-color: #555;
    }

    #textView2, #textView1 {
      margin-top: 30px;
      font-size: 1.5rem;
      font-weight: bold;
      color: #000;
      text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
      background: linear-gradient(45deg, orange, blue);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      padding: 10px;
      border-radius: 8px;
      background-color: blue; /* Added blue background */
      color: white; /* Change text color to white for better contrast */
    }

    #error {
      margin-top: 20px;
      font-size: 1.2rem;
      color: red;
      font-weight: bold;
    }

    /* Login Popup Styles */
    #loginPopup {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.5); 
      display: flex;
      justify-content: center;
      align-items: center;
      visibility: visible;
    }

    .loginForm {
      background-color: white;
      padding: 20px;
      border-radius: 8px;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
      width: 300px;
      text-align: center;
    }

    .loginForm input {
      margin-bottom: 10px;
      padding: 8px;
      width: 100%;
      border: 1px solid #ccc;
      border-radius: 5px;
    }

    .loginForm button {
      width: 100%;
    }

    /* Telegram Popup Styles */
    #telegramPopup {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.5); 
      display: none;
      justify-content: center;
      align-items: center;
      visibility: visible;
    }

    .telegramForm {
      background-color: white;
      padding: 20px;
      border-radius: 8px;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
      width: 300px;
      text-align: center;
    }

    .telegramForm button {
      margin-top: 10px;
      background-color: #33cc33;
      color: white;
      border: none;
      padding: 10px;
      font-size: 1.2rem;
      border-radius: 5px;
      cursor: pointer;
    }

    .telegramForm button:hover {
      background-color: #2a9c2a;
    }
  </style>
</head>
<body>
  <!-- Circle Image at the top center -->
  <div style="text-align: center; margin-top: 20px;">
    <img src="logo.png" alt="Profile Image" class="circle-image">
  </div>

  <!-- Login Popup -->
  <div id="loginPopup">
    <div class="loginForm">
      <h2 style="background: linear-gradient(45deg, blue, green); -webkit-background-clip: text; -webkit-text-fill-color: transparent;">Login</h2>
      <input type="text" id="username" placeholder="Username" required><br>
      <input type="password" id="password" placeholder="Password" required><br>
      <button onclick="login()">Login</button>
      <div id="loginError" style="color: red; font-weight: bold;"></div>
    </div>
  </div>

  <!-- Telegram Channel Popup -->
  <div id="telegramPopup">
    <div class="telegramForm">
      <h2 style="background: linear-gradient(45deg, purple, pink); -webkit-background-clip: text; -webkit-text-fill-color: transparent;">HEY USER FIRST JOIN TELEGRAM CHANNEL FOR START HACK ☯️</h2>
      <button onclick="joinTelegram()">JOIN TELEGRAM</button>
    </div>
  </div>

  <!-- Main content, hidden initially -->
  <div id="mainContent" style="display: none;">
    <h1>DEVELOPERS :- SATYAM & RAJ</h1>

    <div id="textView2">Period Number: Loading...</div>
    <div id="textView1">Result: Loading.....</div>

    <div class="container">
      <button onclick="calculatePeriodAndResult()">SHOW RESULTS</button>
      <div id="error"></div>
    </div>
  </div>

  <script>
    const validUsername = "SATYAM";
    const validPassword = "RAJ";
    
    let resultShown = false;
    let currentPeriod = "";
    let clickCount = 0;
    let hasJoinedTelegram = false;

    // Function to handle login
    function login() {
      const username = document.getElementById("username").value;
      const password = document.getElementById("password").value;

      if (username === validUsername && password === validPassword) {
        document.getElementById("loginPopup").style.display = "none"; // Hide the login popup
        document.getElementById("mainContent").style.display = "block"; // Show the main content
      } else {
        document.getElementById("loginError").innerText = "Invalid username or password!";
      }
    }

    function calculatePeriodAndResult() {
      if (!hasJoinedTelegram) {
        document.getElementById("telegramPopup").style.display = "flex"; // Show Telegram popup
        return; // Don't proceed further until Telegram button is clicked
      }

      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;

      // Check if the period has changed
      if (currentPeriod !== periodNumber) {
        currentPeriod = periodNumber;
        resultShown = false; // Reset result flag when period changes
        clickCount = 0; // Reset click count
        document.getElementById("textView2").innerText = `Period Number: ${periodNumber}`;
        document.getElementById("textView1").innerText = "Result: Loading....."; // Reset result display
        document.getElementById("error").innerText = ""; // Clear any error message
      }

      if (clickCount >= 5) {
        document.getElementById("error").innerText = "WAIT FOR NEXT PERIOD";
        setTimeout(() => {
          document.getElementById("error").innerText = ""; // Clear error message after 5 seconds
        }, 5000);
      } else {
        // Calculate digit sum for period calculation
        let digitSum = 0;
        for (let digitChar of String(periodCalculation)) {
          digitSum += parseInt(digitChar, 10);
        }

        // Calculate result based on digit sum
        const resultNumber = (digitSum * 7) % 10;
        const result = (resultNumber >= 1 && resultNumber <= 4) ? "SMALL" : "BIG";

        document.getElementById("textView1").innerText = `Result: ${result}`;
        clickCount++; // Increment click count

        if (clickCount >= 4) {
          document.getElementById("error").innerText = "RUK JA BC THODI DER";
          setTimeout(() => {
            document.getElementById("error").innerText = ""; // Clear after a short delay
          }, 2000); // Delay for 2 seconds before clearing the message
        }
      }
    }

    function joinTelegram() {
      window.open("https://t.me/+sYJbtbNqjio2MDQ1", "_blank");
      hasJoinedTelegram = true; // Mark as joined and close the popup
      document.getElementById("telegramPopup").style.display = "none"; // Hide the Telegram pop-up
    }
  </script>
</body>
</html>