/* STEP975 / beta.254: desktop PRE-TABLE geometry only.
   The approved beta.253 Lobby is the width and gutter reference.
   Actual playing table layout is completely outside this selector scope. */
@media (min-width: 1200px) {
  body.table-page.table-layout-l9:not(:has(.game-stage.playing)) {
    --sb254-rail-width: clamp(395px, 27.5vw, 460px);
    --sb254-column-gap: 15px;
  }
  body.table-page.table-layout-l9:not(:has(.game-stage.playing)) .table-layout,
  body.table-page.table-layout-l9:not(:has(.game-stage.playing)):has(#sb-chat-drawer.open) .table-layout {
    width: calc(100% - 64px) !important;
    max-width: 1740px !important;
    margin: 0 auto !important;
    padding: 11px 0 12px !important;
    gap: var(--sb254-column-gap, 15px) !important;
    grid-template-columns: minmax(0, 1fr) var(--sb254-rail-width, clamp(395px, 27.5vw, 460px)) !important;
  }
  body.table-page.table-layout-l9:not(:has(.game-stage.playing)) .table-sidebar {
    min-width: 0 !important;
  }
  /* Occupied and empty positions occupy the exact same footprint. */
  body.table-page.table-layout-l9:not(:has(.game-stage.playing))
    .seat-position:is(.left, .right) {
    width: 230px !important;
    max-width: 26% !important;
  }
  body.table-page.table-layout-l9:not(:has(.game-stage.playing))
    .seat-position:is(.left, .right) > .seat-card {
    box-sizing: border-box !important;
    width: 100% !important;
    height: 118px !important;
    min-height: 118px !important;
    max-height: 118px !important;
  }
  body.table-page.table-layout-l9:not(:has(.game-stage.playing))
    .seat-position:is(.left, .right) > .seat-card.free {
    padding: 8px 10px !important;
    align-content: center !important;
    row-gap: 2px !important;
    grid-template-rows: repeat(4, auto) !important;
  }
  body.table-page.table-layout-l9:not(:has(.game-stage.playing))
    .seat-position:is(.left, .right) .seat-move-hint {
    margin-top: 0 !important;
    line-height: 1.15 !important;
  }
  /* Fixed overlay must exactly occupy the already reserved sidebar rail. */
  body.table-page.table-layout-l9:not(:has(.game-stage.playing)) #sb-chat-drawer,
  body.table-page.table-layout-l9:not(:has(.game-stage.playing)):has(#sb-chat-drawer.open) #sb-chat-drawer.sb-trio-table-drawer {
    width: var(--sb254-rail-width, clamp(395px, 27.5vw, 460px)) !important;
    max-width: none !important;
    right: max(32px, calc((100vw - 1740px) / 2)) !important;
    top: 67px !important;
    height: calc(100dvh - 79px) !important;
    border: 1px solid rgba(255,255,255,.1) !important;
    border-radius: 15px !important;
  }
  /* Keep the conversation inside the drawer, never offset it independently. */
  body.table-page.table-layout-l9:not(:has(.game-stage.playing))
    #sb-chat-drawer #sb-chat-conversation {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
  }
  body.table-page.table-layout-l9:not(:has(.game-stage.playing))
    .sb-notifications-drawer {
    width: var(--sb254-rail-width, clamp(395px, 27.5vw, 460px)) !important;
    right: max(32px, calc((100vw - 1740px) / 2)) !important;
  }
}
/* Exact Lobby breakpoint: at <=1480px the approved chat rail is 365px. */
@media (min-width: 1200px) and (max-width: 1480px) {
  body.table-page.table-layout-l9:not(:has(.game-stage.playing)) {
    --sb254-rail-width: 365px;
    --sb254-column-gap: 14px;
  }
}
/* At narrower desktop widths the table already uses one column; never
   let the STEP853 chat drawer change its dimensions when opened. */
@media (min-width: 1000px) and (max-width: 1199px) {
  body.table-page.table-layout-l9:not(:has(.game-stage.playing)):has(#sb-chat-drawer.open) .table-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
/* On wide desktops the Lobby is capped at 1740px, but the profile remains
   anchored to the viewport. Align its right edge with the Lobby chat panel.
   Does not move the centered page navigation or any part of the game. */
@media (min-width: 1805px) {
  body.sb-photo892 .topbar .profile-menu {
    margin-right: calc((100vw - 1740px) / 2 - 34px) !important;
  }
}
