/* BackgammonX v1.0.0 — 24-v1-board-first.css (new in v1.0.0)
   Owns: the BOARD-FIRST page of v1.0.0 in the arrangement of the other X-family pages (js/39 and js/38 are the JS halves):
     • the board row — the board, with the two pop-out side tabs beside it ("Players / Seats", "Pip Race"); a closed tab is a
       46px vertical strip, an open one a panel; on a phone the tabs become full-width bars under the board;
     • the compact console under the board — the Turn & Dice panel (the turn, the dice, the status line and ROLL; Undo Last
       Step, Combined Moves, the dice still to play and New Game) and the saves row as one slim line under it;
     • the grouped page — the four tiles directly under the play area, the panel of the open tile, and the section chosen from
       it (a folded section is not shown at all, so the long list of section bars is gone; an open one is shown as before);
     • the "Choose Your Table" dialog, the Board View and Autosave & Recovery sections, and the footer's Discover link;
     • the page tabs on a phone, tightened so the seven tabs of v1.0.0 keep the one row the six-word tabs of v0.3.06 had.

   PRESENTATION ONLY and override-only: it sits after css/01–23 and edits none of them. Like css/22 and css/23 it sets no size,
   position, transform or z-index on the board frame, the checkers, the rails, the hit targets or the dice layers: it sizes the
   board COLUMN (the same thing css/16 and css/23 did) and the board's own proportions still come from the play-area shell.
   Its values are the X-family ones already in css/16 and css/22 (--x-* tokens) and the measured side-tab values of the
   reference page, so both appearances and every colourway follow. */

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

/* ═══ 1. the play area: the board row, then the console ════════════════════════════════════════════════════════════
   --bgx-v1-chrome is everything above the board (the control bar and the masthead) plus the console, so a whole turn can be
   played without scrolling on a laptop: the board's default size is the screen height less that (never below 520px, never
   above 1100px). A size picked with Board size always wins. */
body.bgx-v1-board-first .bgx-play-body {
  --bgx-v1-chrome: 296px;
  --bgx-v1-fit: clamp(520px, calc(100vh - var(--bgx-v1-chrome)), 1100px);
  --bgx-v1-side: 46px;
  --bgx-v1-gap: 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
@supports (height: 100dvh) {
  body.bgx-v1-board-first .bgx-play-body { --bgx-v1-fit: clamp(520px, calc(100dvh - var(--bgx-v1-chrome)), 1100px); }
}
body.bgx-v1-board-first .bgx-play-body > .bgx-side-column[hidden] { display: none; }
.bgx-board-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: var(--bgx-v1-gap, 14px);
  width: 100%;
  min-width: 0;
}
.bgx-board-row.bgx-board-row--side-open { --bgx-v1-side: clamp(220px, 22vw, 290px); }
.bgx-board-row > .board-column {
  flex: 0 1 auto;
  min-width: 0;
  width: min(var(--bgx-v1-fit), calc(100% - var(--bgx-v1-side, 46px) - var(--bgx-v1-gap, 14px)));
  max-width: none;
  margin: 0;
}
body[data-bgx-board-sized="on"] .bgx-board-row > .board-column {
  width: min(var(--bgx-board-width, 2400px), calc(100% - var(--bgx-v1-side, 46px) - var(--bgx-v1-gap, 14px)));
}

/* ═══ 2. the side tabs (the reference page's Players / Seats and Pip Race) ═══════════════════════════════════════════
   The column is exactly as tall as the board beside it (its own contents never set its height), so opening a tab never pushes
   the play controls under the board down the page. Both toggles always show; an open tab longer than the board scrolls inside
   its own body. Its width is the width the board column leaves for it (--bgx-v1-side). */
.bgx-sidetabs {
  flex: 0 0 auto;
  align-self: stretch;
  box-sizing: border-box;
  width: var(--bgx-v1-side, 46px);
  contain: size;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.bgx-sidetab {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 0;
  width: clamp(220px, 22vw, 290px);
  max-width: 100%;
  border: 1px solid #6b5333;
  border-radius: 12px;
  background: linear-gradient(180deg, #191d29, #121621);
  color: #ecdcb8;
  overflow: hidden;
  transition: width 0.2s ease;
}
.bgx-sidetab.bgx-sidetab-closed { width: 46px; flex-shrink: 0; }
.bgx-sidetab.bgx-sidetab--pips { flex-shrink: 0; }           /* short and fixed: Players / Seats is the one that scrolls */
.bgx-sidetab-toggle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #4d3d27;
  border-radius: 0;
  background: #2a1f15;
  color: #e8c47b;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-align: left;
  cursor: pointer;
}
.bgx-sidetab-toggle:hover { color: #ffe2a4; background: #33261a; }
.bgx-sidetab-toggle:focus-visible { outline: 3px solid #f6cd65; outline-offset: -3px; }
.bgx-sidetab-closed .bgx-sidetab-toggle {
  flex-direction: column;
  justify-content: flex-start;
  min-height: 220px;
  border-bottom: 0;
  padding: 12px 0;
}
.bgx-sidetab--pips.bgx-sidetab-closed .bgx-sidetab-toggle { min-height: 132px; }
.bgx-sidetab-closed .bgx-sidetab-label { writing-mode: vertical-rl; text-orientation: mixed; }
.bgx-sidetab-arrow { font-size: 12px; }
.bgx-sidetab-body { min-height: 0; overflow-y: auto; padding: 10px; }
.bgx-sidetab-body[hidden] { display: none; }

/* the Players panel inside Players / Seats: the tab's own heading names it, and the two cards stack */
#bgx-seats-body .bgx-players-panel { margin: 0; padding: 0; border: 0; background: none; box-shadow: none; max-width: none; width: 100%; }
#bgx-seats-body .bgx-players-head { padding: 0 0 8px; border: 0; background: none; }
#bgx-seats-body .bgx-players-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#bgx-seats-body .bgx-players-body { display: flex; flex-direction: column; gap: 8px; }
#bgx-seats-body .bgx-player-card { margin: 0; }

/* the Pip Race callout */
.bgx-pip-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name num" "track track";
  gap: 4px 8px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(232, 196, 123, 0.12);
}
.bgx-pip-name { grid-area: name; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 13px; letter-spacing: 0.03em; color: #f4ead2; }
.bgx-pip-row[data-current="true"] .bgx-pip-name::before { content: "▸ "; color: #e8c47b; }
.bgx-pip-num { grid-area: num; font: 700 15px/1 "Courier New", monospace; color: #f4ead2; }
.bgx-pip-row[data-leader="true"] .bgx-pip-num { color: #ffe08a; }
.bgx-pip-track { grid-area: track; display: block; height: 6px; border-radius: 3px; background: #2b2b31; overflow: hidden; }
.bgx-pip-fill { display: block; width: 0; height: 100%; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); transition: width 0.25s ease; }
.bgx-pip-row[data-side="P1"] .bgx-pip-fill { background: var(--bgx-p1-mid, #4a90d9); }
.bgx-pip-row[data-side="P2"] .bgx-pip-fill { background: var(--bgx-p2-mid, #c0392b); }
.bgx-pip-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 8px; font-size: 12px; color: #b9ab8c; }
.bgx-pip-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.bgx-pip-more {
  min-height: 40px;
  padding: 4px 12px;
  border: 1px solid #705434;
  border-radius: 8px;
  background: #251b16;
  color: #dec092;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.bgx-pip-more:hover { border-color: #d6ad62; color: #ffe2a4; }
.bgx-pip-more:focus-visible { outline: 3px solid #f6cd65; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .bgx-sidetab, .bgx-pip-fill { transition: none; } }

html[data-appearance="light"] .bgx-sidetab { border-color: var(--x-line); background: var(--x-panel); color: var(--x-text); }
html[data-appearance="light"] .bgx-sidetab-toggle { background: var(--x-header-bg); color: var(--x-header-text); border-bottom-color: var(--x-header-border); }
html[data-appearance="light"] .bgx-pip-name,
html[data-appearance="light"] .bgx-pip-num { color: var(--x-text); }
html[data-appearance="light"] .bgx-pip-row[data-leader="true"] .bgx-pip-num { color: var(--x-gold-bright); }
html[data-appearance="light"] .bgx-pip-track { background: var(--x-panel-3); }
html[data-appearance="light"] .bgx-pip-foot { color: var(--x-text-faint); }
html[data-appearance="light"] .bgx-pip-more { background: var(--x-panel-2); color: var(--x-gold-bright); border-color: var(--x-line); }

/* a phone: the board takes the whole width and the two tabs are bars under it */
@media (max-width: 699px) {
  .bgx-board-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .bgx-board-row > .board-column,
  body[data-bgx-board-sized="on"] .bgx-board-row > .board-column { width: 100%; }
  .bgx-sidetabs { align-self: auto; width: 100%; contain: none; overflow: visible; align-items: stretch; }
  .bgx-sidetabs.bgx-sidetabs--below { margin-top: 2px; }
  .bgx-sidetab,
  .bgx-sidetab.bgx-sidetab-closed { width: 100%; }
  .bgx-sidetab-closed .bgx-sidetab-toggle,
  .bgx-sidetab--pips.bgx-sidetab-closed .bgx-sidetab-toggle { flex-direction: row; min-height: 46px; padding: 10px 12px; }
  .bgx-sidetab-closed .bgx-sidetab-label { writing-mode: horizontal-tb; }
}

/* ═══ 3. the compact console under the board ═══════════════════════════════════════════════════════════════════════
   The Turn & Dice panel (css/23 arranges its two rows) and, under it, the saves row as ONE slim line: Save Game…, Resume /
   Load… and Clear Autosave together, with the autosave line beside them. The board-view group is no longer here (Board View). */
body.bgx-v1-board-first .bgx-console {
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
  width: min(100%, max(720px, calc(var(--bgx-v1-fit) + var(--bgx-v1-side, 46px) + var(--bgx-v1-gap, 14px))));
  margin: 0 auto;
}
body.bgx-v1-board-first[data-bgx-board-sized="on"] .bgx-console {
  width: min(100%, max(720px, calc(var(--bgx-board-width, 2400px) + var(--bgx-v1-side, 46px) + var(--bgx-v1-gap, 14px))));
}
body.bgx-v1-board-first .bgx-console > .dtf-hud { width: 100%; max-width: none; }
body.bgx-v1-board-first .bgx-console > .bgx-saves-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 6px 10px;
  box-sizing: border-box;
}
body.bgx-v1-board-first .bgx-console > .bgx-saves-row .bgx-saves-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
body.bgx-v1-board-first .bgx-console > .bgx-saves-row .bgx-saves-status { flex: 1 1 200px; margin: 0; font-size: 12.5px; line-height: 1.4; }

/* ═══ 4. the grouped page: the play area, the four tiles, the open panel, the one section chosen ════════════════════ */
body.bgx-v1-grouped #bgx-section-stack { display: flex; flex-direction: column; }
body.bgx-v1-grouped #bgx-section-stack > .bgx-stack-section[data-bgx-section="board"] { order: -2; }
body.bgx-v1-grouped #bgx-section-stack > .bgx-groups,
body.bgx-v1-grouped #bgx-section-stack > .bgx-tilepanel { order: -1; }
body.bgx-v1-grouped #bgx-section-stack > .bgx-stack-section.bgx-stack-closed:not([data-bgx-section="board"]) { display: none; }
body.bgx-v1-grouped #bgx-section-stack > .bgx-stack-toolbar { display: none; }
body.bgx-v1-grouped #bgx-section-stack > .bgx-stack-section > .bgx-stack-moves { display: none; }
body.bgx-v1-grouped #bgx-section-stack > .bgx-stack-section:not(.bgx-stack-closed):not([data-bgx-section="board"]) { margin-top: 14px; scroll-margin-top: 14px; }
body.bgx-v1-grouped #bgx-section-stack > .bgx-tilepanel { width: 100%; box-sizing: border-box; }
.bgx-groups { width: 100%; scroll-margin-top: 14px; }
.bgx-groups > .bgx-tiles { width: 100%; margin-top: 18px; }
.bgx-choice[aria-pressed="true"] { color: #10130e; background: #e4c17a; border-color: #e4c17a; }
.bgx-choice--link { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-decoration: none; box-sizing: border-box; }
.bgx-choice--link:focus-visible { outline: 3px solid #f6d88f; outline-offset: 4px; }
.bgx-choice__arrow { font-size: 13px; opacity: 0.85; }
html[data-appearance="light"] .bgx-tilepanel { background: var(--x-panel); border-color: var(--x-line); color: var(--x-text); }
html[data-appearance="light"] .bgx-tilepanel h2 { color: var(--x-text); }
html[data-appearance="light"] .bgx-choice { background: var(--x-panel-2); color: var(--x-text); border-color: var(--x-line); }
html[data-appearance="light"] .bgx-choice[aria-pressed="true"] { background: var(--x-gold); border-color: var(--x-gold); color: #fff; }
html[data-appearance="light"] .bgx-tilepanel__status { color: var(--x-text-faint); }

/* the two sections built in v1.0.0 from moved controls */
.bgx-boardview-note,
.bgx-recovery-note { margin: 0 0 10px; color: var(--x-text-dim); font-size: 14px; line-height: 1.5; }
.bgx-stack-body.bgx-view-group { border: 0; box-shadow: none; background: none; padding: 12px 16px 16px; }
.bgx-recovery { padding: 12px 16px 16px; }
.bgx-recovery-keys { display: flex; flex-wrap: wrap; gap: 8px; }
.bgx-recovery-keys > .bgx-btn { min-height: 44px; }

/* ═══ 5. Choose Your Table ═══════════════════════════════════════════════════════════════════════════════════════ */
.bgx-tables-dialog .bgx-table-intro,
.bgx-tables-dialog .bgx-table-note { margin: 0; font-size: 14px; line-height: 1.5; color: var(--x-text-dim); }
.bgx-table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 14px 0; }
.bgx-table-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--x-line);
  border-radius: var(--x-radius);
  background: var(--x-panel-2);
  color: var(--x-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.bgx-table-card:hover { border-color: var(--x-gold); }
.bgx-table-card:focus-visible { outline: 3px solid var(--x-focus); outline-offset: 2px; }
.bgx-table-card[aria-pressed="true"] { border-color: var(--x-gold); box-shadow: 0 0 0 2px var(--x-gold-dim); }
.bgx-table-card:disabled { opacity: 0.6; cursor: progress; }
.bgx-table-pic { display: block; aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; background: #0a0e1a; }
.bgx-table-img { display: block; width: 100%; height: 100%; object-fit: contain; }
.bgx-table-name { font-weight: 700; font-size: 14px; line-height: 1.3; }
.bgx-table-kind { font-size: 12px; color: var(--x-text-faint); }
.bgx-table-card[aria-pressed="true"] .bgx-table-kind::after { content: " · on the table"; color: var(--x-gold-bright); }
.bgx-table-status { min-height: 1.5em; margin: 0; font-size: 13.5px; color: var(--x-gold-bright); }

/* ═══ 6. the footer's link to the sister game ═══════════════════════════════════════════════════════════════════ */
.bgx-footer-family { display: flex; justify-content: center; margin: 14px 0 0; }
.bgx-discover {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid rgba(216, 180, 106, 0.35);
  border-radius: 22px;
  color: var(--x-gold-bright);
  text-decoration: none;
  font: 14px/1.4 var(--x-font-system);
}
.bgx-discover:hover { background: rgba(216, 180, 106, 0.12); border-color: var(--x-gold); }
.bgx-discover:focus-visible { outline: 3px solid #80d8ff; outline-offset: 2px; }
.bgx-discover__name { font: italic 600 15px/1.4 var(--x-font-serif); letter-spacing: 0.02em; }
.bgx-discover__sub { color: var(--x-text-dim); }
.bgx-discover__sub::before { content: "— "; }
.bgx-discover__arrow { font-size: 12px; opacity: 0.9; }
html[data-appearance="light"] .bgx-discover { border-color: var(--x-gold-dim); }
html[data-appearance="light"] .bgx-discover:focus-visible { outline-color: #0b4f8a; }

/* ═══ 7. the page tabs on a phone ═════════════════════════════════════════════════════════════════════════════════
   v1.0.0's tabs (Play, Players, Boards, Settings, Insights, My Progress, Help) are longer than v0.3.06's, and at css/22's 13px
   with a 14px gap they wrapped to a second row on a 390px phone, which pushed Undo Last Step below the first screen. 12px with
   an 8px gap keeps one row there (15px to spare, measured), so the board and the console's first rows sit where v0.3.06 put
   them at 390, 375 and 360px (measured on both builds). The labels, the 44px touch height and the colours are css/22's. */
@media (max-width: 450px) {
  body.bgx-v22-layout .x-header-bar .bgx-tabbar-track { gap: 0 8px; }
  body.bgx-v22-layout .x-header-bar .bgx-tab { font-size: 12px; }
}
