<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  <link rel="shortcut icon" href="https://i.postimg.cc/mZJxWkK0/1736248575292.jpg" />
  <title>Fancode Web</title>
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Montserrat:wght@400;700&display=swap">
  <style>
    body {
      font-family: 'Roboto', sans-serif;
      margin: 0;
      padding: 20px;
      background-color: #000;
      color: #fff;
    }
    h1 {
      text-align: center;
      color: #FFD700;
      margin-bottom: 20px;
      font-family: 'Montserrat', sans-serif;
    }
    .file-container {
      display: flex;
      flex-wrap: wrap;
      gap: 20px;
      justify-content: center;
    }
    .match-item {
      margin: 10px;
      text-align: center;
      border-radius: 8px;
      overflow: hidden;
      background-color: #1a1a1a;
      padding: 20px;
      width: calc(25% - 20px);
      box-sizing: border-box;
      transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    .match-item img {
      max-width: 100%;
      height: auto;
      margin: 0 auto 10px auto;
    }
    .match-item h3, .match-item p {
      font-family: 'Montserrat', sans-serif;
      margin: 0;
      text-transform: uppercase;
    }
    .match-item h3 {
      font-weight: 700;
      margin-bottom: 10px;
    }
    .match-item p {
      font-weight: 400;
      margin-bottom: 10px;
    }
    .status-live {
      color: yellow;
    }
    .status-upcoming {
      color: #FF5733;
    }
    .telegram-toggle {
      background-color: #EE4B2B;
      color: white;
      padding: 10px 15px;
      border-radius: 50px;
      text-decoration: none;
      font-weight: bold;
      display: block;
      margin: 20px auto;
      text-align: center;
      width: fit-content;
    }
    .stream-button {
      padding: 10px 15px;
      margin: 5px;
      border: none;
      border-radius: 5px;
      font-weight: bold;
      cursor: pointer;
      color: white;
    }
    .normal-button {
      background-color: #007bff;
    }
    .normal-button:hover {
      background-color: #0056b3;
    }
    .adfree-button {
      background-color: #28a745;
    }
    .adfree-button:hover {
      background-color: #218838;
    }
    @media (max-width: 768px) {
      .match-item {
        width: calc(50% - 20px);
      }
    }
    @media (max-width: 480px) {
      .match-item {
        width: calc(100% - 20px);
      }
    }
  </style>
</head>
<body>
  <h1>Fancode WEB</h1>
  <a href="https://t.me/CRICSPORTCENTRAL" class="telegram-toggle">Join Telegram</a>
  <div class="file-container" id="matches"></div>

  <script>
    if (confirm("Join Our Telegram Channel @CRICSPORTCENTRAL")) {
      window.location.href = "https://t.me/CRICSPORTCENTRAL";
    }

    fetch("https://raw.githubusercontent.com/drmlive/fancode-live-events/main/fancode.json")
      .then(response => response.json())
      .then(data => {
        const container = document.getElementById("matches");

        data.matches.forEach(match => {
          const matchDiv = document.createElement("div");
          matchDiv.className = "match-item";

          const statusClass = match.status.toLowerCase() === "live" ? "status-live" : "status-upcoming";

          let buttonsHTML = "";
          if (match.status.toLowerCase() === "live") {
            buttonsHTML = `
              <button class="stream-button normal-button" onclick="window.location.href='https://shz.al/~sportscentral/Player.html?url=${encodeURIComponent(match.dai_url)}'">Normal</button>
              <button class="stream-button adfree-button" onclick="window.location.href='https://shz.al/~sportscentral/Player.html?url=${encodeURIComponent(match.adfree_url)}'">Ad-Free</button>
            `;
          }

          matchDiv.innerHTML = `
            <img src="${match.src}" alt="${match.title}">
            <h3>${match.event_name}</h3>
            <p>${match.team_1} vs ${match.team_2}</p>
            <p class="${statusClass}">${match.status}</p>
            <div>${buttonsHTML}</div>
          `;

          container.appendChild(matchDiv);
        });
      })
      .catch(error => {
        console.error("Error fetching match data:", error);
      });
  </script>
</body>
</html>