/* Fall In 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 and the generated ui/ui.css, behind the gate's media query; every rule starts with
   html.tc-wide, so a phone never applies a line. The token size and the rows of racks come from layoutWide() in index.html (--tok,
   #board.mw-side); these rules only place the regions. ui.css uses two-id :not(#\9#\9) selectors and the page's touch pass uses four,
   so the rules that must win here carry five (:not(#\9#\9#\9#\9#\9)).

   Unified frame (Nov 29, 2026): the top bar is the frame's (#tcfBar), the level picker (#lvlBar) sits under it, and the four
   tools are the frame's bottom bar (#actBar: Restart | Hint | Spare | Undo; icons on these widths).
   tall  (iPad portrait):   the phone stack, wider (game.json "column"); bigger tokens; the bottom bar at most 560 wide, centred.
   wide  (iPad landscape):  top bar across; the camps on the left at full height (stacked or side by side, whichever gives the
                            bigger tokens); a side rail on the thumb side with the level picker, the level name and moves,
                            the status line and the bottom bar's buttons, 52 tall, one under the other (Undo on top).
   fold  (Duo inner, 890x626): the same as wide with a narrower rail.
   fold + a real hinge (html.tcw-hinge): camps on one half, everything else on the other; nothing crosses the hinge.
   The win strip comes up over the rail (wide, fold) so the solved camps stay in view. */

/* ---------- every wide mode ---------- */
/* Skin art (fix, Nov 26): a wide.css never names a skin picture, not even through var(--ui-img-*): a url() taken from a
   variable is resolved against THIS file's folder, which on /outpost/ and /magic/ is the Pixel theme. To give a panel back its
   frame below 740 px tall, the short-screen rule of ui/ui.css keeps drawing its own border-image (so the url is resolved by
   ui.css, in this skin's folder) and only its well variables are pointed at the panel ones on that element. The children get
   the well back from these copies taken on <html>. */
html.tc-wide { --tcwk-well: var(--ui-img-well); --tcwk-well-slice: var(--ui-well-slice); --tcwk-well-bw: var(--ui-well-bw); }
/* the shared filler's fallback tile is a skin variable used from shared/wide.css, so it would load another skin's tile (or a 404):
   drop that fallback here; a skin's own wide backdrop (--tcw-img-backdrop, written by the build) still shows, else the theme's own
   page backdrop shows through */
html.tc-wide #tcWideBg .tcw-fill { --ui-img-bg-tile: none; background-color: transparent; }
html.tc-wide { --mw-rail: clamp(280px, 26vw, 330px); }
html.tc-wide.tcw-fold { --mw-rail: 268px; --fm-px: 12px; }   /* --fm-px: the header's full-bleed margin follows the 12 px fold padding */
html.tc-wide #rotate:not(#\9#\9#\9#\9#\9) { display: none !important; }   /* "turn your phone" never on a wide window */
html.tc-wide #app #boardwrap:not(#\9#\9#\9#\9#\9) { min-width: 0; min-height: 0; }
html.tc-wide #app #actBar .tcf-actions:not(#\9#\9#\9#\9#\9) { max-width: 560px; margin-left: auto; margin-right: auto; }
html.tc-wide #app #lvlBar .tcf-levels > .tcf-plate:not(#\9#\9#\9#\9#\9) { min-width: 160px; }
html.tc-wide #app .status:not(#\9#\9#\9#\9#\9) { font-size: 15px; min-height: 40px; }

/* side by side camps: Orcs left, Humans right, a called spare band across under both */
html.tc-wide #board.mw-side:not(#\9#\9#\9#\9#\9) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 10px; row-gap: 6px; align-items: stretch; }
html.tc-wide #board.mw-side #campO:not(#\9#\9#\9#\9#\9) { grid-column: 1; grid-row: 1; }
html.tc-wide #board.mw-side #campH:not(#\9#\9#\9#\9#\9) { grid-column: 2; grid-row: 1; }
html.tc-wide #board.mw-side #campS:not(#\9#\9#\9#\9#\9) { grid-column: 1 / -1; grid-row: 2; }
html.tc-wide #board.mw-side .camp:not(#\9#\9#\9#\9#\9) { justify-content: center; }

/* ui.css tightens the console below 740 px tall (short phones) and the page slims the status line below 640 px; both also hit an
   iPad in landscape with Safari's bars and the Duo's inner screen: keep the full sizes there */
@media (max-height: 740px) {
  html.tc-wide #app .info:not(#\9#\9#\9#\9#\9) { border-width: 12px; box-shadow: var(--ui-panel-shadow); gap: 5px; padding: 0 2px 2px;
    --ui-img-well: var(--ui-img-panel); --ui-well-slice: var(--ui-panel-slice); --ui-well-bw: var(--ui-panel-bw); }
  html.tc-wide #app .info > * { --ui-img-well: var(--tcwk-well); --ui-well-slice: var(--tcwk-well-slice); --ui-well-bw: var(--tcwk-well-bw); }
}
@media (max-height: 640px) {
  html.tc-wide #app .status:not(#\9#\9#\9#\9#\9) { min-height: 40px; font-size: 15px; }
}

/* ---------- tall: iPad portrait ---------- */
html.tc-wide.tcw-tall #app:not(#\9#\9#\9#\9#\9) { max-width: var(--tcw-col); gap: 10px;
  padding-left: 0; padding-right: 0; padding-bottom: calc(env(safe-area-inset-bottom) + 16px); }
html.tc-wide.tcw-tall #app #tcfBar:not(#\9#\9#\9#\9#\9) { margin-left: 0; margin-right: 0; }   /* the column has no side padding here: the bar keeps its own 16 */
html.tc-wide.tcw-tall #app .info #lvlLabel:not(#\9#\9#\9#\9#\9) { font-size: 18px; }
html.tc-wide.tcw-tall #app .info .chip:not(#\9#\9#\9#\9#\9) { font-size: 15px; }
html.tc-wide.tcw-tall #app .status:not(#\9#\9#\9#\9#\9) { font-size: 16px; min-height: 48px; }
html.tc-wide.tcw-tall #app #actBar:not(#\9#\9#\9#\9#\9) { width: 100%; max-width: 600px; margin: 0 auto; }

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

/* ---------- fold with a real hinge: camps on one half, the rest on the other ---------- */
html.tc-wide.tcw-fold.tcw-hinge #app:not(#\9#\9#\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 . lvl" "board . info" "board . status" "board . controls";
  row-gap: 8px; padding: calc(calc(env(safe-area-inset-top) + var(--tc-frost, 0px)) + 8px) 16px calc(env(safe-area-inset-bottom) + 8px); }
html.tc-wide.tcw-fold.tcw-hinge.tcw-left #app:not(#\9#\9#\9#\9#\9) {
  grid-template-areas: "top . board" "lvl . board" "info . board" "status . board" "controls . board"; }

/* ---------- the regions in a grid layout (wide, fold) ---------- */
html.tc-wide:is(.tcw-wide, .tcw-fold) #app #tcfBar:not(#\9#\9#\9#\9#\9) { grid-area: top; min-width: 0; margin-bottom: 0; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app #lvlBar:not(#\9#\9#\9#\9#\9) { grid-area: lvl; min-width: 0; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app #lvlBar .tcf-levels > .tcf-plate:not(#\9#\9#\9#\9#\9) { flex: 1 1 0; min-width: 0; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app #boardwrap:not(#\9#\9#\9#\9#\9) { grid-area: board; align-self: stretch; justify-self: stretch; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app .info:not(#\9#\9#\9#\9#\9) { grid-area: info; min-width: 0; gap: 8px; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app .info .mid:not(#\9#\9#\9#\9#\9) { flex-direction: column; align-items: center; gap: 6px; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app .info #lvlLabel:not(#\9#\9#\9#\9#\9) { font-size: 17px; text-align: center; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app .info .chip:not(#\9#\9#\9#\9#\9) { font-size: 14px; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app .status:not(#\9#\9#\9#\9#\9) { grid-area: status; font-size: 16px; line-height: 1.4;
  padding: 4px 6px; align-items: center; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app #actBar:not(#\9#\9#\9#\9#\9) { grid-area: controls; min-width: 0; }
/* the bottom bar's buttons in the rail (spec: 52 tall, one under the other, the bar's order reversed so the most used is on top) */
html.tc-wide:is(.tcw-wide, .tcw-fold) #app #actBar .tcf-actions:not(#\9#\9#\9#\9#\9) { flex-direction: column-reverse; max-width: none; margin: 0; padding: 0; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #app #actBar .tcf-actions > .tcf-plate:not(#\9#\9#\9#\9#\9) { --bh: 52px; flex: none; width: 100%; }
html.tc-wide.tcw-fold #app .status:not(#\9#\9#\9#\9#\9) { font-size: 15px; }

/* ---------- pop-ups on a wide window ---------- */
/* level list: wider, one tier per row (tiers hold 6 or 7 battles) */
html.tc-wide #levelsOverlay > .sheet:not(#\9#\9#\9#\9#\9) { max-width: 720px; }
html.tc-wide #levelsOverlay .sheet .grid:not(#\9#\9#\9#\9#\9) { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #levelsOverlay:not(#\9#\9#\9#\9#\9) { align-items: center; }
html.tc-wide.tcw-tall #levelsOverlay:not(#\9#\9#\9#\9#\9) { align-items: center; }
/* the win strip: tall keeps the phone's strip under the camps (the page makes room for it), a bit wider;
   wide and fold put it over the rail, so the camps keep their whole box */
html.tc-wide.tcw-tall #winOverlay > .sheet:not(#\9#\9#\9#\9#\9) { max-width: 560px; }
html.tc-wide.tcw-tall:has(#winOverlay:not(.hidden)) #app:not(#\9#\9#\9#\9#\9) {
  padding-bottom: calc(var(--fm-win) + 40px + env(safe-area-inset-bottom)); }
html.tc-wide:is(.tcw-wide, .tcw-fold):has(#winOverlay:not(.hidden)) #app:not(#\9#\9#\9#\9#\9) {
  padding-bottom: calc(env(safe-area-inset-bottom) + 12px); }
html.tc-wide:is(.tcw-wide, .tcw-fold):not(.tcw-hinge) #winOverlay:not(#\9#\9#\9#\9#\9) {
  justify-content: flex-end; padding-right: max(10px, calc(var(--tcw-colR, 0px) + 8px)); }
html.tc-wide.tcw-left:is(.tcw-wide, .tcw-fold):not(.tcw-hinge) #winOverlay:not(#\9#\9#\9#\9#\9) {
  justify-content: flex-start; padding-left: max(10px, calc(var(--tcw-colL, 0px) + 8px)); padding-right: 10px; }
html.tc-wide:is(.tcw-wide, .tcw-fold):not(.tcw-hinge) #winOverlay > .sheet:not(#\9#\9#\9#\9#\9) {
  max-width: calc(var(--mw-rail) + 16px); }
/* in the rail the strip is narrow: stars and moves on one row, Next across, Replay and Levels across under it */
html.tc-wide:is(.tcw-wide, .tcw-fold) #winOverlay > .sheet:not(#\9#\9#\9#\9#\9) { height: auto; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #winOverlay #winNext:not(#\9#\9#\9#\9#\9) { grid-column: 1 / -1; grid-row: 3; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #winOverlay .sheet > div:last-child:not(#\9#\9#\9#\9#\9) { grid-column: 1 / -1; grid-row: 4; }
html.tc-wide:is(.tcw-wide, .tcw-fold) #winOverlay .sheet > div:last-child .btn:not(#\9#\9#\9#\9#\9) { font-size: 14px; }
/* with a real hinge the sheets keep to the half away from the camps */
html.tc-wide.tcw-fold.tcw-hinge .overlay:not(#\9#\9#\9#\9#\9) { justify-content: flex-end; }
html.tc-wide.tcw-fold.tcw-hinge.tcw-left .overlay:not(#\9#\9#\9#\9#\9) { justify-content: flex-start; }
html.tc-wide.tcw-fold.tcw-hinge .overlay > .sheet:not(#\9#\9#\9#\9#\9) {
  max-width: calc(var(--tcw-w) / 2 - var(--tcw-hinge-w) / 2 - 24px); }
