/* PLAYER V184: fix V183 header wrapping/overlap during a verified QTech game ONLY.
   Original lobby styles, original QTech launch/exit, and all payment handlers untouched.
   Wallet balance tile hidden; all other header actions retained. */
body.qtech-immersive-v182 {
  --v184-header-h: 80px;
  --v184-exit-h: 48px;
}
@media (max-width: 860px) {
  body.qtech-immersive-v182 { --v184-header-h: 64px; --v184-exit-h: 44px; }
}

body.qtech-immersive-v182 #portalScreen .topbar {
  display: flex !important;
  position: fixed !important;
  inset: 0 0 auto 0 !important;
  z-index: 2147483001 !important;
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 0 !important;
  height: var(--v184-header-h) !important;
  min-height: var(--v184-header-h) !important;
  max-height: var(--v184-header-h) !important;
  margin: 0 !important;
  padding: 0 max(10px, env(safe-area-inset-right, 0px)) 0 max(10px, env(safe-area-inset-left, 0px)) !important;
  gap: 8px !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
  transform: none !important;
  visibility: visible !important;
}

/* A game has no site side-panel: hide toggles ONLY while inside QTech. */
body.qtech-immersive-v182 #desktopSidebarToggle,
body.qtech-immersive-v182 #mobileMenuButton {
  display: none !important;
}

/* Reserve room for real original actions. Never collapse or wrap their button row. */
body.qtech-immersive-v182 #portalScreen .topbar > #headerBrandHomeButton {
  flex: 0 1 auto !important;
  min-width: 0 !important;
  max-width: min(280px, 35vw) !important;
}
body.qtech-immersive-v182 #portalScreen .topbar > #headerBrandHomeButton .header-brand-copy {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
body.qtech-immersive-v182 #portalScreen .topbar > .topbar-title {
  flex: 0 1 auto !important;
  min-width: 0 !important;
  max-width: 120px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
body.qtech-immersive-v182 #portalScreen .topbar-actions {
  display: flex !important;
  flex: 1 1 0 !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 2px !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-flow: row nowrap !important;
  gap: 8px !important;
  white-space: nowrap !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
body.qtech-immersive-v182 #portalScreen .topbar-actions > * {
  flex: 0 0 auto !important;
  align-self: center !important;
  max-height: calc(var(--v184-header-h) - 10px) !important;
}
body.qtech-immersive-v182 #portalScreen .topbar-wallet-cluster {
  display: flex !important;
  flex: 0 0 auto !important;
  width: max-content !important;
  min-width: max-content !important;
  max-width: none !important;
  height: auto !important;
  align-items: center !important;
  flex-flow: row nowrap !important;
  gap: 8px !important;
}
/* The ONLY wallet component hidden: its balance tile and internal refresh. */
body.qtech-immersive-v182 #portalScreen .topbar-wallet-card { display: none !important; }
body.qtech-immersive-v182 #portalScreen .topbar-wallet-actions,
body.qtech-immersive-v182 #portalScreen .game-wallet-actions {
  display: flex !important;
  flex: 0 0 auto !important;
  flex-flow: row nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  width: max-content !important;
  min-width: max-content !important;
  height: auto !important;
  gap: 8px !important;
  white-space: nowrap !important;
}
body.qtech-immersive-v182 #portalScreen .topbar-wallet-actions > button {
  display: inline-flex !important;
  flex: 0 0 auto !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 38px !important;
  margin: 0 !important;
  padding: 7px 11px !important;
  align-items: center !important;
  justify-content: center !important;
  white-space: nowrap !important;
}
body.qtech-immersive-v182 #portalScreen .topbar-wallet-actions > button svg {
  width: 18px !important;
  height: 18px !important;
  flex: 0 0 18px !important;
}

/* Separate Exit Game from the iframe's own toolbar; QTech controls never sit
   underneath the site action buttons or the exit control. */
body.qtech-immersive-v182 #gameRuntime {
  top: var(--v184-header-h) !important;
  bottom: 0 !important;
  height: calc(100dvh - var(--v184-header-h)) !important;
  max-height: calc(100dvh - var(--v184-header-h)) !important;
  min-height: 0 !important;
  overflow: hidden !important;
}
body.qtech-immersive-v182 #gameRuntime .game-runtime-toolbar {
  display: flex !important;
  position: relative !important;
  inset: auto !important;
  z-index: 4 !important;
  box-sizing: border-box !important;
  flex: 0 0 var(--v184-exit-h) !important;
  width: 100% !important;
  height: var(--v184-exit-h) !important;
  min-height: var(--v184-exit-h) !important;
  max-height: var(--v184-exit-h) !important;
  margin: 0 !important;
  padding: 2px 10px !important;
  align-items: center !important;
  justify-content: flex-end !important;
  background: #12090c !important;
  border: 0 !important;
  border-bottom: 1px solid rgba(216,164,69,.3) !important;
  pointer-events: auto !important;
}
body.qtech-immersive-v182 #gameRuntime #exitGameButton {
  min-height: 36px !important;
  height: 36px !important;
  min-width: 94px !important;
  padding: 5px 12px !important;
}
body.qtech-immersive-v182 #gameRuntime #gameFrame {
  flex: 1 1 0 !important;
  display: block !important;
  min-height: 0 !important;
  width: 100% !important;
  height: calc(100% - var(--v184-exit-h)) !important;
  max-height: none !important;
  overflow: auto !important;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 860px) {
  body.qtech-immersive-v182 #portalScreen .topbar > #headerBrandHomeButton {
    max-width: min(145px, 25vw) !important;
  }
  body.qtech-immersive-v182 #portalScreen .topbar > .topbar-title {
    max-width: 60px !important;
  }
  /* Show existing wallet ACTIONS first in the scroll strip, never duplicate them. */
  body.qtech-immersive-v182 #portalScreen .topbar-wallet-cluster { order: -1 !important; }
}
