(function () {
  var DEST = "https://www.b9myr10.com/r/fb01";

  // 1) Hide all registration form fields — keep only the button + "You won" header
  var hide = [
    ".form .form__head",
    ".form .select-currency",
    ".form .input-tel",
    ".form .input-tel__wrapper",
    ".form .input-email",
    ".form .input-password",
    ".form .form__promocode",
    ".form .input-promocode",
    ".form .form__haveacc",
    '[data-test-id="promo-add-button"]'
  ].join(",") + "{display:none !important;}" +
    // Center the registration modal vertically on mobile (default was bottom-aligned)
    ".reg-modal{align-items:center !important;padding:24px 0 !important;}" +
    // Nudge the headline down toward the wheel (gap was too big)
    ".game__head{transform:translateY(28px) !important;}" +
    // Center the logo bar on mobile only — desktop keeps the login link on the right
    "@media (max-width:1023px){.header__grid{justify-content:center !important;}}" +
    // Shrink the "免费旋转" label inside the purple FS badge (number stays big)
    ".fs-text span{font-size:.55em !important;letter-spacing:0 !important;}" +
    // Header: keep only our logo — hide the "x" cross and the Dog House game logo
    ".header__cross,.header__game-logo{display:none !important;}" +
    // Our logo: bigger and nudged down
    ".header__logo img{width:190px;height:auto;}" +
    ".header__logo{top:14px !important;}";
  var st = document.createElement("style");
  st.textContent = hide;
  (document.head || document.documentElement).appendChild(st);

  // 2) Force-enable the Register button and send clicks to our website
  function wire() {
    // Logo click -> promo link
    var logo = document.querySelector("picture.header__logo");
    if (logo && !logo.__wired) {
      logo.__wired = 1;
      logo.style.cursor = "pointer";
      logo.addEventListener("click", function () { window.location.href = DEST; });
    }
    var btn = document.querySelector('[data-test-id="register-modal-button"]');
    if (!btn) return;
    if (btn.hasAttribute("disabled")) btn.removeAttribute("disabled");
    btn.disabled = false;
    if (!btn.__wired) {
      btn.__wired = 1;
      btn.addEventListener("click", function (e) {
        e.preventDefault();
        e.stopPropagation();
        e.stopImmediatePropagation();
        window.location.href = DEST;
      }, true);
    }
  }
  new MutationObserver(wire).observe(document.documentElement, {
    childList: true, subtree: true, attributes: true,
    attributeFilter: ["disabled", "class"]
  });
  document.addEventListener("DOMContentLoaded", wire);
  setInterval(wire, 300);

  // --- TEMP: auto-open the modal for verification (remove after testing) ---
  if (location.hash === "#autoreg") {
    var tries = 0;
    var t = setInterval(function () {
      tries++;
      if (document.querySelector('[data-test-id="register-modal-button"]')) { clearInterval(t); return; }
      var g = document.querySelector('.game__button, .game__action');
      if (g) g.click();
      if (tries > 40) clearInterval(t);
    }, 400);
  }
})();
