/* Desktop-wide performance optimizations (formerly Firefox-only) */

/* Base text rendering for all desktop browsers */
.is-firefox body,
.is-desktop body {
  text-rendering: optimizeLegibility;
}

/* Disable heavy effects on elements that opt-in or on low-end desktop devices */
.is-firefox .avoid-heavy-effects,
.is-desktop .avoid-heavy-effects,
.is-firefox.ff-lowperf *:not(#content_container):not(#content_container *):not(.allow-animations):not(.allow-animations *),
.is-desktop.desktop-lowperf *:not(#content_container):not(#content_container *):not(.allow-animations):not(.allow-animations *),
.is-firefox.low-end-device *:not(#content_container):not(#content_container *):not(.allow-animations):not(.allow-animations *) {
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

/* Re-enable backdrop-filter blur for popups and modals on all desktop browsers (except iOS) */
.is-firefox .popup:not(.ios-no-blur),
.is-desktop .popup:not(.ios-no-blur),
.is-firefox .modal:not(.ios-no-blur),
.is-desktop .modal:not(.ios-no-blur),
.is-firefox .popup-overlay:not(.ios-no-blur),
.is-desktop .popup-overlay:not(.ios-no-blur),
.is-firefox .modal-overlay:not(.ios-no-blur),
.is-desktop .modal-overlay:not(.ios-no-blur),
.is-firefox .weapon-drop:not(.ios-no-blur),
.is-desktop .weapon-drop:not(.ios-no-blur),
.is-firefox .history-details-modal:not(.ios-no-blur),
.is-desktop .history-details-modal:not(.ios-no-blur),
.is-firefox .withdraw-modal-overlay:not(.ios-no-blur),
.is-desktop .withdraw-modal-overlay:not(.ios-no-blur),
.is-firefox .allow-animations.popup:not(.ios-no-blur),
.is-desktop .allow-animations.popup:not(.ios-no-blur),
.is-firefox .allow-animations.modal:not(.ios-no-blur),
.is-desktop .allow-animations.modal:not(.ios-no-blur) {
  backdrop-filter: blur(50px) !important;
  -webkit-backdrop-filter: blur(50px) !important;
  background-color: rgba(0, 0, 0, 0.341) !important;
}

/* Reduce animation/transition costs on low-end desktop/Firefox, but preserve roulette */
.is-firefox.ff-lowperf *:not(#content_container):not(#content_container *):not(.allow-animations):not(.allow-animations *),
.is-desktop.desktop-lowperf *:not(#content_container):not(#content_container *):not(.allow-animations):not(.allow-animations *),
.is-firefox.low-end-device *:not(#content_container):not(#content_container *):not(.allow-animations):not(.allow-animations *) {
  animation-duration: 0.1s !important;
  transition-duration: 0.1s !important;
  animation-iteration-count: 1 !important;
}

/* Kill problematic animated elements (like footer coins) on low-end desktop */
.is-firefox.ff-lowperf .footer-coin,
.is-desktop.desktop-lowperf .footer-coin,
.is-firefox.ff-lowperf .footer-coin *,
.is-desktop.desktop-lowperf .footer-coin * {
  animation: none !important;
  transition: none !important;
  transform: none !important;
}

/* Fallback to auto scroll-behavior on low-end desktop to avoid janky smooth scroll */
.is-firefox.ff-lowperf html,
.is-desktop.desktop-lowperf html,
.is-firefox.low-end-device html {
  scroll-behavior: auto !important;
}

/* Disable parallax transforms on low-end desktop but preserve roulette */
.is-firefox.ff-lowperf [data-parallax]:not(#content_container):not(#content_container *):not(.allow-animations):not(.allow-animations *),
.is-desktop.desktop-lowperf [data-parallax]:not(#content_container):not(#content_container *):not(.allow-animations):not(.allow-animations *),
.is-firefox.low-end-device [data-parallax]:not(#content_container):not(#content_container *):not(.allow-animations):not(.allow-animations *) {
  transform: none !important;
}

/* Optional emergency hook for Top Up popup only if explicitly marked as ultra-low-performance */
.is-firefox.ff-lowperf #balancepop.balance-lowperf,
.is-desktop.desktop-lowperf #balancepop.balance-lowperf,
.is-firefox.ff-lowperf #balancepop.balance-lowperf *,
.is-desktop.desktop-lowperf #balancepop.balance-lowperf *,
.is-firefox.ff-lowperf .popBalanceCont.balance-lowperf,
.is-desktop.desktop-lowperf .popBalanceCont.balance-lowperf,
.is-firefox.ff-lowperf .popBalanceCont.balance-lowperf *,
.is-desktop.desktop-lowperf .popBalanceCont.balance-lowperf * {
  animation: none !important;
  transition: none !important;
}

/* Optional emergency hook for Top Up popup blur only if explicitly marked */
.is-firefox.ff-lowperf #balancepop.balance-lowperf,
.is-desktop.desktop-lowperf #balancepop.balance-lowperf,
.is-firefox.ff-lowperf .popBalanceCont.balance-lowperf,
.is-desktop.desktop-lowperf .popBalanceCont.balance-lowperf,
.is-firefox.ff-lowperf .popBalanceCont.balance-lowperf .poper,
.is-desktop.desktop-lowperf .popBalanceCont.balance-lowperf .poper {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  filter: none !important;
}

/* Disable interactive transforms inside balance popup, but keep container centering transforms intact */
.is-firefox #balancepop .coin-item,
.is-desktop #balancepop .coin-item,
.is-firefox #balancepop .coin-item:hover,
.is-desktop #balancepop .coin-item:hover,
.is-firefox #balancepop .coin-item img,
.is-desktop #balancepop .coin-item img,
.is-firefox #balancepop .payment-section,
.is-desktop #balancepop .payment-section,
.is-firefox #balancepop .payment-section .amount-controls,
.is-desktop #balancepop .payment-section .amount-controls,
.is-firefox #balancepop #payBtn,
.is-desktop #balancepop #payBtn {
  transform: none !important;
}

/* Re-enable close button animation/transitions in Top Up popup */
.is-firefox #balancepop #popupclose,
.is-desktop #balancepop #popupclose,
.is-firefox #balancepop .close,
.is-desktop #balancepop .close {
  transition: transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* Firefox scrollbar offset fix for predictable case mobile toolbar */
@media (max-width: 700px) {
    html.is-firefox body.page-predictable-detail .case_container > .main > .top,
    .is-firefox body.page-predictable-detail .case_container > .main > .top,
    body.is-firefox.page-predictable-detail .case_container > .main > .top {
        padding-right: calc(max(15px, env(safe-area-inset-right)) + 6px) !important;
    }
}