/* Christian Educational Games shared game shell — do not restyle per game. */
@font-face{font-family:'Cabin Sketch';src:url('fonts/CabinSketch-400.woff2') format('woff2');font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:'Cabin Sketch';src:url('fonts/CabinSketch-700.woff2') format('woff2');font-weight:700;font-style:normal;font-display:swap}

:root{
  --board:#1c2a22; --board-2:#243429; --board-3:#2c3f31;
  --chalk:#f1ede3; --chalk-dim:#c3bfb3;
  --yellow:#e2b94c; --yellow-d:#a9862f;
  --mint:#8fb89a; --sky:#7593bd; --pink:#e0a0b4; --lilac:#b9a6d8; --red:#e88f7d;
  --line:rgba(241,237,227,.22);
  --wood:#6b4a2f; --wood-2:#8a6238; --wood-3:#4a3220;
  --safe-t:env(safe-area-inset-top,0px); --safe-r:env(safe-area-inset-right,0px);
  --safe-b:env(safe-area-inset-bottom,0px); --safe-l:env(safe-area-inset-left,0px);
}
*,*::before,*::after{box-sizing:border-box}
html,body{height:100%;margin:0;padding:0}
html{overflow:hidden}
body{
  overflow:hidden; overscroll-behavior:none; -webkit-text-size-adjust:100%;
  background:#2f2823;
  background-image:radial-gradient(ellipse at 50% 0%,#3a312a,#241e1a 70%);
  font-family:system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
  color:var(--chalk);
  display:flex; align-items:center; justify-content:center;
  padding:clamp(4px,1.2vh,14px) clamp(4px,1.2vw,16px);
  padding-top:max(clamp(4px,1.2vh,14px),var(--safe-t));
  padding-right:max(clamp(4px,1.2vw,16px),var(--safe-r));
  padding-bottom:max(clamp(4px,1.2vh,14px),var(--safe-b));
  padding-left:max(clamp(4px,1.2vw,16px),var(--safe-l));
  touch-action:manipulation;
}

/* wooden frame */
#frame{
  position:relative; width:100%; height:100%; max-width:1600px;
  border-radius:10px;
  background:linear-gradient(160deg,var(--wood-2),var(--wood) 45%,var(--wood-3));
  padding:clamp(5px,0.9vh,10px);
  box-shadow:0 18px 42px rgba(0,0,0,.55), inset 0 0 0 1px rgba(255,255,255,.08);
  display:flex; min-height:0;
}
#board{
  position:relative; flex:1 1 auto; min-width:0; min-height:0;
  border-radius:5px; overflow:hidden;
  background:var(--board);
  background-image:
    radial-gradient(ellipse at 28% 16%,rgba(255,255,255,.055),transparent 62%),
    radial-gradient(ellipse at 78% 88%,rgba(255,255,255,.03),transparent 58%),
    radial-gradient(rgba(255,255,255,.022) 1px,transparent 1px);
  background-size:auto,auto,3px 3px;
  box-shadow:inset 0 0 34px rgba(0,0,0,.55), inset 0 0 0 1px rgba(0,0,0,.35);
  display:grid;
  grid-template-rows:auto minmax(0,1fr);
  grid-template-areas:"head" "play";
  color:var(--chalk);
  font-size:clamp(14px,1.55vh,17px);
  -webkit-tap-highlight-color:transparent;
}

/* header */
#head{
  grid-area:head; display:flex; align-items:center; gap:clamp(6px,.9vw,14px);
  padding:clamp(4px,.8vh,9px) clamp(8px,1.1vw,16px);
  border-bottom:1px dashed var(--line);
  min-width:0;
}
#brand{
  font-family:'Cabin Sketch',cursive; font-weight:700; letter-spacing:.5px;
  font-size:clamp(14px,1.9vh,19px); color:var(--chalk-dim); white-space:nowrap;
  display:flex; align-items:center; gap:.4em; flex:0 0 auto;
}
#brand .ico{font-size:1.15em; line-height:1}
#title{
  font-family:'Cabin Sketch',cursive; font-weight:700; letter-spacing:1px;
  font-size:clamp(15px,2.6vh,26px); margin:0; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis; min-width:0; flex:1 1 auto;
}
#headTools{display:flex; gap:6px; flex:0 0 auto; align-items:center}
.tbtn{
  font-family:'Cabin Sketch',cursive; font-weight:700; letter-spacing:.5px;
  font-size:clamp(16px,1.6vh,18px); line-height:1;
  background:transparent; color:var(--chalk-dim);
  border:2px solid var(--line); border-radius:999px;
  padding:clamp(4px,.75vh,7px) clamp(9px,1vw,14px); cursor:pointer;
  min-height:44px; display:inline-flex; align-items:center; gap:.35em;
  /* Header chips are one short label each, so they must never wrap: a wrapped
     "? How to play" made the whole header 66px tall on a portrait phone while every
     other chip stayed one line. The title ellipsis absorbs the squeeze instead. */
  white-space:nowrap;
  transition:color .12s,border-color .12s,background .12s;
}
.tbtn:hover{color:var(--chalk); border-color:rgba(241,237,227,.45)}
.tbtn[aria-pressed="true"]{color:var(--board); background:var(--yellow); border-color:var(--yellow)}
.tbtn:active{transform:translateY(1px)}
/* Favorites star: one glyph, so it keeps a square-ish footprint instead of
   stretching with the word buttons beside it. */
.tbtn.star{padding:0; min-width:44px; justify-content:center; font-size:clamp(15px,2.1vh,19px)}

/* play area */
#play{
  grid-area:play; min-height:0; min-width:0; position:relative;
  padding:clamp(6px,1vh,14px) clamp(8px,1.1vw,18px);
  display:flex; flex-direction:column; gap:clamp(5px,.9vh,10px);
  overflow:hidden;
}

/* generic chalk UI pieces games should reuse */
.btn{
  font-family:'Cabin Sketch',cursive; font-weight:700; letter-spacing:1px;
  font-size:clamp(14px,2vh,21px); color:var(--board); background:var(--yellow);
  border:2px solid var(--yellow); border-radius:10px; cursor:pointer;
  padding:clamp(5px,.9vh,9px) clamp(12px,1.4vw,22px);
  box-shadow:0 4px 0 var(--yellow-d); transition:transform .07s,box-shadow .07s;
  min-height:44px; display:inline-flex; align-items:center; justify-content:center; gap:.4em;
}
.btn:active{transform:translateY(3px); box-shadow:0 1px 0 var(--yellow-d)}
.btn[disabled]{opacity:.45; cursor:not-allowed; transform:none; box-shadow:0 4px 0 var(--yellow-d)}
.btn.ghost{
  background:transparent; color:var(--sky); border:2px solid var(--sky); box-shadow:none;
}
.btn.ghost:active{transform:translateY(2px)}
.btn.small{font-size:16px; min-height:44px; padding:4px 12px; box-shadow:0 3px 0 var(--yellow-d)}
.card{
  background:rgba(0,0,0,.16); border:2px dashed var(--line); border-radius:12px;
  padding:clamp(8px,1.4vh,16px);
}
.hint{color:var(--chalk-dim); font-size:clamp(16px,1.55vh,17px); line-height:1.45}
.chip{
  display:inline-flex; align-items:center; gap:.35em;
  border:2px dashed var(--line); border-radius:999px;
  padding:.2em .75em; font-size:16px; color:var(--chalk-dim);
}
.chip.on{color:var(--board); background:var(--mint); border-color:var(--mint); border-style:solid}
.row{display:flex; align-items:center; gap:clamp(6px,.9vw,12px); min-width:0}
.col{display:flex; flex-direction:column; gap:clamp(5px,.9vh,10px); min-width:0}
.grid{display:grid; gap:clamp(5px,.9vh,10px); min-width:0}
.scroll{overflow:auto; min-height:0; scrollbar-width:thin}
.eyebrow{
  font-family:'Cabin Sketch',cursive; letter-spacing:1.5px; text-transform:uppercase;
  font-size:14px; color:var(--yellow);
}
.big{font-family:'Cabin Sketch',cursive; font-weight:700; line-height:1;
  font-size:clamp(22px,4.4vh,46px)}
.stat{font-variant-numeric:tabular-nums}

/* popover */
.pop{
  position:absolute; inset:0; z-index:40; display:none;
  align-items:center; justify-content:center; padding:clamp(8px,2vh,24px);
  background:rgba(12,18,14,.72); backdrop-filter:blur(2px);
}
.pop.open{display:flex}
.pop .sheet{
  background:var(--board-2); border:2px solid var(--line); border-radius:14px;
  max-width:min(620px,100%); max-height:100%; overflow:auto;
  padding:clamp(12px,2vh,22px); display:flex; flex-direction:column; gap:.7em;
  box-shadow:0 20px 50px rgba(0,0,0,.5);
}
.pop h2{font-family:'Cabin Sketch',cursive; font-weight:700; letter-spacing:1px;
  margin:0; font-size:clamp(18px,2.8vh,26px)}
.pop .x{align-self:flex-end}
.tbtn.x{min-width:44px; min-height:44px}

/* toast */
#toast{
  position:absolute; left:50%; bottom:clamp(46px,9vh,90px); transform:translate(-50%,10px);
  background:var(--yellow); color:var(--board); font-weight:700;
  padding:.5em 1.1em; border-radius:999px; opacity:0; pointer-events:none;
  transition:opacity .18s,transform .18s; z-index:60; font-size:16px;
  box-shadow:0 8px 20px rgba(0,0,0,.4); max-width:90%;
}
#toast.show{opacity:1; transform:translate(-50%,0)}

/* rotate prompt (portrait phones) */
#rotate{
  position:fixed; inset:0; z-index:90; display:none;
  align-items:center; justify-content:center; flex-direction:column; gap:1em;
  background:var(--board); color:var(--chalk); text-align:center; padding:2em;
  font-family:'Cabin Sketch',cursive; letter-spacing:1px;
}
#rotate .ph{font-size:clamp(40px,14vw,72px); animation:tip 1.8s ease-in-out infinite}
#rotate p{font-size:clamp(15px,4.6vw,22px); margin:0; line-height:1.4}
@keyframes tip{0%,100%{transform:rotate(0)}50%{transform:rotate(-90deg)}}
/* The "turn sideways" wall is opt-in: a game whose portrait layout cannot be played
   adds class="needs-landscape" to its <body>. Every other game plays upright. */
@media (orientation:portrait) and (pointer:coarse) and (max-width:600px) and (max-height:950px){
  body.touch.needs-landscape #rotate{display:flex}
}

/* touch-only and desktop-only helpers */
.touchonly{display:none!important}
body.touch .touchonly{display:initial!important}
body.touch .touchonly.flex{display:flex!important}
body.touch .touchonly.grid{display:grid!important}
body:not(.touch) .desktoponly{display:initial!important}

/* thumb controls standard look */
.thumb{
  position:absolute; display:flex; flex-direction:column; align-items:center; justify-content:center;
  border-radius:50%; font-family:'Cabin Sketch',cursive; font-weight:700; letter-spacing:.5px;
  background:rgba(241,237,227,.10); border:2px solid rgba(241,237,227,.45); color:var(--chalk);
  user-select:none; -webkit-user-select:none; touch-action:none; z-index:30;
}
.thumb:active,.thumb.on{background:var(--yellow); color:var(--board); border-color:var(--yellow)}
.stickzone{position:absolute; touch-action:none; z-index:29}
.stick{
  position:absolute; width:clamp(96px,22vh,140px); aspect-ratio:1; border-radius:50%;
  border:2px dashed rgba(241,237,227,.35); background:rgba(0,0,0,.18);
  display:none; align-items:center; justify-content:center; z-index:30; touch-action:none;
}
.stick.on{display:flex}
.stick .knob{
  width:42%; aspect-ratio:1; border-radius:50%; background:rgba(226,185,76,.85);
  border:2px solid var(--yellow); pointer-events:none;
}

/* coarse-pointer (touch) targets: header chips get a real thumb size */
/* any-pointer:coarse also catches a touch screen on a laptop whose mouse is the
   primary pointer — those users can still tap the chips. */
@media (pointer:coarse), (any-pointer:coarse){
  .tbtn{min-height:44px; padding:6px 14px}
  .tbtn.star{min-width:44px}
  .tbtn.x{min-width:44px; min-height:44px}
  .btn.small{min-height:44px}
  .btn.small.x{min-width:44px}
}

/* Narrow headers: the wordmark is decoration, the game name and the controls are not.
   Drop the wordmark first, then tighten the chips, so the header never overflows. */
/* The chip row must NOT shrink. Every chip is nowrap, so shrinking the row does not
   make it narrower, it just pushes the overflow past the header's right edge: at
   390x844 the favourites star sat 42px outside the header with half of it off-screen.
   The title is the only thing that can give, so it absorbs the whole squeeze. */
#headTools{flex:0 0 auto; min-width:0}
#title{min-width:0}
@media (max-width:700px){
  #brand{display:none}
}
/* Tablet upright (768x1024 and similar): words stay, but the chips tighten so the
   title is not ellipsised down to four characters in a wide header. */
@media (min-width:561px) and (max-width:1024px){
  #headTools .tbtn{padding:0 10px; min-height:44px}
  #headTools{gap:5px}
  #title{font-size:clamp(14px,1.9vw,22px)}
}
/* Narrow phones: drop the chip words, keep the glyph and the 44px box, so the
   game's own name gets the header room instead of being ellipsised to "Ark…". */
@media (max-width:560px){
  #headTools .lbl{display:none}
  /* A glyph-only chip is narrow, but it is still a thumb target: hold 44px in
     BOTH directions or the header is the one place on the page you cannot tap. */
  #headTools .tbtn{gap:0; padding:0; min-width:44px; min-height:44px; justify-content:center}
}
@media (max-width:420px){
  #headTools{gap:3px}
}

@media (max-width:460px){
  #head{gap:5px; padding-left:6px; padding-right:6px}
  #headTools{gap:4px}
  .tbtn{padding:5px 9px; font-size:16px; letter-spacing:0}
  #title{font-size:clamp(14px,2.4vh,22px); letter-spacing:.5px}
}

/* Readable header + close chips (Nov 9): the chip words and the help/menu close
   glyph rendered at 11-12px on phones (1.6vh floors at 12px on any screen under
   750px tall). Words now never go under 16px, glyph-only chips and the close mark
   get a 20px glyph, and every chip keeps its 44px box. The chips do not grow taller
   (line-height 1 inside a 44px box), so the play area is untouched; the extra width
   comes out of the title ellipsis, and the wordmark drops on landscape phones too. */
#headTools .tbtn{font-size:clamp(16px,1.9vh,19px)}
/* tablets: 16px words, as wide as before, so the game title keeps its room */
@media (min-width:561px) and (max-width:1024px){ #headTools .tbtn:not(.star){font-size:16px} }
#headTools .tbtn.star,.pop .tbtn.x{font-size:clamp(20px,2.4vh,22px)}
@media (max-height:500px){ #brand{display:none} }
@media (max-width:560px){ #headTools .tbtn .ico{font-size:1.25em} }
/* Phone portrait: the full game name wraps onto a second line instead of being
   ellipsised; the header grows by one line and the play row (minmax(0,1fr)) absorbs it. */
@media (max-width:560px) and (orientation:portrait){
  #title{white-space:normal; overflow:visible; text-overflow:clip; overflow-wrap:break-word; line-height:1.1; font-size:clamp(16px,2.4vh,20px)}
}
.pop .tbtn.x{padding-left:10px; padding-right:10px; justify-content:center}

/* ---- shell v2: full screen in landscape ----
   100dvh keeps the board inside the visible area when browser bars come and go (100%
   stays as the fallback). In our full screen / home-screen app in landscape the header
   gives way to a slim rail in the board grid (never over the game), the wooden frame
   drops its margins, and the board follows the visual viewport inside the safe areas. */
@supports (height:100dvh){ html,body{height:100dvh} }
.tbtn.fsbtn{padding:0; min-width:44px; justify-content:center; font-size:clamp(20px,2.4vh,22px)}
body.touch .tbtn.fsbtn{display:none}
#natFsBar{display:none}
html.nat-fs body{height:var(--nat-vh,100dvh); padding:var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l)}
html.nat-fs #frame{padding:0; border-radius:0; max-width:none; box-shadow:none}
html.nat-fs #board{border-radius:0; grid-template-rows:minmax(0,1fr); grid-template-columns:minmax(0,1fr) auto; grid-template-areas:"play fsbar"}
html.nat-fs #head{display:none}
/* v2.1: the rail spans every explicit row of the board grid. v2 pinned it to row 1,
   so a game whose full-screen grid puts an auto-height band first (adverb-racing:
   "toast fsbar" / "play fsbar") had that band stretched to the rail height (~206px). */
html.nat-fs #natFsBar{grid-area:fsbar; grid-row:1 / -1; display:flex; flex-direction:column; gap:6px; padding:6px; border-left:1px dashed var(--line); overflow:auto; min-height:0}
#natFsBar .tbtn{min-width:44px; min-height:44px; padding:0; justify-content:center; font-size:20px}
html.nat-app #natFsBar [data-fs-exit]{display:none}
/* Tablet upright (768x1024, 810x1080, 834x1112 ...): the game name wraps onto a second
   line like it does on phones instead of being ellipsised ("Preposition Playgr…"), and
   it never drops under 16px. Mid-width landscape keeps one line but also holds 16px. */
@media (min-width:561px) and (max-width:1024px){ #title{font-size:clamp(16px,1.9vw,22px)} }
@media (min-width:561px) and (max-width:1100px) and (orientation:portrait){
  #title{white-space:normal; overflow:visible; text-overflow:clip; overflow-wrap:break-word; line-height:1.1; font-size:clamp(16px,2.2vw,22px)}
}
/* toast: in landscape full screen it is a small top-edge note (the header is gone, so
   the strip is free), shorter-lived and never a tap target; inside a game's own
   [data-toast-slot] it sits in normal flow there. */
html.nat-fs #toast{top:6px; bottom:auto; left:calc(50% - 28px); padding:.3em .9em; box-shadow:0 4px 10px rgba(0,0,0,.35); max-width:min(70%,520px); white-space:normal; text-align:center}
#toast.in-slot{position:relative; left:auto; top:auto; bottom:auto; transform:none; display:inline-block; max-width:100%}
#toast.in-slot:not(.show){visibility:hidden}
/* v2.1: the full-screen top-edge rule above (html.nat-fs #toast) out-ranks #toast.in-slot,
   so in full screen a slotted toast was shifted right by calc(50% - 28px) and down 6px,
   out of its slot (and, with the rail now spanning every row, onto the rail column). */
html.nat-fs #toast.in-slot{left:auto; top:auto; bottom:auto}
