/* kids-games.css: owned by area B1, Games (tools/kids/CONTRACT.md sections 0, 5 and 16c; FUN.md section 4). Class prefix kg-.
 * The first five games, made to move (55-little-games.js): pop, pairs, mixer, dots, odd. Each game is one box on a scene (LR.fx.stage), with the shared
 * meter and streak mark on top (kids-fx.css) and the shared ending (LR.fx.endPanel) in place of the box when it is done. Objects only: balloons, cards, carts,
 * boats and stars (no face, no animal); big targets (the band's --kids-target at least); no sound, no flashing; light only.
 * Reduced motion (the last block): every effect is a fade, nothing moves, the game stays playable.
 * Text never sits straight on a scene: a letter always sits on a card, a sticker or a plate of its own (white or a colour's tint).
 * Arabic is one element each, in the mushaf face (a lone Yaa in Amiri Quran: .ar-dots), line-height 1.6 with a little padding so no mark is cut. */

.kg-game [hidden] { display: none !important; }

/* ---- the box: a scene behind, the meter and the how-to key on top, the play area, the foot ----
 * The box is the one size container of the game (its play area, its head and the things in it are sized in cqw). A size container has no width of its own to offer a parent that sizes
 * itself from its content (the class board's unit, Teach at home: they shrink to fit what is inside), so it names the width it wants (--kg-nat) and the board zooms the rest.
 * --kg-room (the whole box: the screen's height from its top edge down to whatever sits under it) and --kg-play (what is left for the play area) are set by the game
 * (55-little-games.js, fit) in the page's own pixels, the words' size (Aa) already allowed for: the balloons, the cards, the carts and the dots' shape take their size from
 * them, so what a child has to press is on the first screen. A game that is not on a page of its own (no data-own: the class board, Teach at home) sets neither (its stage zooms the
 * whole game to fit instead): the sizes then fall back to their own caps. */
.kg-game {
  --kg-nat: 640px;
  display: flex; flex-direction: column; row-gap: 8px; width: 100%; max-width: 840px; margin-inline: auto; min-height: min(var(--kg-room, 0px), 860px);
  padding: 12px 12px 14px; box-sizing: border-box;
  container-type: inline-size; contain-intrinsic-inline-size: var(--kg-nat);
}
/* until the game has measured the room (the next frame, data-fit) the box is a whole window tall: a page that scrolls its stage into view the moment it opens a game (Today) then has a page to scroll to */
.kg-game[data-own]:not([data-fit]) { min-height: min(100dvh, 860px); }
.kg-head { flex: none; display: grid; gap: 8px; min-width: 0; }
.kg-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px 10px; min-width: 0; }
.kg-howkey { min-width: var(--kids-target, 56px); }
/* on a phone the how-to key is the question mark alone (its words are the aria-label), so the meter has room */
@media (max-width: 559px) {
  .kg-howkey .key__label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
}
.kg-meterbox { min-width: 0; }
.kg-meterbox .kx-meter { margin: 0; max-width: none; }
/* the streak mark keeps the room it needs (stars alone for Little ones, stars and the number for the others), so the meter never changes width when it shows */
.kg-top .kx-streak { min-width: 96px; padding-inline: 8px; }
.kg-game:not([data-band="little"]) .kg-top .kx-streak { min-width: 124px; }
/* a narrow box (a small phone, or the words zoomed up with Aa): the streak mark stays beside the how-to key and the meter takes the whole row under them, so it is never squeezed to nothing */
@container (max-width: 299px) {
  .kg-top { grid-template-columns: auto minmax(0, 1fr); }
  .kg-top > .kx-streak { grid-column: 2; grid-row: 1; justify-self: end; }
  .kg-meterbox { grid-column: 1 / -1; grid-row: 2; }
}
.kg-top .kx-streak[data-level="1"] .kx-streak__star { width: 22px; height: 22px; }
.kg-top .kx-streak[data-level="2"] .kx-streak__star { width: 24px; height: 24px; }
.kg-top .kx-streak[data-level="3"] .kx-streak__star { width: 26px; height: 26px; }
.kg-howtext {
  justify-self: center; margin: 0; max-width: 36ch; padding: 6px 16px; border-radius: var(--r-pill, 999px); background: rgba(255, 255, 255, .92); text-align: center;
  font: 700 var(--t-body)/1.4 var(--font-body); color: var(--ink); text-wrap: pretty;
}
.kg-game[data-short] .kg-howtext { display: none; }                   /* a short window (under 700 of the page's own pixels, Aa allowed for: set by the game) needs the room for the game: the ? key says it */
.kg-stage { flex: 1 1 auto; display: grid; place-items: center; width: 100%; min-width: 0; }   /* the play area takes what the box has left; it never shrinks below what the game needs: the foot is never covered */
/* the foot (hear again, the tick, Done) */
.kg-foot { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 100%; }
/* the mixer's page is long (up to 28 letters): on a page of its own (data-own) its Done key floats at the bottom edge of the screen while the letters scroll (its empty parts take no tap) */
.kg-g-mixer[data-own] .kg-foot { position: sticky; bottom: 8px; z-index: 3; pointer-events: none; }
.kg-g-mixer .kg-foot > * { pointer-events: auto; }
.kg-hear { min-width: var(--kids-target, 56px); }
.kg-meterbox.is-reset .kx-meter__fill, .kg-meterbox.is-reset .kx-meter__art { transition: none !important; }

/* Arabic in a game: one element, never wrapped; the mushaf face is 1.76em tall, the dotted Yaa (Amiri Quran) about 2.1em */
.kg-ar { display: block; margin: 0; direction: rtl; line-height: 1.6; padding-block: .1em; white-space: nowrap; word-break: keep-all; overflow-wrap: normal; text-align: center; }
.kg-ar.ar-dots { padding-block: .12em .45em; }

/* ---- pop: balloons with strings rise from below and bob; the right one bursts into pieces ---- */
.kg-balloons {
  /* a balloon is as wide as the row allows, at most --kg-max, and never so big that the rows (a balloon is 1.56 times its width, a string and a gap below) do not fit the room --kg-play leaves;
     never under 64px: a window too short for that scrolls instead */
  --kg-cols: 2; --kg-rows: 2; --kg-gap: 14px; --kg-max: 190px;
  --kg-vmax: max(64px, calc((var(--kg-play, 9999px) - 42px - (var(--kg-rows) - 1) * 6px) / (1.56 * var(--kg-rows))));
  --kg-b: min(calc((100cqw - 12px - (var(--kg-cols) - 1) * var(--kg-gap)) / var(--kg-cols)), var(--kg-max), var(--kg-vmax));
  display: grid; grid-template-columns: repeat(var(--kg-cols), var(--kg-b)); justify-content: center; align-content: center; justify-items: center; gap: 6px var(--kg-gap);
  width: 100%; min-height: 100%; padding: 6px 4px 36px; box-sizing: border-box;
}
.kg-balloons[data-n="5"], .kg-balloons[data-n="6"] { --kg-cols: 3; }
@container (min-width: 620px) {
  .kg-balloons[data-n="4"] { --kg-cols: 4; --kg-rows: 1; }
  .kg-balloons[data-n="5"] { --kg-cols: 5; --kg-rows: 1; }
  .kg-balloons[data-n="6"] { --kg-cols: 6; --kg-rows: 1; }
}
/* a phone on its side is short: one row of balloons as soon as they fit it at 64px (4 need 310px, 5 need 388px, 6 need 466px) instead of two rows that need the page to scroll */
@media (orientation: landscape) {
  @container (min-width: 320px) { .kg-game[data-short] .kg-balloons[data-n="4"] { --kg-cols: 4; --kg-rows: 1; } }
  @container (min-width: 400px) { .kg-game[data-short] .kg-balloons[data-n="5"] { --kg-cols: 5; --kg-rows: 1; } }
  @container (min-width: 480px) { .kg-game[data-short] .kg-balloons[data-n="6"] { --kg-cols: 6; --kg-rows: 1; } }
}
.kg-game[data-band="readers"] .kg-balloons { --kg-max: 160px; }
.kg-game[data-band="big"] .kg-balloons { --kg-max: 150px; }
@supports not (width: 1cqw) {
  .kg-balloons { display: flex; flex-wrap: wrap; --kg-b: clamp(104px, 28vw, 150px); }
}
.kg-balloon {
  appearance: none; position: relative; top: var(--kg-y, 0px); flex: none; display: block; box-sizing: border-box; width: var(--kg-b); height: calc(var(--kg-b) * 1.56); margin: 0; padding: 0;
  border: 0; background: none; color: var(--ink); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  animation: kg-rise .8s cubic-bezier(.2, .8, .3, 1) backwards; animation-delay: var(--kg-d, 0s);
}
.kg-balloon__in, .kg-balloon__sway { position: absolute; inset: 0; display: block; }
.kg-balloon .kx-art.kg-balloon__body { position: absolute; left: 0; top: 0; width: 100%; height: auto; }
.kg-balloon .kx-art.kg-balloon__string { position: absolute; left: 0; top: calc(var(--kg-b) * 1.08); width: 100%; height: auto; }
.kg-balloon__label {
  position: absolute; left: 50%; top: calc(var(--kg-b) * .15); width: calc(var(--kg-b) * .62); height: calc(var(--kg-b) * .66); margin-left: calc(var(--kg-b) * -.31);
  display: grid; place-items: center; border-radius: 50%; background: #fff; box-shadow: 0 2px 0 rgba(26, 31, 28, .12); font-size: calc(var(--kg-b) * .46);
}
.kg-balloon__label .kg-ar { font-size: 1em; line-height: 1.5; padding-block: .06em; }
.kg-balloon__label .kg-ar.ar-dots { padding-block: .06em .3em; transform: translateY(-.41em); }   /* Amiri Quran's yaa hangs below the line: lift it into the sticker */
@media (hover: hover) { .kg-balloon:hover .kg-balloon__label { box-shadow: 0 0 0 4px rgba(255, 255, 255, .7), 0 2px 0 rgba(26, 31, 28, .12); } }
.kg-balloon:focus-visible { outline: none; }
.kg-balloon:focus-visible::before {
  content: ''; position: absolute; left: -5px; right: -5px; top: -5px; height: calc(var(--kg-b) * 1.12 + 10px); border-radius: 50%; border: 4px solid var(--lapis); box-shadow: 0 0 0 2px #fff; pointer-events: none;
}
@keyframes kg-rise { from { transform: translateY(var(--kg-from, 240px)); opacity: 0; } 55% { opacity: 1; } to { transform: none; opacity: 1; } }
/* the pop: the body snaps and goes, the sticker jumps out, the string drops, a ring spreads, the others are blown a little way from the blast */
.kg-balloon.is-burst { pointer-events: none; }
.kg-balloon.is-burst .kg-balloon__in, .kg-balloon.is-burst .kg-balloon__sway { animation-play-state: paused; }
.kg-balloon.is-burst .kg-balloon__body { animation: kg-snap .2s ease-out forwards; }
.kg-balloon.is-burst .kg-balloon__string { animation: kg-drop .8s cubic-bezier(.5, 0, .9, .6) forwards; transform-origin: 50% 0; }
.kg-balloon.is-burst .kg-balloon__label { animation: kg-letter .9s cubic-bezier(.3, .7, .4, 1) forwards; }
.kg-balloon.is-burst::after {
  content: ''; position: absolute; left: 4%; top: 3%; width: 92%; height: calc(var(--kg-b) * 1.02); border-radius: 50%; border: 6px solid var(--kx-c); pointer-events: none;
  animation: kg-ring .5s ease-out forwards;
}
.kg-balloon.is-nudged { animation: kg-nudge .6s cubic-bezier(.3, .7, .4, 1); }
@keyframes kg-snap { from { scale: 1; opacity: 1; } to { scale: 1.3; opacity: 0; } }
@keyframes kg-drop { from { translate: 0 0; rotate: 0deg; opacity: 1; } to { translate: 0 90%; rotate: 16deg; opacity: 0; } }
@keyframes kg-letter { 0% { translate: 0 0; scale: 1; opacity: 1; } 32% { translate: 0 -9%; scale: 1.3; opacity: 1; } 72% { translate: 0 -5%; scale: 1.2; opacity: 1; } 100% { translate: 0 -10%; scale: 1.2; opacity: 0; } }
@keyframes kg-ring { from { scale: .5; opacity: .9; } to { scale: 1.35; opacity: 0; } }
@keyframes kg-nudge { 0% { transform: none; } 28% { transform: translate(var(--kg-nx, 0), var(--kg-ny, 0)) rotate(var(--kg-nr, 0deg)); } 100% { transform: none; } }
.kg-balloons.is-away { animation: kg-away .46s cubic-bezier(.5, 0, .8, .5) forwards; pointer-events: none; }
@keyframes kg-away { to { transform: translateY(-62%); opacity: 0; } }

/* ---- pairs: cards that really flip; a matched pair shines and flies to the meter ---- */
.kg-pgrid {
  /* the board is as wide as the room allows (a card is 1.24 times its width, and the rows and gaps must fit --kg-play), at most 560px, and never narrower than cards of 72px: a short window
     (a phone on its side) scrolls, it never shrinks the cards past what a finger can press. --kg-cw is the width of one card (the letter is 58% of it) */
  --kg-pgap: 12px;
  --kg-pw: min(560px, max(calc(var(--kg-cols, 3) * 72px + (var(--kg-cols, 3) - 1) * var(--kg-pgap) + 8px),
    calc((var(--kg-play, 9999px) - 16px - (var(--kg-rows, 2) - 1) * var(--kg-pgap)) / var(--kg-rows, 2) / 1.24 * var(--kg-cols, 3) + (var(--kg-cols, 3) - 1) * var(--kg-pgap) + 8px)));
  --kg-cw: calc((min(100cqw, var(--kg-pw)) - 8px - (var(--kg-cols, 3) - 1) * var(--kg-pgap)) / var(--kg-cols, 3));
  display: grid; grid-template-columns: repeat(var(--kg-cols, 3), minmax(0, 1fr)); gap: var(--kg-pgap); width: 100%; max-width: var(--kg-pw); padding: 6px 4px 10px;
}
@supports (width: 1cqw) { .kg-pgrid { --kg-pgap: clamp(6px, 3cqw, 12px); } }
.kg-pcard {
  appearance: none; position: relative; display: block; box-sizing: border-box; min-width: 0; width: 100%; aspect-ratio: 5 / 6; padding: 0; border: 0; border-radius: 16px; background: none;
  font-size: clamp(2rem, calc(var(--kg-cw, 100px) * .58), 5.4rem); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  animation: kg-deal .5s cubic-bezier(.3, .8, .4, 1) backwards; animation-delay: calc(var(--kg-n, 0) * 55ms);
}
.kg-pcard[data-cols="4"], .kg-pgrid[data-cols="4"] .kg-pcard { aspect-ratio: 5 / 6.2; }
.kg-pcard__persp { position: absolute; inset: 0; display: block; perspective: 700px; }
.kg-pcard__in { position: absolute; inset: 0; display: block; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.3, .7, .3, 1); }
.kg-pcard[data-state="up"] .kg-pcard__in, .kg-pcard[data-state="done"] .kg-pcard__in { transform: rotateY(180deg); }
.kg-pcard__back, .kg-pcard__front { position: absolute; inset: 0; display: block; border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.kg-pcard__back { box-shadow: 0 5px 0 var(--kx-c-deep), 0 9px 14px rgba(26, 31, 28, .2); }
.kg-pcard .kx-art.kg-pcard__art { position: absolute; inset: 0; width: 100%; height: 100%; clip-path: inset(0 round 16px); }
.kg-pcard__front {
  transform: rotateY(180deg); display: grid; place-items: center; box-sizing: border-box; background: #fff; border: 4px solid var(--kx-c);
  box-shadow: inset 0 0 0 3px var(--kx-c-tint), 0 5px 0 var(--kx-c-deep), 0 9px 14px rgba(26, 31, 28, .2);
}
.kg-face { display: grid; justify-items: center; align-content: center; gap: 0; max-width: 100%; color: var(--ink); }
.kg-face .kg-ar { font-size: 1em; line-height: 1.4; padding-block: .18em; }
.kg-face .kg-ar.ar-dots { padding-block: .12em .5em; }
.kg-face--ear .icon { width: .6em; height: .6em; stroke: var(--ink); fill: none; }
.kg-pcard__cap { font: 700 var(--t-cap)/1.1 var(--font-body); color: var(--ink-soft); }
.kg-pcard[data-state="done"] .kg-pcard__front { border-color: var(--kx-mint); background: var(--kx-mint-tint); }
.kg-pcard.is-miss .kg-pcard__front { border-color: var(--kx-amber); background: var(--kx-amber-tint); }
.kg-pcard.is-glow .kg-pcard__front { animation: kg-glow .9s ease-out; }
@keyframes kg-glow {
  0% { box-shadow: inset 0 0 0 3px var(--kx-c-tint), 0 5px 0 var(--kx-c-deep), 0 0 0 0 rgba(255, 194, 71, .95); }
  45% { box-shadow: inset 0 0 0 3px var(--kx-c-tint), 0 5px 0 var(--kx-c-deep), 0 0 0 16px rgba(255, 194, 71, .45); }
  100% { box-shadow: inset 0 0 0 3px var(--kx-c-tint), 0 5px 0 var(--kx-c-deep), 0 0 0 26px rgba(255, 194, 71, 0); }
}
/* a pair that has flown to the meter leaves an empty place, not a hole in the board */
.kg-pcard.is-gone { pointer-events: none; }
.kg-pcard.is-gone .kg-pcard__persp { visibility: hidden; }
.kg-pcard.is-gone::before { content: ''; position: absolute; inset: 0; border-radius: 16px; border: 3px dashed rgba(255, 255, 255, .85); background: rgba(255, 255, 255, .2); }
.kg-pcard:focus-visible { outline: 4px solid var(--lapis); outline-offset: 3px; }
@keyframes kg-deal { from { transform: translateY(-44px) rotate(-8deg) scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- mixer: a letter and a mark slide together into a syllable; a boat sails with each new sound ---- */
.kg-mix {
  /* --kg-s: the bench's unit, the side of its two slots (64px, smaller when the box is narrower: the bench has to hold [slot] + [slot] = [sound, 1.94 units wide] in one row, so it never
     wraps and the sound is never cut off: a 360px phone, a 320px one, the words zoomed up). Everything in the bench is a multiple of it. */
  --kg-s: 64px;
  display: grid; justify-items: center; align-content: start; gap: 12px; width: 100%; max-width: 640px;
}
@supports (width: 1cqw) { .kg-mix { --kg-s: min(64px, calc((100cqw - 98px) / 3.96)); } }
.kg-mix__top { display: grid; justify-items: center; gap: 10px; width: 100%; padding: 10px 6px 12px; border-radius: 28px; background: rgba(255, 255, 255, .6); }
@media (min-height: 700px) { .kg-mix__top { position: sticky; top: calc(var(--topbar-h, 56px) + 2px); z-index: 2; } }
.kg-bench {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 6px; max-width: 100%; padding: 10px 10px; border-radius: 26px; background: #fff;
  box-shadow: 0 5px 0 var(--kx-sky), 0 9px 18px rgba(8, 71, 127, .18);
}
.kg-bslot {
  display: grid; place-items: center; flex: none; box-sizing: border-box; width: var(--kg-s); height: var(--kg-s); border-radius: calc(var(--kg-s) * .28); border: 3px dashed var(--kx-sky); background: var(--kx-sky-tint); color: var(--ink); font-size: calc(var(--kg-s) * .55);
}
.kg-bslot:not([data-empty]) { border-style: solid; border-color: var(--kx-sky-deep); background: #fff; }
.kg-bslot .kg-ar { font-size: 1em; line-height: 1.5; padding-block: .06em; }
.kg-bslot__mark { font-size: calc(var(--kg-s) * .6); }
.kg-bslot .kg-bslot__mark.kg-ar { line-height: 1.2; padding-block: .3em; }
.kg-bslot .kg-bslot__mark.kg-ar.ar-dots { font-size: .8em; transform: translateY(-.15em); }
.kg-op { flex: none; min-width: .8em; text-align: center; font: 800 1.5rem/1 var(--font-body); color: var(--kx-sky-deep); }
.kg-mix__out {
  display: grid; place-items: center; flex: none; box-sizing: border-box; width: calc(var(--kg-s) * 1.94); min-height: calc(var(--kg-s) * 2.06); border-radius: calc(var(--kg-s) * .34); border: 3px solid var(--kx-mint-deep); background: var(--kx-mint-tint); color: var(--ink); font-size: var(--kg-s);
}
/* the sound that comes out of the bench: the syllables with a mark above or below the letter (and the lone yaa's dots) need room above and below the letter, or the mark leaves the box */
.kg-mix__out .kg-ar { line-height: 1.35; padding-block: .25em; }
.kg-mix__out .kg-ar.ar-dots { padding-block: 0 .55em; }
.kg-mix__out[data-empty] { border-style: dashed; border-color: var(--kx-mint); background: var(--kx-mint-tint); }
.kg-mix__hole { width: calc(var(--kg-s) * .47); height: calc(var(--kg-s) * .47); border-radius: 50%; border: 3px dashed var(--kx-sky); opacity: .8; }
.kg-mix__out .kg-ar { font-size: 1em; }
.kg-bench.is-mixing .kg-bslot--letter { animation: kg-slide-in .6s ease-in-out; }
.kg-bench.is-mixing .kg-bslot--mark { animation: kg-slide-in-l .6s ease-in-out; }
.kg-bench.is-mixing .kg-mix__out { box-shadow: 0 0 0 6px rgba(111, 221, 164, .55); }
@keyframes kg-slide-in { 35% { translate: 16px 0; scale: .9; } 100% { translate: 0 0; scale: 1; } }
@keyframes kg-slide-in-l { 35% { translate: -16px 0; scale: .9; } 100% { translate: 0 0; scale: 1; } }
.kg-mix__marks, .kg-mix__letters { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
.kg-mix__letters { padding: 10px 8px; border-radius: 26px; background: rgba(255, 255, 255, .6); box-sizing: border-box; }
.kg-mark, .kg-lt {
  appearance: none; box-sizing: border-box; display: grid; place-items: center; min-width: max(var(--kids-target, 56px), 56px); min-height: max(var(--kids-target, 56px), 56px); padding: 0 6px;
  border-radius: 18px; border: 3px solid var(--kx-c); border-bottom-width: 6px; border-bottom-color: var(--kx-c-deep); background: #fff; color: var(--ink);
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.kg-mark { font-size: 2.8rem; min-width: 64px; min-height: 64px; background: var(--kx-c-tint); }
.kg-lt { font-size: 2.4rem; min-width: 64px; }
.kg-game[data-band="little"] .kg-lt { min-width: 72px; min-height: 72px; font-size: 2.8rem; }
.kg-mark .kg-ar, .kg-lt .kg-ar { font-size: 1em; line-height: 1.5; padding-block: .1em; }
.kg-mark .kg-ar { line-height: 1.2; padding-block: .3em; }
.kg-mark .kg-ar.ar-dots { font-size: .85em; transform: translateY(-.12em); }          /* the long-ee mark is a yaa in Amiri Quran: smaller, and lifted off the key's lower edge */
.kg-mark[aria-pressed="true"], .kg-lt[aria-pressed="true"] { background: var(--kx-c); border-bottom-width: 3px; box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--kx-c-deep); }
.kg-mark.is-off { opacity: .35; cursor: not-allowed; border-bottom-width: 3px; }
@media (hover: hover) { .kg-mark:not(.is-off):hover, .kg-lt:hover { background: var(--kx-c-tint); } }
.kg-mark:focus-visible, .kg-lt:focus-visible { outline: 3px solid var(--lapis); outline-offset: 3px; }
/* until a first sound is made Done is a quiet, solid key (not see-through: it floats over the letters) */
.kg-done-key[disabled] { opacity: 1; background: #E9EEEB; color: #6F7A73; border-color: #C9D1CC; }

/* ---- dots: the dotless shape on a pad, dots to drop into the places above and below; the shape spins into the real letter ---- */
.kg-dpad {
  /* --kg-sl: a place for a dot (68px, narrower when the box is, so three always fit a row); --kg-base: the plain shape's height (the room --kg-play leaves less the two rows of places, the paddings) */
  --kg-sl: min(68px, calc((100cqw - 32px) / 3));
  --kg-base: clamp(158px, calc(var(--kg-play, 9999px) - 114px), 288px);
  display: grid; justify-items: center; width: min(100%, 420px); padding: 14px 10px 16px; box-sizing: border-box; border-radius: 30px; background: rgba(255, 255, 255, .94);
  box-shadow: 0 6px 0 var(--kx-mint), 0 10px 22px rgba(7, 92, 54, .2);
}
.kg-dstage { display: grid; justify-items: center; gap: 0; width: 100%; max-width: 400px; }
.kg-dz { display: flex; justify-content: center; gap: 6px; min-height: var(--kg-sl); }
.kg-dz--above { margin-bottom: -26px; position: relative; z-index: 1; }
.kg-dz--below { margin-top: -26px; position: relative; z-index: 1; }
.kg-slot { appearance: none; display: grid; place-items: center; width: var(--kg-sl); height: var(--kg-sl); padding: 0; border: 0; background: transparent; border-radius: 50%; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.kg-slot__dot { display: block; width: calc(var(--kg-sl) * .65); height: calc(var(--kg-sl) * .65); border-radius: 50%; border: 3px dashed var(--kx-sky-deep); background: var(--kx-sky-tint); box-sizing: border-box; opacity: .75; }
.kg-slot.is-on .kg-slot__dot {
  opacity: 1; border: 3px solid var(--kx-amber-deep); background: radial-gradient(circle at 34% 30%, #FFF0BF 0, var(--kx-amber) 52%, #F0A000 100%);
  animation: kg-dot-in .4s cubic-bezier(.3, 1.4, .5, 1);
}
@keyframes kg-dot-in { from { translate: 0 -28px; scale: .4; opacity: 0; } to { translate: 0 0; scale: 1; opacity: 1; } }
.kg-slot:focus-visible { outline: 3px solid var(--lapis); outline-offset: 2px; }
/* the shape is as big as the room allows (a tablet on its side is short): its box (a line of Arabic: 1.8 times the letter's size) is 288px high at most (a letter of 10rem), and never so small that the dots lose their places.
   It is a coin with two faces: the plain shape in front, the real letter on a back that is already turned round (backface hidden), so neither face is ever seen from behind */
.kg-dbase { position: relative; display: grid; place-items: center; width: 100%; height: var(--kg-base); color: var(--ink); font-size: calc(var(--kg-base) / 1.8); transform-style: preserve-3d; }
.kg-dbase__face { grid-area: 1 / 1; display: grid; place-items: center; width: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.kg-dbase__back { transform: rotateY(180deg); }
.kg-dbase .kg-ar { font-size: 1em; }
.kg-dbase .kg-ar.ar-dots { padding-block: .1em; }                         /* Amiri Quran's dotless qaaf, faa and noon carry no marks: they sit on the line like the other shapes */
.kg-dstage.is-done .kg-dz { visibility: hidden; }
.kg-dstage.is-done .kg-dbase { color: var(--kx-mint-deep); }
.kg-dbase.is-flip { transform: rotateY(180deg); animation: kg-coin .85s cubic-bezier(.4, .1, .3, 1); }
@keyframes kg-coin { 0% { transform: perspective(700px) rotateY(0deg) scale(1); } 50% { transform: perspective(700px) rotateY(90deg) scale(1.18); } 100% { transform: perspective(700px) rotateY(180deg) scale(1); } }
.kg-check { min-width: var(--kids-target, 56px); }
.kg-check.is-ready { animation: kg-ready 1.3s ease-in-out 3; }
@keyframes kg-ready { 0%, 100% { scale: 1; } 50% { scale: 1.12; } }

/* ---- odd: four carts on the rails; the odd one rolls out of the station ---- */
.kg-tiles {
  /* four carts in two rows: a cart is 1.12 times as wide as it is tall, with a rail under it (24px), so the width follows the room --kg-play leaves (never under 208px: a cart then is 72px wide) */
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; width: 100%; max-width: min(460px, max(208px, calc((var(--kg-play, 9999px) - 86px) * 1.12 + 64px))); padding: 18px 20px 8px; box-sizing: border-box; border-radius: 30px;
  background: rgba(255, 255, 255, .66);
}
.kg-cell { position: relative; padding-bottom: 24px; container-type: inline-size; }
.kg-cell::after { content: ''; position: absolute; left: -13px; right: -13px; bottom: 0; height: 8px; border-radius: 4px; background: repeating-linear-gradient(90deg, #5B6660 0 12px, #7E8983 12px 16px); }
.kg-cart {
  appearance: none; position: relative; display: block; width: 100%; aspect-ratio: 1.12; box-sizing: border-box; padding: 0; border-radius: 20px; border: 3px solid var(--kx-c-deep); border-bottom-width: 8px;
  background: var(--kx-c); color: var(--ink); font-size: clamp(3.8rem, 17vw, 6rem); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  animation: kg-rollin .55s cubic-bezier(.3, .8, .4, 1) backwards; animation-delay: calc(var(--kg-n, 0) * 70ms);
}
.kg-cart::before, .kg-cart::after {
  content: ''; position: absolute; bottom: -24px; width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle, #F4F1E8 0 26%, #3F4A45 28%); pointer-events: none;
}
.kg-cart::before { left: 15%; }
.kg-cart::after { right: 15%; }
@supports (width: 1cqw) { .kg-cart { font-size: 42cqw; } }
.kg-cart__plate { position: absolute; inset: 9% 8% 7%; display: grid; place-items: center; border-radius: 14px; background: #fff; }
.kg-tile__ar { font-size: 1em; }
.kg-cart .kg-ar { font-size: 1em; line-height: 1.5; padding-block: .06em; }
.kg-cart .kg-ar:not(.ar-dots) { transform: translateY(-.04em); }
.kg-cart .kg-ar.ar-dots { padding-block: .06em .3em; transform: translateY(-.28em); }
.kg-cart:focus-visible { outline: 4px solid var(--lapis); outline-offset: 3px; }
@media (hover: hover) { .kg-cart:hover .kg-cart__plate { box-shadow: 0 0 0 4px rgba(255, 255, 255, .8); } }
.kg-tiles.is-solved .kg-cart { pointer-events: none; }
.kg-cart.is-right { z-index: 3; animation: kg-rollout .65s cubic-bezier(.5, 0, .9, .6) .15s forwards; }
.kg-tiles.is-leaving .kg-cart:not(.is-right) { animation: kg-rollleft .55s cubic-bezier(.5, 0, .9, .6) forwards; animation-delay: calc(var(--kg-n, 0) * 45ms); }
@keyframes kg-rollin { from { transform: translateX(150%); } to { transform: none; } }
@keyframes kg-rollout { 0% { transform: none; } 22% { transform: translateX(-7%); } 100% { transform: translateX(190%); } }
@keyframes kg-rollleft { to { transform: translateX(-190%); } }

/* ---- a press feels like a press: the balloon squashes, the card dips, the keycap goes down ---- */
.kg-balloon .kg-balloon__in { transition: scale .12s ease-out; }
.kg-balloon:active:not(.is-burst) .kg-balloon__in { scale: .94; }
.kg-pcard .kg-pcard__persp { transition: scale .12s ease-out; }
.kg-pcard:active .kg-pcard__persp { scale: .95; }
.kg-lt:active, .kg-mark:active:not(.is-off) { border-bottom-width: 3px; translate: 0 3px; }
.kg-cart:active { border-bottom-width: 5px; translate: 0 3px; }
.kg-slot:active:not(:disabled) .kg-slot__dot { scale: .88; }

/* ---- the end of a game is LR.fx.endPanel (kids-fx.css); the page's own Done bar steps aside when a game shows its own ending ---- */
.kh-play:has(.kg-end) > .kh-donebar, .kh-playpage:has(.kg-end) .kh-donebar { display: none; }

/* ---- reduced motion: every effect is a fade, nothing moves or turns, the game stays playable ---- */
@keyframes kg-fade-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .kg-balloon .kg-balloon__in, .kg-pcard .kg-pcard__persp { transition: none; }
  .kg-balloon:active .kg-balloon__in, .kg-pcard:active .kg-pcard__persp, .kg-slot:active .kg-slot__dot { scale: none; }
  .kg-lt:active, .kg-mark:active, .kg-cart:active { translate: none; }
  .kg-balloon, .kg-pcard, .kg-cart { animation: kx-fade .3s linear backwards; animation-delay: 0s; }
  .kg-balloon.is-nudged { animation: none; }
  .kg-balloon.is-burst .kg-balloon__body, .kg-balloon.is-burst .kg-balloon__string { animation: kg-fade-out .25s linear forwards; }
  .kg-balloon.is-burst .kg-balloon__label { animation: kg-fade-out .6s linear .2s forwards; }
  .kg-balloon.is-burst::after { display: none; }
  .kg-balloons.is-away { animation: kg-fade-out .2s linear forwards; }
  .kg-pcard__in { transition: none; transform: none !important; }
  .kg-pcard__front { transform: none; }
  .kg-pcard__back, .kg-pcard__front { backface-visibility: visible; -webkit-backface-visibility: visible; transition: opacity .25s linear; }
  .kg-pcard[data-state="down"] .kg-pcard__front, .kg-pcard:not([data-state="down"]) .kg-pcard__back { opacity: 0; }
  .kg-pcard.is-glow .kg-pcard__front { animation: none; outline: 4px solid var(--kx-amber-deep); outline-offset: 2px; }
  .kg-slot.is-on .kg-slot__dot { animation: none; }
  .kg-check.is-ready { animation: none; }
  .kg-dbase.is-flip { animation: none; transform: none; }
  .kg-dbase__face { backface-visibility: visible; -webkit-backface-visibility: visible; transition: opacity .3s linear; }
  .kg-dbase__back { transform: none; opacity: 0; }
  .kg-dbase.is-flip .kg-dbase__back { opacity: 1; }
  .kg-dbase.is-flip .kg-dbase__front { opacity: 0; }
  .kg-bench.is-mixing .kg-bslot { animation: none; }
  .kg-cart.is-right { animation: kg-fade-out .3s linear .1s forwards; box-shadow: 0 0 0 5px var(--kx-mint-deep); }
  .kg-tiles.is-leaving .kg-cart:not(.is-right) { animation: kg-fade-out .3s linear forwards; }
}
