/* STEP989 / beta.256: shared authenticated topbar for Lobby, pre-table and game.
   Additive facade only. Original table.js, gameplay, chat and status nodes remain untouched. */
/* Logout existed, but was visually hidden by beta.250/Lobby design rules. */
body.sb-photo892 .topbar .profile-menu > #logout-button.icon-button,
.sb-global-topbar .sb-global-actions > .sb-global-logout {
  position: static !important;
  inset: auto !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 auto !important;
  width: 54px !important;
  min-width: 54px !important;
  height: 35px !important;
  min-height: 35px !important;
  margin: 0 !important;
  padding: 0 9px !important;
  opacity: 1 !important;
  visibility: visible !important;
  overflow: visible !important;
  border: 1px solid rgba(222,189,114,.28) !important;
  border-radius: 999px !important;
  background: rgba(19,30,23,.88) !important;
  color: #f4dfb4 !important;
  cursor: pointer !important;
  font-size: 0 !important;
  line-height: 1 !important;
  text-decoration: none !important;
}
body.sb-photo892 #logout-button::after,
.sb-global-topbar .sb-global-logout::after {
  content: "Esci";
  font-size: 12px;
  font-weight: 750;
}
body.sb-photo892 #logout-button:hover,
.sb-global-topbar .sb-global-logout:hover,
body.sb-photo892 #logout-button:focus-visible,
.sb-global-topbar .sb-global-logout:focus-visible {
  background: rgba(200,170,109,.15) !important;
  border-color: #d4b474 !important;
  outline: 1px solid rgba(218,193,136,.48);
}
/* Table retains original operational status IDs for table.js, but presents
   the same public navigation as the Lobby on pre-table and during gameplay. */
body.table-page:has(> .sb-global-topbar) {
  --sb256-topbar-height: 62px;
  min-height: 100dvh !important;
}
body.table-page > .sb-global-topbar {
  position: relative !important;
  top: auto !important;
  z-index: 1010 !important;
}
body.table-page:has(> .sb-global-topbar) .table-topbar {
  display: none !important;
}
body.table-page:has(> .sb-global-topbar) .table-app {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-rows: minmax(0,1fr) !important;
  height: calc(100dvh - var(--sb256-topbar-height)) !important;
  min-height: 0 !important;
}
body.table-page:has(> .sb-global-topbar) .table-layout {
  box-sizing: border-box !important;
  height: 100% !important;
  min-height: 0 !important;
}
/* During play, all three major containers must fit BELOW the same header;
   the game board uses existing absolute inset:0 within the resized stage. */
body.table-page:has(> .sb-global-topbar):has(.game-stage.playing) .table-sidebar,
body.table-page:has(> .sb-global-topbar) .game-stage.playing {
  box-sizing: border-box !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
}
/* Topbar stays usable while shared table chat or notifications are open. */
body.table-page:has(> .sb-global-topbar):has(.game-stage.playing) .sb-chat-drawer,
body.table-page:has(> .sb-global-topbar):has(.game-stage.playing) .sb-notifications-drawer {
  top: var(--sb256-topbar-height) !important;
  height: calc(100dvh - var(--sb256-topbar-height)) !important;
  max-height: calc(100dvh - var(--sb256-topbar-height)) !important;
}
/* Reconcile Lobby's approved 1740px wide topbar alignment. */
@media (min-width: 1805px) {
  body.table-page .sb-global-topbar .sb-global-actions {
    margin-right: calc((100vw - 1740px) / 2 - 34px) !important;
  }
}
/* Mobile screens must keep menu, profile and logout accessible. */
@media (max-width: 780px) {
  body.table-page:has(> .sb-global-topbar) { --sb256-topbar-height: 60px; }
  body.table-page:has(> .sb-global-topbar):has(.game-stage.playing) .table-app {
    display: grid !important;
    grid-template-rows: minmax(0, 1fr) !important;
  }
  body.table-page:has(> .sb-global-topbar):has(.game-stage.playing) .table-layout {
    min-height: 0 !important;
  }
}
@media (max-width: 780px) {
  body.sb-photo892 .topbar .profile-menu > #logout-button.icon-button,
  .sb-global-topbar .sb-global-actions > .sb-global-logout {
    width: 35px !important;
    min-width: 35px !important;
    padding: 0 !important;
  }
  body.sb-photo892 #logout-button::after,
  .sb-global-topbar .sb-global-logout::after { content: "↪"; font-size: 19px; }
}
@media (max-width: 440px) {
  body.sb-photo892 .topbar .live-summary,
  body.table-page .sb-global-topbar .sb-global-summary {
    font-size: .66rem !important;
    margin-left: 3px !important;
  }
  body.table-page .sb-global-topbar .sb-global-actions { gap: 3px !important; }
}

/* Tournament L9 uses a higher-specificity 100dvh minimum in game state.
   Override that minimum only while the shared topbar is present. */
body.table-page.table-layout-l9:has(> .sb-global-topbar):has(.game-stage.playing) .table-layout {
  height: 100% !important;
  min-height: 0 !important;
}
@media (min-width: 781px) and (max-width: 1050px) {
  body.table-page:has(> .sb-global-topbar) { --sb256-topbar-height: 74px; }
}
