
 
// KATEGORİLER (Sadece anasayfada göster)
function insertImageRow() {
  if (location.pathname !== '/') return; // Anasayfa kontrolü

  // Mobilde 2x2 düzeni için media query ekle (sadece bir kez)
  if (!document.getElementById('custom-image-row-responsive-style')) {
    const mediaStyle = document.createElement('style');
    mediaStyle.id = 'custom-image-row-responsive-style';
    mediaStyle.textContent = `
      @media (max-width: 600px) {
        .custom-image-row a {
          flex: 1 1 calc(50% - 20px) !important;
          max-width: calc(90% - 20px) !important;
        }
      }
    `;
    document.head.appendChild(mediaStyle);
  }

  const slider = document.querySelector('section.landing-slider');
  if (!slider || document.querySelector('.custom-image-row')) return;

  const row = document.createElement('div');
  row.className = 'custom-image-row';
  row.style.cssText = `
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
    position: relative;
    z-index: 1;
  `;

  const urls = [
    { src: 'https://hullbet.ytseogency.com/assets/casino.png', link: '/livecasino' },
    { src: 'https://hullbet.ytseogency.com/assets/spor.png', link: '/Sport/betconstruct/prematch' },
    { src: 'https://hullbet.ytseogency.com/assets/slot.png', link: '/casino' },
    { src: 'https://hullbet.ytseogency.com/assets/bonus.png', link: '/promotions' }
  ];

  urls.forEach(({ src, link }) => {
    const a = document.createElement('a');
    a.href = link;
    a.style.cssText = `
      flex: 1 1 calc(25% - 20px);
      max-width: 320px;
      width: 100%;
      display: block;
      transition: transform 0.3s ease;
    `;

    const img = document.createElement('img');
    img.src = src;
    img.style.cssText = `
      width: 100%;
      height: auto;
      border-radius: 8px;
      display: block;
    `;

    // Hover efekti
    a.addEventListener('mouseenter', () => {
      a.style.transform = 'translateY(-10px)';
    });
    a.addEventListener('mouseleave', () => {
      a.style.transform = 'translateY(0)';
    });

    a.appendChild(img);
    row.appendChild(a);
  });

  slider.parentNode.insertBefore(row, slider.nextSibling);
}

// Sayfa yüklendiğinde çalıştır
document.addEventListener('DOMContentLoaded', insertImageRow);

const observer = new MutationObserver(insertImageRow);
observer.observe(document.body, { childList: true, subtree: true });
insertImageRow();

// —————————— AFFBANNER EKLEME ——————————
(function () {
  function manageAffBanner() {
    const casinoSection = document.querySelector('.custom-games-section');
    const bannerWrapper = document.querySelector('.custom-affbanner-wrapper');
    // Anasayfa kontrolü ("/" veya "/index.html")
    const isHome = window.location.pathname === '/' || window.location.pathname === '/index.html';

    if (isHome) {
      // Anasayfada ve banner yoksa ekle
      if (casinoSection && !bannerWrapper) {
        const wrapper = document.createElement('a');
        wrapper.href = 'https://hullbet.ytseogency.com/affiliate';
        wrapper.target = '_blank';
        wrapper.className = 'custom-affbanner-wrapper';

        const img = document.createElement('img');
        img.src = 'https://hullbet.ytseogency.com/assets/affbanner2.png';
        img.alt = 'Hullbet Ortağı Olmak İster misiniz?';
        img.className = 'custom-affbanner';
        img.style = 'max-width:1360px; width: 100%; margin:20px auto; margin-top: 77px !important; display:block;border-radius:10px; @media (max-width: 992px) {.custom-affbanner-wrapper{display: none;}}';

        wrapper.appendChild(img);
        casinoSection.parentNode.insertBefore(wrapper, casinoSection.nextSibling);
      }
    } else {
      // Anasayfa değilse varsa kaldır
      if (bannerWrapper) bannerWrapper.remove();
    }
  }

  const observer = new MutationObserver(manageAffBanner);
  observer.observe(document.body, { childList: true, subtree: true });
  manageAffBanner();
})();

//TEST
console.log("hello world");

//ANASAYFADA CASİNOYU SAKLAMA
(() => {
  const STYLE_ID = 'hide-casino-style';
  const STYLE_CONTENT = `.casino,.live-casino { display: none !important; }`;

  // Stil ekle
  function addStyle() {
    if (!document.getElementById(STYLE_ID)) {
      const s = document.createElement('style');
      s.id = STYLE_ID;
      s.textContent = STYLE_CONTENT;
      document.head.appendChild(s);
    }
  }

  // Stil kaldır
  function removeStyle() {
    const s = document.getElementById(STYLE_ID);
    if (s) s.remove();
  }

  // Path değişimini kontrol edip ekle/kaldır
  let lastPath = location.pathname;
  function checkPath() {
    const p = location.pathname;
    if (p !== lastPath) {
      lastPath = p;
      if (p === '/') addStyle();
      else removeStyle();
    }
  }

  // İlk yüklemede uygula/kaldır
  if (location.pathname === '/') addStyle();

  // Her 100ms’de kontrol et
  setInterval(checkPath, 100);
})();


// ————————————— SCROLL FONKSİYONLARI —————————————

// Sonsuz, sağa kayan liste
function initScroll(wrapper) {
    const list = wrapper.querySelector('.games-list');
    const items = Array.from(list.children);
    items.forEach(item => list.appendChild(item.cloneNode(true)));

    const halfWidth = list.scrollWidth / 2;
    const speed = 0.5;
    let pos = 0, isHovered = false, isDragging = false, dragStartX = 0, dragStartPos = 0;

    wrapper.style.cursor = 'grab';
    wrapper.addEventListener('mouseenter', () => isHovered = true);
    wrapper.addEventListener('mouseleave', () => isHovered = false);

    wrapper.addEventListener('pointerdown', e => {
        // link tıklamalarında drag başlatma
        if (e.target.closest('a')) return;
        isDragging = true;
        dragStartX = e.clientX;
        dragStartPos = pos;
        wrapper.setPointerCapture(e.pointerId);
        wrapper.style.cursor = 'grabbing';
    });
    wrapper.addEventListener('pointermove', e => {
        if (!isDragging) return;
        const delta = e.clientX - dragStartX;
        pos = (dragStartPos + delta) % halfWidth;
        if (pos < 0) pos += halfWidth;
        list.style.transform = `translateX(${pos - halfWidth}px)`;
    });
    wrapper.addEventListener('pointerup', e => {
        isDragging = false;
        wrapper.releasePointerCapture(e.pointerId);
        wrapper.style.cursor = 'grab';
    });
    wrapper.addEventListener('pointercancel', e => {
        isDragging = false;
        wrapper.releasePointerCapture(e.pointerId);
        wrapper.style.cursor = 'grab';
    });

    (function animate() {
        if (!isHovered && !isDragging) {
            pos = (pos + speed) % halfWidth;
            list.style.transform = `translateX(${pos - halfWidth}px)`;
        }
        requestAnimationFrame(animate);
    })();
}

// Sonsuz, sola kayan liste
function initScrollReverse(wrapper) {
    const list = wrapper.querySelector('.games-list');
    const items = Array.from(list.children);
    items.forEach(item => list.appendChild(item.cloneNode(true)));

    const halfWidth = list.scrollWidth / 2;
    const speed = 0.5;
    let pos = 0, isHovered = false, isDragging = false, dragStartX = 0, dragStartPos = 0;

    wrapper.style.cursor = 'grab';
    wrapper.addEventListener('mouseenter', () => isHovered = true);
    wrapper.addEventListener('mouseleave', () => isHovered = false);

    wrapper.addEventListener('pointerdown', e => {
        // link tıklamalarında drag başlatma
        if (e.target.closest('a')) return;
        isDragging = true;
        dragStartX = e.clientX;
        dragStartPos = pos;
        wrapper.setPointerCapture(e.pointerId);
        wrapper.style.cursor = 'grabbing';
    });
    wrapper.addEventListener('pointermove', e => {
        if (!isDragging) return;
        const delta = dragStartX - e.clientX;
        pos = (dragStartPos + delta) % halfWidth;
        if (pos < 0) pos += halfWidth;
        list.style.transform = `translateX(${pos - halfWidth}px)`;
    });
    wrapper.addEventListener('pointerup', e => {
        isDragging = false;
        wrapper.releasePointerCapture(e.pointerId);
        wrapper.style.cursor = 'grab';
    });
    wrapper.addEventListener('pointercancel', e => {
        isDragging = false;
        wrapper.releasePointerCapture(e.pointerId);
        wrapper.style.cursor = 'grab';
    });

    (function animate() {
        if (!isHovered && !isDragging) {
            pos = (pos - speed + halfWidth) % halfWidth;
            list.style.transform = `translateX(${pos - halfWidth}px)`;
        }
        requestAnimationFrame(animate);
    })();
}


// —————————— CASINO OYUNLARI BÖLÜMÜ ——————————
(function () {
  // Manuel ekleme yapacağın yer:
  const gameItems = [
    { src: 'https://hullbet.ytseogency.com/assets/c-1.avif', link: '/PlayGame/179288' },
    { src: 'https://hullbet.ytseogency.com/assets/c-2.avif', link: '/PlayGame/179291' },
    { src: 'https://hullbet.ytseogency.com/assets/c-3.avif', link: '/PlayGame/179285' },
    { src: 'https://hullbet.ytseogency.com/assets/c-4.avif', link: '/PlayGame/187137' },
    { src: 'https://hullbet.ytseogency.com/assets/c-5.avif', link: '/PlayGame/186831' },
    { src: 'https://hullbet.ytseogency.com/assets/c-6.avif', link: '/PlayGame/179620' },
    { src: 'https://hullbet.ytseogency.com/assets/c-7.avif', link: '/PlayGame/184702' },
    { src: 'https://hullbet.ytseogency.com/assets/c-8.avif', link: '/PlayGame/184084' },
    // yeni eklemek istediğin her resim için:
    // { src: 'YENI_RESIM_URL', link: 'YENI_LINK' },
  ];

  function insertCasinoSection() {
    const targetSection = document.querySelector('section.casino.amusnetIframesizeHome');
    if (!targetSection || document.querySelector('.custom-casino-section')) return;

    const sec = document.createElement('section');
    sec.className = 'custom-casino-section';

    const items = gameItems
      .concat(gameItems) // istersen çift sırada gösterir
      .map(({ src, link }) => `
        <a href="${link}" draggable="false" style="flex:0 0 auto; text-decoration:none;">
          <div class="game-item">
            <img src="${src}" class="game-img" draggable="false">
          </div>
        </a>`)
      .join('');

    sec.innerHTML = `
      <style>
        /* GENEL STİLLER */
        .custom-casino-section { position:relative; z-index:1; }
        .custom-casino-section .heading {
          display:flex; align-items:center; justify-content:space-between;
          color:#fff; max-width:1370px; margin:230px auto 20px;
        }
        .custom-casino-section .heading-left { display:flex; align-items:center; gap:12px; }
        .custom-casino-section .icon {
          background:linear-gradient(to right,#db340c 0%,#fc6825 100%);
          width:40px; height:40px; border-radius:4px;
          display:flex; align-items:center; justify-content:center;
        }
        .custom-casino-section .icon i   { font-size:28px; color:#fff; }
        .custom-casino-section .right h3 { font-size:20px; font-family:Inter,sans-serif; color:#F5F4F3; margin:2px 0 0; }
        .custom-casino-section .right span { font-size:1rem; color:#fff; }
        .custom-casino-section .view-all-btn{
          font-size:14px; background:#fc6825; color:#fff; padding:8px 16px;
          border:none; border-radius:4px; cursor:pointer; font-family:Inter,sans-serif;
          transition:background .3s ease;
        }
        .custom-casino-section .view-all-btn:hover{ background:#db340c; }

        .custom-casino-section .games-wrapper{
          position:relative; max-width:1370px; margin:0 auto; overflow:hidden; cursor:grab;
        }
        .custom-casino-section .games-list{
          display:flex; gap:20px; user-select:none; will-change:transform;
        }
        .custom-casino-section .game-item{
          position:relative; flex:0 0 auto; border-radius:8px; overflow:hidden;
          transition:transform .3s ease; border-top:2px solid #7c7c7c;
        }
        .custom-casino-section .game-item:hover{ transform:translateY(-10px); }
        .custom-casino-section .game-img{ width:100%; height:229px; object-fit:cover; pointer-events:none; display:block; }

        /* SADECE MOBİL İÇİN */
        .custom-casino-section .games-wrapper{
          overflow-x:auto !important; -webkit-overflow-scrolling:touch; padding:0 20px;
        }
        .custom-casino-section .games-wrapper::-webkit-scrollbar{ display:none; }

        @media (max-width:767px){
          .custom-casino-section .games-list{ gap:10px; }
          .custom-casino-section .game-item{ flex:0 0 calc((100% - 20px)/3) !important; transition:none !important; }
          .custom-casino-section .game-item:hover{ transform:none !important; }
        }
      </style>

      <div class="heading">
        <div class="heading-left">
          <div class="icon"><i class="icon-nav-casino"></i></div>
          <div class="right">
            <h3>Casino Oyunları</h3>
            <span>Yüzlerce oyun sağlayıcısı, kazandıran casino.</span>
          </div>
        </div>
        <button onclick="window.location.href='/casino/'" class="view-all-btn">Daha fazla göster</button>
      </div>

      <div class="games-wrapper">
        <div class="games-list">
          ${items}
        </div>
      </div>
    `;

    targetSection.parentNode.insertBefore(sec, targetSection.nextSibling);
    initScroll(sec.querySelector('.games-wrapper'));
  }

  new MutationObserver(insertCasinoSection).observe(document.body, { childList:true, subtree:true });
  insertCasinoSection();
})();


// —————————— CANLI CASINO OYUNLARI BÖLÜMÜ ——————————
(function () {
  // 1) Manuel ekleme yapacağın yer:
  const gameItems = [
    { src: 'https://hullbet.ytseogency.com/assets/cc-1.avif', link: '/PlayGame/179504' },
    { src: 'https://hullbet.ytseogency.com/assets/cc-2.avif', link: '/PlayGame/179516' },
    { src: 'https://hullbet.ytseogency.com/assets/cc-3.avif', link: '/PlayGame/179648' },
    { src: 'https://hullbet.ytseogency.com/assets/cc-4.avif', link: '/PlayGame/179010' },
    { src: 'https://hullbet.ytseogency.com/assets/cc-5.avif', link: '/PlayGame/179024' },
    { src: 'https://hullbet.ytseogency.com/assets/cc-6.avif', link: '/PlayGame/187955' },
    { src: 'https://hullbet.ytseogency.com/assets/cc-7.avif', link: '/PlayGame/183636' },
    { src: 'https://hullbet.ytseogency.com/assets/cc-8.avif', link: '/PlayGame/178976' },
    // yeni ekleyeceğin her görsel için:
    // { src: 'YENI_RESIM_URL', link: 'YENI_LINK' },
  ];

  function insertGamesSection() {
    const isHome = location.pathname === "/" || location.pathname === "/index.html";
    const existing = document.querySelector(".custom-games-section");
    if (!isHome) {
      existing?.remove();
      return;
    }
    if (existing) return;

    const row = document.querySelector(".custom-image-row");
    if (!row) return;

    const sec = document.createElement("section");
    sec.className = "custom-games-section";

    // 2) Otomatik oluşturma:
    const items = gameItems
      .concat(gameItems) // istersen çift sırada gösterir
      .map(({ src, link }) => `
        <a href="${link}" draggable="false" style="flex:0 0 auto; text-decoration:none;">
          <div class="game-item">
            <img src="${src}" class="game-img" draggable="false">
          </div>
        </a>`)
      .join("");

    sec.innerHTML = `
      <style>
        /* GENEL STİLLER */
        .custom-games-section { position:relative; z-index:1 }
        .custom-games-section .heading {
          display:flex; align-items:center; justify-content:space-between;
          color:#fff; max-width:1370px; margin:50px auto 20px;
        }
        .custom-games-section .heading-left {
          display:flex; align-items:center; gap:12px;
        }
        .custom-games-section .icon {
          background: linear-gradient(to right,#db340c 0%,#fc6825 100%);
          width:40px; height:40px; border-radius:4px;
          display:flex; align-items:center; justify-content:center;
        }
        .custom-games-section .icon i { font-size:28px; color:#fff; }
        .custom-games-section .right h3 {
          font-size:20px; font-family:Inter,sans-serif;
          color:#F5F4F3; margin:2px 0 0;
        }
        .custom-games-section .right span { font-size:1rem; color:#fff; }
        .custom-games-section .view-all-btn {
          font-size:14px; background:#fc6825; color:#fff;
          padding:8px 16px; border-radius:4px; border:none;
          cursor:pointer; font-family:Inter,sans-serif;
          transition:background .3s ease;
        }
        .custom-games-section .view-all-btn:hover { background:#db340c; }
        .custom-games-section .games-wrapper {
          position:relative; max-width:1370px;
          margin:0 auto; overflow:hidden; cursor:grab;
        }
        .custom-games-section .games-list {
          display:flex; gap:20px;
          user-select:none; will-change:transform;
        }
        .custom-games-section .game-item {
          position:relative; flex:0 0 auto;
          border-radius:8px; overflow:hidden;
          transition:transform .3s ease;
          border-top:1px solid #7c7c7c;
        }
        .custom-games-section .game-item:hover {
          transform:translateY(-10px);
        }
        .custom-games-section .game-img {
          width:100%; height:229px; object-fit:cover;
          pointer-events:none; display:block;
        }

        /* SADECE MOBİL İÇİN */
        .custom-games-section .games-wrapper {
          overflow-x: auto !important;
          -webkit-overflow-scrolling: touch;
          padding:0 20px;
        }
        .custom-games-section .games-wrapper::-webkit-scrollbar {
          display:none;
        }
        @media (max-width: 767px) {
          .custom-games-section .games-list {
            gap:10px;
          }
          .custom-games-section .game-item {
            flex:0 0 calc((100% - 20px)/3) !important;
            transition:none !important;
          }
          .custom-games-section .game-item:hover {
            transform:none !important;
          }
        }
      </style>

      <div class="heading">
        <div class="heading-left">
          <div class="icon"><i class="icon-card-roulette"></i></div>
          <div class="right">
            <h3>Canlı Casino</h3>
            <span>Gerçek krupiyelerle canlı casino deneyimi.</span>
          </div>
        </div>
        <button onclick="location.href='/livecasino/'" class="view-all-btn">Daha fazla göster</button>
      </div>

      <div class="games-wrapper">
        <div class="games-list">
          ${items}
        </div>
      </div>
    `;

    // ekleme
    const anchor = document.querySelector(".custom-casino-section");
    if (anchor) anchor.parentNode.insertBefore(sec, anchor.nextSibling);
    else document.querySelector("footer")?.parentNode.insertBefore(sec, document.querySelector("footer"));

    // otomatik scroll
    initScrollReverse(sec.querySelector(".games-wrapper"));
  }

  // SPA geçişleri ve DOM değişimleri için
  ["pushState", "replaceState"].forEach(m =>
    history[m] = ((orig) => function () {
      orig.apply(this, arguments);
      insertGamesSection();
    })(history[m])
  );
  window.addEventListener("popstate", insertGamesSection);
  new MutationObserver(insertGamesSection).observe(document.body, { childList: true, subtree: true });

  // ilk çağrı
  insertGamesSection();
})();


//PROVİDER LOGOLARINI YUKARI ÇIKARDIĞIM BÖLÜM
(function () {
  function moveProviderLogos() {
    const footer = document.querySelector('footer');
    const providerLogos = footer?.querySelector('.provider-logos');
    if (!footer || !providerLogos) return;

    // Yeni bir sarmalayıcı div oluştur (ortalamak ve genişlik sınırlamak için)
    const wrapper = document.createElement('div');
    wrapper.style.cssText = `
      max-width: 1370px;
      margin: 40px auto;
    `;
    wrapper.appendChild(providerLogos);

    // Footer'ın hemen üstüne yerleştir
    footer.parentNode.insertBefore(wrapper, footer);
  }

  new MutationObserver(moveProviderLogos)
    .observe(document.body, { childList: true, subtree: true });

  moveProviderLogos();
})();

//provider logo anasayfada değilsek kapat
(function () {
  function toggleProviderLogos() {
    const el = document.querySelector('.provider-logos');
    if (!el) return;
    const isHome = window.location.pathname === '/' || window.location.pathname === '/index.html';
    el.style.display = isHome ? '' : 'none';
  }

  // History API üzerinden geçişleri yakala
  const origPush = history.pushState;
  history.pushState = function () {
    origPush.apply(this, arguments);
    toggleProviderLogos();
  };
  const origReplace = history.replaceState;
  history.replaceState = function () {
    origReplace.apply(this, arguments);
    toggleProviderLogos();
  };
  window.addEventListener('popstate', toggleProviderLogos);

  // DOM değişimlerinde de kontrol et
  new MutationObserver(toggleProviderLogos)
    .observe(document.body, { childList: true, subtree: true });

  // Başlangıçta çalıştır
  toggleProviderLogos();
})();


//telegram butonu
(function() {
  function insertTelegramButton() {
    const bLinks = document.querySelector('header .top .functions .b-links');
    if (!bLinks || bLinks.querySelector('.telegram-button')) return; // iki kere eklemesin

    const a = document.createElement('a');
    a.href = 'https://t.me/hullbetcom'; // kendi Telegram linkin
    a.target = '_blank';
    a.className = 'button secondary telegram-button';

    const img = document.createElement('img');
    img.src = 'https://hullbet.ytseogency.com/assets/tg.png';
    img.alt = 'Telegram';
    img.style.width = '100%';
    img.style.height = '32px';
    img.style.objectFit = 'contain';

    const span = document.createElement('span');
    span.className = 'tooltiptext';
    span.innerText = 'Telegram';

    a.appendChild(img);
    a.appendChild(span);

    const firstButton = bLinks.querySelector('a.button.secondary');
    if (firstButton) {
      bLinks.insertBefore(a, firstButton); // en başa ekliyoruz
    } else {
      bLinks.appendChild(a);
    }
  }

  new MutationObserver(insertTelegramButton)
    .observe(document.body, { childList: true, subtree: true });

  insertTelegramButton();
})();



// —————————— CUSTOM CASINO MENU EKLEME & STİL ——————————
(function () {
  // 1) Rastgele oyun linkleri
  const games = [
    '/PlayGame/179288',
    '/PlayGame/179291',
    '/PlayGame/179285',
    '/PlayGame/187137',
    '/PlayGame/186831',
    '/PlayGame/179620',
    '/PlayGame/184702',
    '/PlayGame/184084',
    '/PlayGame/222224',
    '/PlayGame/188957',
    '/PlayGame/221017',
    '/PlayGame/179291',
    '/PlayGame/179287',
    '/PlayGame/180949',
    '/PlayGame/183755',
    '/PlayGame/188718',
    '/PlayGame/188801',
    '/PlayGame/180946',
    '/PlayGame/188739',
    '/PlayGame/180932',
    '/PlayGame/188894',
    '/PlayGame/221017',
    '/PlayGame/221018',
    '/PlayGame/221009',
    '/PlayGame/188749'
  ];

  function manageCustomMenu() {
    const filter = document.querySelector('.casino-filter.filter-casino');
    const existing = document.querySelector('.custom-casino-menu');

    if (window.location.pathname !== '/casino') {
      if (existing) existing.remove();
      return;
    }

    if (filter && !existing) {
      // Stil
      const style = document.createElement('style');
      style.textContent = `
        .custom-casino-menu {
          font-size: 14px;
          display: flex;
          justify-content: center;
          gap: 12px;
          margin: 16px 0;
          margin-top: 552px;
        }
        .custom-casino-menu ul {
          display: flex;
          box-shadow: 0 -1px 0 rgb(255 255 255 / 15%), 1px 0 0 rgb(255 255 255 / 15%);
          gap: 12px;
          padding: 10px;
          width: 1370px;
          background-color: #121418;
          margin: 0;
          list-style: none;
          border-radius: 10px;
        }
        .custom-casino-menu li.active a,
        .custom-casino-menu a:hover {
          background-color: #1e2228;
          color: #ee521b;
        }
        .custom-casino-menu a {
          display: flex;
          align-items: center;
          gap: 6px;
          padding: 8px 16px;
          background-color: #121417;
          border-radius: 10px;
          color: #fff;
          font-weight: 500;
          text-decoration: none;
          transition: background-color .2s;
        }
        .custom-casino-menu i {
          font-size: 13px;
        }
        .custom-casino-menu .dice-icon {
          font-size: 20px;
          color: #fff;
        }
        @media (max-width: 768px) {
          .custom-casino-menu ul {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            flex-wrap: nowrap;
          }
          .custom-casino-menu ul li {
            flex: 0 0 auto;
          }
        }
      `;
      document.head.appendChild(style);

      // Menünün HTML’i
      const nav = document.createElement('div');
      nav.className = 'custom-casino-menu';
      nav.innerHTML = `
        <ul>
          <li><a href="javascript:void(0)"><i class="icon-lobby"></i>Tümü</a></li>
          <li><a href="javascript:void(0)"><i class="icon-slots"></i>Free Spin AL</a></li>
          <li><a href="javascript:void(0)"><i class="icon-live"></i>Yeni</a></li>
          <li><a href="javascript:void(0)"><i class="icon-shows"></i>Megaways</a></li>
          <li><a href="javascript:void(0)"><i class="icon-table"></i>Jackpots</a></li>
          <li><a href="javascript:void(0)"><i class="icon-originals"></i>Popüler</a></li>
          <li><a href="javascript:void(0)"><i class="icon-originals"></i>Video Slotlar</a></li>
          <li><a href="javascript:void(0)"><i class="icon-originals"></i>Masa Oyunları</a></li>
          <li><a href="javascript:void(0)"><i class="icon-originals"></i>Turnuva</a></li>
          <li><a href="javascript:void(0)"><i class="icon-originals"></i>Live Spins</a></li>
        </ul>
      `;

      // Zar butonunu ekle
      const diceLi = document.createElement('li');
      const diceA = document.createElement('a');
      diceA.href = 'javascript:void(0)';
      const diceIcon = document.createElement('span');
      diceIcon.className = 'dice-icon';
      diceIcon.textContent = '🎲';
      diceA.appendChild(diceIcon);
      diceLi.appendChild(diceA);
      nav.querySelector('ul').appendChild(diceLi);

      // Menü ekleme
      filter.parentNode.insertBefore(nav, filter);

      // Sekme tıklama ve filtre trigger’ı
      const tabs = nav.querySelectorAll('ul li');
      const base = document.querySelectorAll('#fixedPosition .container ul li');
      tabs.forEach((li, idx) => {
        li.addEventListener('click', e => {
          e.preventDefault();
          // Zar li’si ise oyun aç
          if (li.contains(diceIcon)) {
            const idx = Math.floor(Math.random() * games.length);
            window.location.href = games[idx];
            return;
          }
          // Diğer sekmeler
          tabs.forEach(x => x.classList.remove('active'));
          li.classList.add('active');
          if (base[idx]) {
            base.forEach(b => b.classList.remove('active'));
            base[idx].classList.add('active');
            base[idx].querySelector('a').click();
          }
        });
      });
      tabs[0].classList.add('active');
    }
  }

  const observer = new MutationObserver(manageCustomMenu);
  observer.observe(document.body, { childList: true, subtree: true });
  window.addEventListener('resize', manageCustomMenu);
  manageCustomMenu();
})();

// —— FontAwesome yükleyici —— 
if (!document.getElementById('fa-css')) {
  const link = document.createElement('link');
  link.id = 'fa-css';
  link.rel = 'stylesheet';
  link.href = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css';
  document.head.appendChild(link);
}

//çarkıfelek bonus talep taşıma
// ".cards.landing" öğesini tek seferlik ve güvenli şekilde taşıma
(function () {
  function moveCardsLanding() {
    const cards = document.querySelector('.cards.landing');
    const slider = document.querySelector('.home section.landing-slider');
    if (!cards || !slider || cards.dataset.moved) return;
    slider.parentNode.insertBefore(cards, slider.nextSibling);
    cards.dataset.moved = 'true';
  }

  document.addEventListener('DOMContentLoaded', moveCardsLanding);
  new MutationObserver(moveCardsLanding)
    .observe(document.body, { childList: true, subtree: true });
})();



// SLİDER EKLEME (CASİNO)
// 1) Genel slider stilleri — sayfaya bir kez eklenir
const style = document.createElement('style');
style.textContent = `
.custom-mobile-slider { display: none; }
@media (max-width: 767px) {
  .custom-mobile-slider {
    display: block;
    position: relative;
    width: 100%;
    overflow: hidden;
    margin-bottom: 20px;
  }
  .custom-mobile-slider .slides {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .custom-mobile-slider .slides::-webkit-scrollbar { display: none; }
  .custom-mobile-slider .slide {
    flex: 0 0 100%;
    scroll-snap-align: start;
  }
  .custom-mobile-slider .slide img {
    width: 100%;
    display: block;
  }
  .custom-mobile-slider .dots {
    text-align: center;
    margin-top: 8px;
  }
  .custom-mobile-slider .dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin: 0 4px;
    background: #fff;
    opacity: 0.5;
    border-radius: 50%;
    cursor: pointer;
  }
  .custom-mobile-slider .dot.active {
    opacity: 1;
  }
}
`;
document.head.appendChild(style);

// 2) Slider içeriği ve davranışı
(function() {
  const slidesData = [
    { img: 'https://hullbet.ytseogency.com/assets/casino-slider-2.png', link: '/casino' },
    { img: 'https://hullbet.ytseogency.com/assets/casino-slider-3.png', link: '/casino' },
    { img: 'https://hullbet.ytseogency.com/assets/casino-slider-4.png', link: '/casino' },
    { img: 'https://hullbet.ytseogency.com/assets/casino-slider-6.png', link: '/casino' },
    { img: 'https://hullbet.ytseogency.com/assets/casino-slider-7.png', link: '/casino' }
  ];

  function throttle(fn, wait) {
    let time = Date.now();
    return function() {
      if (Date.now() - time >= wait) {
        fn();
        time = Date.now();
      }
    }
  }

  function initSlider(container) {
    const track = container.querySelector('.slides');
    const dots = Array.from(container.querySelectorAll('.dot'));
    let current = 0;
    const total = dots.length;

    // Aktif dot’u işaretle
    function setActive(i) {
      dots.forEach((d, idx) => d.classList.toggle('active', idx === i));
    }
    setActive(0);

    // Scroll event’i
    track.addEventListener('scroll', throttle(() => {
      current = Math.round(track.scrollLeft / container.offsetWidth);
      setActive(current);
    }, 100));

    // Dot tıklama
    dots.forEach((d, i) => {
      d.addEventListener('click', () => {
        current = i;
        track.scrollTo({ left: i * container.offsetWidth, behavior: 'smooth' });
        setActive(i);
      });
    });

    // Otomatik kaydırma
    setInterval(() => {
      current = (current + 1) % total;
      track.scrollTo({ left: current * container.offsetWidth, behavior: 'smooth' });
      setActive(current);
    }, 3000);
  }

  function insertMobileSlider() {
    if (window.innerWidth > 767) return;
    const casino = document.querySelector('section.casino');
    if (!casino || document.querySelector('.custom-mobile-slider')) return;

    const slider = document.createElement('section');
    slider.className = 'custom-mobile-slider';
    slider.innerHTML = `
      <div class="slides">
        ${slidesData.map(s => `
          <a href="${s.link}" class="slide"><img src="${s.img}" alt=""></a>
        `).join('')}
      </div>
      <div class="dots">
        ${slidesData.map(_ => `<span class="dot"></span>`).join('')}
      </div>
    `;
    casino.insertBefore(slider, casino.firstChild);
    initSlider(slider);
  }

  window.addEventListener('resize', insertMobileSlider);
  new MutationObserver(insertMobileSlider).observe(document.body, { childList: true, subtree: true });
  insertMobileSlider();
})();



//amusnet kapat
(function() {
  const STYLE_ID = 'page-specific-styles';

  function applyStyles() {
    // Eski stil varsa kaldır
    const old = document.getElementById(STYLE_ID);
    if (old) old.remove();

    const isMobile = window.matchMedia('(max-width: 767px)').matches;
    const url = window.location.href.toLowerCase();
    const isCasino = url.includes('/casino');

    let css = '';

    // Mobilde .custom-mobile-slider’ı gizle
    if (isMobile) {
      css += '.custom-mobile-slider{display:none!important;}';
    }
    // Mobil + URL’de casino varsa .amusnetIframesize gizle, slider’ı tekrar göster
    if (isMobile && isCasino) {
      css += '.amusnetIframesize{display:none!important;}';
      css += '.custom-mobile-slider{display:block!important;}';
    }

    if (css) {
      const style = document.createElement('style');
      style.id = STYLE_ID;
      style.textContent = css;
      document.head.appendChild(style);
    }
  }

  // History API’yi sar, popstate/hashchange/resize dinle
  ['pushState','replaceState'].forEach(fn => {
    const orig = history[fn];
    history[fn] = function() {
      const res = orig.apply(this, arguments);
      applyStyles();
      return res;
    };
  });
  window.addEventListener('popstate', applyStyles);
  window.addEventListener('hashchange', applyStyles);
  window.addEventListener('resize', applyStyles);

  // İlk yüklemede uygula
  applyStyles();
})();


//KENDİMİ ŞANSI HİSSEDİYORUM
(function() {
  // 1) CSS’i tek seferlik ekle
  const style = document.createElement('style');
  style.textContent = `
    .custom-lucky-wrapper {
      margin-bottom: 16px;
      width: 100%;
      text-align: center;
    }
    .lucky-rectangle {
      display: inline-flex;
      align-items: center;
      background: linear-gradient(to top, #000000 0%, #000000 50%, #00121c 100%) !important;
          box-shadow:1px -1px 7px rgb(255 255 255 / 15%), 0.1px -1px 31px rgb(255 255 255 / 15%) !important;

      width: 94%;
    padding-left: 21px;
      border-radius: 8px;
    }
    .lucky-rectangle .dice {
      font-size: 2.5rem;
      cursor: pointer;
      color: #fff;
      margin-right: 12px;
    }
    .lucky-rectangle .lucky-message {
      font-size: 10px;
      padding-left: 4%;
      color: #fff;
      font-weight: bold;
    }
  `;
  document.head.appendChild(style);

  // 2) Random oyun linkleri
 const games = [
  '/PlayGame/179288',
  '/PlayGame/179291',
  '/PlayGame/179285',
  '/PlayGame/187137',
  '/PlayGame/186831',
  '/PlayGame/179620',
  '/PlayGame/184702',
  '/PlayGame/184084',
  '/PlayGame/222224',
  '/PlayGame/188957',
  '/PlayGame/221017',
  '/PlayGame/179291',
  '/PlayGame/179287',
  '/PlayGame/180949',
  '/PlayGame/183755',
  '/PlayGame/188718',
  '/PlayGame/188801',
  '/PlayGame/180946',
  '/PlayGame/188739',
  '/PlayGame/180932',
  '/PlayGame/188894',
  '/PlayGame/221017',
  '/PlayGame/221018',
  '/PlayGame/221009',
  '/PlayGame/188749'
];


  // 3) DOM değişikliklerini dinleyip eklemeyi yapan fonksiyon
  function manageLuckyBanner() {
    const target = document.querySelector('.all-games');
    const existing = document.querySelector('.custom-lucky-wrapper');

    if (target && !existing) {
      // wrapper
      const wrapper = document.createElement('div');
      wrapper.className = 'custom-lucky-wrapper';

      // dikdörtgen içi
      const rect = document.createElement('div');
      rect.className = 'lucky-rectangle';

      // zar
      const dice = document.createElement('span');
      dice.className = 'dice';
      dice.textContent = '🎲';
      rect.appendChild(dice);

      // mesaj
      const msg = document.createElement('span');
      msg.className = 'lucky-message';
msg.textContent = 'KENDİMİ ŞANSLI HİSSEDİYORUM';
const sparkle = document.createElement('span');
sparkle.style.marginLeft = '8px';
sparkle.style.fontSize = '12px';
sparkle.textContent = '💫';
msg.appendChild(sparkle);
      rect.appendChild(msg);

      // tıklama ile rastgele yönlendirme
      dice.addEventListener('click', () => {
        const idx = Math.floor(Math.random() * games.length);
        window.location.href = games[idx];
      });

      wrapper.appendChild(rect);
      target.parentNode.insertBefore(wrapper, target);
    }
    // hedef yoksa varsa wrapper’ı temizle
    else if (!target && existing) {
      existing.remove();
    }
  }

  // 4) MutationObserver kur
  const observer = new MutationObserver(manageLuckyBanner);
  observer.observe(document.body, { childList: true, subtree: true });

  // 5) İlk çalıştırma
  manageLuckyBanner();
})();

