/* Online games (/games/, scripts/games.mjs, public/games/*.js). Uses the tokens in style.css. */
.gm { margin: var(--s5) 0 0; padding: 16px; border: 2px solid var(--line-2); border-radius: var(--radius-lg); background: var(--card); }
.gm-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); margin: 0 0 var(--s3); }
.gm-meta { margin: 0; font-weight: 800; }
.gm-count { margin: 0; display: flex; gap: var(--s4); flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.gm-count strong { font-size: var(--t-lg); }
.gm-opts { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin: 0 0 var(--s3); }
.gm-sel { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 700; }
.gm-sel select { font: inherit; min-height: 48px; padding: 6px 12px; border: 2px solid var(--ink); border-radius: 12px; background: #fff; color: var(--ink); max-width: 100%; }
.gm-tools { display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s3); }
.gm-tools2 { margin: var(--s3) 0 0; }
.gm-stage { position: relative; }
.gm-board { position: relative; }
.gm-cover { position: absolute; inset: 0; z-index: 2000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s3); background: rgba(255, 250, 240, .97); border-radius: var(--radius); font-weight: 800; font-size: var(--t-lg); min-height: 200px; }
.gm-cover[hidden] { display: none; }
.gm-status { min-height: 1.6em; margin: var(--s3) 0 0; color: var(--ink); }
.gm-done { margin: var(--s3) 0 0; padding: 16px 18px; border-radius: var(--radius); background: var(--green-soft); }
.gm-done h3 { margin: 0 0 6px; font-size: 1.5rem; }
.gm-done h3:focus { outline: none; }
.gm-done p { margin: 8px 0; }
.gm-dlg { max-width: min(560px, calc(100vw - 32px)); border: 2px solid var(--ink); border-radius: var(--radius-lg); padding: 20px 24px; color: var(--ink); background: var(--card); }
.gm-dlg::backdrop { background: rgba(29, 29, 59, .45); }
.gm-dlg h2 { margin: 0 0 12px; font-size: 1.5rem; }
.gm-dlg li { margin: 6px 0; }
.gm-nojs { color: var(--muted); }
.gm-big .gm-status, .gm-big .gm-meta, .gm-big .gm-count { font-size: 1.3rem; }
.gm-big button, .gm-big .gm-sel select { font-size: 1.2rem; min-height: 56px; }

/* Resume choice after a reload (shell.js resumable) */
.gm-offer p { margin: 0; max-width: 34ch; text-align: center; padding: 0 12px; }
.gm-offer .gm-offer-b { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: center; }

/* Big screen (care homes, classrooms): extra-large print, high contrast, no clock, larger targets (shell.js) */
.gm-huge { --ink: #000; --muted: #222; --line-2: #000; color: #000; background: #fff; border: 4px solid #000; font-size: 1.3rem; }
.gm-huge .gm-clock { display: none; }
.gm-huge .gm-status, .gm-huge .gm-meta, .gm-huge .gm-count { font-size: 1.6rem; font-weight: 800; color: #000; }
/* toolbar, option and panel buttons only: board pieces (tiles, cards, letter cells) keep their own sizes */
.gm-huge :is(.primary, .alt, .chip), .gm-huge :is(.gm-tools, .gm-opts, .gm-cover, .gm-done, .gm-dlg) button, .gm-huge .gm-sel select, .gm-huge .gm-sel input { font-size: 1.4rem; min-height: 64px; border-width: 3px; }
.gm-huge :is(.primary, .alt, .chip), .gm-huge :is(.gm-tools, .gm-opts, .gm-cover, .gm-done, .gm-dlg) button { padding: 12px 24px; }
.gm-huge .gm-sel { max-width: 100%; }
.gm-huge .gm-sel select { font-size: 1.25rem; min-width: 0; width: 100%; }
.gm-huge .alt, .gm-huge .chip { --b-bg: #fff; --b-fg: #000; --b-bd: #000; }
.gm-huge .chip[aria-pressed="true"], .gm-huge .alt[aria-pressed="true"] { --b-bg: #000; --b-fg: #fff; --b-bd: #000; }
.gm-huge .primary { --b-bg: #8c2a10; --b-bd: #000; --b-fg: #fff; }
.gm-huge button:disabled { opacity: 1; --b-bg: #e6e6e6; --b-fg: #000; }
.gm-huge :focus-visible { outline: 5px solid #0047b3; outline-offset: 3px; }
.gm-huge .gm-cover { background: #fff; color: #000; font-size: 1.6rem; }
.gm-huge .gm-done { background: #fff; border: 3px solid #000; font-size: 1.4rem; }
.gm-huge .gm-done h3 { font-size: 2rem; }
.gm-huge a { color: #0039a6; text-decoration-thickness: 2px; }

/* ---------- hub ---------- */
.gh-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.gh-card a { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; height: 100%; padding: 16px 18px; border: 2px solid var(--line-2); border-radius: var(--radius); background: var(--card); color: var(--ink); text-decoration: none; }
.gh-card a:hover { border-color: var(--ink); }
.gh-new a { border-color: var(--coral); background: var(--coral-soft); }
.gh-name { font-weight: 800; font-size: var(--t-lg); flex: 1 1 100%; }
.gh-what { flex: 1 1 100%; color: var(--muted); font-size: var(--t-sm); }
.gh-tag { font-size: .875rem; font-weight: 800; padding: 2px 10px; border-radius: 999px; }
.gh-tag.on { background: var(--green-soft); color: var(--green); }
.gh-tag.pr { background: var(--blue-soft); color: var(--sky); }
.gh-tag.nw { background: var(--sun); color: var(--ink); }

/* ---------- Klondike ---------- */
.gm[data-game="solitaire"] .gm-board { --gap: clamp(4px, 1.4cqi, 12px); --cw: calc((100cqi - 6 * var(--gap)) / 7); --ch: calc(var(--cw) * 1.4); --off: calc(var(--cw) * .3); --offd: calc(var(--cw) * .12); touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.gm[data-game="solitaire"] .gm-stage { container-type: inline-size; max-width: 820px; margin: 0 auto; }
.gm-big[data-game="solitaire"] .gm-board { --off: calc(var(--cw) * .42); }
.sol-top, .sol-tab { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--gap); }
.sol-top { margin-bottom: calc(var(--gap) * 2); }
.sol-pile { position: relative; height: var(--ch); border-radius: 8px; outline-offset: 3px; }
.sol-pile.empty, .sol-f, .sol-s { background: rgba(29, 29, 59, .06); box-shadow: inset 0 0 0 2px rgba(29, 29, 59, .18); }
.sol-f::before { content: attr(data-suit); position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * .5); color: rgba(29, 29, 59, .22); }
.sol-s.recycle::before { content: "↻"; position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * .5); color: rgba(29, 29, 59, .45); }
.sol-t { height: calc(var(--ch) + (var(--n, 1) - var(--nd, 0) - 1) * var(--off) + var(--nd, 0) * var(--offd)); min-height: var(--ch); }
.sol-pile:focus-visible { outline: 3px solid var(--focus); }
.sol-card { position: absolute; left: 0; top: 0; width: 100%; height: var(--ch); border-radius: 8px; background: #fff; border: 1.5px solid #8a8aa6; box-shadow: 0 1px 2px rgba(29, 29, 59, .15); cursor: pointer; overflow: hidden; }
.sol-t .sol-card { top: calc(var(--d) * var(--offd) + (var(--i) - var(--d)) * var(--off)); }
.sol-w .sol-card.fan { left: calc(var(--i) * var(--cw) * .22); }
.sol-w { overflow: visible; }
.sol-card.back { background: repeating-linear-gradient(45deg, #c8401c 0 6px, #e4572e 6px 12px); border-color: #fff; box-shadow: 0 0 0 1px #a3330f; }
.sol-card.red { color: #b3261e; }
.sol-card.black { color: #1d1d3b; }
.sol-corner { position: absolute; left: 6%; top: 2%; font: 800 calc(var(--cw) * .3) / 1 var(--font); letter-spacing: -.04em; display: flex; gap: 1px; align-items: baseline; }
.sol-corner span { font-size: .9em; }
.sol-mid { position: absolute; inset: 30% 0 0; display: grid; place-items: center; font-size: calc(var(--cw) * .62); line-height: 1; }
.gm-big .sol-corner { font-size: calc(var(--cw) * .4); }
.sol-card.sel { box-shadow: 0 0 0 3px var(--sun), 0 0 0 5px var(--ink); }
.sol-card.dragging { z-index: 1000; box-shadow: var(--shadow-float); }

/* ---------- Tile matching ---------- */
.gm[data-game="tiles"] .gm-board { margin: 0 auto; max-width: 1100px; touch-action: manipulation; }
.tl { all: unset; box-sizing: border-box; position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(var(--tw) * .05) calc(var(--tw) * .04) calc(var(--tw) * .03); border-radius: calc(var(--tw) * .1); background: linear-gradient(#fffdf6, #f2ead6); border: 1.5px solid #8a7f62; box-shadow: 3px 4px 0 #cfc3a3, 3px 4px 0 1.5px #8a7f62; cursor: pointer; filter: saturate(.5) brightness(.9); }
.tl.free { filter: none; }
.tl svg { display: block; width: auto; height: 72%; max-width: 92%; aspect-ratio: 1; flex: none; }
.tl-name { font: 700 clamp(8px, calc(var(--tw) * .155), 18px) / 1.1 var(--font); letter-spacing: -.02em; color: var(--ink); white-space: nowrap; overflow: hidden; max-width: 100%; }
.gm-big .tl-name { font-size: calc(var(--tw) * .2); font-weight: 800; }
.tl:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.tl.sel { background: var(--sun); box-shadow: 0 0 0 3px var(--ink); }
.tl.hint { background: #cfe0ff; box-shadow: 0 0 0 3px var(--sky); }
.tl[hidden] { display: none; }

/* ---------- Jigsaw ---------- */
.jg-sizes { display: flex; flex-wrap: wrap; gap: 8px; }
.jg-who { font-weight: 400; font-size: .85em; }
.jg-choose { flex: 1 1 100%; }
.jg-choose summary { cursor: pointer; font-weight: 800; min-height: 44px; display: flex; align-items: center; }
.jg-gh { font-size: var(--t-md); margin: 12px 0 6px; }
.jg-pics { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.jg-pic { all: unset; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 6px; border: 2px solid var(--line-2); border-radius: 12px; cursor: pointer; text-align: center; font-size: var(--t-xs); font-weight: 700; background: #fff; }
.jg-pic:hover { border-color: var(--ink); }
.jg-pic:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.jg-pic img { width: 96px; height: 96px; border-radius: 8px; }
.jg-area { position: relative; width: 100%; }
.jg-frame { position: absolute; left: 0; top: 0; border: 2px dashed #8a8aa6; border-radius: 6px; background: #fff; box-sizing: content-box; margin: -2px; }
.jg-ghost { width: 100%; height: 100%; opacity: .22; display: block; transition: opacity .2s; pointer-events: none; }
.jg-cursor { position: absolute; box-shadow: inset 0 0 0 3px var(--sky); pointer-events: none; }
.jg-piece { position: absolute; z-index: 5; cursor: grab; touch-action: none; filter: drop-shadow(1px 2px 2px rgba(29, 29, 59, .35)); }
.jg-piece.placed { cursor: default; filter: none; z-index: 1; }
.jg-piece.dragging { cursor: grabbing; filter: drop-shadow(3px 6px 6px rgba(29, 29, 59, .4)); }
.jg-piece:focus-visible { outline: 3px solid var(--focus); outline-offset: -6px; }
.jg-colour { margin: var(--s3) 0 0; font-weight: 700; }

/* ---------- Memory match (public/games/memory.js) ---------- */
.mm-grid { --cols: 4; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: clamp(4px, 1.4vw, 12px); max-width: 920px; margin: 0 auto; touch-action: manipulation; }
.mm-card { all: unset; box-sizing: border-box; position: relative; aspect-ratio: 4 / 5; border-radius: 12px; cursor: pointer; perspective: 600px; }
.mm-card > span { position: absolute; inset: 0; border-radius: 12px; backface-visibility: hidden; transition: transform .3s ease; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.mm-back { background: repeating-linear-gradient(135deg, #1f62d6 0 8px, #3b7be6 8px 16px); border: 3px solid #fff; box-shadow: 0 0 0 2px #1a4fae, 0 2px 4px rgba(29, 29, 59, .2); }
.mm-back::after { content: ""; width: 34%; aspect-ratio: 1; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: inset 0 0 0 4px #ffcf4a; }
.mm-face { background: #fff; border: 2px solid #8a8aa6; transform: rotateY(180deg); padding: 6%; box-sizing: border-box; }
.mm-face svg { width: 88%; flex: 1 1 auto; min-height: 0; }
.mm-word { display: none; font: 800 clamp(.7rem, 2.6vw, 1.15rem) / 1.1 var(--font); color: var(--ink); text-align: center; overflow-wrap: anywhere; }
.mm-words .mm-word { display: block; }
.gm-big .mm-word { font-size: clamp(.95rem, 3.4vw, 1.5rem); }
.mm-card.up .mm-back { transform: rotateY(180deg); }
.mm-card.up .mm-face { transform: rotateY(360deg); }
.mm-card.matched .mm-face { background: var(--green-soft); border-color: var(--green); }
.mm-card.matched .mm-face::after { content: "✓"; position: absolute; top: 4px; right: 8px; font-weight: 800; color: var(--green); }
.mm-card:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
.mm-card.pop .mm-face { animation: mm-pop .35s ease; }
@keyframes mm-pop { 50% { transform: scale(1.06); } }
.gm[data-style="kids"] .mm-back { background: repeating-linear-gradient(135deg, #e4572e 0 10px, #ff8a3d 10px 20px); box-shadow: 0 0 0 2px #a3330f; }
.gm[data-style="kids"] .mm-face { border-width: 3px; border-color: #ffcf4a; }
.gm[data-style="calm"] .mm-back { background: #2f5aa8; }
.gm[data-style="calm"] .mm-back::after { box-shadow: none; background: rgba(255, 255, 255, .6); }
.gm[data-style="calm"] .mm-face { border-width: 3px; border-color: var(--ink); }
.gm[data-style="calm"] .mm-word { font-size: clamp(1rem, 3.6vw, 1.6rem); }
.gm[data-style="calm"] .gm-count > span:first-child { display: none; }
.gm[data-style="calm"] .mm-grid { gap: clamp(8px, 2vw, 18px); max-width: 760px; }
@media (prefers-reduced-motion: reduce) { .mm-card > span { transition: none; } .mm-card.pop .mm-face { animation: none; } }

/* ---------- Nonograms (public/games/nonograms.js) ---------- */
.ng-pens { display: inline-flex; gap: 6px; }
.ng-wrap { display: flex; justify-content: center; overflow-x: auto; padding: 2px; }
.ng { --cell: 32px; --clue-w: 60px; display: table; border-collapse: collapse; touch-action: none; user-select: none; -webkit-user-select: none; }
.ng-row { display: flex; }
.ng-corner { width: var(--clue-w); flex: none; }
.ng-cc { width: var(--cell); flex: none; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 4px; font: 700 calc(var(--cell) * .42) / 1.15 var(--font); color: var(--ink); }
.ng-rc { width: var(--clue-w); height: var(--cell); flex: none; display: flex; justify-content: flex-end; align-items: center; gap: .35em; padding-right: 6px; box-sizing: border-box; font: 700 calc(var(--cell) * .42) / 1 var(--font); color: var(--ink); }
.ng-cc.done, .ng-rc.done { color: #6e6e8e; text-decoration: line-through; text-decoration-thickness: 1px; }
.ng-c { width: var(--cell); height: var(--cell); flex: none; box-sizing: border-box; border: 1px solid #b8b8cc; margin: 0 -1px -1px 0; background: #fff; cursor: pointer; position: relative; }
.ng-c.ng-r5 { border-right: 2px solid var(--ink); }
.ng-c.ng-b5 { border-bottom: 2px solid var(--ink); }
.ng-c.on { background: var(--ink); border-color: var(--ink); }
.ng-c.x::before, .ng-c.x::after { content: ""; position: absolute; left: 22%; right: 22%; top: 50%; height: 2px; background: #8a8aa6; transform: rotate(45deg); }
.ng-c.x::after { transform: rotate(-45deg); }
.ng-c.bad { box-shadow: inset 0 0 0 3px #d32f2f; }
.ng-c.hinted { box-shadow: inset 0 0 0 3px var(--sun); }
.ng-c:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; z-index: 2; }
.ng-row:first-child { align-items: flex-end; }
.ng.ng-won .ng-c.on { background: var(--coral); border-color: var(--coral); transition: background .4s; }

/* ---------- Word guess (public/games/word-guess.js) ---------- */
.wg { display: grid; grid-template-columns: minmax(120px, 220px) minmax(0, 1fr); gap: var(--s4); align-items: start; }
@media (max-width: 560px) { .wg { grid-template-columns: minmax(0, 1fr); } .wg-art { max-width: 170px; margin: 0 auto; } }
.wg-art { aspect-ratio: 200 / 220; }
.wg-art svg { display: block; }
.wg-part { transition: opacity .6s ease, transform .6s ease; }
.wg-part.gone { opacity: 0; transform: translateY(24px); }
@media (prefers-reduced-motion: reduce) { .wg-part { transition: none; } }
.wg-cat { margin: 0 0 var(--s2); font-weight: 800; color: var(--muted); }
.wg-word { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 var(--s3); }
.wg-l { min-width: 1.3em; text-align: center; border-bottom: 4px solid var(--ink); font: 800 clamp(1.6rem, 6vw, 2.4rem) / 1.15 var(--font); color: var(--ink); text-transform: uppercase; }
.wg-l.told { color: var(--coral); }
.gm-big .wg-l { font-size: clamp(2rem, 8vw, 3rem); }
.wg-clue { margin: 0 0 var(--s3); }
.wg-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; max-width: 560px; }
.wg-key { all: unset; box-sizing: border-box; min-height: 48px; display: flex; align-items: center; justify-content: center; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font: 800 1.2rem / 1 var(--font); color: var(--ink); cursor: pointer; }
.wg-key:hover:not(:disabled) { background: var(--sun-soft); }
.wg-key:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wg-key:disabled { cursor: default; border-style: dashed; color: #6b6b88; background: #f4f1ea; }
.wg-key.yes::after { content: "✓"; font-size: .7em; margin-left: 2px; }
.wg-key.no { text-decoration: line-through; }
.gm-big .wg-keys { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); }
.gm-big .wg-key { min-height: 60px; font-size: 1.5rem; }
.wg-wrong { min-height: 1.5em; margin: var(--s3) 0 0; font-weight: 700; color: var(--muted); }
.wg-after { margin: var(--s3) 0 0; padding: 12px 16px; border-radius: var(--radius); background: var(--blue-soft); }
.wg-after p { margin: 6px 0; }
