/* THE PUZZLE GAMES' SHARED PAGE STYLE (21 November 2026): the Mathster look for every game page (resources/games),
   the league or free-play switch, the levels, and the class league pop-up. Each game page adds its own board styles. */
:root{--blue:#2563eb;--blued:#1d4ed8;--bluesoft:rgba(37,99,235,.10);--navy:#17324d;--ink:#0f2540;--muted:#5b6b80;
  --line:#dce3ec;--ground:#f6f8fb;--card:#fff;--amber:#f59e0b;--amberd:#b45309;--ambersoft:#fff4dc;
  --ok:#15803d;--oksoft:#dcfce7;--bad:#dc2626;--badsoft:#fde8e8}
*{box-sizing:border-box}
html,body{margin:0}
body{font:15px/1.5 Inter,system-ui,-apple-system,"Segoe UI",sans-serif;color:var(--ink);background:var(--ground);
  -webkit-tap-highlight-color:transparent;overflow-x:clip}
button{font:inherit;color:inherit;cursor:pointer}
[hidden]{display:none!important}
.page{max-width:620px;margin:0 auto;padding:16px 16px 40px}
.head{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin-bottom:10px}
h1{font-size:26px;line-height:1.1;margin:0;font-weight:800;letter-spacing:-.01em}
h1 small{display:block;font-size:13px;font-weight:500;color:var(--muted);letter-spacing:0;margin-top:3px}
.lgbtn{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);background:var(--card);border-radius:10px;
  padding:8px 12px;font-weight:700;font-size:14px}
.seg{display:flex;background:var(--card);border:1px solid var(--line);border-radius:11px;padding:3px;gap:3px;margin-bottom:10px}
.seg button{flex:1;border:0;background:transparent;padding:8px 10px;border-radius:8px;font-weight:600;font-size:14px}
.seg button[aria-pressed="true"]{background:var(--navy);color:#fff}
.mode{border-radius:12px;padding:9px 12px;font-size:13.5px;margin-bottom:10px;border:1px solid}
.mode.league{background:var(--ambersoft);border-color:#f3d28a;color:#6b4100}
.mode.free{background:#eef2f7;border-color:var(--line);color:var(--muted)}
.mode b{font-weight:700}
.levels{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-bottom:12px}
.lv{border:1px solid var(--line);background:var(--card);border-radius:12px;padding:8px 10px;text-align:left;line-height:1.25;min-height:54px}
.lv b{display:block;font-size:14.5px}
.lv small{display:block;font-size:12px;color:var(--muted)}
.lv small.done{color:var(--ok);font-weight:600}
.lv[aria-pressed="true"]{border-color:var(--blue);box-shadow:inset 0 0 0 1.5px var(--blue)}
.rule{font-size:14px;color:var(--muted);margin:0 0 10px}
.veil{position:absolute;inset:0;border-radius:10px;background:rgba(246,248,251,.94);display:flex;flex-direction:column;align-items:center;
  justify-content:center;gap:12px;text-align:center;padding:24px;z-index:5}
.veil h2{font-size:22px;margin:0}
.veil p{margin:0;color:var(--muted);max-width:320px}
.btn{border:0;border-radius:10px;padding:10px 18px;font-weight:700;font-size:15px;background:var(--blue);color:#fff;box-shadow:0 2px 0 var(--blued)}
.btn:active{transform:translateY(1px);box-shadow:none}
.btn:disabled{opacity:.5;cursor:default}
.btn.ghost{background:var(--card);color:var(--ink);border:1px solid var(--line);box-shadow:0 2px 0 var(--line)}
.controls{display:flex;justify-content:center;gap:10px;margin-top:12px;flex-wrap:wrap}
.status{text-align:center;min-height:24px;margin:10px 0 0;font-size:14px;color:var(--muted)}
.status.ok{color:var(--ok);font-weight:700}
.status.bad{color:var(--bad)}
.back{display:inline-block;margin-top:14px;font-size:13.5px;font-weight:700;color:var(--blue);text-decoration:none}
.back:hover{text-decoration:underline}
.foot{text-align:center}
.scrim{position:fixed;inset:0;background:rgba(15,37,64,.45);display:flex;align-items:flex-end;justify-content:center;z-index:50;padding:12px}
@media (min-width:640px){.scrim{align-items:center}}
.sheet{background:#fff;border-radius:16px;width:100%;max-width:560px;max-height:90vh;overflow:auto;padding:18px 18px 16px;position:relative}
.sheet h2{margin:0 0 6px;font-size:21px}
.sheet h3{margin:14px 0 6px;font-size:14.5px}
.x{position:absolute;right:10px;top:8px;border:0;background:none;font-size:26px;line-height:1;color:var(--muted);padding:6px}
.muted{color:var(--muted);font-size:13px;margin:0 0 6px}
.lvrow{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 0;border-bottom:1px solid #eef2f6}
.lvrow .nm b{display:block}
.lvrow .nm small{color:var(--muted);font-size:12px}
.done{color:var(--ok);font-weight:700;font-size:13.5px}
.segs{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0 6px}
.segs .seg{margin:0;flex:1;min-width:200px}
.seg.small button{padding:6px 8px;font-size:13px}
.sheet table{width:100%;border-collapse:collapse;font-size:14px}
.sheet th,.sheet td{padding:6px 8px;border-bottom:1px solid #eef2f6;text-align:left}
.sheet th{font-size:12px;color:var(--muted);font-weight:600}
.sheet td.num,.sheet th.num{text-align:right;font-variant-numeric:tabular-nums}
.sheet td.pos{width:30px;font-weight:800;color:var(--blued)}
.sheet tr.me td{background:var(--bluesoft);font-weight:700}
.sheet tr.none td{color:#94a3b8}
.rules{font-size:12.5px;line-height:1.5;margin:12px 0 4px}
.sheet select{font:inherit;font-size:13px;padding:6px 8px;border:1px solid var(--line);border-radius:9px;background:#fff;margin:0 0 6px}

/* ONE SCREEN, NO SCROLLBARS (Richard, 29 Nov 2026: Shikaku "playable in the browser without the need for scrollbars",
   then "make the other four behave the same way"; Boxes has its own layout). A game page opts in with
   <body class="fitpage"> and <main class="fit">. .side holds the controls: .top above, .bottom below. .stage holds the
   board: .zone is the space it may fill (a CSS size container), .wrap the board itself, as big as the zone allows at its
   shape (--ar, width ÷ height); .over and .under sit just above and below it. A wide window has the controls beside the
   board, an upright one (a phone) above and below it. If a window is too short for every control, only .side scrolls,
   never the board; a tiny window scrolls. */
.fitpage{display:flex;flex-direction:column;height:100vh;height:100dvh;overflow-x:hidden;overflow-y:auto}
.fit{flex:1 1 auto;min-height:260px;width:100%;max-width:1180px;margin:0 auto;padding:18px 22px;display:grid;
  grid-template-columns:minmax(250px,330px) minmax(0,1fr);grid-template-rows:minmax(0,1fr);column-gap:30px}
.fit .side{min-width:0;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px;scrollbar-width:thin}
.fit .top{min-width:0}
.fit .bottom{min-width:0;display:flex;flex-direction:column;align-items:stretch;gap:10px}
.fit .stage{min-width:0;min-height:0;display:flex;flex-direction:column;align-items:center;gap:10px}
.fit .zone{flex:1 1 auto;min-height:0;align-self:stretch;container-type:size;display:flex;align-items:center;justify-content:center}
.fit .stage:has(.under) .zone{align-items:flex-end}
.fit .stage:has(.over) .zone{align-items:flex-start}
.fit .stage:has(.over):has(.under) .zone{align-items:center}
.fit .wrap{--ar:1;position:relative;width:min(100cqw,calc(100cqh * var(--ar)));aspect-ratio:var(--ar)}
.fit .over,.fit .under{flex:0 0 auto;width:min(100%,560px);margin:0}
.fit .lgbtn{padding:7px 10px;font-size:13.5px}
.fit .levels{margin-bottom:10px}
.fit .mode{font-size:13px}
.fit .rule{margin:0}
.fit .status{text-align:left;margin:0;min-height:22px}
.fit .controls{justify-content:flex-start;align-items:center;margin:0}
.fit .controls .back{margin:0 0 0 auto}
.fit .veil{border-radius:16px}
@media (max-aspect-ratio:1/1){
  .fit{max-width:640px;padding:10px 12px 12px;column-gap:0;row-gap:8px;grid-template-columns:minmax(0,1fr);
    grid-template-rows:auto minmax(220px,1fr) auto;grid-template-areas:"top" "stage" "bottom"}
  .fit .side{display:contents}
  .fit .top{grid-area:top} .fit .stage{grid-area:stage;gap:8px} .fit .bottom{grid-area:bottom}
  .fit .head{margin-bottom:6px}
  .fit h1{font-size:22px}
  .fit .seg,.fit .mode{margin-bottom:8px}
  .fit .mode{padding:7px 10px}
  .fit .levels{margin-bottom:6px}
  .fit .lv{min-height:46px;padding:6px 9px}
  .fit .rule{font-size:13px}
  .fit .bottom{flex-direction:row;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px 10px}
  .fit .status{flex-basis:100%;text-align:center}
  .fit .controls{justify-content:center}
  .fit .controls .back{flex-basis:100%;text-align:center;margin:2px 0 0}
}
@media (max-aspect-ratio:1/1) and (max-height:740px){
  .fit{grid-template-rows:auto minmax(180px,1fr) auto}
  .fit h1 small,.fit .rule{display:none}
}
@media (max-aspect-ratio:1/1) and (max-height:700px){ .fit .mode{display:none} }
/* A short wide window (a phone on its side): the controls tighter, so they fit beside the board. */
@media (min-aspect-ratio:1/1) and (max-height:560px){
  .fit{padding:10px 16px;column-gap:20px;min-height:200px;grid-template-columns:minmax(200px,250px) minmax(0,1fr)}
  .fit .side{gap:8px}
  .fit h1{font-size:20px}
  .fit h1 small,.fit .rule,.fit .mode{display:none}
  .fit .head,.fit .seg{margin-bottom:6px}
  .fit .seg button{padding:5px 8px;font-size:13px}
  .fit .levels{margin-bottom:0;gap:6px}
  .fit .lv{min-height:0;padding:5px 8px}
  .fit .lv b{font-size:13px}
  .fit .lv small{font-size:11px}
  .fit .bottom{gap:6px}
  .fit .btn{padding:7px 14px;font-size:14px}
  .fit .status{font-size:12.5px;line-height:1.35;min-height:0}
  .fit .bottom .controls{gap:6px}
  .fit .bottom .controls .btn{padding:6px 10px;font-size:13px}
  .fit .head .lgbtn,.fit .head .helpbtn{padding:5px 9px;font-size:12.5px}
}
