/* BackgammonX v0.3.06 — 23-x-page-layout.css (new in v0.3.06)
   Owns: the PAGE COMPOSITION in the style of the other X-family pages. The board comes first, straight after the masthead; the
   play console (whose turn, the dice, ROLL, Undo Last Step, Combined Moves, New Game and the status line) sits directly under it;
   the saves row and the board-view controls (Rotate Board, Auto-Rotate, Board size) are grouped beneath the console; the Players
   panel, with each player's pip count, is a compact side panel beside the board where the screen has room for it, and stacks
   under the console on a tablet held upright and on a phone. The "Make this page yours" toolbar follows the play area.

   WHERE THE PARTS COME FROM. Nothing here is built by this file. js/28 composes .bgx-play-body out of the EXISTING nodes (moved,
   never cloned): .board-column (the board stage), .bgx-side-column (the Players panel, which js/32 appends) and .bgx-console
   (the Turn & Dice HUD, then the saves row that js/31 savesRow() inserts and js/34 fills, then .bgx-view-group with the
   Rotate Board / Auto-Rotate row and the Board size row). This file decides where each part sits and how it is spaced.

   PRESENTATION ONLY and override-only: it sits after css/01–22 and edits none of them. It sets no size, position, transform or
   z-index on the board frame, the checkers, the rails, the hit targets or the dice layers (the inherited tests read those in
   css/02–13); it places the existing columns and sizes the board COLUMN exactly as css/16 did (the board's own proportions
   still come from the play-area shell). The values for spacing, panel look and keys are the X-family ones already in css/16 and
   css/22 (--x-* tokens), so both appearances and every colourway follow. */

:root { --bgx-css-23: 1; }

/* ═══ the play area comes first ═══════════════════════════════════════
   Board & Play is the play area, not a section to be folded: its heading bar and its move keys are not shown (the section keeps its
   label for assistive technology and for the page tabs). "Reset layout" brings the board-first order back after a section was moved. */
.bgx-stack-section[data-bgx-section="board"] > .bgx-stack-heading,
.bgx-stack-section[data-bgx-section="board"] > .bgx-stack-moves { display: none; }
.bgx-stack-section[data-bgx-section="board"] > .bgx-stack-body { padding: 4px 0 0; }
#bgx-section-stack > .bgx-stack-toolbar { margin: 0 auto; }

/* ═══ Board & Play: the board, the console under it, the supporting panels ═══════════════════════════════════════════
   One column by default (a phone, a tablet held upright): board, console, then the side panels. On a wide landscape screen the
   side panels sit beside the board and the console spans the width of both. --x-chrome is everything above the board (the control
   bar and the masthead) plus the console's first rows, so a turn can be played without scrolling on a laptop: the board's
   default size is the screen height less that, never below 520px (a size picked with Board size always wins). */
.bgx-play-body {
  --x-aside: 300px;
  --x-aside-min: 260px;
  --x-gap: 16px;
  --x-chrome: 304px;
  --x-fit: clamp(520px, calc(100vh - var(--x-chrome)), 1000px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "board" "console" "side";
  row-gap: 12px;
  align-items: start;
  justify-content: stretch;
}
@supports (height: 100dvh) {
  .bgx-play-body { --x-fit: clamp(520px, calc(100dvh - var(--x-chrome)), 1000px); }
}
.bgx-play-body > .board-column { grid-area: board; }
.bgx-play-body > .bgx-console { grid-area: console; }
.bgx-play-body > .bgx-side-column { grid-area: side; margin: 0; }

@media (min-width: 1000px) and (min-aspect-ratio: 5/4) {
  .bgx-play-body {
    grid-template-columns:
      minmax(0, min(var(--x-fit), calc(100% - var(--x-aside-min) - var(--x-gap))))
      minmax(var(--x-aside-min), var(--x-aside));
    grid-template-areas: "board side" "console console";
    column-gap: var(--x-gap);
    justify-content: center;
  }
  body[data-bgx-board-sized="on"] .bgx-play-body {
    grid-template-columns:
      minmax(0, min(var(--bgx-board-width, 2400px), calc(100% - var(--x-aside-min) - var(--x-gap))))
      minmax(var(--x-aside-min), var(--x-aside));
  }
}

/* the supporting panels (the Players panel): a compact column beside the board on a wide landscape screen; under the console
   otherwise, where the two player cards sit side by side once there is room for two */
.bgx-side-column { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bgx-side-column > .bgx-players-panel { width: 100%; max-width: none; margin: 0; }
@media (min-width: 560px) and (max-width: 1023px), (min-width: 560px) and (max-aspect-ratio: 5/4) {
  .bgx-side-column .bgx-players-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
/* a tablet held upright: the console and the side panel follow the board's width (as the HUD always did), but never narrower than
   640px, which is what the two rows of keys need */
@media (max-width: 1023px) and (min-width: 640px) {
  .bgx-play-body > .bgx-side-column,
  .bgx-play-body > .bgx-console { width: 100%; max-width: max(min(var(--bgx-board-width, 2400px), 760px), 640px); margin-left: auto; margin-right: auto; }
}

/* ═══ the console: the HUD first, then the saves row and the board-view group beneath it ═════════════════════════════ */
.bgx-console {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 12px;
  min-width: 0;
}
.bgx-console > .dtf-hud { grid-column: 1 / -1; width: 100%; max-width: none; margin: 0; }
.bgx-console > .bgx-saves-row { grid-column: 1; width: auto; max-width: none; margin: 0; }
.bgx-console > .bgx-view-group { grid-column: 2; }
@media (max-width: 699px) {
  .bgx-console { grid-template-columns: minmax(0, 1fr); }
  .bgx-console > .bgx-saves-row,
  .bgx-console > .bgx-view-group { grid-column: 1; }
}

/* The HUD's own rows stay in the DOM as they were. Here the two key rows only stop being boxes (display: contents) so their
   children line up as the console wants them, in the order a turn is played:
     - a phone (under 700px): a two-column grid — the status line; whose turn and the dice; ROLL | New Game; Undo Last Step |
       Combined Moves; the dice still to play;
     - 700px and over (a tablet held upright, a laptop): two rows. The first holds whose turn it is, the rolled dice, the status
       line as a recessed readout, and ROLL at the end; the second holds Undo Last Step, Combined Moves, the dice still to play, and
       New Game at the far end. A result line goes above them and the opening-roll note below. The rows are the same at every
       width, so the console never reshuffles when the dice appear. */
.bgx-console > .dtf-hud > .dtf-hud-row-primary,
.bgx-console > .dtf-hud > .bgx-x-controls { display: contents; }
.bgx-console > .dtf-hud > .dtf-opening-attribution,
.bgx-console > .dtf-hud > .dtf-result,
.bgx-console > .dtf-hud > .dtf-test-mode-note { margin: 0; }
.bgx-console > .dtf-hud > .dtf-status { margin: 0; }
.bgx-console > .dtf-hud > .dtf-status:empty { display: none; }

@media (max-width: 699px) {
  .bgx-console > .dtf-hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; align-items: center; }
  .bgx-console > .dtf-hud > .dtf-status,
  .bgx-console > .dtf-hud > .dtf-opening-attribution,
  .bgx-console > .dtf-hud > .dtf-result,
  .bgx-console > .dtf-hud > .dtf-test-mode-note,
  .bgx-console > .dtf-hud .bgx-dice-left,
  .bgx-console > .dtf-hud .bgx-route-chips { grid-column: 1 / -1; }
  .bgx-console > .dtf-hud .dtf-active-side-label { display: none; }
  .bgx-console > .dtf-hud .dtf-active-side { grid-column: span 2; margin-right: 0; }
  .bgx-console > .dtf-hud .dtf-dice-stage { grid-column: span 2; justify-self: end; }
  .bgx-console > .dtf-hud .dtf-roll-btn,
  .bgx-console > .dtf-hud .dtf-new-game-btn,
  .bgx-console > .dtf-hud .bgx-undo-btn,
  .bgx-console > .dtf-hud .bgx-combo-toggle { grid-column: span 2; width: 100%; min-width: 0; margin: 0; }
  .bgx-console > .dtf-hud > .dtf-result { order: -2; }
  .bgx-console > .dtf-hud > .dtf-status { order: -1; }
  .bgx-console > .dtf-hud .dtf-active-side { order: 2; }
  .bgx-console > .dtf-hud .dtf-dice-stage { order: 3; }
  .bgx-console > .dtf-hud .dtf-roll-btn { order: 4; }
  .bgx-console > .dtf-hud .dtf-new-game-btn { order: 5; }
  .bgx-console > .dtf-hud .bgx-undo-btn { order: 6; }
  .bgx-console > .dtf-hud .bgx-combo-toggle { order: 7; }
  .bgx-console > .dtf-hud .bgx-dice-left { order: 8; }
  .bgx-console > .dtf-hud .bgx-route-chips { order: 9; }
  .bgx-console > .dtf-hud > .dtf-opening-attribution { order: 10; }
  .bgx-console > .dtf-hud > .dtf-test-mode-note { order: 11; }
}
@media (min-width: 700px) {
  .bgx-console > .dtf-hud { display: flex; flex-flow: row wrap; align-items: center; gap: 8px 12px; }
  .bgx-console > .dtf-hud::after { content: ""; order: 6; flex: 1 1 100%; height: 0; margin-top: -8px; }     /* the line between the two rows of keys */
  .bgx-console > .dtf-hud > .dtf-result { order: -1; flex: 1 1 100%; }
  .bgx-console > .dtf-hud .dtf-active-side-label { order: 1; }
  .bgx-console > .dtf-hud .dtf-active-side { order: 2; }     /* its own right margin (css/09) keeps the dice's launch marker clear of the name */
  .bgx-console > .dtf-hud .dtf-dice-stage { order: 3; }
  .bgx-console > .dtf-hud > .dtf-status { order: 4; flex: 1 1 150px; min-width: 0; }
  .bgx-console > .dtf-hud .dtf-roll-btn { order: 5; margin: 0; min-width: 130px; }
  .bgx-console > .dtf-hud .bgx-undo-btn { order: 7; }
  .bgx-console > .dtf-hud .bgx-combo-toggle { order: 8; }
  .bgx-console > .dtf-hud .bgx-dice-left { order: 9; }
  .bgx-console > .dtf-hud .dtf-new-game-btn { order: 10; margin: 0 0 0 auto; min-width: 100px; }
  .bgx-console > .dtf-hud .bgx-route-chips { order: 11; flex: 1 1 100%; }
  .bgx-console > .dtf-hud > .dtf-opening-attribution { order: 12; flex: 1 1 100%; }
  .bgx-console > .dtf-hud > .dtf-test-mode-note { order: 13; flex: 1 1 100%; }
  /* the status line is a recessed readout in the first row, level with the keys */
  html[data-appearance="dark"] .bgx-console > .dtf-hud > .dtf-status {
    min-height: 44px;
    padding: 6px 12px;
    border: 1px solid var(--x-line);
    border-radius: var(--x-radius-sm);
    background: var(--x-panel-2);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
    font-size: 13.5px;
  }
  html[data-appearance="light"] .bgx-console > .dtf-hud > .dtf-status { min-height: 44px; padding: 6px 12px; font-size: 13.5px; }
}

/* ═══ saves row and board-view group: two panels side by side beneath the console ════════════════════════════════════ */
.bgx-view-group {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px 10px;
  border: 1px solid var(--x-line-soft);
  border-radius: var(--x-radius);
  background-color: var(--x-panel);
  color: var(--text);
  box-shadow: var(--x-raised);
}
html[data-appearance="dark"] .bgx-view-group { background-image: linear-gradient(180deg, var(--x-panel-glow), rgba(0, 0, 0, 0) 48px); border-color: rgba(255, 255, 255, 0.08); }
/* the two rows lose the HUD's own panel edges: the group is the panel */
.bgx-view-group > .dtf-hud-row-presentation { margin: 0; padding: 0; border-top: 0; gap: 8px; }
.bgx-view-group > .bgx-board-size-row {
  margin: 0;
  padding: 8px 0 0;
  border: 0;
  border-top: 1px solid var(--x-line-soft);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
/* the rotation keys keep the look they had in the HUD (css/16 and css/22 styled them as the HUD's descendants) */
.bgx-view-group .x-button.bgx-rotate-btn,
.bgx-view-group .x-button.bgx-auto-rotate-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--x-radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
html[data-appearance="dark"] .bgx-view-group .x-button.bgx-rotate-btn,
html[data-appearance="dark"] .bgx-view-group .x-button.bgx-auto-rotate-btn {
  background-color: var(--x-panel-2);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0));
  box-shadow: var(--x-key-shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s, color 0.15s;
}
html[data-appearance="dark"] .bgx-view-group .x-button.bgx-rotate-btn { color: var(--x-blue); border-color: var(--x-blue); }
html[data-appearance="dark"] .bgx-view-group .x-button.bgx-auto-rotate-btn { color: var(--x-text-dim); }
html[data-appearance="dark"] .bgx-view-group .x-button.bgx-auto-rotate-btn[aria-pressed="true"] {
  color: var(--x-gold-bright);
  background-color: rgba(216, 180, 106, 0.12);
  border-color: rgba(216, 180, 106, 0.7);
}
html[data-appearance="dark"] .bgx-view-group .x-button.bgx-rotate-btn:hover:not(:disabled) { background-color: var(--x-blue); color: #0a121a; box-shadow: var(--x-key-shadow-hover); }
html[data-appearance="dark"] .bgx-view-group .x-button.bgx-auto-rotate-btn:hover:not(:disabled) { background-color: var(--x-blue); color: #0a121a; border-color: var(--x-blue); box-shadow: var(--x-key-shadow-hover); }
html[data-appearance="dark"] .bgx-view-group .x-button.bgx-rotate-btn:active:not(:disabled),
html[data-appearance="dark"] .bgx-view-group .x-button.bgx-auto-rotate-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: var(--x-key-shadow-active); }
@media (max-width: 639px) {
  .bgx-view-group .x-button.bgx-rotate-btn,
  .bgx-view-group .x-button.bgx-auto-rotate-btn { flex: 1 1 40%; padding: 0 8px; font-size: 12px; }
}
