/* Fog of War on wide screens (iPad, the Duo's inner screen). Nov 26, 2026. docs/ipad-duo/GAME-WORKER-GUIDE.md.
   Linked only in --wide builds, after the theme, the generated ui/ui.css and the skin's touch.css, behind the gate's media query;
   every rule starts with html.tc-wide, so a phone never applies a line. The tile size and the grid's shape come from fitWide() in
   index.html (the shape is locked for the whole board, so a card never moves); these rules only place and size the regions.
   The generated ui.css pins sizes with two-id :not(#\9#\9) selectors and the page / Magic touch pass uses !important, so the rules
   that must win carry :not(#\9#\9#\9) (three more ids) and, where the rule they beat is !important, !important too.

   tall  (iPad portrait):   the phone stack, wider (game.json "column") and taller strips; the grid takes all the spare height;
                            the read-outs and the buttons stay no wider than 640 px, centred.
   wide  (iPad landscape):  the grid on the left at full height; a side rail on the thumb side: the name, Leave / Help / Menu,
                            the three read-outs, the best line, and at the bottom New game (52 tall).
   Since the unified frame (Nov 29, 2026) the top bar is the frame's .tcf-bar, New game is its bottom bar (TCFrame.actions in
   .controls) and the board size is a Menu choice: the old Games / ? / ♪ and size-plate rules are gone.
   fold  (Duo inner, 890x626, no hinge reported): the same as wide with a narrower rail.
   fold + a real hinge (html.tcw-hinge): the grid on one half, the rail on the other; nothing crosses the hinge.
   Sheets: How to play and the confirm sheet centred; the win sheet comes up over the rail (wide, fold) so the cleared board stays
   in view; in portrait every sheet is centred and wider than a phone's. */

/* ---------- every wide mode ---------- */
html.tc-wide { --fw-rail: clamp(296px, 26vw, 360px); --fw-strip: 640px; }
html.tc-wide.tcw-fold { --fw-rail: 268px; }
html.tc-wide #app #gridWrap:not(#\9#\9#\9) { min-width: 0; min-height: 0; }
/* the coin art at whole device pixels (size from fitWide(); without the variable the page's own 74% / 60%) */
html.tc-wide #grid .face.front svg:not(#\9#\9#\9) { width: var(--fw-svg, 74%); height: var(--fw-svg, 74%); }
html.tc-wide #grid.showname .face.front svg:not(#\9#\9#\9) { width: var(--fw-svg, 60%); height: var(--fw-svg, 60%); }
/* the frame's bars: no reaching out over the phone's 18 px side padding (the regions below place them) */
html.tc-wide #app > .tcf-bar:not(#\9#\9#\9), html.tc-wide #app .controls:not(#\9#\9#\9) { margin-left: 0; margin-right: 0; }
html.tc-wide #app .hud:not(#\9#\9#\9) { height: 64px; gap: 10px; }
html.tc-wide #app .stat small:not(#\9#\9#\9) { font-size: 12px !important; letter-spacing: .16em !important; }
html.tc-wide #app .stat b:not(#\9#\9#\9) { font-size: 26px; }
html.tc-wide #app .best:not(#\9#\9#\9) { font-size: 15px; min-height: 19px; margin-top: -2px; }
/* sheets: not phone width, never taller than the window */
html.tc-wide .overlay:not(#\9#\9#\9) { align-items: center; padding: 24px; }
html.tc-wide .overlay > .sheet:not(#\9#\9#\9) { max-width: 560px; max-height: calc(var(--tcw-h, 100dvh) - 48px); }
html.tc-wide #winOverlay .tcf-plate:not(#\9#\9#\9) { --bh: 52px; font-size: 16px; }

/* ---------- tall: iPad portrait (the phone stack, bigger) ---------- */
html.tc-wide.tcw-tall #app:not(#\9#\9#\9) { max-width: var(--tcw-col); gap: 14px; padding-left: 0; padding-right: 0;
  padding-top: 0; padding-bottom: 12px; }
html.tc-wide.tcw-tall #app :is(.tcf-bar, .hud, .best, .controls):not(#\9#\9#\9) { width: 100%; max-width: var(--fw-strip); margin-left: auto; margin-right: auto; }
/* the bar right under the top safe area and New game 8 above the bottom one (the frame adds both), lined up with the read-outs */
html.tc-wide.tcw-tall #app > .tcf-bar:not(#\9#\9#\9) { padding-left: 0; padding-right: 0; }
html.tc-wide.tcw-tall #app .controls .tcf-actions:not(#\9#\9#\9) { padding: 0; max-width: none; }
html.tc-wide.tcw-tall #app .best:not(#\9#\9#\9) { margin-top: -6px; }
html.tc-wide.tcw-tall #winOverlay > .sheet:not(#\9#\9#\9) { max-width: 600px; }

/* ---------- wide and fold (no real hinge): grid on the left at full height, rail on the thumb side ---------- */
html.tc-wide:is(.tcw-wide, .tcw-fold):not(.tcw-hinge) #app:not(#\9#\9#\9) {
  display: grid; max-width: var(--tcw-col); width: 100%; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr) var(--fw-rail);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-areas: "board top" "board hud" "board best" "board ." "board controls";
  column-gap: 20px; row-gap: 12px;
  padding: calc(calc(env(safe-area-inset-top) + var(--tc-frost, 0px)) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px); }
html.tc-wide.tcw-left:is(.tcw-wide, .tcw-fold):not(.tcw-hinge) #app:not(#\9#\9#\9) {
  grid-template-columns: var(--fw-rail) minmax(0, 1fr);
  grid-template-areas: "top board" "hud board" "best board" ". board" "controls board"; }
html.tc-wide.tcw-fold:not(.tcw-hinge) #app:not(#\9#\9#\9) { column-gap: 14px; row-gap: 8px;
  padding: calc(calc(env(safe-area-inset-top) + var(--tc-frost, 0px)) + 10px) 12px calc(env(safe-area-inset-bottom) + 10px); }

/* ---------- fold with a real hinge: grid on one half, the rail on the other ---------- */
html.tc-wide.tcw-fold.tcw-hinge #app:not(#\9#\9#\9) {
  display: grid; max-width: none; width: 100%; margin: 0;
  grid-template-columns: minmax(0, 1fr) calc(var(--tcw-hinge-w) + 32px) minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-areas: "board . top" "board . hud" "board . best" "board . ." "board . controls";
  row-gap: 10px; padding: calc(calc(env(safe-area-inset-top) + var(--tc-frost, 0px)) + 10px) 16px calc(env(safe-area-inset-bottom) + 10px); }
html.tc-wide.tcw-fold.tcw-hinge.tcw-left #app:not(#\9#\9#\9) {
  grid-template-areas: "top . board" "hud . board" "best . board" ". . board" "controls . board"; }

/* ---------- the regions in the grid layout (wide, fold) ---------- */
/* the frame's bar in the rail: #app's own padding keeps the top safe area clear, so the bar adds none */
html.tc-wide:is(.tcw-wide, .tcw-fold) #app > .tcf-bar:not(#\9#\9#\9) { grid-area: top; min-width: 0; height: auto; padding: 0; flex-wrap: wrap; row-gap: 8px; }
/* the name on its own row at the top of the rail, Leave and Help / Menu under it */
html.tc-wide:is(.tcw-wide, .tcw-fold) #app > .tcf-bar > .tcf-title:not(#\9#\9#\9) { order: -1; flex: 1 1 100%; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app > .tcf-bar > .tcf-back:not(#\9#\9#\9) { margin-right: auto; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app .hud:not(#\9#\9#\9) { grid-area: hud; min-width: 0; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app .best:not(#\9#\9#\9) { grid-area: best; min-width: 0; margin-top: -4px; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app #gridWrap:not(#\9#\9#\9) { grid-area: board; align-self: stretch; justify-self: stretch; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app .controls:not(#\9#\9#\9) { grid-area: controls; min-width: 0; }
/* the spec's iPad landscape rule: the bottom bar's buttons go into the side rail, 52 tall, most-used on top (#app keeps the bottom safe area) */
html.tc-wide:is(.tcw-wide, .tcw-fold) #app .controls .tcf-actions:not(#\9#\9#\9) { flex-direction: column-reverse; padding: 0; margin: 0; max-width: none; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app .controls .tcf-actions > .tcf-plate:not(#\9#\9#\9) { --bh: 52px; flex: none; width: 100%; }
/* the Duo's inner screen is 626 px tall: slimmer strips */
html.tc-wide.tcw-fold #app .hud:not(#\9#\9#\9) { height: 58px; gap: 8px; }
html.tc-wide.tcw-fold #app .stat b:not(#\9#\9#\9) { font-size: 23px; }

/* ---------- sheets on a landscape window ---------- */
/* the win sheet over the rail, so the cleared board stays in view */
html.tc-wide:is(.tcw-wide, .tcw-fold):not(.tcw-hinge) #winOverlay:not(#\9#\9#\9) {
  justify-content: flex-end; padding-right: max(12px, calc(var(--tcw-colR, 0px) + 6px)); }
html.tc-wide.tcw-left:is(.tcw-wide, .tcw-fold):not(.tcw-hinge) #winOverlay:not(#\9#\9#\9) {
  justify-content: flex-start; padding-left: max(12px, calc(var(--tcw-colL, 0px) + 6px)); padding-right: 24px; }
html.tc-wide:is(.tcw-wide, .tcw-fold):not(.tcw-hinge) #winOverlay > .sheet:not(#\9#\9#\9) { max-width: calc(var(--fw-rail) + 28px); }
/* with a real hinge every sheet keeps to the rail's half */
html.tc-wide.tcw-fold.tcw-hinge .overlay:not(#\9#\9#\9) { justify-content: flex-end; }
html.tc-wide.tcw-fold.tcw-hinge.tcw-left .overlay:not(#\9#\9#\9) { justify-content: flex-start; }
html.tc-wide.tcw-fold.tcw-hinge .overlay > .sheet:not(#\9#\9#\9) { max-width: calc(var(--tcw-w) / 2 - var(--tcw-hinge-w) / 2 - 32px); }
