/* ──────────────────────────────────────────────────────────────────────────
   Krabsy game UI kit (docs/game-ui-kit.md). Guide sheet: /lib/game-ui/guide.html
   One interface for every game: screens, buttons, answer chips, top bar,
   feedback, end screen. Class prefix kg-. The kit holds no text.

   Loads the fonts and the tokens itself (/lib/krabsy-tokens.css): a game needs only this file.
   Colours come ONLY from those tokens; --kg-surface = --k-surface (white).

   THE SYSTEM: light "sticker" cards over a navy scrim.
     • Every panel is a white card with a navy outline and a solid navy bottom
       edge. Full screens (loading, start, pause, level, end, confirm) put that
       card on a navy scrim over the game; in-play pieces (top bar, question
       card, toasts) are the same cards without a scrim.
     • Why light and not navy cards: the Krabsy icons have a navy outline and
       pastel fills, so they only read on a light surface; the palette's
       contrast values (muted text, violet links, tints) are defined for light
       ground; and the site, the drills and the games then share one look.
       The navy outline keeps a white card readable on any game world, bright
       or dark, without blur or soft shadows (performance rules of krabsy-ui.css:
       no backdrop-filter, no blur, no text-shadow, no animated box-shadow).
     • Right = turquoise, wrong = violet. Never red.
     • Buttons are chunky: a solid bottom edge that the button sinks into when
       pressed (transform only; the shadow switches without a transition).

   Layout: put everything in ONE wrapper over the canvas:
       <div class="kg-root"> top bar, question card, toasts, screens </div>
   .kg-root is a size container, so the kit adapts to the GAME FRAME, not the
   browser window (games run in iframes): narrow frame = phone portrait, low
   and wide frame = phone landscape. Browsers without container queries get
   the fluid base layout.
   ────────────────────────────────────────────────────────────────────────── */

@import url('/lib/fonts/krabsy-fonts.css?v=2026-11-26f');
@import url('/lib/krabsy-tokens.css?v=2026-11-29');


:root {
  --kg-surface: var(--k-surface);   /* white card surface (krabsy-tokens.css) */
  --kg-line: 3px;                   /* the navy outline of cards, buttons, chips */
  --kg-edge: 5px;                   /* the solid bottom edge of buttons */
  --kg-scrim: 0.66;                 /* opacity of the navy scrim under a screen */
  --kg-tap: 48px;                   /* smallest touch target (rule: at least 44px) */
}

/* ── Root wrapper over the canvas ─────────────────────────────────────────── */

.kg-root {
  position: absolute;
  inset: 0;
  container: kg / size;
  pointer-events: none;              /* the canvas stays playable between the pieces */
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
  color: var(--k-ink);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.kg-root *, .kg-root *::before, .kg-root *::after { box-sizing: border-box; }
.kg-root [hidden] { display: none !important; }

/* ── Icons (the Krabsy set only) ──────────────────────────────────────────── */

.kg-ico { width: 24px; height: 24px; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.kg-ico--16 { width: 16px; height: 16px; }
.kg-ico--20 { width: 20px; height: 20px; }
.kg-ico--32 { width: 32px; height: 32px; }
.kg-ico--48 { width: 48px; height: 48px; }
.kg-ico--64 { width: 64px; height: 64px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.kg-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 24px;
  margin: 0 0 var(--kg-edge);        /* room for the bottom edge */
  border: var(--kg-line) solid var(--k-ink);
  border-radius: var(--radius-md);
  box-shadow: 0 var(--kg-edge) 0 var(--k-ink);
  background: var(--kg-surface);
  color: var(--k-ink);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: normal;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.kg-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--k-ink); }
.kg-btn:focus-visible { outline: 3px solid var(--k-main); outline-offset: 3px; }
.kg-btn:disabled, .kg-btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

.kg-btn--primary { background: var(--k-btn-bg); color: var(--k-btn-fg); }
.kg-btn--secondary { background: var(--kg-surface); color: var(--k-ink); }
.kg-btn--ghost {
  border-color: transparent; box-shadow: none; background: transparent;
  color: var(--k-link); font-family: var(--font-body); font-weight: 800; font-size: 1rem;
  text-decoration: underline; text-decoration-color: var(--k-main-45); text-decoration-thickness: 2px; text-underline-offset: 4px;
}
.kg-btn--ghost:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
@media (hover: hover) {
  .kg-btn--primary:hover:not(:disabled) { background: var(--k-btn-bg-hover); }
  .kg-btn--secondary:hover:not(:disabled) { background: var(--k-acc-16); }
  .kg-btn--ghost:hover:not(:disabled) { color: var(--k-link-hover); background: var(--k-main-8); }
}

.kg-btn--sm { min-height: var(--kg-tap); padding: 4px 16px; font-size: 1rem; gap: 8px; }
.kg-btn--lg { min-height: 64px; padding: 8px 34px; font-size: 1.5rem; border-radius: var(--radius-lg); gap: 12px; }
.kg-btn--block { display: flex; width: 100%; }
.kg-btn--start { justify-content: flex-start; }   /* icon left, text left (menu lists) */

/* An icon on a violet button sits on a white disc (navy outlines need light ground). */
.kg-btn-ico {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 32px; height: 32px; margin-left: -8px;
  border-radius: 50%; background: var(--kg-surface);
}
.kg-btn--lg .kg-btn-ico { width: 40px; height: 40px; margin-left: -14px; }
.kg-btn-ico--end { margin-left: 0; margin-right: -8px; }

/* Icon-only button: menu, sound, close. Always with an aria-label. */
.kg-iconbtn {
  pointer-events: auto;
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: var(--kg-tap); height: var(--kg-tap); padding: 0; margin: 0 0 4px;
  border: var(--kg-line) solid var(--k-ink);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 0 var(--k-ink);
  background: var(--kg-surface);
  color: var(--k-ink);
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.12s ease;
}
.kg-iconbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--k-ink); }
.kg-iconbtn:focus-visible { outline: 3px solid var(--k-main); outline-offset: 3px; }
.kg-iconbtn[aria-pressed="false"] { background: var(--k-ink-8); }   /* a toggle that is off */
.kg-iconbtn--quiet { border-color: transparent; box-shadow: none; background: transparent; margin: 0; }
.kg-iconbtn--quiet:active { transform: translateY(1px); box-shadow: none; }
@media (hover: hover) {
  .kg-iconbtn:hover { background: var(--k-acc-16); }
  .kg-iconbtn--quiet:hover { background: var(--k-ink-8); }
}

/* A row of buttons under a card's content. */
.kg-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 12px; margin-top: 18px; }
.kg-actions--stack { flex-direction: column; align-items: stretch; }
.kg-actions > .kg-btn { flex: 1 1 120px; padding-left: 12px; padding-right: 12px; }
.kg-actions--stack > .kg-btn { flex: 0 0 auto; }

/* ── Screens and cards ────────────────────────────────────────────────────── */

.kg-screen {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  pointer-events: auto;
}
.kg-screen::before {                 /* the navy scrim (opacity, so it needs no rgba value) */
  content: ""; position: absolute; inset: 0;
  background: var(--k-ink); opacity: var(--kg-scrim);
}
.kg-screen--solid::before { opacity: 1; }      /* loading: nothing to see behind yet */
.kg-screen--clear::before { display: none; }   /* over key art that should stay bright */

.kg-card {
  position: relative;
  width: 100%; max-width: 440px; max-height: 100%;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 24px 24px 20px;
  border: var(--kg-line) solid var(--k-ink);
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 0 var(--k-ink);
  background: var(--kg-surface);
  color: var(--k-ink);
  text-align: center;
  pointer-events: auto;
  animation: kg-in 0.22s ease-out both;
}
.kg-card--sm { max-width: 330px; }
.kg-card--wide { max-width: 560px; }
@keyframes kg-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }

/* Corner slot of a card (sound toggle on the start menu, close on a dialog). */
.kg-corner { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 1; }
.kg-corner--left { right: auto; left: 10px; }

/* Text inside cards */
.kg-title { margin: 0; font-family: var(--font-display); font-weight: normal; font-size: 2.1rem; line-height: 1.1; color: var(--k-ink); }
.kg-title--md { font-size: 1.6rem; }
.kg-title em { font-style: normal; color: var(--k-main); }     /* one highlighted word */
.kg-kicker {                                                    /* small label over a title */
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 6px; padding: 3px 12px;
  border-radius: var(--radius-pill); background: var(--k-acc-16); color: var(--k-ink);
  font-size: 0.82rem; font-weight: 800; letter-spacing: 0.02em;
}
.kg-goal { margin: 8px auto 0; max-width: 34ch; font-size: 1.05rem; font-weight: 700; line-height: 1.35; color: var(--k-ink); }
.kg-text { margin: 8px 0 0; font-size: 1rem; font-weight: 600; color: var(--k-ink-72); }
.kg-label { margin: 16px 0 8px; font-size: 0.85rem; font-weight: 800; color: var(--k-ink-72); }
.kg-link {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 6px;
  color: var(--k-link); font-weight: 800; font-size: 0.95rem;
  text-decoration: underline; text-decoration-color: var(--k-main-45); text-decoration-thickness: 2px; text-underline-offset: 4px;
}

/* Two columns when the frame is low and wide (phone landscape); stacked otherwise. */
.kg-cols { display: flex; flex-direction: column; }
.kg-col { min-width: 0; }

/* ── 1. Loading screen ────────────────────────────────────────────────────── */

.kg-load { position: relative; width: 100%; max-width: 380px; text-align: center; color: var(--kg-surface); pointer-events: auto; }
.kg-load-crab { display: block; width: 132px; height: auto; margin: 0 auto 6px; animation: kg-bob 1.5s ease-in-out infinite; }
.kg-load .kg-title { color: var(--kg-surface); }
.kg-load .kg-title em { color: var(--k-acc); }
@keyframes kg-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.kg-bar {                             /* progress bar: loading, and round progress */
  display: block; height: 20px; margin: 18px auto 0; padding: 0; overflow: hidden;
  border: var(--kg-line) solid var(--k-ink); border-radius: var(--radius-pill);
  background: var(--kg-surface);
}
.kg-bar > i { display: block; height: 100%; width: 100%; background: var(--k-acc); transform-origin: 0 50%; transition: transform 0.25s ease; }
.kg-load .kg-bar { border-color: var(--kg-surface); background: var(--k-ink); }

.kg-tip {                             /* one short tip line with the bulb */
  display: inline-flex; align-items: center; gap: 8px; margin: 16px auto 0; padding: 6px 14px 6px 8px;
  border-radius: var(--radius-pill); background: var(--kg-surface); color: var(--k-ink);
  font-size: 0.92rem; font-weight: 700; text-align: left; line-height: 1.25;
}

/* ── 2. Start menu ────────────────────────────────────────────────────────── */

.kg-heroes { display: flex; justify-content: center; gap: 10px; margin: 0; padding: 0; list-style: none; }
.kg-hero {
  pointer-events: auto; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  flex: 0 1 104px; min-width: 0; min-height: 44px; padding: 6px 4px 8px; margin: 0 0 4px;
  border: var(--kg-line) solid var(--k-ink-22); border-radius: var(--radius-md);
  background: var(--k-ink-4); color: var(--k-ink-72);
  font-family: var(--font-body); font-size: 0.82rem; font-weight: 800; line-height: 1.15;
  cursor: pointer; transition: transform 0.08s ease;
}
.kg-hero img { display: block; width: 100%; max-width: 76px; height: auto; aspect-ratio: 1; object-fit: contain; }
.kg-hero.is-on, .kg-hero[aria-checked="true"], .kg-hero[aria-pressed="true"] {
  border-color: var(--k-ink); background: var(--k-acc-16); color: var(--k-ink);
  box-shadow: 0 4px 0 var(--k-ink);
}
.kg-hero-tick { position: absolute; top: -9px; right: -9px; width: 26px; height: 26px; display: none; }
.kg-hero.is-on .kg-hero-tick, .kg-hero[aria-checked="true"] .kg-hero-tick, .kg-hero[aria-pressed="true"] .kg-hero-tick { display: block; }
.kg-hero:active { transform: translateY(2px); }
.kg-hero:focus-visible { outline: 3px solid var(--k-main); outline-offset: 2px; }

/* Topic row on the start screen (docs/topic-choice.md): chips like the hero choice. */
.kg-topicrow .kg-label { margin-top: 12px; }
.kg-topics { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.kg-topic {
  pointer-events: auto; min-height: 44px; max-width: 100%; padding: 7px 14px;
  border: var(--kg-line) solid var(--k-ink-22); border-radius: var(--radius-pill);
  background: var(--k-ink-4); color: var(--k-ink-72);
  font-family: var(--font-body); font-size: 0.88rem; font-weight: 800; line-height: 1.2;
  cursor: pointer; transition: transform 0.08s ease;
}
.kg-topic.is-on, .kg-topic[aria-checked="true"] { border-color: var(--k-ink); background: var(--k-acc-16); color: var(--k-ink); box-shadow: 0 3px 0 var(--k-ink); }
.kg-topic:active { transform: translateY(2px); }
.kg-topic:focus-visible { outline: 3px solid var(--k-main); outline-offset: 2px; }
/* the child's "up next" (lib/krabsy-path.js): a small violet sparkle and a dashed violet ring */
.kg-topic.is-next { display: inline-flex; align-items: center; gap: 5px; border-style: dashed; border-color: var(--k-main); }
.kg-topic.is-next.is-on, .kg-topic.is-next[aria-checked="true"] { border-style: solid; border-color: var(--k-ink); }
.kg-topic--fixed { display: inline-flex; align-items: center; cursor: default; }   /* teacher link: the topic, not a choice */
.kg-topic--fixed:active { transform: none; }
.kg-topic-nx { width: 16px; height: 16px; flex: 0 0 auto; color: var(--k-main); fill: currentColor; }
/* many topics (docs/topic-path.md): a short row + "More topics +n" → all, grouped by stage */
.kg-topics-all[hidden], .kg-topics-short[hidden] { display: none; }
.kg-topicstage { margin: 10px 0 6px; font-size: 0.74rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--k-ink-72); }
.kg-topicmore {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; margin: 10px auto 0; min-height: 40px; padding: 5px 6px 5px 14px;
  border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--k-ink);
  font-family: var(--font-body); font-size: 0.86rem; font-weight: 800; cursor: pointer;
  box-shadow: inset 0 0 0 2px var(--k-ink-22);
}
.kg-topicmore b { min-width: 28px; padding: 2px 7px; border-radius: var(--radius-pill); background: var(--k-ink); color: #fff; font-size: 0.8rem; text-align: center; }
.kg-topicmore b[hidden] { display: none; }
.kg-topicmore[aria-expanded="true"] { padding-right: 14px; }
.kg-topicmore:focus-visible { outline: 3px solid var(--k-main); outline-offset: 2px; }
.kg-topicrow.is-many { display: flex; flex-direction: column; align-items: center; }
.kg-topicrow.is-many > .kg-label, .kg-topicrow.is-many > .kg-topics, .kg-topicrow.is-many > .kg-topics-all { align-self: stretch; }
.kg-vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.kg-controls { margin: 12px auto 0; max-width: 40ch; font-size: 0.9rem; font-weight: 700; line-height: 1.9; color: var(--k-ink-72); }
.kg-key {                              /* a key cap in the controls line */
  display: inline-block; min-width: 26px; padding: 0 7px; margin: 0 1px;
  border: 2px solid var(--k-ink); border-bottom-width: 4px; border-radius: var(--radius-sm);
  background: var(--kg-surface); color: var(--k-ink);
  font-family: var(--font-body); font-size: 0.8rem; font-weight: 800; line-height: 1.45; text-align: center;
}
.kg-start-play { margin-top: 18px; }

/* ── 11. Player badge ─────────────────────────────────────────────────────── */

.kg-badge {
  position: relative; display: inline-block; flex: 0 0 auto;
  width: 56px; height: 56px; overflow: hidden;
  border: var(--kg-line) solid var(--k-ink); border-radius: 50%;
  /* Light violet ground: faces stand out, but not dark (owner 2026-11-29, two rounds). */
  background: radial-gradient(circle at 50% 38%, var(--k-main-15) 0%, var(--k-main-45) 75%);
}
/* Head shots (/assets/figures/heads/<char>.webp, 256 px, tools/render_figure_portraits.cjs --heads)
   are framed for the circle: no zoom needed. */
.kg-badge img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.kg-badge--sm { width: 44px; height: 44px; border-width: 2.5px; }
.kg-badge--lg { width: 96px; height: 96px; border-width: 4px; }
.kg-badge--main { background: radial-gradient(circle at 50% 38%, var(--k-acc-16) 0%, var(--k-acc-35) 75%); }  /* second player / a tutor */
.kg-player { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.1rem; color: var(--k-ink); }

/* ── 3. Top bar during play ───────────────────────────────────────────────── */

.kg-hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: flex-start; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  pointer-events: none;
}
.kg-hud > * { pointer-events: auto; }
.kg-hud-mid { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; pointer-events: none; }
.kg-hud-mid > * { pointer-events: auto; }
.kg-hud-end { display: flex; align-items: flex-start; gap: 8px; }

.kg-pill {                             /* a value in the bar: shells, lives, time */
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--kg-tap); padding: 0 14px 0 10px; margin: 0 0 4px;
  border: var(--kg-line) solid var(--k-ink); border-radius: var(--radius-pill);
  box-shadow: 0 4px 0 var(--k-ink);
  background: var(--kg-surface); color: var(--k-ink);
  font-family: var(--font-display); font-size: 1.15rem; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.kg-pill.is-low { background: var(--k-main); color: var(--kg-surface); }          /* time nearly up */
.kg-pill.is-low .kg-ico { background: var(--kg-surface); border-radius: 50%; }
.kg-pill.is-bump { animation: kg-bump 0.35s ease-out; }                             /* a shell arrived */
@keyframes kg-bump { 0% { transform: scale(1); } 40% { transform: scale(1.14); } 100% { transform: scale(1); } }

.kg-lives { gap: 2px; padding: 0 10px; }
.kg-lives .kg-ico.is-lost { opacity: 0.22; }

.kg-progress {                         /* "4 / 12" with a bar */
  display: inline-flex; align-items: center; gap: 10px;
  height: var(--kg-tap); width: 100%; max-width: 280px; padding: 0 12px 0 14px; margin: 0 0 4px;
  border: var(--kg-line) solid var(--k-ink); border-radius: var(--radius-pill);
  box-shadow: 0 4px 0 var(--k-ink);
  background: var(--kg-surface); color: var(--k-ink);
  font-family: var(--font-display); font-size: 1.05rem; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.kg-progress .kg-bar { flex: 1 1 auto; height: 14px; margin: 0; border-width: 2px; background: var(--k-ink-8); }
.kg-progress--plain { width: auto; }   /* number only, no bar */

/* ── 4. Question card ─────────────────────────────────────────────────────── */

.kg-q {
  position: absolute; z-index: 20;
  left: 0; right: 0; bottom: calc(max(14px, env(safe-area-inset-bottom)) + var(--kg-q-bottom, 0px));   /* --kg-q-bottom: room for a game's own bottom panel */
  width: calc(100% - 24px); max-width: 560px; margin: 0 auto;
  padding: 16px 18px 14px;
  border: var(--kg-line) solid var(--k-ink); border-radius: var(--radius-lg);
  box-shadow: 0 6px 0 var(--k-ink);
  background: var(--kg-surface); color: var(--k-ink);
  text-align: center;
  pointer-events: auto;
  animation: kg-in 0.2s ease-out both;
}
.kg-q--center { top: 0; bottom: 0; height: fit-content; margin: auto; }
.kg-q--static { position: relative; bottom: auto; }      /* inside a card or a page flow */

.kg-q-cap { margin: 0 0 6px; font-size: 0.82rem; font-weight: 800; color: var(--k-ink-72); }
.kg-q-text {
  margin: 0; font-family: var(--font-display); font-weight: normal;
  font-size: 1.7rem; line-height: 1.3; color: var(--k-ink);
  overflow-wrap: anywhere;
}
.kg-q-text--sentence { font-size: 1.35rem; }
.kg-q-hint { margin: 4px 0 0; font-size: 0.95rem; font-weight: 700; color: var(--k-ink-72); }   /* (go) / translation */
.kg-arrow { display: inline-block; margin: 0 0.2em; color: var(--k-ink-45); }
.kg-arrow .kg-ico { width: 0.8em; height: 0.8em; vertical-align: -0.05em; opacity: 0.55; }

.kg-blank {                            /* the asked gap: always highlighted */
  display: inline-block; min-width: 3.4em; padding: 0 0.3em; margin: 0 0.08em;
  border-radius: var(--radius-sm); border-bottom: 4px solid var(--k-main);
  background: var(--k-main-15); color: var(--k-main-lo);
  line-height: 1.25; text-align: center;
}
.kg-blank:empty::before { content: "\00a0"; }
.kg-blank--later { border-bottom-color: var(--k-ink-22); background: var(--k-ink-4); }   /* a gap that is asked next */
.kg-blank.is-right { border-bottom-color: var(--k-acc-dk); background: var(--k-acc-35); color: var(--k-ink); }
.kg-blank.is-wrong { border-bottom-color: var(--k-main); background: var(--k-main-15); color: var(--k-main-lo); }

.kg-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 14px 0 0; padding: 0; list-style: none; }
.kg-choices--3 { grid-template-columns: 1fr 1fr 1fr; }
.kg-choices--stack { grid-template-columns: 1fr; }
.kg-choice {
  pointer-events: auto; position: relative;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 56px; padding: 6px 12px; margin: 0 0 var(--kg-edge);
  border: var(--kg-line) solid var(--k-ink); border-radius: var(--radius-md);
  box-shadow: 0 var(--kg-edge) 0 var(--k-ink);
  background: var(--kg-surface); color: var(--k-ink);
  font-family: var(--font-display); font-size: 1.3rem; font-weight: normal; line-height: 1.15;
  overflow-wrap: anywhere;
  cursor: pointer; transition: transform 0.08s ease, background-color 0.12s ease;
}
.kg-choice:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--k-ink); }
.kg-choice:focus-visible { outline: 3px solid var(--k-main); outline-offset: 3px; }
@media (hover: hover) { .kg-choice:hover:not(:disabled):not(.is-right):not(.is-wrong) { background: var(--k-main-8); } }
.kg-choice-key {                       /* keyboard hint 1 2 3 4 (hide on touch devices) */
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 6px; background: var(--k-ink-8); color: var(--k-ink-72);
  font-family: var(--font-body); font-size: 0.75rem; font-weight: 800;
}
@media (hover: none) { .kg-choice-key { display: none; } }
.kg-choice .kg-ico { width: 26px; height: 26px; }

/* typed answer */
.kg-type { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0 0; }
.kg-input {
  pointer-events: auto; flex: 1 1 auto; min-width: 0; height: 56px; padding: 0 14px;
  border: var(--kg-line) solid var(--k-ink); border-radius: var(--radius-md);
  background: var(--kg-surface); color: var(--k-ink);
  font-family: var(--font-display); font-size: 1.35rem; text-align: center;
  user-select: text; -webkit-user-select: text;
}
.kg-input::placeholder { color: var(--k-ink-45); }
.kg-input:focus { outline: 3px solid var(--k-main); outline-offset: 2px; }
.kg-input.is-right { background: var(--k-acc-35); }
.kg-input.is-wrong { background: var(--k-main-15); border-color: var(--k-main); color: var(--k-main-lo); }
.kg-type .kg-btn { min-height: 56px; margin-bottom: 0; box-shadow: none; flex: 0 0 auto; }
.kg-type .kg-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }

/* ── 5. Feedback ──────────────────────────────────────────────────────────── */

.kg-choice.is-right, .kg-choice.is-right:disabled { background: var(--k-acc); color: var(--k-ink); opacity: 1; }
.kg-choice.is-wrong, .kg-choice.is-wrong:disabled {
  background: var(--k-main-15); border-color: var(--k-main); color: var(--k-main-lo);
  box-shadow: 0 var(--kg-edge) 0 var(--k-main); opacity: 1;
  animation: kg-nudge 0.3s ease-out;
}
.kg-choice.is-dim, .kg-choice:disabled { opacity: 0.4; cursor: default; }
@keyframes kg-nudge { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-5px); } 65% { transform: translateX(4px); } }

.kg-fb {                               /* the line under the choices after an answer */
  display: flex; align-items: center; gap: 10px; margin: 12px 0 0; padding: 10px 12px;
  border-radius: var(--radius-md); text-align: left;
  font-weight: 800; font-size: 1.05rem; line-height: 1.3; color: var(--k-ink);
}
.kg-fb--right { background: var(--k-acc-16); }
.kg-fb--wrong { background: var(--k-main-8); flex-wrap: wrap; }
.kg-fb-main { flex: 1 1 0; min-width: 0; }
.kg-fb-answer { font-family: var(--font-display); font-weight: normal; font-size: 1.25rem; color: var(--k-main-lo); }
.kg-fb-teach { display: flex; align-items: flex-start; gap: 6px; margin: 4px 0 0; font-size: 0.92rem; font-weight: 700; color: var(--k-ink-72); }
.kg-fb-teach .kg-ico { width: 20px; height: 20px; margin-top: 1px; }
.kg-fb-gain { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-display); font-weight: normal; font-size: 1.2rem; white-space: nowrap; }
.kg-fb .kg-btn { margin-bottom: var(--kg-edge); }

.kg-pop {                              /* "+1 shell" that floats up from the answer */
  position: absolute; left: 0; right: 0; top: -18px; z-index: 2;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  font-family: var(--font-display); font-size: 1.5rem; color: var(--k-ink);
  pointer-events: none; opacity: 0;
}
.kg-pop > span {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 14px 2px 8px;
  border: var(--kg-line) solid var(--k-ink); border-radius: var(--radius-pill); background: var(--k-acc);
}
.kg-pop.is-on { animation: kg-pop 0.9s ease-out both; }
.kg-pop.is-shown { opacity: 1; transform: translateY(-10px); }   /* guide sheet: frozen frame */
@keyframes kg-pop {
  0% { opacity: 0; transform: translateY(10px) scale(0.8); }
  20% { opacity: 1; transform: translateY(0) scale(1.1); }
  70% { opacity: 1; transform: translateY(-14px) scale(1); }
  100% { opacity: 0; transform: translateY(-26px); }
}

/* ── 6. Pause menu (and any menu list) ────────────────────────────────────── */

.kg-menu { display: flex; flex-direction: column; gap: 6px; margin: 16px 0 0; padding: 0; list-style: none; }
.kg-menu .kg-btn { width: 100%; justify-content: flex-start; padding-left: 16px; }
.kg-menu .kg-btn--primary { justify-content: center; }
.kg-menu-state { margin-left: auto; padding: 2px 10px; border-radius: var(--radius-pill); background: var(--k-acc-35); color: var(--k-ink); font-family: var(--font-body); font-size: 0.8rem; font-weight: 800; }
.kg-menu-state.is-off { background: var(--k-ink-8); color: var(--k-ink-72); }

/* ── 7. Level complete ────────────────────────────────────────────────────── */

.kg-stars { display: flex; justify-content: center; align-items: flex-end; gap: 4px; margin: 4px 0 10px; }
.kg-stars .kg-ico { width: 56px; height: 56px; animation: kg-star 0.4s ease-out both; }
.kg-stars .kg-ico:nth-child(2) { width: 76px; height: 76px; margin-bottom: 8px; animation-delay: 0.12s; }
.kg-stars .kg-ico:nth-child(3) { animation-delay: 0.24s; }
@keyframes kg-star { from { opacity: 0; transform: scale(0.4) rotate(-20deg); } 70% { transform: scale(1.12); } to { opacity: 1; transform: none; } }

.kg-gain {                             /* "+12" with the shell: level complete and end screen */
  display: inline-flex; align-items: center; gap: 8px; margin: 6px 0 0;
  font-family: var(--font-display); font-size: 2.4rem; line-height: 1.1; color: var(--k-ink);
}
.kg-gain .kg-ico { width: 44px; height: 44px; }
.kg-gain--md { font-size: 1.6rem; }
.kg-gain--md .kg-ico { width: 32px; height: 32px; }

/* ── 8. End screen ────────────────────────────────────────────────────────── */

.kg-flag {                             /* "Neuer Rekord!": only when an old best was beaten */
  display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 0; padding: 3px 14px 3px 4px;
  border-radius: var(--radius-pill); background: var(--k-main); color: var(--kg-surface);
  font-size: 0.92rem; font-weight: 800;
}
.kg-flag .kg-ico { width: 26px; height: 26px; padding: 2px; border-radius: 50%; background: var(--kg-surface); }

.kg-stats { display: flex; justify-content: center; gap: 8px; margin: 14px 0 0; }
.kg-stat { flex: 1 1 0; min-width: 0; max-width: 150px; padding: 8px 6px; border-radius: var(--radius-md); background: var(--k-ink-4); }
.kg-stat-v { display: block; font-family: var(--font-display); font-size: 1.5rem; line-height: 1.15; color: var(--k-ink); font-variant-numeric: tabular-nums; }
.kg-stat-v.is-best { color: var(--k-main-lo); }
.kg-stat-l { display: block; font-size: 0.8rem; font-weight: 800; color: var(--k-ink-72); }

.kg-missed { margin: 16px 0 0; text-align: left; }
.kg-missed-h { margin: 0 0 6px; font-size: 0.85rem; font-weight: 800; color: var(--k-ink-72); }
.kg-missed-list { display: flex; flex-direction: column; gap: 5px; margin: 0; padding: 0; list-style: none; }
.kg-missed-list li { padding: 7px 12px; border-radius: var(--radius-sm); background: var(--k-main-8); color: var(--k-ink); font-weight: 700; font-size: 0.98rem; }
.kg-missed-list b { color: var(--k-main-lo); font-weight: 800; }

.kg-next {                             /* a link to another game of the topic */
  display: flex; align-items: center; gap: 12px; min-height: 60px; margin: 14px 0 0; padding: 6px 12px 6px 6px;
  border: 2px solid var(--k-ink-22); border-radius: var(--radius-md);
  background: var(--kg-surface); color: var(--k-ink); text-align: left; text-decoration: none;
}
.kg-next img { flex: 0 0 auto; width: 76px; height: 46px; object-fit: cover; border-radius: 10px; }
.kg-next-t { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; font-family: var(--font-display); font-size: 1.05rem; line-height: 1.2; }
.kg-next-t small { font-family: var(--font-body); font-size: 0.8rem; font-weight: 800; color: var(--k-ink-72); }
@media (hover: hover) { .kg-next:hover { background: var(--k-acc-8); border-color: var(--k-ink); } }

.kg-rate { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 2px 6px; margin: 12px 0 0; font-size: 0.92rem; font-weight: 800; color: var(--k-ink-72); }
.kg-rate button {
  pointer-events: auto; display: inline-grid; place-items: center; width: var(--kg-tap); height: var(--kg-tap); padding: 0;
  border: 0; border-radius: 50%; background: none; cursor: pointer; transition: transform 0.1s ease;
}
.kg-rate button .kg-ico { width: 36px; height: 36px; }
.kg-rate button:active { transform: scale(0.9); }
.kg-rate button:focus-visible { outline: 3px solid var(--k-main); outline-offset: 0; }
@media (hover: hover) { .kg-rate button:hover { transform: translateY(-3px); } }

/* ── 9. Toasts ────────────────────────────────────────────────────────────── */

.kg-toasts {
  position: absolute; z-index: 40; top: 70px; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 12px;
  pointer-events: none;
}
.kg-toast {
  display: flex; align-items: center; gap: 10px; max-width: 100%; padding: 6px 18px 6px 6px;
  border: var(--kg-line) solid var(--k-ink); border-radius: var(--radius-pill);
  box-shadow: 0 4px 0 var(--k-ink);
  background: var(--kg-surface); color: var(--k-ink); text-align: left;
  animation: kg-toast 0.3s ease-out both;
}
.kg-toast.is-out { animation: kg-toast-out 0.25s ease-in both; }
.kg-toast-ico { display: inline-grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; background: var(--k-acc-35); }
.kg-toast-ico .kg-ico { width: 28px; height: 28px; }
.kg-toast--main .kg-toast-ico { background: var(--k-main-15); }
.kg-toast-t { display: flex; flex-direction: column; min-width: 0; font-family: var(--font-display); font-size: 1.1rem; line-height: 1.2; }
.kg-toast-t small { font-family: var(--font-body); font-size: 0.85rem; font-weight: 700; color: var(--k-ink-72); }
@keyframes kg-toast { from { opacity: 0; transform: translateY(-16px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes kg-toast-out { to { opacity: 0; transform: translateY(-12px); } }

/* ── Narrow frame: phone portrait ─────────────────────────────────────────── */

@container kg (max-width: 480px) {
  .kg-screen { padding: 12px; }
  .kg-card { padding: 20px 16px 16px; }
  .kg-title { font-size: 1.8rem; }
  .kg-title--md { font-size: 1.45rem; }
  .kg-heroes { gap: 8px; }
  .kg-hero { font-size: 0.78rem; }
  .kg-hud { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .kg-hud-end { gap: 6px; }
  .kg-pill { padding: 0 10px 0 8px; font-size: 1.05rem; gap: 4px; }
  .kg-lives { padding: 0 8px; }
  .kg-lives .kg-ico { width: 20px; height: 20px; }
  .kg-progress { padding: 0 10px; gap: 8px; }
  .kg-hud .kg-badge { display: none; }                 /* the bar keeps menu, progress, shells, lives */
  .kg-q { padding: 14px 12px 10px; width: calc(100% - 16px); bottom: max(8px, env(safe-area-inset-bottom)); }
  .kg-q-text { font-size: 1.45rem; }
  .kg-q-text--sentence { font-size: 1.2rem; }
  .kg-choices { gap: 4px 8px; }
  .kg-choice { font-size: 1.15rem; min-height: 54px; }
  .kg-choices--3 { grid-template-columns: 1fr; }
  .kg-gain { font-size: 2.1rem; }
  .kg-toasts { top: 66px; }
}

/* ── Low, wide frame: phone landscape (844 × 390) ─────────────────────────── */

@container kg (max-height: 480px) and (min-width: 560px) {
  .kg-screen { padding: 8px 16px; }
  .kg-card { max-width: 720px; padding: 14px 20px 10px; }
  .kg-card--sm { max-width: 420px; }
  .kg-cols { flex-direction: row; align-items: center; gap: 24px; }
  .kg-col { flex: 1 1 0; }
  .kg-title { font-size: 1.7rem; }
  .kg-title--md { font-size: 1.4rem; }
  .kg-goal { font-size: 0.98rem; margin-top: 6px; }
  .kg-label { margin: 0 0 6px; }
  .kg-controls { margin-top: 6px; line-height: 1.75; }
  .kg-start-play { margin-top: 12px; }
  .kg-btn--lg { min-height: 56px; font-size: 1.35rem; }
  .kg-actions { margin-top: 12px; }
  .kg-hero img { max-width: 60px; }
  .kg-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 12px; }
  .kg-menu > :first-child { grid-column: 1 / -1; }
  .kg-stars { margin: 0 0 4px; }
  .kg-stars .kg-ico { width: 44px; height: 44px; }
  .kg-stars .kg-ico:nth-child(2) { width: 58px; height: 58px; }
  .kg-gain { font-size: 1.9rem; margin-top: 2px; }
  .kg-gain .kg-ico { width: 36px; height: 36px; }
  .kg-badge--lg { width: 56px; height: 56px; border-width: var(--kg-line); }
  .kg-flag { margin-top: 2px; }
  .kg-stats { margin-top: 6px; }
  .kg-stat { padding: 4px 6px; }
  .kg-stat-v { font-size: 1.25rem; }
  .kg-actions .kg-btn { min-height: var(--kg-tap); }
  .kg-rate { margin-top: 0; }
  .kg-rate button { width: 44px; height: 44px; }
  .kg-missed { margin-top: 0; }
  .kg-next { margin-top: 8px; min-height: 52px; }
  .kg-rate { margin-top: 6px; }
  .kg-load-crab { width: 96px; }
  .kg-bar { margin-top: 12px; }
  .kg-tip { margin-top: 10px; }
  /* the question card: question left, answers right, to keep the world visible */
  .kg-q { max-width: 760px; padding: 10px 14px 8px; bottom: max(8px, env(safe-area-inset-bottom)); }
  .kg-q .kg-cols { gap: 16px; }
  .kg-q .kg-col:first-child { flex: 0 1 44%; }
  .kg-q-text { font-size: 1.4rem; }
  .kg-q-text--sentence { font-size: 1.15rem; }
  .kg-choices, .kg-type { margin-top: 0; }
  .kg-choice { min-height: 48px; font-size: 1.1rem; }
  .kg-fb { margin-top: 8px; padding: 6px 10px; }
  .kg-toasts { top: 64px; }
}

/* ── Less motion ──────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .kg-card, .kg-q, .kg-toast, .kg-load-crab, .kg-stars .kg-ico, .kg-choice.is-wrong, .kg-pill.is-bump { animation: none; }
  .kg-pop.is-on { animation: none; opacity: 1; }
  .kg-btn, .kg-iconbtn, .kg-choice, .kg-hero { transition: none; }
}

/* ── Options for the script (2026-11-29, from Towers, Penalty, Platformer) ──── */

/* loading.set(null): no progress known, the fill moves by itself */
.kg-bar--busy > i { width: 35%; transform: none; animation: kg-busy 1.1s ease-in-out infinite alternate; }
@keyframes kg-busy { from { transform: translateX(0); } to { transform: translateX(186%); } }

/* start({ side }): a game panel (level list) beside the start card; below it on narrow frames */
.kg-start-wrap { position: relative; display: flex; align-items: center; justify-content: center; gap: 16px; width: 100%; max-width: 1000px; max-height: 100%; }
.kg-start-wrap > .kg-card { flex: 0 1 520px; }
.kg-start-side { flex: 1 1 380px; min-width: 0; max-height: 100%; overflow: auto; pointer-events: auto; }
@container kg (max-width: 760px) {
  .kg-start-wrap { flex-direction: column; align-items: stretch; overflow: auto; }
  .kg-start-wrap > .kg-card { flex: 0 0 auto; }
  .kg-start-side { flex: 0 0 auto; overflow: visible; }
}
/* start({ below }): e.g. a language switch under Play */
.kg-start-below { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* feedback(): the answer beat alone, docked at the bottom, narrow (fits between a touch stick and a jump button) */
.kg-q--fb { max-width: 460px; padding-top: 10px; padding-bottom: 10px; }
.kg-q--fb .kg-fb { margin-top: 0; }

@media (prefers-reduced-motion: reduce) { .kg-bar--busy > i { animation: none; transform: translateX(93%); } }

/* Verb chain as a staircase (ask({ chain: 'stair' }), or 'auto' when one line doesn't fit):
   three lines, each form a step further in, still read left to right (from Bubble Shot). */
.kg-q-text--stair { display: inline-flex; flex-direction: column; align-items: flex-start; text-align: left; line-height: 1.35; white-space: normal; }
.kg-q-text--stair > span { white-space: nowrap; }
.kg-q-text--stair > span:nth-child(2) { padding-left: 1.3em; }
.kg-q-text--stair > span:nth-child(3) { padding-left: 2.6em; }
.kg-q-slot { text-align: center; }

/* Fixes from the first games (2026-11-29, Kitchen / Air Control):
   a screen taller than the frame scrolls instead of losing its top (safe centring);
   toasts move to the bottom while a full screen is open, so they never cover its card. */
.kg-screen { overflow-y: auto; align-items: safe center; justify-content: safe center; }
.kg-start-wrap { max-height: none; }
.kg-root:has(> .kg-screen) .kg-toasts { top: auto; bottom: max(16px, env(safe-area-inset-bottom)); }

/* Phones: small dialogs (confirm, pause, level) keep a clear margin instead of running edge to
   edge (owner 2026-11-29, Penalty); their buttons stack, the safe choice (violet) on top. */
@container kg (max-width: 480px) {
  .kg-card--sm { width: calc(100% - 44px); max-width: 300px; }
  .kg-card--sm .kg-actions { flex-direction: column-reverse; align-items: stretch; }
  .kg-card--sm .kg-actions > .kg-btn { flex: 0 0 auto; }
}

/* Level screen (levels(), owner rule 2026-11-29, from the Verb Platformer): small tiles, the
   number and the stars, the next level in the main colour. */
.kg-levels { max-width: 460px; }
.kg-levels-head { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; margin-bottom: 14px; }
.kg-levels-head .kg-title { margin: 0; }
.kg-levels-total { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: var(--k-ink); font-variant-numeric: tabular-nums; }
.kg-levels-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.kg-ltile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 64px; aspect-ratio: 1 / 0.9; padding: 6px 4px; font: inherit; cursor: pointer;
  border: 2px solid var(--k-ink-22); border-radius: var(--radius-md);
  background: var(--kg-surface); color: var(--k-ink);
}
.kg-ltile:hover { border-color: var(--k-ink); }
.kg-ltile:active { transform: translateY(2px); }
.kg-ltile:focus-visible { outline: 3px solid var(--k-main); outline-offset: 2px; }
.kg-ltile-n { font-family: var(--font-display); font-size: 1.7rem; line-height: 1; }
.kg-ltile-stars { display: inline-flex; gap: 1px; }
.kg-ltile-stars .kg-ico { width: 16px; height: 16px; }
.kg-ltile.is-done { background: var(--k-acc-8); }
.kg-ltile.is-next { border: var(--kg-line) solid var(--k-ink); box-shadow: 0 4px 0 var(--k-ink); background: var(--k-main); color: var(--kg-surface); }
.kg-ltile.is-locked { cursor: default; opacity: 0.55; background: var(--k-ink-4); }
.kg-ltile.is-locked:hover { border-color: var(--k-ink-22); }
@container kg (max-height: 480px) and (min-width: 560px) {
  .kg-levels { max-width: 640px; }
  .kg-levels-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kg-ltile { aspect-ratio: auto; }
}

.kg-ltile.is-next .kg-ltile-stars { opacity: 0.55; }
/* A tile with a picture (levels({ levels: [{ pic }] })): the picture fills the tile, the number
   sits in the top-left corner, the stars stay at the bottom; locked = greyed picture + lock. */
.kg-ltile.has-pic { position: relative; justify-content: flex-end; aspect-ratio: auto; gap: 2px; padding: 16px 4px 7px; }
.kg-ltile-pic { display: flex; align-items: center; justify-content: center; width: 100%; }
.kg-ltile-pic img { display: block; width: min(76px, 82%); height: auto; }
.kg-ltile.has-pic .kg-ltile-n { position: absolute; top: 5px; left: 8px; font-size: 1.1rem; }
.kg-ltile.has-pic.is-locked .kg-ltile-pic img { filter: grayscale(1); opacity: 0.45; }
.kg-ltile.has-pic.is-locked > .kg-ico { position: absolute; top: 6px; right: 7px; width: 18px; height: 18px; }
@container kg (max-height: 480px) and (min-width: 560px) {
  .kg-ltile-pic img { width: min(60px, 78%); }
}   /* empty stars on violet must not read as earned */

/* Topic row in a short, wide frame (phone held sideways): one swipeable line instead of
   several wrapped lines, so Play stays visible (Verb Platformer, 2026-11-30). */
@container kg (max-height: 480px) and (min-width: 560px) {
  .kg-topicrow .kg-label { margin: 8px 0 4px; }
  .kg-topics { flex-wrap: nowrap; justify-content: safe center; overflow-x: auto; padding: 2px 2px 6px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .kg-topics::-webkit-scrollbar { display: none; }
  .kg-topic { flex: 0 0 auto; white-space: nowrap; }
}

/* A drag inside a game never scrolls the page around the game frame (owner 2026-11-30: on a
   phone the page slid up and the site bar covered the game's top bar). */
html, body { overscroll-behavior: none; }

/* Turn-your-phone-upright cover (phones play upright, owner 2026-11-30; createGameUI({ sideways: true })
   opts out). Shown only on touch screens held sideways. */
.kg-turn { display: none; }
@media (pointer: coarse) and (orientation: landscape) and (max-height: 540px) {
  .kg-turn {
    display: flex; position: fixed; inset: 0; z-index: 2147483000; pointer-events: auto;
    flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px;
    background: var(--k-ink, #1d2350); color: #fff; text-align: center;
    font-family: var(--font-display, 'Fredoka', sans-serif); font-size: 1.35rem;
  }
  .kg-turn p { margin: 0; max-width: 22em; }
  .kg-turn .kg-turn-ico { box-sizing: content-box; width: 52px; height: 52px; padding: 14px; border-radius: 50%; background: #fff; animation: kg-turn 2.4s ease-in-out infinite; }
}
@keyframes kg-turn { 0%, 30% { transform: rotate(90deg); } 60%, 100% { transform: rotate(0deg); } }
@media (prefers-reduced-motion: reduce) { .kg-turn .kg-turn-ico { animation: none; } }

/* Short frames (phone review 2026-11-30, X1): small phones give the game 480-560 px; the end,
   level-done and start cards then scroll. Compact sizes, the missed list cut to two lines, and
   the action row pinned to the bottom of the visible screen so Again / Next / Back are always
   in view (the card scrolls behind them). */
@container kg (max-height: 560px) {
  .kg-screen .kg-card { padding-top: 14px; padding-bottom: 12px; }
  .kg-badge--lg { width: 60px; height: 60px; }
  .kg-missed-list li:nth-child(n+3) { display: none; }
  .kg-missed-list li { padding: 5px 10px; font-size: 0.92rem; }
  .kg-screen .kg-card .kg-actions {
    position: sticky; bottom: -12px; z-index: 2; margin-top: 10px; padding: 10px 0 12px;
    background: var(--kg-surface, #fff);
    box-shadow: 0 -14px 14px -10px rgba(29, 35, 80, 0.18);
  }
}
/* X5: on very narrow frames the top-bar progress bar collapses to a sliver: keep "n / N" only. */
@container kg (max-width: 340px) {
  .kg-progress .kg-bar { display: none; }
}
/* X12: a text-only controls line wraps into tall lines with the key-cap line height. */
.kg-controls { line-height: 1.6; }
.kg-controls .kg-key { margin-block: 2px; }
/* Narrow phones: end-card buttons stack full width instead of wrapping their words
   ("Nächstes Spiel" broke at 390 px, Penalty review 2026-11-30). */
@container kg (max-width: 400px) {
  .kg-card .kg-actions { flex-direction: column; align-items: stretch; }
  .kg-card .kg-actions > .kg-btn { flex: 0 0 auto; width: 100%; justify-content: center; white-space: nowrap; }
}
