<div class="home-button">
  <a href="index.php">Ana Sayfa</a>
</div>
<div class="transparent-frame"></div>
<div class="background-scene"></div>
<div class="logo-container">
  <img src="upload/games/logo_bonus.png" alt="Bonus Logo" class="bonus-logo" />
</div>
<div class="jackpot-banner" id="jackpot-banner">
  <button class="jackpot-button" id="jackpot-button">100X Jackpot şansını kaçırma! Hemen Bonus veya Mayın Tarlası al!</button>
</div>

<div class="status-container">
  <div class="status-item">
    <div class="status-item-title">Cüzdan</div>
    <div class="status-item-value" id="wallet-display">0</div>
  </div>
  <div class="status-item">
    <div class="status-item-title">Bilet</div>
    <div class="status-item-value" id="tiket-display">0</div>
  </div>
  <div class="status-item">
    <div class="status-item-title">Mayın Tarlası</div>
    <div class="status-item-value" id="scratch-card-display">0</div>
  </div>
  <div class="status-item">
    <div class="status-item-title">Bonus</div>
    <div class="status-item-value" id="bonus-display">0</div>
  </div>
</div>

  <!-- Hediye Paketleri -->
  <div id="app"></div>

  <!-- Ödül Mesajı -->
  
<!-- Bonus Satın Alma Modal Penceresi -->
<div id="bonus-purchase-modal" class="bonus-modal hidden">
  <div class="modal-content">
    <p>Bonus satın almak için bir yöntem seçin:</p>

    <!-- Slider ve Değer -->
    <div class="slider-container">
      <input
        id="quantity-slider"
        type="range"
        min="1"
        max="100"
        step="1"
        value="1"
        class="slider"
      />
      <p>Seçilen Miktar: <span id="slider-value">1</span></p>
    </div>

    <!-- Satın Alma Butonları -->
    <div class="purchase-options">
      <button id="buy-with-ticket" class="purchase-button">1 Bilet = 10 Bonus</button>
      <button id="buy-with-money" class="purchase-button">1 TL = 1 Bonus</button>
      <button id="buy-with-bonus-minefield" class="purchase-button">5 Bonus = 1 Mayın Tarlası</button>
      <button id="buy-with-money-minefield" class="purchase-button">5 TL = 1 Mayın Tarlası</button>
    </div>

    <button id="close-modal" class="close-button">Kapat</button>
  </div>
</div>

<div id="minefield-info" class="hidden">
  <div class="info-item">
    <span>Toplam Kazanç:</span>
    <span id="total-earnings">0 TL</span>
  </div>
  <div class="info-item">
    <span>Çarpan:</span>
    <span id="current-multiplier">0x</span>
  </div>
<div class="info-item">
  <span>Kalan Adım:</span>
  <span id="separate-remaining-attempts">0</span>
</div>
</div>
<div id="reward-container" class="reward-message hidden"></div>
<div id="centered-text">3 kutudan 1'i boş yada Mayın!</div>
<div id="auto-open-container">
  <button id="auto-open-button">Otomatik Kutu Aç</button>
</div>

<script>
document.addEventListener("DOMContentLoaded", function () {
  const app = document.getElementById("app");
  const bonusDisplay = document.getElementById("bonus-display");
  const walletDisplay = document.getElementById("wallet-display");
  const tiketDisplay = document.getElementById("tiket-display");
  const scratchCardDisplay = document.getElementById("scratch-card-display");
  const bonusPurchaseModal = document.getElementById("bonus-purchase-modal");
  const closeModalButton = document.getElementById("close-modal");
  const buyWithTicketButton = document.getElementById("buy-with-ticket");
  const buyWithMoneyButton = document.getElementById("buy-with-money");

  document.addEventListener("DOMContentLoaded", function () {
  // .transparent-frame elementini oluştur ve DOM'a ekle
  const transparentFrame = document.createElement("div");
  transparentFrame.className = "transparent-frame";
  document.body.appendChild(transparentFrame);
});
document.getElementById("jackpot-button").addEventListener("click", openModal);
 // URL'den user_id'yi almak için yardımcı fonksiyon
 function getUserIdFromUrl() {
    const urlParams = new URLSearchParams(window.location.search);
    return urlParams.get("user_id"); // URL'den user_id parametresini al
  }

  const userId = getUserIdFromUrl(); // URL'deki user_id değerini al

  if (!userId) {
    alert("Kullanıcı ID bulunamadı! URL'de 'user_id' parametresi eksik.");
    return; // Eğer user_id yoksa işlemleri durdur
  }
  // Modal açma/kapatma fonksiyonları
  function openModal() {
    bonusPurchaseModal.classList.remove("hidden");
  }

  function closeModal() {
    bonusPurchaseModal.classList.add("hidden");
  }

  closeModalButton.addEventListener("click", closeModal);

// Bonus bilgisini güncelleyen fonksiyon
async function updateBonus() {
    try {
        const response = await fetch(`gift_bonus.php?user_id=${userId}`);
        const data = await response.json();
        if (data.success) {
            bonusDisplay.textContent = ` ${data.bonus}`;
            walletDisplay.textContent = ` ${data.wallet}`;
            tiketDisplay.textContent = ` ${data.tiket}`;
            scratchCardDisplay.textContent = ` ${data.mayin_tarlasi}`; // Mayın tarlası bilgisi gösteriliyor

            // Bonus ve mayın tarlası sıfırsa modal aç
            if (parseInt(data.bonus) === 0 && parseInt(data.mayin_tarlasi) === 0) {
                openModal();
            }
        } else {
            bonusDisplay.textContent = "Bonus bilgisi alınamadı.";
            walletDisplay.textContent = "Cüzdan bilgisi alınamadı.";
            tiketDisplay.textContent = "Tiket bilgisi alınamadı.";
            scratchCardDisplay.textContent = "Mayın Tarlası bilgisi alınamadı.";
        }
    } catch (error) {
        console.error("Bonus bilgisi alınamadı:", error);
        bonusDisplay.textContent = "Bonus bilgisi alınamadı.";
        walletDisplay.textContent = "Cüzdan bilgisi alınamadı.";
        tiketDisplay.textContent = "Tiket bilgisi alınamadı.";
        scratchCardDisplay.textContent = "Mayın Tarlası bilgisi alınamadı.";
    }
}


  // Mesaj göstermek için genel bir fonksiyon
function showSiteMessage(message, type = "success") {
  const messageContainer = document.createElement("div");
  messageContainer.className = `site-message ${type}`;
  messageContainer.textContent = message;

  // Mesajı body'ye ekleyin
  document.body.appendChild(messageContainer);

  // 3 saniye sonra mesajı kaldır
  setTimeout(() => {
    messageContainer.remove();
  }, 3000);
}


// Bonus satın alma fonksiyonu
async function purchaseBonus(method, quantity) {
  try {
    const response = await fetch("purchase_bonus.php", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        user_id: userId, // Kullanıcı ID'si (global bir değişken olmalı)
        method: method, // Satın alma yöntemi (ör. ticket, money)
        quantity: quantity, // Satın alınacak miktar
      }),
    });

    const data = await response.json();
    if (data.success) {
      showSiteMessage(`${quantity} adet başarıyla satın alındı!`, "success");
      await updateBonus(); // Bonus bilgilerini güncelleme
    } else {
      showSiteMessage(data.message || "Satın alma işlemi başarısız.", "error");
    }
  } catch (error) {
    console.error("Satın alma işlemi sırasında hata:", error);
    showSiteMessage("Bir hata oluştu. Lütfen tekrar deneyin.", "error");
  }
}

// Kaydırma çubuğu olayları
const slider = document.getElementById("quantity-slider");
const sliderValueDisplay = document.getElementById("slider-value");
slider.addEventListener("input", () => {
  sliderValueDisplay.textContent = slider.value; // Slider değeri güncellenir
});

// Satın alma butonlarına tıklama olayları
document.getElementById("buy-with-ticket").addEventListener("click", function () {
  const quantity = parseInt(slider.value, 10); // Slider değerini al
  purchaseBonus("ticket", quantity);
});

document.getElementById("buy-with-money").addEventListener("click", function () {
  const quantity = parseInt(slider.value, 10); // Slider değerini al
  purchaseBonus("money", quantity);
});

document.getElementById("buy-with-bonus-minefield").addEventListener("click", function () {
  const quantity = parseInt(slider.value, 10); // Slider değerini al
  purchaseBonus("bonus_minefield", quantity);
});

document.getElementById("buy-with-money-minefield").addEventListener("click", function () {
  const quantity = parseInt(slider.value, 10); // Slider değerini al
  purchaseBonus("money_minefield", quantity);
});

// Modal Kapatma Fonksiyonu
document.getElementById("close-modal").addEventListener("click", function () {
  document.getElementById("bonus-purchase-modal").classList.add("hidden");
});



function showRewardMessage(data) {
  const appContainer = document.body; // Mesajları gövdeye ekleyeceğiz

  let message = "";
  let soundFile = ""; // Çalınacak ses dosyasının yolu
  let containerClass = "success"; // Varsayılan yeşil tasarım
  let displayDuration = 4000; // Varsayılan görünme süresi
  let countSpeed = 2000; // Sayı artışı için varsayılan süre
  let stepAmount = 1; // Sayı artışı için varsayılan adım

  // Kazanç türüne göre mesajlar ve tasarımlar
  if (data.gift_classification) {
    switch (data.gift_classification) {
      case 1:
        message = `<span class="earned-units">0</span> bonus kazandınız!`;
        soundFile = "upload/games/bonus/win.mp3";
        break;
      case 2:
        message = `<span class="earned-units">0</span> bilet kazandınız!`;
        soundFile = "upload/games/bonus/win.mp3";
        break;
      case 3:
        message = `<span class="earned-units">0</span> TL kazandınız!`;
        soundFile = "upload/games/bonus/cash_bonus.mp3";
        break;
      case 4:
        message = `<span class="earned-units">0</span> Kazı Kazan kazandınız!`;
        soundFile = "upload/games/bonus/win.mp3";
        break;
      case 5:
        message = `Mayın Tarlası! Kazanılan: <span class="earned-units">0</span> TL`;
        soundFile = "upload/games/bonus/minefield_progress.mp3";
        containerClass = "minefield";
        countSpeed = 3000; // 3 saniyede artışı tamamlayacak süre
        break;
      case 6:
        message = `Mayın Tarlası geçildi. Kazanılan: <span class="earned-units">0</span> TL`;
        soundFile = "upload/games/bonus/bwin.mp3";
        containerClass = "minefield";
        break;
      case 7:
        message = `Patladın!`;
        soundFile = "upload/games/bonus/explosion.mp3";
        containerClass = "fail";
        break;
      case 9:
        message = "Boş kutu!";
        soundFile = "upload/games/bonus/empty.mp3";
        containerClass = "fail";
        break;
      case 10:
        message = `JACKPOT! Kazandınız! Çarpanınız x<span class="earned-units">0</span>`;
        soundFile = "upload/games/bonus/jackpot.mp3"; // Jackpot için özel ses
        containerClass = "jackpot"; // Jackpot tasarımı
        displayDuration = 6000; // Jackpot için özel süre (10 saniye)
        countSpeed = 2000; // Jackpot için daha hızlı süre
        stepAmount = 10; // Jackpot için 10'luk artış
        break;
      default:
        message = "Bilinmeyen ödül!";
        soundFile = "";
        break;
    }
  }

  if (!message) return; // Mesaj boş ise devam etmiyoruz

  // Yeni bir mesaj kutusu oluştur
  const rewardContainer = document.createElement("div");
  rewardContainer.className = `reward-message ${containerClass}`;
  rewardContainer.innerHTML = message; // HTML içeriği ekliyoruz

  // Mesajı gövdeye ekle
  appContainer.appendChild(rewardContainer);

  // Dinamik sayı artışı efekti (Sadece "earned-units" olan durumlar için)
  const earnedUnitsElement = rewardContainer.querySelector(".earned-units");
  if (earnedUnitsElement && data.earned_units > 0) {
    // Hedef sayıyı ve artış hızını hesapla
    const duration = 3000; // Artışın tamamlanacağı toplam süre (3 saniye)
    const start = 0; // Başlangıç değeri
    const end = data.earned_units; // Gelen hedef değer
    const steps = 60; // 60 FPS'e uygun adım sayısı
    const stepTime = duration / steps; // Her adımın süresi
    const increment = Math.ceil(end / steps); // Her adımda artış miktarı
    let current = start;

    const timer = setInterval(() => {
      current += increment; // Mevcut değeri artır
      if (current >= end) {
        current = end; // Hedefe ulaşıldığında sabitle
        clearInterval(timer); // Döngüyü durdur
      }
      earnedUnitsElement.textContent = current.toLocaleString("tr-TR"); // Sayıyı güncelle
    }, stepTime);
  }

  // Mesajı görünür yap
  setTimeout(() => {
    rewardContainer.classList.add("show");
  }, 100); // Kısa bir gecikme ile animasyonu tetikleme

  // Ses dosyasını çal
  if (soundFile) {
    const audio = new Audio(soundFile);
    audio.play().catch((error) => console.error("Ses çalma hatası:", error));
  }

  // Mesajı belirli bir süre sonra kaldır
  setTimeout(() => {
    rewardContainer.classList.remove("show");
    setTimeout(() => {
      rewardContainer.remove();
    }, 500); // Kapanış animasyonu süresi
  }, displayDuration); // Özel süreyi uygulama
}
let isAutoOpening = false; // Otomatik açma durumu takip değişkeni
let autoOpenInterval; // Otomatik açma için interval

// Otomatik kutu açma fonksiyonu
async function autoOpenGifts() {
  const gifts = document.querySelectorAll(".gift");
  if (gifts.length === 0 || isCreatingGifts) return; // Eğer kutular yoksa veya yeni kutular oluşturuluyorsa işlem yapma

  for (let i = 0; i < gifts.length; i++) {
    if (!isAutoOpening) break; // Eğer otomatik açma durdurulursa döngüyü kes
    const gift = gifts[i];
    if (!gift.classList.contains("opened")) {
      gift.click(); // Kutuya tıklayarak aç
      await new Promise((resolve) => setTimeout(resolve, 3000)); // Her kutuyu açmak için biraz bekle (2.5 saniye)
    }
  }

  if (isAutoOpening) {
    setTimeout(autoOpenGifts, 1000); // Yeni kutular oluşturulduktan sonra tekrar çalıştır
  }
}

// Butona tıklama işlemi
document.getElementById("auto-open-button").addEventListener("click", function () {
  if (isAutoOpening) {
    // Eğer otomatik açma zaten aktifse durdur
    isAutoOpening = false;
    clearInterval(autoOpenInterval);
    this.innerText = "Otomatik Kutu Aç";
    console.log("Otomatik kutu açma durduruldu.");
  } else {
    // Otomatik açmayı başlat
    isAutoOpening = true;
    this.innerText = "Durdur";
    console.log("Otomatik kutu açma başlatıldı.");
    autoOpenGifts(); // Otomatik açma işlemini başlat
  }
});

// Kutu açıldıktan sonra "opened" sınıfını eklemek için `openGift` fonksiyonuna ekleme
async function openGift(gift, index) {
  try {
    const response = await fetch(`gift_action.php?user_id=${userId}`);
    const data = await response.json();

    if (data.success) {
      gift.classList.remove("dukdik");
      gift.querySelector(".gift-top").classList.add("boxOpen");
      gift.querySelector(".gift-box").classList.add("boxDown");
      gift.classList.add("opened"); // Açılmış kutu işaretlemesi
      // Kalan kodlar aynen devam ediyor...
    }
  } catch (error) {
    console.error("Hediye açma hatası:", error);
  }
}



let isMinefieldActive = false; // Mayın Tarlası durumu takip değişkeni

// Sadece Mayın Tarlası için kullanılacak müzik
const minefieldBackgroundMusic = new Audio('upload/games/bonus/minefield-music.mp3');

// Arka plan müziğini döngüye al
minefieldBackgroundMusic.loop = true;

async function openGift(gift, index) {
  try {
    const response = await fetch(`gift_action.php?user_id=${userId}`);
    const data = await response.json();

    if (data.success) {
      gift.classList.remove("dukdik");
      gift.querySelector(".gift-top").classList.add("boxOpen");
      gift.querySelector(".gift-box").classList.add("boxDown");

      const transparentFrame = document.querySelector(".transparent-frame");

      // Jackpot durumu kontrolü
      if (data.gift === "jackpot") {
        handleJackpot(data); // Jackpot ödülünü işleme al
      }

      // Mayın Tarlası durumu kontrolü
      if (data.mayin_tarlasi) {
        const { toplam, kalan_hak, durum, carpan } = data.mayin_tarlasi;

        if (durum === "başladı") {
          if (!isMinefieldActive) { // Sadece bir kez başlat
            isMinefieldActive = true; // Modu aktif işaretle
            transparentFrame.classList.add("animate"); // Animasyonu başlat
            try {
              minefieldBackgroundMusic.play(); // Müziği başlat
              console.log("Mayın Tarlası müziği çalıyor.");
            } catch (error) {
              console.error("Mayın Tarlası müziği başlatılamadı:", error);
            }
          }
          updateMinefieldInfo(toplam, kalan_hak, carpan); // Bilgileri güncelle
        } else if (durum === "tamamlandı" || durum === "patladı" || durum === "devam ediyor") {
          if (isMinefieldActive) { // Sadece aktif durumda durdurma işlemi yap
            if (durum === "tamamlandı" || durum === "patladı") {
              isMinefieldActive = false; // Modu kapalı işaretle
              transparentFrame.classList.remove("animate"); // Animasyonu durdur
              try {
                minefieldBackgroundMusic.pause(); // Müziği durdur
                minefieldBackgroundMusic.currentTime = 0; // Müziği başa sar
                console.log("Mayın Tarlası müziği durduruldu.");
              } catch (error) {
                console.error("Mayın Tarlası müziği durdurulamadı:", error);
              }
            }
          }

          // Eğer durum tamamlandı veya patladıysa alanı gizle
          if (durum === "tamamlandı" || durum === "patladı") {
            updateMinefieldInfo(); // Parametresiz çağrı alanı gizler
          } else {
            updateMinefieldInfo(toplam, kalan_hak, carpan || 0); // Kazançları güncelle
          }
        }
      }

      // Tüm veriyi showRewardMessage'e gönderiyoruz
      showRewardMessage(data);

      // Bonusları ve diğer bilgileri güncelle
      await updateBonus();

      // Yeni kutuları yeniden oluştur
      setTimeout(createGifts, 2000);
    } else {
      // Hata durumunda işlem
      if (data.message === "Yeterli bonus ve mayın tarlası hakkı kalmadı. Lütfen bonus veya mayın tarlası satın alın.") {
        openModal();
      } else {
        console.error(data.message || "Hediye açma işlemi başarısız.");
      }
    }
  } catch (error) {
    console.error("Hediye açma hatası:", error);
  }
}

function handleJackpot(data) {
  const jackpotContainerId = "jackpot-container"; // Jackpot için özel bir div ID'si
  let jackpotContainer = document.getElementById(jackpotContainerId);

  // Eğer div mevcut değilse oluştur
  if (!jackpotContainer) {
    jackpotContainer = document.createElement("div");
    jackpotContainer.id = jackpotContainerId;
    jackpotContainer.className = "jackpot-wrapper"; // Özel bir stil için sınıf
    document.body.appendChild(jackpotContainer);
  }

  // Jackpot mesajını güncelle
  jackpotContainer.innerHTML = `
    
   
 
    <div
      class="coin coin--animated"
      style="--coin-to-x: calc(-100px + 24px); --coin-to-y: calc(-105px + 24px); --coin-delay: 0.3s;"
    ></div>
    <div
      class="coin coin--animated"
      style="--coin-to-x: calc(-70px + 24px); --coin-to-y: -90px; --coin-delay: 0.1s;"
    ></div>
    <div
      class="coin coin--animated"
      style="--coin-to-x: calc(-30px + 24px); --coin-to-y: -125px; --coin-delay: 0s;"
    ></div>
    <div
      class="coin coin--animated"
      style="--coin-to-x: calc(10px + 24px); --coin-to-y: -130px; --coin-delay: 0.2s;"
    ></div>
    <div
      class="coin coin--animated"
      style="--coin-to-x: calc(30px + 24px); --coin-to-y: -100px; --coin-delay: 0.1s;"
    ></div>
    <div
      class="coin coin--animated"
      style="--coin-to-x: calc(70px + 24px); --coin-to-y: -95px; --coin-delay: 0.4s;"
    ></div>
    <div
      class="coin coin--animated"
      style="--coin-to-x: calc(100px + 24px); --coin-to-y: -100px; --coin-delay: 0.2s;"
    ></div>
  </div>
 <div class="jackpot-message">
      <p>
        <strong>JACKPOT!</strong> 
        <span class="earned-units">${data.carpan}X</span>
      </p>
    </div>
  `;

  // Mesajı görünür yap
  jackpotContainer.classList.remove("hidden");

  // Ses çal
  const audio = new Audio("upload/games/bonus/jackpot.mp3");
  audio.play();
  setTimeout(() => {
  jackpotContainer.classList.add("hidden");
}, 6000);

setTimeout(() => {
  jackpotContainer.classList.add("hidden");
}, 10000);
}

const rewardImages = {
  cash_bonus: "upload/games/bonus/cash-bonus.png",
  tiket: "upload/games/bonus/ticket.png",
  silver_scratch_card: "upload/games/bonus/scratch-card.png",
  bonus: "upload/games/bonus/bonus.png",
  empty: "upload/games/bonus/empty.png",
};

  // Gösterim Alanı
  function updateMinefieldInfo(totalEarnings = null, remainingAttempts = null, multiplier = null) {
  const infoContainer = document.getElementById("minefield-info");
  const totalEarningsElement = document.getElementById("total-earnings");
  const multiplierElement = document.getElementById("current-multiplier");
  const remainingAttemptsElement = document.getElementById("separate-remaining-attempts");

  if (totalEarnings !== null && remainingAttempts !== null && multiplier !== null) {
    // Bilgiler varsa, alanları güncelle ve görünür yap
    totalEarningsElement.textContent = `${totalEarnings} TL`;
    multiplierElement.textContent = `${multiplier}x`;
    remainingAttemptsElement.textContent = remainingAttempts;

    infoContainer.classList.remove("hidden"); // Görünür yap
  } else {
    // Eğer bilgiler eksikse, alanları gizle
    infoContainer.classList.add("hidden"); // Gizle
    remainingAttemptsElement.textContent = "0"; // Kalan hak için varsayılan değer
  }
}




let isCreatingGifts = false; // Kutular oluşturulurken işlem yapılmasını engellemek için

// Hediye kutularını oluştur
function createGifts() {
  if (isCreatingGifts) return; // Eğer zaten kutular oluşturuluyorsa tekrar çalıştırma
  isCreatingGifts = true; // Kutular oluşturuluyor

  const app = document.getElementById("app");
  app.innerHTML = ""; // Mevcut kutuları temizle

  for (let i = 0; i < 3; i++) {
    const gift = document.createElement("div");
    gift.classList.add("gift");

    // Kutunun başlangıç pozisyonu yukarıda başlıyor
    gift.style.left = `calc(50% + ${(i - 1) * 120}px)`; 
    gift.style.top = "-200px"; // Yukarıda başlar
    gift.style.opacity = "0"; // Başlangıçta görünmez
    gift.style.transition = "top 0.5s ease, opacity 0.5s ease"; // Düşme ve görünürlük animasyonu

    const giftTop = document.createElement("div");
    giftTop.classList.add("gift-top");
    gift.appendChild(giftTop);

    const giftBox = document.createElement("div");
    giftBox.classList.add("gift-box");
    gift.appendChild(giftBox);

    let isOpened = false;

    // Kutu tıklama işlemi
    gift.addEventListener("click", async function () {
      if (isOpened || isCreatingGifts) return; // Zaten açıldıysa tekrar işlem yapma
      isOpened = true;

      // Hediye açma işlemi
      await openGift(gift, i);

      // Kutuları yenile
      refreshGifts();
    });

    app.appendChild(gift);

    // Animasyonu başlatmak için gecikme
    setTimeout(() => {
      gift.style.top = "65%"; // Nihai pozisyon
      gift.style.opacity = "1"; // Görünür hale gelir
    }, (i + 1) * 300); // Her kutu için gecikme (ilk kutuya da gecikme eklenir)
  }

  // Kutular tamamen oluşturulduktan sonra işlem yapılabilir hale getirin
  setTimeout(() => {
    isCreatingGifts = false; // Kutular oluşturuldu, işlem yapılabilir
  }, 1200); // Tüm kutuların düşmesi tamamlanana kadar bekleyin
}

// Kutuları yenileme işlemi
function refreshGifts() {
  const gifts = document.querySelectorAll(".gift");

  // Kutuların yukarı doğru kaybolmasını sağlayın
  gifts.forEach((gift, index) => {
    setTimeout(() => {
      gift.style.top = "-200px"; // Yukarı kaydır
      gift.style.opacity = "0"; // Görünmez yap
    }, index * 200);
  });

  // Kaybolma işlemi tamamlandıktan sonra yeni kutular oluştur
  setTimeout(() => {
    isCreatingGifts = false; // Yeni kutuların oluşturulmasına izin ver
    createGifts(); // Kutuları tekrar oluştur
  }, 1000); // Kaybolma süresi kadar bekle
}

// Sayfa yüklenirken bonus bilgisini getir ve kutuları oluştur
updateBonus();
createGifts();

});


</script>
<style>

/* Arka Plan Görseli */
.background-scene {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('upload/games/arka_bonus.png'); /* Arka plan görseli */
  background-size: cover; /* Görseli ekranı kaplayacak şekilde ayarla */
  background-position: center; /* Ortala */
  z-index: -1; /* Diğer her şeyin arkasında */
}

/* Bonus Logo */
.logo-container {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%); /* Tam olarak merkeze alır */
  z-index: 1;
}

.bonus-logo {
  width: 300px;
  height: auto;
  animation: float 3s ease-in-out infinite; /* Hafif yukarı-aşağı animasyonu */
}

/* Logo için Hafif Yukarı-Aşağı Animasyon */
@keyframes float {
  0%, 100% {
    transform: translateY(0); /* Yukarı-aşağı hareket başlangıç ve bitiş */
  }
  50% {
    transform: translateY(-10px); /* Hareket mesafesi */
  }
}


/* #app için Varsayılan Stil Giderme */
#app {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex; /* Kutuların düzgün hizalanması için */
  justify-content: center;
  align-items: center;
  background: transparent; /* Görünmez yap */
  margin: 0;
  padding: 0;
  z-index: 0;
  border: none; /* Varsa çizgiyi kaldırır */
}

/* Mobil Uyumluluk */
@media (max-width: 768px) {
  .bonus-logo {
    width: 250px;
  }
}

@media (max-width: 480px) {
  .bonus-logo {
    width: 200px;
  }
}

.gift {
  position: absolute;
  top: 65%; /* Daha alta taşındı */
  left: 50%;
  width: 100px;
  height: 100px;
  transform-origin: 0% 0%;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: 1s;
}

@media (max-width: 768px) {
  .gift {
    width: 80px; /* Mobilde daha küçük görünmesi için boyut azaltıldı */
    height: 80px;
    top: 70%; /* Daha da alta taşındı */
    border-width: 6px; /* Çerçeve genişliği büyütüldü */
    border-radius: 12px; /* Köşeler daha yuvarlak */
  }
}

@media (max-width: 480px) {
  .gift {
    width: 70px; /* Daha küçük boyut */
    height: 70px;
    top: 75%; /* Daha aşağı */
    border-width: 5px; /* Çerçeve genişliği artırıldı */
    border-radius: 10px; /* Daha yuvarlak köşeler */
  }
}
.dukdik{
  transform-origin: 0% 0%;
  cursor: pointer;
  animation: dukdik 0.5s infinite;
}
@keyframes dukdik {
  0% {
    transform: rotate(0deg) translate(-50%, -50%);
  }
  25%{
    transform: rotate(1deg) translate(-50%, -50%);
  }
  50%{
    transform: rotate(0deg) translate(-50%, -50%);
  }
  70%{
    transform: rotate(-1deg) translate(-50%, -50%);
  }
  100%{
    transform: rotate(0deg) translate(-50%, -50%);
  }
}
.gift-top {
  position: relative;
  width: 110%;
  height: 25%;
  background: #F54537;
  border-radius: 5px 5px 0 0;
  transform: translate3d(-5%, 0, 0);
  background-image: linear-gradient(to right, #F54537 0%, #F54537 44%, #FFC113 44%, #FFC113 56%, #F54537 56%, #F54537 100%);
  transition: 1s;
}
.gift-top.boxOpen{
  animation: box-open 1s;
  opacity:0;
}
@keyframes box-open{
  0%{
    top:0px;
    opacity:1;
  }
  100%{
    top:-50px;
    opacity:0;
  }
}
.gift-top::before,
.gift-top::after {
    content: "";
    width: 15px;
    height: 15px;
    border: 10px solid #FFC113;
    border-radius: 50% 50% 0 50%;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate3d(-100%, -100%, 0) skew(10deg, 10deg);
}

.gift-top::after {
  border-radius: 50% 50% 50% 0;
  transform: translate3d(0, -100%, 0) skew(-10deg, -10deg);
}

.gift-text {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: 0;
  color: #FFFFFF;
  white-space: nowrap;
  transform: translate3d(-50%, -50%, 0) scale(.5);
  transform-origin: center center;
  z-index: -1;
  opacity:1;
  transition: 5s;
}

.gift-box {
  width: 100%;
  height: 75%;
  position: relative;
  background-image: linear-gradient(to right, #D43130 0%, #D43130 45%, #FF900A 45%, #FF900A 55%, #D43130 55%, #D43130 100%);
  border-radius: 0 0 5px 5px;
  transition: 1s;
  box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.5); /* Gölge ekler */
}
.gift-box.boxDown{
  animation: box-down 1s; 
   opacity:0; 
}
@keyframes box-down{
  0%{
    top:0px;
    opacity:1;
  }
  100%{
    top:50px;
    opacity:0;
  }  
}

/* Ortak Tasarım */
#reward-container {
  position: fixed;
  top: 50%; /* Orta noktaya biraz daha yakın */
  left: 50%;
  transform: translate(-50%, -50%); /* Tam ortalama */
  font-size: 1.4rem; /* Orta boyut */
  font-weight: bold;
  padding: 18px 35px; /* Orta boyutlu alan */
  border-radius: 15px; /* Yuvarlak kenarlar */
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.8); /* Daha dengeli gölge */
  z-index: 9999;
  text-align: center;
  display: none; /* Varsayılan olarak gizli */
  transition: opacity 0.5s ease, transform 0.5s ease, background-color 0.5s ease;
  background: linear-gradient(145deg, #1a1a1a, #2d2d2d); /* Koyu degrade arka plan */
  color: #ffffff; /* Beyaz yazı */
}

/* Özel Stil: Kazanç Miktarını Vurgulama */
.reward-message .earned-units {
  font-size: 2.2rem; /* Orta büyüklükte yazı */
  font-weight: bold; /* Kalın yazı */
  color: #ffd700; /* Altın sarısı renk */
  text-shadow: 0 4px 8px rgba(255, 223, 0, 0.8); /* Parlak gölge */
  display: inline-block;
  margin: 0 5px;
  animation: quick-flash 1s infinite; /* Hızlı parlama animasyonu */
}

/* Ortak Mesaj Tasarımı */
.reward-message {
  position: fixed;
  top: 45%; /* Orta noktaya biraz daha yakın */
  left: 50%;
  transform: translate(-50%, -50%); /* Tam ortalama */
  font-size: 1.4rem;
  font-weight: bold;
  padding: 22px 45px;
  border-radius: 15px;
  box-shadow: 0 9px 28px rgba(0, 0, 0, 0.9); /* Hafif daha derin gölge */
  z-index: 9999;
  text-align: center;
  opacity: 0; /* Başlangıçta görünmez */
  display: block;
  transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
}

/* Jackpot Mesajı */
.reward-message.jackpot {
  position: fixed; /* Sayfanın ortasında sabit */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); /* Tam ortalama */
  background: linear-gradient(145deg, #37474f, #222222); /* Koyu gri degrade */
  color: #ffeb3b; /* Sarı yazı */
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.8); /* Hafif gölge */
  font-size: 2.5rem; /* Ana yazı boyutu */
  font-weight: bold;
  text-align: center; /* Yazıyı ortala */
  padding: 30px 50px; /* İçerik alanı */
  border-radius: 20px; /* Yuvarlak köşeler */
  border: 2px solid #ffeb3b; /* Sarı çerçeve */
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4); /* Hafif çevre gölge */
  animation: flicker 1.2s infinite; /* Hafif titreme efekti */
  z-index: 9999; /* Üstte görünmesi için */
}

/* Jackpot Yazısı Efektleri */
.reward-message.jackpot span {
  display: block;
  font-size: 1.8rem; /* Jackpot yazı boyutu */
  color: #ffeb3b; /* Sarı yazı */
  text-shadow: 
    0 0 10px rgba(255, 235, 59, 0.8), 
    0 0 20px rgba(255, 193, 7, 0.6); /* Neon etkisi */
  animation: jackpot-glow 1.5s infinite alternate, jackpot-move 2s infinite; /* Hafif yanıp sönme ve hareket efekti */
}

/* Kazanılan Sayıya Özel Efektler */
.reward-message.jackpot .earned-units {
  font-size: 4rem; /* Büyük sayı boyutu */
  font-weight: bold;
  color: #ffffff; /* Beyaz renkte belirgin sayı */
  text-shadow: 
    0 0 10px rgba(255, 235, 59, 0.9), 
    0 0 20px rgba(255, 193, 7, 0.7); /* Hafif parlama */
  animation: pulse 1.2s infinite alternate; /* Hafif büyüyüp küçülme efekti */
  margin-top: 10px;
}

/* Hafif Titreme Efekti */
@keyframes flicker {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.9;
  }
}

/* Jackpot Yazısına Parlama Efekti */
@keyframes jackpot-glow {
  0% {
    text-shadow: 
      0 0 5px rgba(255, 235, 59, 0.6), 
      0 0 15px rgba(255, 193, 7, 0.4);
  }
  100% {
    text-shadow: 
      0 0 15px rgba(255, 235, 59, 1), 
      0 0 25px rgba(255, 193, 7, 0.8);
  }
}

/* Jackpot Yazısına Hafif Hareket Efekti */
@keyframes jackpot-move {
  0% {
    transform: translateY(-2px);
  }
  50% {
    transform: translateY(2px);
  }
  100% {
    transform: translateY(-2px);
  }
}

/* Sayıya Özel Büyüme ve Parlama */
@keyframes pulse {
  0% {
    transform: scale(1);
    text-shadow: 
      0 0 10px rgba(255, 235, 59, 0.8), 
      0 0 20px rgba(255, 193, 7, 0.6);
  }
  100% {
    transform: scale(1.1);
    text-shadow: 
      0 0 15px rgba(255, 235, 59, 1), 
      0 0 25px rgba(255, 193, 7, 0.9);
  }
}

/* Başarı */
.reward-message.success {
  background: linear-gradient(145deg, #28a745, #1d8348); /* Canlı yeşil degrade */
  color: #ffffff;
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

/* Başarısızlık */
.reward-message.fail {
  background: linear-gradient(145deg, #ff0000, #b71c1c); /* Canlı kırmızı degrade */
  color: #ffffff;
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
  animation: quick-flash-repeat 0.8s infinite; /* Hızlı tekrar eden parlama efekti */
}

/* Mayın Tarlası */
.reward-message.minefield {
  background: linear-gradient(145deg, #37474f, #222222); /* Koyu gri degrade */
  color: #ffeb3b; /* Sarı yazı */
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.8);
  animation: flicker 1.2s infinite; /* Hafif titreme efekti */
}

/* Görünür hale geldiğinde */
.reward-message.show {
  opacity: 1;
  transform: translate(-50%, -50%);
}

/* Parlama Efekti */
@keyframes quick-flash {
  0%, 100% {
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6), 0 0 20px rgba(255, 215, 0, 0.4);
  }
  50% {
    text-shadow: 0 0 20px rgba(255, 215, 0, 1), 0 0 40px rgba(255, 215, 0, 0.8);
  }
}

/* Başarısızlık İçin Hızlı Tekrarlayan Parlama */
@keyframes quick-flash-repeat {
  0%, 100% {
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5), 0 0 20px rgba(255, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.9), 0 0 40px rgba(255, 0, 0, 0.7);
  }
}


/* Hafif Titreme */
@keyframes flicker {
  0%, 100% {
    box-shadow: 0 0 15px rgba(255, 235, 59, 0.8), 0 0 30px rgba(255, 235, 59, 0.6);
  }
  50% {
    box-shadow: 0 0 8px rgba(255, 235, 59, 0.5), 0 0 15px rgba(255, 235, 59, 0.4);
  }
}

/* Mobil Uyumluluk */
@media (max-width: 768px) {
  .reward-message {
    font-size: 1.1rem;
    padding: 15px 30px;
  }
}

@media (max-width: 480px) {
  .reward-message {
    font-size: 0.9rem;
    padding: 12px 25px;
  }
}


/* Durum Göstergesi Konteyneri */
.status-container {
  position: absolute;
  bottom: 10px; /* Daha aşağı yerleştirildi */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  gap: 15px; /* Çerçeve aralıkları daraltıldı */
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.6), #ffb347);
  padding: 10px 15px; /* Daha az padding */
  border-radius: 12px; /* Daha yuvarlak köşeler */
  box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.5);
  z-index: 10;
  border: 2px solid #fff; /* Çerçeve inceltildi */
}

/* Durum Göstergesi Öğesi */
.status-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 8px; /* Daha az padding */
  border-radius: 8px;
  box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.4);
  width: 90px; /* Daha dar genişlik */
  min-height: 100px;
  justify-content: space-between;
  gap: 5px;
  transition: transform 0.3s ease;
  overflow: hidden; /* Taşmayı önler */
}

/* Hover Efekti */
.status-item:hover {
  transform: scale(1.1);
  box-shadow: 0px 4px 10px rgba(255, 255, 255, 0.7);
}

/* Yazı Alanı */
.status-item-title {
  font-size: clamp(9px, 1.5vw, 11px); /* Dinamik boyutlandırma */
  font-weight: bold;
  text-align: center;
  color: #fff;
  line-height: 1.2;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 4px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  overflow: hidden; /* Taşmayı önler */
  text-overflow: ellipsis; /* Taşan metinler için üç nokta koyar */
  white-space: nowrap; /* Satır taşmasını engeller */
}

/* Yazı küçültme: Çok fazla içerik varsa dinamik şekilde küçültme */
.status-item-title {
  font-size: min(max(9px, 1.5vw), 11px); /* Boyut min 9px, max 11px arasında */
  overflow-wrap: break-word; /* Uzun kelimeler bölünür */
  word-break: break-word; /* Taşma durumunda kelimeleri böler */
}


/* Sayı Alanı */
.status-item-value {
  font-size: clamp(18px, 3vw, 22px); /* Dinamik boyutlandırma */
  font-weight: 900;
  color: #ffe600;
  background: rgba(0, 0, 0, 0.85);
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  text-align: center;
  width: 100%;
  box-shadow: inset 0px 0px 8px rgba(255, 255, 255, 0.3);
  overflow: hidden; /* Taşmayı önler */
  text-overflow: clip; /* Üç nokta koymaz */
  white-space: nowrap; /* Satır taşmasını engeller */
}

/* Mobil Uyumluluk */
@media (max-width: 768px) {
  .status-container {
    gap: 10px;
    padding: 8px 10px;
  }

  .status-item {
    width: 80px;
    min-height: 90px;
  }

  .status-item-title {
    font-size: clamp(8px, 1.2vw, 10px);
  }

  .status-item-value {
    font-size: clamp(16px, 2.5vw, 20px);
    padding: 5px 6px;
  }
}

@media (max-width: 480px) {
  .status-item {
    width: 70px;
    min-height: 80px;
  }

  .status-item-title {
    font-size: clamp(7px, 1vw, 9px);
  }

  .status-item-value {
    font-size: clamp(14px, 2vw, 18px);
    padding: 4px 5px;
  }
}



/* Ana Sayfa Butonu */
.home-button {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 9999;
  background: linear-gradient(135deg, #f54242, #ffb347);
  border-radius: 10px;
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3);
  padding: 10px 20px;
  font-family: 'Arial', sans-serif;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.home-button a {
  text-decoration: none;
  font-size: 14px;
  font-weight: bold;
  color: white;
  display: inline-block;
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
  transition: color 0.3s ease;
}

/* Hover Efekti */
.home-button:hover {
  transform: scale(1.1);
  box-shadow: 0px 6px 15px rgba(0, 0, 0, 0.5);
}

.home-button a:hover {
  color: #ffe600; /* Altın sarısı */
}

/* Ana Sayfa Butonu */
.home-button {
  position: fixed;
  top: 70px; /* Butonu biraz daha aşağı taşıdık */
  left: 20px;
  z-index: 9999;
  background: linear-gradient(135deg, #f54242, #ffb347);
  border-radius: 10px;
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3);
  padding: 10px 20px;
  font-family: 'Arial', sans-serif;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.home-button a {
  text-decoration: none;
  font-size: 14px;
  font-weight: bold;
  color: white;
  display: inline-block;
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
  transition: color 0.3s ease;
}

/* Hover Efekti */
.home-button:hover {
  transform: scale(1.1);
  box-shadow: 0px 6px 15px rgba(0, 0, 0, 0.5);
}

.home-button a:hover {
  color: #ffe600; /* Altın sarısı */
}

/* Kar Teması Efekti */
.home-button::before {
  content: '';
  position: absolute;
  top: -10px;
  left: -10px;
  width: calc(100% + 20px);
  height: calc(100% + 20px);
  border-radius: 15px;
  background-size: 20px;
  background-repeat: repeat;
  opacity: 0.3;
  z-index: -1;
  animation: snowEffect 5s infinite linear;
}

/* Kar Tanesi Hareketi */
@keyframes snowEffect {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: -50px 50px;
  }
}

/* Mobil Uyumluluk */
@media (max-width: 768px) {
  .home-button {
    padding: 8px 15px;
    top: 70px; /* Mobil cihazlarda biraz daha alta */
  }

  .home-button a {
    font-size: 12px;
  }
}
/* Bonus Modal */
.bonus-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5); /* Transparan arka plan */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}

/* Modal İçerik */
.modal-content {
  background: linear-gradient(135deg, #fffde7, #fff9c4); /* Pastel sarı tonları */
  border: 3px solid #ffe082; /* Pastel altın kenarlık */
  padding: 30px;
  border-radius: 20px;
  text-align: center;
  width: 400px;
  box-shadow: 0px 8px 20px rgba(0, 0, 0, 0.2);
  font-family: 'Roboto', sans-serif;
}

/* Satın Alma Seçenekleri */
.purchase-options {
  display: grid;
  grid-template-columns: 1fr 1fr; /* 2 sütun yapısı */
  grid-template-rows: 1fr 1fr; /* 2 satır yapısı */
  gap: 10px; /* Butonlar arasında boşluk */
  margin: 20px 0; /* Üst ve alt boşluk */
}

/* Satın Alma Düğmeleri */
.purchase-button {
  background: linear-gradient(135deg, #ffca28, #ffca28); /* Açık pastel sarı degrade */
  color: #4b4b4b;
  font-size: 15px;
  font-weight: bold;
  border: 1px solid #ffca28; /* Pastel altın kenarlık */
  padding: 12px 15px; /* İç boşluk */
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.purchase-button:hover {
  transform: scale(1.1);
  box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);
  background: linear-gradient(135deg, #ffca28, #ffca28); /* Degrade ters çevrilir */
}

/* Kapatma Butonu */
.close-button {
  background: linear-gradient(135deg, #ffca28, #ffca28); /* Pastel açık sarı degrade */
  color: #4b4b4b;
  font-size: 14px;
  font-weight: bold;
  border: 1px solid #ffca28; /* Pastel altın kenarlık */
  padding: 10px 15px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
}

.close-button:hover {
  transform: scale(1.1);
  box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);
}

/* Genel Modern ve Pastel Tema */
.modal-content {
  background: linear-gradient(135deg, #fffde7, #fff9c4); /* Pastel açık sarı degrade */
  border: 3px solid #ffca28; /* Pastel altın kenarlık */
  box-shadow: 0px 8px 20px rgba(0, 0, 0, 0.1);
}


/* Site Mesajları */
.site-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 15px 25px;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, #ffd54f, #ffca28); /* Altın sarısı tonları */
  border-radius: 15px;
  box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.4);
  z-index: 999999;
  animation: fadeInOut 3s ease-in-out;
  pointer-events: none; /* Tıklanmayı engeller */
}

.site-message.error {
  background: linear-gradient(135deg, #e53935, #ef5350); /* Kırmızı tonları */
}

/* Fade-in ve Fade-out Animasyonu */
@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: translate(-50%, -30px);
  }
  10% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  90% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -30px);
  }
}

/* Mobil Uyumluluk */
@media (max-width: 768px) {
  .modal-content {
    width: 90%;
  }

  .purchase-button,
  .close-button {
    font-size: 14px;
    padding: 10px 15px;
  }

  .site-message {
    font-size: 14px;
    padding: 10px 15px;
  }
}

#minefield-info {
  position: fixed;
  top: 75%; /* Daha yukarı taşındı */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85); /* Arka plan rengi aynı */
  color: #fff;
  padding: 10px 15px; /* Daha sıkı padding */
  border-radius: 8px; /* Daha kompakt köşeler */
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.3); /* Hafif gölge */
  font-size: 14px; /* Daha küçük genel font boyutu */
  font-family: Arial, sans-serif;
  display: flex;
  gap: 10px; /* Elemanlar arasındaki boşluk azaltıldı */
  z-index: 9999;
  max-width: 95%; /* Mobil uyum için genişlik sınırlandırıldı */
  width: auto; /* Dinamik genişlik */
}

#minefield-info.hidden {
  display: none;
}

.info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* Dikey ve yatay ortalama */
  padding: 5px; /* Daha sıkı padding */
  background: rgba(255, 255, 255, 0.1); /* Hafif saydam arka plan */
  border-radius: 6px; /* Daha yuvarlak köşeler */
  box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.2); /* Hafif gölge */
  gap: 3px; /* İç elemanlar arası sıkı boşluk */
}

.info-item span:first-child {
  font-size: 12px; /* Daha küçük başlık */
  font-weight: bold;
  text-transform: uppercase;
  color: #ffcc00; /* Altın rengi */
  text-align: center;
  white-space: nowrap; /* Alta kaymayı engeller */
}

.info-item span:last-child {
  font-size: 18px; /* Sayılar için kompakt boyut */
  font-weight: bold;
  color: #00ff00; /* Yeşil renk */
  background: rgba(0, 0, 0, 0.2); /* Hafif siyah arka plan */
  padding: 4px 6px; /* Daha sıkı padding */
  border-radius: 4px; /* Daha yuvarlak köşeler */
  text-align: center;
  white-space: nowrap; /* Yazıların alta kaymasını engeller */
}

/* Mobil Uyumluluk */
@media (max-width: 768px) {
  #minefield-info {
    top: 75%; /* Mobilde daha yukarı taşındı */
    padding: 8px 12px; /* Daha küçük padding */
    gap: 8px; /* Elemanlar arası boşluk azaltıldı */
  }

  .info-item {
    padding: 4px; /* Daha sıkı padding */
  }

  .info-item span:first-child {
    font-size: 10px; /* Daha küçük başlık */
  }

  .info-item span:last-child {
    font-size: 16px; /* Daha küçük sayı boyutu */
    padding: 3px 5px; /* Daha dar padding */
  }
}

@media (max-width: 480px) {
  #minefield-info {
    top: ; 75%/* Mobilde en yukarı taşındı */
    padding: 6px 10px; /* Daha küçük padding */
    gap: 6px; /* Daha sıkı eleman aralığı */
  }

  .info-item {
    padding: 3px; /* Daha dar padding */
  }

  .info-item span:first-child {
    font-size: 9px; /* Çok küçük başlık */
  }

  .info-item span:last-child {
    font-size: 14px; /* Daha küçük sayı boyutu */
    padding: 2px 4px; /* Daha dar padding */
  }
}


.transparent-frame {
  position: fixed; /* Sayfaya göre konumlandır */
  top: 65%; /* Dikey konumlandırma */
  left: 50%; /* Yatay konumlandırma */
  transform: translate(-50%, -50%); /* Tam merkeze alma */
  width: 400px; /* Genişlik */
  height: 180px; /* Yükseklik */
  border: 10px solid #ffcc00; /* Altın rengi çerçeve */
  border-radius: 20px; /* Yuvarlak köşeler */
  pointer-events: none; /* Tıklamaları engellemek için */
  background: rgba(255, 255, 153, 0.8); /* Soluk sarı arka plan (hafif şeffaf) */
  box-shadow: 
    0 0 15px 5px rgba(255, 215, 0, 0.6), /* Parlama efekti */
    0 0 30px 10px rgba(255, 215, 0, 0.5), 
    0 0 45px 15px rgba(255, 215, 0, 0.4); /* Daha büyük parlama */
}
.transparent-frame.animate {
  animation: border-glow-red 1s infinite; /* Çerçeve parlaması */
}

@keyframes border-glow-red {
  0% {
    border-color: rgba(255, 0, 0, 0.2); /* Hafif kırmızı */
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.2);
  }
  50% {
    border-color: rgba(255, 0, 0, 0.8); /* Parlak kırmızı */
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.6);
  }
  100% {
    border-color: rgba(255, 0, 0, 0.2); /* Hafif kırmızı */
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.2);
  }
}


/* Mobil Uyumluluk */
@media (max-width: 768px) {
  .transparent-frame {
    width: 400px; /* Mobil boyutu */
    height: 180px;
	top: 65%; /* Daha da alta taşındı */
	border-width: 8px; /* Çerçeve inceltildi */
    border-radius: 16px; /* Daha yuvarlak köşeler */
    background: rgba(255, 255, 153, 0.9); /* Mobil için soluk sarı arka plan */
    box-shadow: 
      0 0 10px 3px rgba(255, 215, 0, 0.6), 
      0 0 20px 6px rgba(255, 215, 0, 0.5),
      0 0 30px 9px rgba(255, 215, 0, 0.4); /* Mobil için optimize edilmiş parlama */
  }
}

/* Küçük Mobil Cihazlar İçin */
@media (max-width: 480px) {
  .transparent-frame {
    width: 350px; /* Küçük mobil cihazlar için sabit boyut */
    height: 140px;
	top: 65%; /* Daha da alta taşındı */
	border-width: 6px; /* Daha ince çerçeve */
    border-radius: 12px; /* Daha yuvarlak köşeler */
    background: rgba(255, 255, 153, 1); /* Küçük cihazlarda daha belirgin soluk sarı */
    box-shadow: 
      0 0 8px 2px rgba(255, 215, 0, 0.6), 
      0 0 16px 4px rgba(255, 215, 0, 0.5),
      0 0 24px 6px rgba(255, 215, 0, 0.4); /* Daha yumuşak parlama */
  }
}

/* Jackpot Banner Container */
.jackpot-banner {
  position: fixed;
  top: 12%; /* Ana menünün hemen altına yerleştir */
  right: 17%; /* Sağ köşe */
  z-index: 1000; /* Üstte görünsün */
  display: flex;
  align-items: center; /* Butonu dikey olarak ortala */
  justify-content: center; /* Butonu yatay olarak ortala */
  width: 200px; /* Buton genişliği */
  height: 50px; /* Buton yüksekliği */
  border: 3px solid #E0C068; /* Altın çerçeve */
  border-radius: 8px; /* Hafif yuvarlatılmış köşeler */
  background: rgba(240, 230, 140, 0.9); /* Soluk altın sarısı arka plan */
  box-shadow: 
    0 0 8px rgba(224, 192, 104, 0.6), 
    0 0 12px rgba(224, 192, 104, 0.4); /* Pastel parlama efekti */
  cursor: pointer;
}

/* Jackpot Button */
.jackpot-button {
  font-size: 1.2rem; /* Yazı boyutu */
  font-weight: bold;
  color:rgb(221, 13, 13); /* Beyaz renk */
  text-shadow: 
    1px 1px 3px rgba(0, 0, 0, 0.6), /* Siyah gölge efekti */
    0 0 4px rgba(255, 255, 255, 0.7); /* Parlama efekti */
  border: none;
  background: none; /* Arka plan yok, sadece çerçeve */
  cursor: pointer;
  animation: text-glow 1.5s infinite alternate; /* Parlama animasyonu */
}

.jackpot-button:hover {
  text-shadow: 
    2px 2px 5px rgba(0, 0, 0, 0.8), 
    0 0 8px rgba(255, 255, 255, 1); /* Daha yoğun parlama efekti */
}

/* Yazıya Yanıp Sönen Parlama Efekti */
@keyframes text-glow {
  0% {
    text-shadow: 
      1px 1px 3px rgba(0, 0, 0, 0.6), 
      0 0 4px rgba(255, 255, 255, 0.7);
  }
  100% {
    text-shadow: 
      2px 2px 5px rgba(0, 0, 0, 0.8), 
      0 0 6px rgba(255, 255, 255, 0.9);
  }
}

/* Mobil Uyum */
@media (max-width: 768px) {
  .jackpot-banner {
    top: 10%; /* Mobilde daha aşağı */
    right: 2%; /* Daha yakın sağ */
    width: 170px;
    height: 45px;
  }

  .jackpot-button {
    font-size: 1rem; /* Daha küçük yazı */
  }
}






/* Animasyonlar */

@keyframes pulse {
  0% {
    transform: scale(1);
    text-shadow: 
      0 0 10px rgba(255, 235, 59, 0.8), 
      0 0 20px rgba(255, 193, 7, 0.6);
  }
  100% {
    transform: scale(1.1);
    text-shadow: 
      0 0 15px rgba(255, 235, 59, 1), 
      0 0 25px rgba(255, 193, 7, 0.9);
  }
}

/* Gizli Stil */
.hidden {
  display: none; /* Görünmez */
}
/* Jackpot Konteyneri */
#jackpot-container {
  position: fixed; /* Sabit konum */
  top: 30%; /* Orta kısmın biraz üzerinde */
  left: 50%;
  transform: translate(-50%, -50%); /* Tam yatay ve dikey merkezleme */
  z-index: 9999; /* Diğer tüm içeriklerin üzerinde */
  text-align: center; /* Yazıyı ortala */
  background: linear-gradient(45deg, #ffcc00, #ff9900); /* Renkli degrade arka plan */
  padding: 15px 30px; /* Daha dar iç boşluk */
  border-radius: 15px; /* Yuvarlatılmış köşeler */
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3); /* Hafif bir gölge */
  animation: pulse-bg 2s infinite; /* Pulse animasyonu */
  display: inline-flex; /* Yazıları yatay hizala */
  align-items: center; /* Dikeyde ortala */
  gap: 15px; /* Yazılar arasındaki boşluk */
}

/* Jackpot Yazısı */
.jackpot-message {
  font-family: 'Poppins', sans-serif; /* Modern font */
  color: #ffffff; /* Beyaz yazı */
  font-size: 2.5rem; /* Dinamik yazı boyutu */
  font-weight: 900; /* Daha kalın yazı */
  text-transform: uppercase; /* Tamamen büyük harf */
  letter-spacing: 1.5px; /* Harfler arasında boşluk */
  text-shadow: 
    0 0 10px #ffffff, 
    0 0 20px #ff8561, 
    0 0 30px #ffa561; /* Parlama efekti */
  animation: glowing-text 1.5s infinite alternate; /* Parlama animasyonu */
  white-space: nowrap; /* Yazının alt satıra taşmasını engelle */
}

/* Çarpan Verisi */
.jackpot-message .earned-units {
  font-family: 'Poppins', sans-serif; /* Aynı font */
  color: #ffeb3b; /* Altın sarısı */
  font-size: 3rem; /* Dinamik çarpan yazısı */
  font-weight: 900; /* Daha kalın yazı */
  letter-spacing: 1px; /* Hafif boşluk */
  text-shadow: 
    0 0 10px #ffeb3b, 
    0 0 20px #ffd700, 
    0 0 30px #ffc107; /* Parlak altın efekti */
  animation: glowing-units 1.5s infinite alternate; /* Çarpana özel animasyon */
  white-space: nowrap; /* Alt satıra taşmayı engelle */
}

/* Pulse Arka Plan Animasyonu */
@keyframes pulse-bg {
  0% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  }
}

/* Yazıya Parlama Animasyonu */
@keyframes glowing-text {
  0% {
    text-shadow: 
      0 0 10px #ffffff, 
      0 0 20px #ff8561, 
      0 0 30px #ffa561;
  }
  100% {
    text-shadow: 
      0 0 20px #ffffff, 
      0 0 40px #ff8561, 
      0 0 60px #ffa561;
  }
}

@keyframes glowing-units {
  0% {
    text-shadow: 
      0 0 10px #ffeb3b, 
      0 0 20px #ffd700, 
      0 0 30px #ffc107;
  }
  100% {
    text-shadow: 
      0 0 20px #ffeb3b, 
      0 0 40px #ffd700, 
      0 0 60px #ffc107;
  }
}

/* Mobil Uyumluluk */
@media (max-width: 768px) {
  #jackpot-container {
    padding: 10px 20px; /* Daha dar iç boşluk */
    gap: 10px; /* Yazılar arasındaki boşluğu azalt */
  }
  .jackpot-message {
    font-size: 2rem; /* Daha küçük yazı boyutu */
  }
  .jackpot-message .earned-units {
    font-size: 2.5rem; /* Çarpan yazısı da küçültüldü */
  }
}






.coin {
  position: absolute;
  top: var(--coin-from-x, 24px);
  left: var(--coin-from-y, 24px);
  z-index: 100;
  opacity: 0;
}

.coin::after {
  content: "$";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 10px;
  color: rgb(237, 196, 107);
  background: rgb(227, 162, 23);
  border: 2px solid rgb(237, 196, 107);
  border-radius: 50%;
  opacity: 0;
}

.coin--animated,
.coin--animated::after {
  animation-delay: var(--coin-delay, 0s);
  animation-duration: var(--coin-duration, 1.5s);
  animation-direction: normal;
  animation-fill-mode: both;
  animation-play-state: running;
  animation-iteration-count: infinite;
}

.coin--animated {
  animation-name: coin-x-axis;
  animation-timing-function: ease-in;
}

.coin--animated::after {
  animation-name: coin-y-axis-and-flip;
  animation-timing-function: ease-out;
}

@keyframes coin-x-axis {
  30% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  to {
    left: calc(var(--coin-to-x) * 1.5);
  }
}

@keyframes coin-y-axis-and-flip {
  30% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  to {
    transform: translateY(calc(var(--coin-to-y) * 1.5)) rotate3d(1, 1, 1, 1080deg);
  }
}

/* Yazıyı Tam Ortada Hizalama */
#centered-text {
  position: fixed; /* Sabit konum */
  top: 52%; /* Yatayda ortala */
  left: 50%; /* Dikeyde ortala */
  transform: translate(-50%, -50%); /* Tam ortalama */
  z-index: 0; /* En altta kalacak şekilde index */
  text-align: center; /* Yazıyı ortala */
  font-family: 'Poppins', sans-serif; /* Modern font */
  font-size: 2rem; /* Küçük yazı boyutu (varsayılan) */
  font-weight: bold; /* Kalın yazı */
  color: #ffffff; /* Beyaz yazı */
  background: #ffd54f; /* Sarı arka plan */
  padding: 10px 20px; /* Yazının etrafındaki boşluk */
  border-radius: 10px; /* Arka planın köşelerini yuvarla */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Hafif gölge */
  white-space: nowrap; /* Yazının alt satıra taşmasını engelle */
  overflow: hidden; /* Taşmaları önle */
}

/* Mobil Uyumluluk (Küçük Ekranlar) */
@media (max-width: 768px) {
  #centered-text {
    font-size: 1.5rem; /* Daha küçük yazı boyutu */
    padding: 8px 16px; /* Daha dar iç boşluk */
  }
}

/* Çok Küçük Ekranlar */
@media (max-width: 480px) {
  #centered-text {
    font-size: 1.2rem; /* Daha küçük yazı boyutu */
    padding: 6px 12px; /* Daha dar iç boşluk */
  }
}
/* Otomatik Açma Butonu */
#auto-open-container {
  position: fixed;
  top: 50%;
  left: 30%; /* Varsayılan olarak mobil için */
  transform: translate(-50%, -50%);
  z-index: 9999;
}

#auto-open-button {
  padding: 15px 30px;
  background: linear-gradient(135deg, #ffca28, #ffc107); /* Pastel sarı degrade */
  color: #4b4b4b;
  font-size: 18px;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); /* Hafif gölge */
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#auto-open-button:hover {
  transform: scale(1.1); /* Butonu büyütme efekti */
  box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2); /* Daha güçlü gölge */
}

#auto-open-button:active {
  background: linear-gradient(135deg, #ff7043, #ff5722); /* Aktif durum rengi */
  color: #fff;
}

/* Mobil Uyumluluk (Küçük Ekranlar) */
@media (max-width: 768px) {
  #auto-open-container {
    left: 15%;
    top: 45%; /* Mobilde sol pozisyon sabit */
  }

  #auto-open-button {
    font-size: 10px; /* Daha küçük yazı boyutu */
    padding: 8px 12px; /* Daha küçük buton boyutu */
  }
}

/* Masaüstü Ekranlar */
@media (min-width: 769px) {
  #auto-open-container {
    left: 35%; /* Masaüstünde biraz daha ortaya yakın */
  }
}



</style>
