/* Desktop Poker shares its page with two chat/sidebar areas. Its fixed frame
   supplies both dimensions; native-poker-layout fits cards inside that space. */
@media (min-width: 1181px) {
  body.native-game-active.has-unity-embed.game-mode-pokerduel {
    /* Use the shared dashboard height budget without its 560px minimum:
       a resizable card table must also fit a shorter browser content area. */
    --unityH: clamp(0px, calc(100dvh - var(--topbarH) - 84px), 800px) !important;
  }
  .native-game-shell.mode-pokerduel .worker-spectate-content-main {
    container-type: inline-size;
    container-name: poker-workspace;
  }
  .native-game-shell.mode-pokerduel .native-poker-board {
    --poker-desktop-layout: 1;
    container-name: poker-table;
    align-self: start;
    height: max-content;
    max-height: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(32px, auto) auto auto auto;
  }
  .native-game-shell.mode-pokerduel .worker-spectate-board-wrap,
  .native-game-shell.mode-pokerduel [data-native-board-slot] {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    align-self: stretch;
  }
  .native-game-shell.mode-pokerduel [data-native-board-slot] {
    /* At extreme heights preserve readable cards and make the whole table
       reachable through one scroll surface instead of clipping its contents. */
    overflow: auto;
    scrollbar-gutter: stable;
    align-items: start;
    grid-template-rows: max-content;
  }
  .native-game-shell.mode-pokerduel .native-poker-hand {
    grid-template-columns: repeat(5, minmax(0, var(--native-poker-card-width)));
  }
  .native-poker-score-player > strong { line-height: 1.35; }

  /* Other hosts, including Clan, retain their existing desktop arrangement. */
  @container poker-workspace (max-width: 900px) {
    body:not(.home-route-page) .native-game-shell.mode-pokerduel .native-game-main {
      grid-template-columns: minmax(0, 1fr) minmax(200px, 28%);
      gap: 12px;
    }
  }

  /* Follow the Home panel's compact composition. A second 200px sidebar
     leaves too little table space when the player widens Global chat. */
  @container rookx-game (max-width: 900px) {
    body.native-game-active .native-game-shell.mode-pokerduel .native-game-main {
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: minmax(0, 1fr) auto;
      overflow: hidden;
    }
    body.native-game-active .native-game-shell.mode-pokerduel .native-game-main [data-native-board-slot] {
      overflow: auto;
    }
    body.native-game-active .native-game-shell.mode-pokerduel .native-poker-board {
      max-height: none;
      overflow: visible;
    }
  }

  @container poker-table (max-width: 600px) {
    .native-poker-hand {
      gap: 6px;
    }
    .native-poker-hand > .native-poker-card { width: 100%; min-width: 0; }
    .native-poker-score { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
    .native-poker-score-pips { display: none; }
    .native-poker-score-player { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; max-width: 100%; }
    .native-poker-score-player.opponent { justify-content: end; }
    .native-poker-round-label { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; min-width: 0; }
    .native-poker-score-player.opponent > span:first-child { grid-column: 2; }
    .native-poker-score-player.opponent > strong { grid-column: 1; }
    .native-poker-table-center { height: auto; min-height: 0; }
    .native-poker-dealer-row {
      grid-template-columns: auto minmax(0, 1fr) auto;
      grid-template-rows: auto;
      min-height: 0;
      gap: 8px;
    }
    .native-poker-table-line { display: none; }
    .native-poker-shared-cards { grid-column: 3; grid-row: 1; justify-self: end; }
    .native-poker-dealer-unit { grid-column: 1; grid-row: 1; justify-self: start; }
    .native-poker-center-console {
      grid-column: 2;
      grid-row: 1;
      grid-template-columns: minmax(0, 1fr);
      height: auto;
      min-height: 58px;
    }
    .native-poker-center-console:has(.native-poker-controls) .native-poker-phase-copy { display: none; }
    .native-poker-controls { gap: 8px; }
    .native-poker-center-action .native-poker-control-buttons { width: auto; }
    .native-poker-control-buttons .btn { min-height: 44px; }
  }
  @container poker-table (max-width: 460px) {
    .native-poker-dealer-row { grid-template-columns: 1fr auto; grid-template-rows: auto auto; }
    .native-poker-shared-cards { grid-column: 2; }
    .native-poker-center-console { grid-column: 1 / -1; grid-row: 2; }
  }
}
