/* Gameflix Kids (docs/kids/): its own light colour set, the Andika font, big touch targets.
   Amber stays the colour of the main action, mint means "live", like in Gameflix. */
@font-face { font-family: "Andika"; src: url("/kids/fonts/Andika-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Andika"; src: url("/kids/fonts/Andika-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --k-bg: #fff6e6;
  --k-surface: #ffffff;
  --k-surface-2: #fdebcb;
  --k-line: #efd9b4;
  --k-line-strong: #cbb48c;
  --k-text: #2a2238;
  --k-text-2: #5e5470;
  --k-ink: #100e17;

  --k-amber: #ffb547;
  --k-amber-hover: #ffc56e;
  --k-amber-ink: #2b1a00;
  --k-live: #1fae7a;
  --k-danger: #d63a52;
  --k-danger-soft: #fde3e7;
  --k-warn: #b98100;

  /* tile colours: one per area */
  --k-sun: #ffd166;
  --k-sky: #8fd3ff;
  --k-grass: #9be38f;
  --k-berry: #ffb0c8;
  --k-lilac: #c9b6ff;
  /* Chart series (checked for colour vision deficiencies on the white panel) */
  --k-chart-play: #2a78d6;
  --k-chart-extra: #e87ba4;
  --k-chart-right: #1baf7a;
  --k-chart-wrong: #eb6834;

  --k-font: "Andika", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --k-r: 22px;
  --k-r-s: 14px;
  --k-touch: 64px;
  --k-pad: clamp(16px, 3.5vw, 40px);
  --k-shadow: 0 6px 0 rgba(42, 34, 56, .12), 0 14px 30px rgba(42, 34, 56, .1);
  --k-ease: cubic-bezier(.2, .8, .3, 1.2);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--k-bg);
  color: var(--k-text);
  font: 400 1.25rem/1.4 var(--k-font);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 4px solid #4b7bff; outline-offset: 3px; }

.k-app { min-height: 100dvh; display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.k-boot { margin: auto; width: 56px; height: 56px; border-radius: 16px; background: var(--k-amber); opacity: .6; }
.k-noscript { padding: 40px; text-align: center; }
.k-muted { color: var(--k-text-2); }
.k-small { font-size: 1rem; }

/* ---------- Buttons ---------- */
.k-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--k-touch); padding: 0 26px;
  border: 0; border-radius: 999px;
  background: var(--k-surface); color: var(--k-text);
  box-shadow: inset 0 0 0 3px var(--k-line);
  font-weight: 700; text-decoration: none;
  touch-action: manipulation;
  transition: transform .15s var(--k-ease), background .15s;
}
.k-btn:active { transform: scale(.96); }
.k-btn-primary { background: var(--k-amber); color: var(--k-amber-ink); box-shadow: 0 5px 0 #d98a1c; }
.k-btn-primary:hover { background: var(--k-amber-hover); }
.k-btn-danger { color: var(--k-danger); box-shadow: inset 0 0 0 3px var(--k-danger-soft); }
.k-btn-small { min-height: 48px; padding: 0 18px; font-size: 1.05rem; }
.k-btn:disabled { opacity: .5; cursor: default; transform: none; }
.k-icon-btn {
  display: inline-grid; place-items: center;
  width: var(--k-touch); height: var(--k-touch); padding: 0;
  border: 0; border-radius: 50%;
  background: var(--k-surface); color: var(--k-text);
  box-shadow: inset 0 0 0 3px var(--k-line);
  touch-action: manipulation;
  transition: transform .15s var(--k-ease);
}
.k-icon-btn:active { transform: scale(.92); }

/* ---------- Header ---------- */
.k-header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px var(--k-pad);
}
.k-header-title { flex: 1; min-width: 0; font-size: 1.6rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-me { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.k-me-name { font-size: 1.5rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.3rem; }
.k-logo svg { flex: none; }

/* ---------- Avatars ---------- */
.k-avatar {
  --size: 56px;
  display: inline-grid; place-items: center; flex: none;
  width: var(--size); height: var(--size); border-radius: 50%;
  background: var(--k-tint, var(--k-sun));
  font-size: calc(var(--size) * .56); line-height: 1;
}
.k-avatar-xl { --size: clamp(110px, 16vw, 160px); }
.k-avatar-l { --size: 76px; }
.k-avatar.has-picture { overflow: hidden; }
.k-avatar img { width: 100%; height: 100%; display: block; }

/* ---------- Main area ---------- */
.k-title { font-size: clamp(1.8rem, 1.3rem + 1.6vw, 2.4rem); }
.k-main { flex: 1; display: flex; flex-direction: column; gap: 24px; padding: 8px var(--k-pad) calc(var(--k-pad) + 8px); }
.k-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; text-align: center; padding: var(--k-pad); }
.k-center h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3rem); }

/* ---------- Profile picker ---------- */
.k-profiles { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(18px, 3vw, 36px); }
.k-profile {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  min-width: 150px; padding: 18px 14px 16px;
  border: 0; border-radius: var(--k-r);
  background: transparent;
  touch-action: manipulation;
  transition: transform .15s var(--k-ease);
}
.k-profile:hover { background: rgba(255, 255, 255, .6); }
.k-profile:active { transform: scale(.94); }
.k-profile-name { font-size: 1.6rem; font-weight: 700; max-width: 220px; overflow-wrap: anywhere; }
.k-corner { position: fixed; right: calc(var(--k-pad) + env(safe-area-inset-right)); bottom: calc(var(--k-pad) + env(safe-area-inset-bottom)); }

/* ---------- Tiles ---------- */
/* Four big tiles, two by two: they fill a tablet in both orientations. */
.k-tiles { flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(clamp(140px, calc(50dvh - 110px), 340px), auto); gap: clamp(14px, 2.5vw, 28px); }
.k-tile {
  position: relative;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 6px;
  min-height: 140px; padding: clamp(16px, 2.5vw, 26px);
  border: 0; border-radius: var(--k-r);
  background: var(--k-tint, var(--k-sun));
  color: var(--k-text); text-align: left; text-decoration: none;
  box-shadow: var(--k-shadow);
  overflow: hidden;
  touch-action: manipulation;
  transition: transform .18s var(--k-ease), box-shadow .18s;
}
.k-tile:active { transform: scale(.96); box-shadow: 0 2px 0 rgba(42, 34, 56, .12); }
.k-tile-glyph { position: absolute; right: 14px; top: 10px; font-size: clamp(3.4rem, 9vw, 7.5rem); line-height: 1; }
.k-tile-name { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.6rem); font-weight: 700; line-height: 1.1; }
.k-tile-note { font-size: 1.05rem; color: var(--k-text-2); }
@media (max-width: 480px) { .k-tile[aria-disabled="true"] .k-tile-note { display: none; } }
.k-tile[aria-disabled="true"] { filter: saturate(.35); opacity: .75; cursor: default; }
.k-tile[aria-disabled="true"]:active { transform: none; }
.k-soon { position: absolute; left: 18px; top: 16px; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, .8); font-size: 1rem; font-weight: 700; }
/* In Advent the calendar as a banner across the top (not stretched); the four tiles get a little
   smaller, so all still fit on a tablet. */
.k-tiles.has-banner { grid-template-rows: max-content; grid-auto-rows: minmax(clamp(130px, calc(50dvh - 180px), 340px), auto); }
.k-tile.is-banner { grid-column: 1 / -1; min-height: 110px; }
.k-tile.is-banner .k-tile-glyph { font-size: clamp(3rem, 7vw, 5rem); }

/* ---------- Advent calendar ---------- */
.k-advent-title { font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.6rem); }
.k-doors { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(8px, 1.5vw, 16px); margin-top: 14px; }
/* Three rows on a tablet held sideways, four upright, six on a phone: all doors on one screen. */
@media (orientation: landscape) and (min-width: 900px) { .k-doors { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
@media (max-width: 600px) { .k-doors { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.k-door {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  aspect-ratio: 1; min-height: var(--k-touch); padding: 6px;
  border: 0; border-radius: var(--k-r-s);
  background: var(--k-tint, var(--k-sun)); color: var(--k-text);
  font: inherit; font-weight: 700; box-shadow: 0 5px 0 rgba(42, 34, 56, .16);
  touch-action: manipulation; cursor: pointer;
  transition: transform .18s var(--k-ease);
}
.k-door:active { transform: scale(.95); }
.k-door-number { font-size: clamp(1.6rem, 1.1rem + 2vw, 2.6rem); line-height: 1; }
.k-door.is-ready { box-shadow: inset 0 0 0 5px var(--k-amber), 0 5px 0 rgba(42, 34, 56, .16); }
.k-door.is-shut { filter: saturate(.3); opacity: .6; }
.k-door.is-open { background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-line); }
.k-door.is-open .k-door-number { position: absolute; left: 8px; top: 6px; font-size: 1rem; color: var(--k-text-2); }
.k-door-picture { width: 78%; height: auto; border-radius: 50%; }
.k-door-stars { font-size: clamp(1rem, .8rem + .8vw, 1.4rem); }
:root[data-animations="off"] .k-door:active { transform: none; }

/* ---------- Wishes and goals, sticker album (K6-2) ---------- */
.k-stars-ready { margin-left: 4px; font-size: 1.15em; }
.k-wishes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.k-wish { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--k-r-s); background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-line); }
.k-wish.is-ready { box-shadow: inset 0 0 0 4px var(--k-amber); }
.k-wish.is-requested { background: #fff6dc; }
.k-wish-emoji { font-size: 2.6rem; line-height: 1; }
.k-wish-main { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.k-wish-state { margin: 0; font-weight: 700; }
.k-wish-row .k-wish-emoji { font-size: 2rem; }
.k-wish-row.is-requested { background: #fff6dc; }
.k-album { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.k-sticker { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 50%; background: var(--k-surface); box-shadow: inset 0 0 0 4px var(--k-sun), 0 4px 0 rgba(42, 34, 56, .1); }
.k-sticker-emoji { font-size: 2.2rem; line-height: 1; }
.k-sticker.is-missing { background: var(--k-surface-2); box-shadow: inset 0 0 0 3px var(--k-line); }
.k-sticker.is-missing .k-sticker-emoji { font-size: 1.4rem; color: var(--k-text-2); font-weight: 700; }
.k-sticker-count { position: absolute; right: -2px; bottom: -2px; padding: 1px 7px; border-radius: 999px; background: var(--k-amber); color: var(--k-amber-ink); font-size: .85rem; font-weight: 700; }

/* ---------- Read-aloud mode, dictation, voices (K6-3) ---------- */
/* A small speaker on tiles and game covers; it reads the name and does not press the tile. */
.k-tile-wrap { position: relative; display: flex; min-width: 0; }
.k-tile-wrap > .k-tile, .k-tile-wrap > .k-game { flex: 1; min-width: 0; }
.k-tile-wrap.is-banner { grid-column: 1 / -1; }
.k-say { position: absolute; left: 10px; top: 10px; z-index: 1; display: grid; place-items: center; width: 52px; height: 52px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .9); color: var(--k-text); box-shadow: 0 3px 0 rgba(42, 34, 56, .15); touch-action: manipulation; }
.k-listen { display: flex; width: max-content; margin: 0 auto 16px; gap: 10px; font-size: 1.4rem; min-height: 72px; padding: 0 28px; }
.k-reading { display: flex; flex-direction: column; gap: 14px; }
.k-voice-row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.k-voice-row .k-select { flex: 1 1 240px; min-width: 0; }
.k-voice-row select { width: 100%; }
.k-voice-help ul { margin: 8px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

/* ---------- Movement break (K6-4) ---------- */
.k-move-glyph { font-size: 5.5rem; line-height: 1; }
.k-move h2 { font-size: 1.6rem; }
.k-move-bar { width: 100%; height: 14px; border-radius: 999px; background: var(--k-surface-2); overflow: hidden; }
.k-move-bar > span { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--k-grass); }

/* ---------- Learning map (K6-4) ---------- */
.k-learn-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.k-map-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.k-map-legend > span { display: inline-flex; align-items: center; gap: 2px; }
.k-islands { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; gap: 18px; }
.k-island { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 40px 28px 44px 30px; background: var(--k-tint, var(--k-sky)); box-shadow: var(--k-shadow); }
.k-island.is-focus { box-shadow: 0 0 0 5px var(--k-amber), var(--k-shadow); }
.k-island-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.k-island-head h2 { font-size: 1.5rem; }
.k-island-head .k-say { position: static; flex: none; }
.k-spots { display: flex; flex-wrap: wrap; gap: 10px; }
.k-spot { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: var(--k-touch); padding: 10px 16px; border-radius: var(--k-r-s); background: var(--k-surface); color: var(--k-text); text-decoration: none; font-weight: 700; box-shadow: 0 4px 0 rgba(42, 34, 56, .14); touch-action: manipulation; }
.k-spot.is-focus { box-shadow: 0 0 0 4px var(--k-amber), 0 0 22px 4px var(--k-amber); }
.k-spot-flags { display: inline-flex; gap: 2px; }
.k-flag { color: var(--k-line-strong); }
.k-flag.is-on { color: var(--k-amber); }
.k-flag.is-on path:first-child { stroke: var(--k-text-2); }
.k-flag.is-on path:last-child { stroke: var(--k-amber-ink); stroke-width: 1; stroke-linejoin: round; }
:root:not([data-animations="off"]) .k-spot:active { transform: scale(.96); }

/* ---------- Presents (Advent door, birthday) ---------- */
.k-gift-picture { width: 180px; height: 180px; border-radius: 50%; box-shadow: 0 6px 0 rgba(42, 34, 56, .12); }
.k-gift-item { font-size: 1.15rem; }
.k-gift h2 { display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ---------- Games ---------- */
.k-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 200px), 1fr)); gap: clamp(16px, 2.5vw, 28px); }
.k-game { display: block; border-radius: var(--k-r); text-decoration: none; touch-action: manipulation; transition: transform .18s var(--k-ease); }
.k-game:active { transform: scale(.95); }
.k-game .cover { border-radius: var(--k-r); box-shadow: var(--k-shadow); }
.k-empty { padding: 40px 0; text-align: center; color: var(--k-text-2); }

/* Covers as in Gameflix (public/styles/components.css), generated from accent + icon + title. */
.cover {
  --c: #8a7cff;
  position: relative; display: block; overflow: hidden;
  container-type: inline-size;
  border-radius: var(--k-r-s);
  background:
    radial-gradient(90% 70% at 88% 105%, color-mix(in oklab, var(--c) 90%, white) 0%, transparent 62%),
    linear-gradient(155deg, color-mix(in oklab, var(--c) 62%, var(--k-ink)) 0%, color-mix(in oklab, var(--c) 22%, var(--k-ink)) 78%);
  isolation: isolate;
}
.cover-tile { aspect-ratio: 4 / 5; }
.cover-thumb { aspect-ratio: 1; width: 72px; flex: none; }
.cover-glyph { position: absolute; right: -14%; bottom: -12%; font-size: 78cqi; line-height: 1; transform: rotate(-11deg); filter: drop-shadow(0 8cqi 10cqi rgba(0, 0, 0, .35)); z-index: -1; user-select: none; }
.cover-thumb .cover-glyph { position: static; display: grid; place-items: center; height: 100%; font-size: 58cqi; transform: none; filter: none; }
.cover-title {
  position: absolute; left: 7%; right: var(--title-right, 30%); bottom: 7%;
  color: #fff;
  font: 700 clamp(.6rem, var(--title-size, 13cqi), 3.2rem)/1.06 var(--k-font);
  text-wrap: balance; overflow-wrap: break-word;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .35);
}
.cover.has-image { background: var(--k-ink); }
.cover.has-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover.has-image::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .55), transparent 55%); }
.cover-title-shadow { z-index: 1; }

/* ---------- Play ---------- */
.k-play { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; background: #000; }
.k-play-bar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(6px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 6px calc(10px + env(safe-area-inset-left));
  background: var(--k-text); color: #fff;
}
.k-play-bar .k-icon-btn { width: 56px; height: 56px; background: rgba(255, 255, 255, .14); color: #fff; box-shadow: none; }
.k-play-title { flex: 1; min-width: 0; font-size: 1.3rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-play-stage { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; overflow: hidden; padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.k-play .game-frame { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border: 0; background: #000; display: block; transform-origin: 0 0; }
.k-play-status { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px; color: #fff; text-align: center; }
.k-play-status .cover-thumb { width: 96px; }

/* ---------- Forms and cards (setup, sign-in, parents' area) ---------- */
.k-card { width: min(100%, 560px); display: flex; flex-direction: column; gap: 18px; padding: clamp(20px, 4vw, 32px); border-radius: var(--k-r); background: var(--k-surface); box-shadow: var(--k-shadow); text-align: left; }
.k-card h2 { font-size: 1.6rem; }
.k-card h3 { margin: 0; font-size: 1.35rem; }
.k-field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.k-field input {
  min-height: 56px; padding: 0 16px;
  border: 3px solid var(--k-line); border-radius: var(--k-r-s);
  background: #fffdf8; font-weight: 400;
}
.k-field input:focus { border-color: var(--k-amber); outline: none; }
.k-field-hint { font-weight: 400; font-size: 1rem; color: var(--k-text-2); }
.k-error { min-height: 1.4em; color: var(--k-danger); font-size: 1.05rem; }
.k-note { padding: 12px 16px; border-radius: var(--k-r-s); background: #fff1c9; box-shadow: inset 0 0 0 3px #f7d77a; }
.k-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.k-section { display: flex; flex-direction: column; gap: 16px; }
.k-section > h2 { font-size: 1.7rem; }
.k-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.k-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: var(--k-r-s); background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-line); }
.k-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.k-row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.k-badge { padding: 2px 10px; border-radius: 999px; background: var(--k-surface-2); font-size: .95rem; font-weight: 700; }
.k-parents { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 28px; align-items: start; }
.k-avatars { display: flex; flex-wrap: wrap; gap: 8px; border: 0; margin: 0; padding: 0; }
.k-avatars legend { padding: 0 0 6px; font-weight: 700; }
.k-avatars label { position: relative; }
.k-avatars input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.k-avatars span { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--k-surface-2); font-size: 1.8rem; box-shadow: inset 0 0 0 3px transparent; }
.k-avatars input:checked + span { box-shadow: inset 0 0 0 4px var(--k-amber); background: #fff3dc; }
.k-avatars input:focus-visible + span { outline: 4px solid #4b7bff; outline-offset: 2px; }

/* ---------- PIN pad ---------- */
.k-dialog { border: 0; padding: 0; border-radius: var(--k-r); background: var(--k-surface); color: var(--k-text); box-shadow: 0 30px 80px rgba(42, 34, 56, .35); max-width: calc(100vw - 32px); }
.k-dialog::backdrop { background: rgba(42, 34, 56, .45); }
.k-pin { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px clamp(18px, 4vw, 32px); }
.k-pin:focus { outline: none; }
.k-pin h2 { font-size: 1.6rem; }
.k-pin-dots { display: flex; gap: 12px; min-height: 22px; }
.k-pin-dots i { width: 20px; height: 20px; border-radius: 50%; background: var(--k-line); }
.k-pin-dots i.is-set { background: var(--k-text); }
.k-pin-keys { display: grid; grid-template-columns: repeat(3, var(--k-touch)); gap: 12px; }
.k-pin-keys button { width: var(--k-touch); height: var(--k-touch); border: 0; border-radius: 50%; background: var(--k-surface-2); font-size: 1.6rem; font-weight: 700; touch-action: manipulation; }
.k-pin-keys button:active { transform: scale(.92); }
.k-pin-keys [data-pin="ok"] { background: var(--k-amber); color: var(--k-amber-ink); font-size: 1.15rem; }
.k-pin .k-error { text-align: center; max-width: 280px; }
@media (max-height: 560px) {
  .k-pin { gap: 10px; padding: 14px 18px; }
  .k-pin-keys { grid-template-columns: repeat(4, 54px); gap: 8px; }
  .k-pin-keys button { width: 54px; height: 54px; }
}

/* ---------- Toast ---------- */
.k-toasts { position: fixed; z-index: 30; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; width: min(92vw, 520px); pointer-events: none; }
.k-toast { padding: 14px 20px; border-radius: var(--k-r-s); background: var(--k-text); color: #fff; font-size: 1.1rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .k-btn:active, .k-icon-btn:active, .k-tile:active, .k-profile:active, .k-game:active, .k-pin-keys button:active { transform: none; }
}

/* ---------- Stars ---------- */
.k-stars {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 52px; padding: 0 16px 0 12px;
  border-radius: 999px; background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-sun);
  font-size: 1.35rem; font-weight: 700; text-decoration: none; white-space: nowrap;
  touch-action: manipulation;
}
.k-stars-icon { font-size: 1.5rem; line-height: 1; }
.k-stars.is-bumped { animation: k-bump .5s var(--k-ease); }
@keyframes k-bump { 40% { transform: scale(1.18); } }
.k-fly-star { position: fixed; z-index: 40; left: 0; top: 0; font-size: 2rem; pointer-events: none; }

/* ---------- Learning ---------- */
.k-learn { align-items: center; }
.k-daily { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; font-weight: 700; text-align: center; }
@media (max-width: 480px) { .k-me-name { display: none; } } /* the avatar is enough next to the stars */
/* Narrow phones: back, avatar, stars, door and lock fit in one row (touch targets stay above 48 px). */
.k-me .k-avatar { flex: none; }
@media (max-width: 420px) {
  .k-header { gap: 8px; }
  .k-header .k-icon-btn { width: 52px; height: 52px; }
}
.k-daily-slots { display: flex; gap: 6px; font-size: 1.8rem; line-height: 1; }
.k-daily-slot { filter: grayscale(1); opacity: .35; }
.k-daily-slot.is-done { filter: none; opacity: 1; }
.k-task { width: min(100%, 980px); display: flex; flex-direction: column; gap: 18px; }
.k-task-card {
  display: grid; gap: 18px 28px; align-items: center;
  padding: clamp(18px, 3vw, 30px); border-radius: var(--k-r);
  background: var(--k-surface); box-shadow: var(--k-shadow);
}
.k-task-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.k-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--k-surface-2); font-size: 1.05rem; font-weight: 700; }
.k-chip-review { background: #e3f1ff; }
.k-task-top .k-icon-btn { margin-left: auto; }
.k-task-picture { font-size: clamp(4rem, 12vw, 7rem); line-height: 1; text-align: center; }
.k-task-question { font-size: clamp(1.6rem, 1.1rem + 2vw, 2.6rem); font-weight: 700; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.k-task-answer { display: flex; flex-direction: column; align-items: center; gap: 14px; }
@media (min-width: 900px) {
  .k-task-card.is-number { grid-template-columns: 1fr auto; }
  .k-task-card.is-number .k-task-top { grid-column: 1 / -1; }
}

.k-number-row { display: flex; align-items: center; gap: 10px; font-size: 1.6rem; font-weight: 700; }
.k-number-display {
  min-width: 170px; min-height: 72px; padding: 6px 18px;
  display: grid; place-items: center;
  border-radius: var(--k-r-s); background: #fffdf8; box-shadow: inset 0 0 0 3px var(--k-line);
  font-size: 2.4rem; font-weight: 700; letter-spacing: .04em;
}
.k-number-display.is-empty { color: var(--k-line); }
.k-numpad { display: grid; grid-template-columns: repeat(3, 76px); gap: 10px; }
.k-numpad button { height: 72px; border: 0; border-radius: var(--k-r-s); background: var(--k-surface-2); font-size: 1.9rem; font-weight: 700; touch-action: manipulation; transition: transform .12s var(--k-ease); }
.k-numpad button:active { transform: scale(.92); }
.k-numpad [data-key="ok"] { background: var(--k-amber); color: var(--k-amber-ink); font-size: 1.3rem; }
@media (max-height: 620px) and (orientation: landscape) {
  .k-numpad { grid-template-columns: repeat(4, 64px); }
  .k-numpad button { height: 56px; }
}

.k-choices { width: 100%; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.k-choice {
  min-height: 84px; padding: 12px 18px;
  border: 0; border-radius: var(--k-r);
  background: var(--k-surface-2); box-shadow: inset 0 0 0 3px var(--k-line);
  font-size: clamp(1.3rem, 1rem + 1vw, 1.8rem); font-weight: 700; overflow-wrap: anywhere;
  touch-action: manipulation; transition: transform .15s var(--k-ease);
}
.k-choice:active { transform: scale(.96); }
.k-choice:disabled { cursor: default; transform: none; opacity: .55; }
.k-choice.is-right { opacity: 1; background: #d8f5e6; box-shadow: inset 0 0 0 4px var(--k-live); }
.k-choice.is-wrong { opacity: 1; background: var(--k-danger-soft); box-shadow: inset 0 0 0 4px var(--k-danger); }
.k-choice-yes { background: #e2f7df; }
.k-choice-no { background: #fde8e8; }

.k-result { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 22px; border-radius: var(--k-r); text-align: center; background: var(--k-surface); box-shadow: var(--k-shadow); }
.k-task-result { grid-column: 1 / -1; }
.k-task-result:empty { display: none; }
.k-task-result .k-result { padding: 14px 18px; box-shadow: none; }
.k-task-result .k-result.is-right { background: #e9f9f1; box-shadow: inset 0 0 0 4px var(--k-live); }
.k-task-result .k-result.is-wrong { background: #fff6dc; box-shadow: inset 0 0 0 4px var(--k-sun); }
.k-result-title { display: flex; align-items: center; gap: 10px; font-size: 2rem; font-weight: 700; }
.k-result-stars { font-size: 1.6rem; font-weight: 700; }
.k-result-solution { font-size: 1.4rem; font-weight: 700; }
.k-result .k-actions { justify-content: center; }

/* ---------- Reward ---------- */
.k-overlay { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; padding: 24px; background: rgba(42, 34, 56, .45); }
.k-reward { position: relative; z-index: 1; width: min(100%, 440px); display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 30px 26px; border-radius: var(--k-r); background: var(--k-surface); text-align: center; box-shadow: 0 30px 80px rgba(42, 34, 56, .35); }
.k-reward:focus { outline: none; }
.k-reward-star { font-size: 5.5rem; line-height: 1; animation: k-pop .6s var(--k-ease); }
.k-reward h2 { font-size: 1.9rem; }
.k-reward-amount { font-size: 1.6rem; font-weight: 700; }
@keyframes k-pop { from { transform: scale(.3) rotate(-30deg); } }
.k-confetti { position: fixed; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; }

/* ---------- Star account ---------- */
.k-account { width: min(100%, 720px); align-self: center; display: flex; flex-direction: column; gap: 20px; }
.k-account-total { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; border-radius: var(--k-r); background: var(--k-sun); box-shadow: var(--k-shadow); }
.k-account-total strong { font-size: 3.4rem; line-height: 1; }
.k-entry-amount { font-size: 1.4rem; font-weight: 700; white-space: nowrap; }

/* ---------- Parents: children and their settings ---------- */
.k-child { flex-wrap: wrap; }
.k-child-stats { color: var(--k-text-2); font-size: 1rem; }
.k-select { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 1rem; }
.k-select select { min-height: 48px; padding: 0 12px; border: 3px solid var(--k-line); border-radius: var(--k-r-s); background: #fffdf8; font-size: 1.1rem; }
.k-check { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 700; font-size: 1.05rem; }
.k-check input { width: 26px; height: 26px; accent-color: var(--k-amber); }

@media (prefers-reduced-motion: reduce) {
  .k-stars.is-bumped, .k-reward-star { animation: none !important; }
  .k-numpad button:active, .k-choice:active { transform: none; }
}

/* ---------- Play time ---------- */
.k-time-pill { flex: none; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .14); font-weight: 700; white-space: nowrap; }
.k-time-pill.is-low { background: var(--k-sun); color: var(--k-text); }
.k-play-stage.is-paused .game-frame { filter: blur(6px) saturate(.6); }
.k-time-layer { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 20px; background: rgba(42, 34, 56, .55); overflow-y: auto; }
.k-time-card {
  width: min(100%, 560px); display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: clamp(22px, 4vw, 34px); border-radius: var(--k-r);
  background: var(--k-surface); color: var(--k-text); text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
.k-time-card h2 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); }
.k-time-card .k-actions { justify-content: center; }
.k-time-glyph { font-size: 4.5rem; line-height: 1; }
.k-waiting { animation: k-float 2.4s ease-in-out infinite; }
@keyframes k-float { 50% { transform: translateY(-8px) rotate(-4deg); } }
.k-grant-choices { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.k-grant-choices .k-btn { padding: 0 10px; }

/* ---------- Parents: requests and play time ---------- */
.k-requests { display: flex; flex-direction: column; gap: 12px; }
.k-request { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; border-radius: var(--k-r-s); background: #fff3d6; box-shadow: inset 0 0 0 3px var(--k-sun); }
.k-request.is-answered { background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-line); }
.k-request-head { display: flex; align-items: center; gap: 12px; }
.k-request-text { flex: 1; min-width: 0; font-weight: 700; }
.k-request .k-actions .k-btn { min-height: 52px; padding: 0 16px; }
.k-time-form { display: flex; flex-direction: column; gap: 14px; }
.k-time-form .k-error:empty { display: none; }
.k-birthday { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; padding: 0; border: 0; }
.k-birthday legend { margin-bottom: 6px; font-weight: 700; }
.k-time-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.k-time-row > strong { flex-basis: 100%; }
.k-select input[type="time"] { min-height: 48px; padding: 0 10px; border: 3px solid var(--k-line); border-radius: var(--k-r-s); background: #fffdf8; font-size: 1.1rem; }
.k-time-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; }

/* ---------- Parents: child page and statistics ---------- */
.k-child-head { display: flex; align-items: center; gap: 14px; }
.k-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.k-section-head h2 { font-size: 1.7rem; }
.k-child .k-row-main { gap: 2px; }
.k-panel h4 { margin: 4px 0 0; font-size: 1.05rem; }
.k-child-head h1 { font-size: clamp(1.7rem, 1.3rem + 1.4vw, 2.3rem); }
.k-segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--k-surface-2); }
.k-segmented button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; font-weight: 700; }
.k-segmented button[aria-pressed="true"] { background: var(--k-surface); box-shadow: 0 2px 6px rgba(42, 34, 56, .12); }
[data-stats] { display: flex; flex-direction: column; gap: 18px; }
.k-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 12px; }
.k-kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--k-r-s); background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-line); }
.k-kpi-label { font-size: 1rem; color: var(--k-text-2); font-weight: 700; }
.k-kpi-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.k-kpi-note { font-size: .95rem; color: var(--k-text-2); }
.k-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 18px; align-items: start; }
.k-panel { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; border-radius: var(--k-r); background: var(--k-surface); box-shadow: var(--k-shadow); }
.k-panel h3 { margin: 0; font-size: 1.3rem; }
.k-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 1.05rem; }
.k-facts li { display: flex; justify-content: space-between; gap: 12px; }
.k-facts .k-muted { white-space: nowrap; }

.k-chart { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.k-chart-title { font-weight: 700; }
.k-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .95rem; color: var(--k-text-2); }
.k-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.k-legend-item i { width: 12px; height: 12px; border-radius: 3px; }
.k-chart-body { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 170px auto; column-gap: 8px; row-gap: 4px; }
.k-chart-ticks { display: flex; flex-direction: column; justify-content: space-between; font-size: .8rem; color: var(--k-text-2); text-align: right; margin: -0.5em 0; }
.k-chart-plot { position: relative; display: flex; align-items: flex-end; justify-content: space-around; gap: 2px; border-bottom: 1px solid #e3d6bd; }
.k-chart-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid #f0e6d2; pointer-events: none; }
.k-col { position: relative; flex: 1; max-width: 24px; height: 100%; display: flex; flex-direction: column-reverse; gap: 2px; outline-offset: 2px; cursor: pointer; }
.k-col:hover, .k-col:focus { background: rgba(42, 34, 56, .05); }
.k-seg { display: block; width: 100%; min-height: 2px; }
.k-seg:last-child { border-radius: 4px 4px 0 0; }
.k-col:hover::after, .k-col:focus::after {
  content: attr(data-tip); position: absolute; z-index: 3; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 220px; padding: 8px 10px; border-radius: 8px;
  background: var(--k-text); color: #fff; font-size: .9rem; line-height: 1.3; white-space: normal; pointer-events: none;
}
.k-col.is-first:hover::after, .k-col.is-first:focus::after { left: 0; transform: none; }
.k-col.is-last:hover::after, .k-col.is-last:focus::after { left: auto; right: 0; transform: none; }
.k-chart-days { display: flex; justify-content: space-around; gap: 2px; font-size: .8rem; color: var(--k-text-2); }
.k-chart-days span { flex: 1; max-width: 24px; display: flex; justify-content: center; white-space: nowrap; }
.k-chart-table summary { cursor: pointer; font-size: .95rem; color: var(--k-text-2); }
.k-chart-table table { width: 100%; border-collapse: collapse; font-size: .95rem; margin-top: 6px; }
.k-chart-table th, .k-chart-table td { padding: 4px 6px; border-bottom: 1px solid #f0e6d2; text-align: right; }
.k-chart-table th:first-child { text-align: left; }
.k-form-grid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.k-select input[type="date"] { min-height: 48px; padding: 0 10px; border: 3px solid var(--k-line); border-radius: var(--k-r-s); background: #fffdf8; font-size: 1.1rem; }
.k-select select:disabled, .k-select input:disabled { opacity: .55; }

/* ---------- Animations switched off by the parents ---------- */
:root[data-animations="off"] *, :root[data-animations="off"] *::before, :root[data-animations="off"] *::after { transition: none !important; animation: none !important; }
:root[data-animations="off"] .k-btn:active, :root[data-animations="off"] .k-tile:active, :root[data-animations="off"] .k-profile:active,
:root[data-animations="off"] .k-choice:active, :root[data-animations="off"] .k-numpad button:active, :root[data-animations="off"] .k-game:active { transform: none; }

/* ---------- Parents: family quiz, packs; operator: content ---------- */
.k-choice-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0 20px; border: 0; margin: 0; padding: 0; min-width: 0; }
.k-choice-row legend { padding: 0 0 2px; font-weight: 700; }
.k-packs .k-check { font-weight: 400; }
.k-task-form div[data-type-fields] { display: flex; flex-direction: column; gap: 8px; }
.k-wrong { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 10px; }
.k-task-row, .k-pack-row, .k-subject-row { flex-wrap: wrap; }
.k-task-row .k-row-title, .k-pack-row .k-row-title { white-space: normal; }
.k-task-row .k-row-main, .k-pack-row .k-row-main { flex: 1 1 260px; }
.k-task-row.is-off, .k-pack-row.is-off { background: #fbf6ec; }
.k-task-row.is-off .k-row-title, .k-pack-row.is-off .k-row-title { color: var(--k-text-2); }
.k-subject-icon { font-size: 1.8rem; line-height: 1; }
.k-form-grid .k-field { flex: 1 1 200px; }
.k-form-grid .k-field-short { flex: 0 1 7em; }
.k-error-block { white-space: pre-line; overflow-wrap: anywhere; }
.k-card code { font-size: .95em; padding: 1px 5px; border-radius: 6px; background: var(--k-surface-2); }
.k-field input[type="file"] { min-height: 0; padding: 12px; }

/* ---------- Avatar and shop ---------- */
.k-tile-picture { display: block; width: 1.15em; height: 1.15em; border-radius: 50%; }
.k-avatar-page { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: clamp(18px, 3vw, 36px); align-items: start; }
.k-avatar-page > section { min-width: 0; }
.k-avatar-stage { position: sticky; top: 12px; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px; border-radius: var(--k-r); background: var(--k-surface); box-shadow: var(--k-shadow); text-align: center; }
.k-avatar-stage img { width: min(100%, 240px); aspect-ratio: 1; border-radius: 50%; background: var(--k-surface-2); }
.k-avatar-stage .k-actions { justify-content: center; }
.k-avatar-note { min-height: 1.4em; font-size: 1.05rem; color: var(--k-text-2); }
.k-shop-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: thin; }
.k-shop-tabs button { flex: none; min-height: 52px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-line); font-size: 1.1rem; font-weight: 700; }
.k-shop-tabs button[aria-pressed="true"] { background: var(--k-amber); box-shadow: none; color: var(--k-amber-ink); }
.k-shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.k-shop-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: var(--k-touch); padding: 10px 8px 12px; border: 0; border-radius: var(--k-r-s); background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-line); font-size: 1rem; text-align: center; }
.k-shop-item img { width: 96px; height: 96px; border-radius: 50%; background: var(--k-surface-2); }
.k-shop-item[aria-pressed="true"] { box-shadow: inset 0 0 0 4px var(--k-amber); background: #fff7e6; }
.k-shop-name { font-weight: 700; line-height: 1.2; }
.k-shop-price { font-size: .95rem; color: var(--k-text-2); }
.k-shop-price.is-owned { color: var(--k-live); font-weight: 700; }
.k-shop-badge { position: absolute; top: 6px; left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--k-lilac); font-size: .8rem; font-weight: 700; }
.k-shop-badge.is-new { left: auto; right: 6px; background: var(--k-sun); }
@media (max-width: 720px) {
  .k-avatar-page { grid-template-columns: 1fr; }
  .k-avatar-stage { position: static; }
  .k-avatar-stage img { width: 180px; }
  .k-shop-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .k-shop-item img { width: 76px; height: 76px; }
}

/* ---------- Achievements ---------- */
.k-achievements { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.k-achievement { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--k-r-s); background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-line); }
.k-achievement.is-done { background: #fff6dc; box-shadow: inset 0 0 0 3px var(--k-sun); }
.k-achievement:not(.is-done) .k-achievement-icon { filter: grayscale(1); opacity: .55; }
.k-achievement-icon { font-size: 2.4rem; line-height: 1; }
.k-achievement-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.k-progress { display: block; height: 10px; border-radius: 999px; background: var(--k-surface-2); overflow: hidden; }
.k-progress i { display: block; height: 100%; border-radius: 999px; background: var(--k-amber); }
.k-reward-stars { font-size: 1.4rem; }
.k-achievement-pop {
  position: fixed; z-index: 40; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(calc(100% - 32px), 460px); display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 18px;
  border-radius: var(--k-r); background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-sun), 0 18px 50px rgba(42, 34, 56, .3);
  animation: k-pop-in .35s var(--k-ease);
}
.k-achievement-pop-icon { font-size: 2.8rem; line-height: 1; }
.k-achievement-pop-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.k-achievement-pop-text strong { font-size: 1.3rem; }
.k-achievement-pop .k-icon-btn { width: 48px; height: 48px; flex: none; }
@keyframes k-pop-in { from { transform: translate(-50%, 30px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .k-achievement-pop { animation: none; } }

/* ---------- A task over a game (Gameflix.kids.tasks.ask) ---------- */
.k-task-overlay { align-items: start; overflow-y: auto; }
.k-task-sheet { width: min(100%, 860px); display: flex; flex-direction: column; gap: 14px; padding: 18px; border-radius: var(--k-r); background: var(--k-bg); box-shadow: 0 30px 80px rgba(42, 34, 56, .35); }
.k-task-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 1.25rem; }

/* ---------- Friends and chat ---------- */
.k-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.k-friends { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.k-friend-card { display: flex; flex-direction: column; border-radius: var(--k-r); background: var(--k-surface); box-shadow: var(--k-shadow); }
.k-friend {
  display: flex; align-items: center; gap: 16px; min-height: 104px; padding: 14px 18px;
  border-radius: var(--k-r); color: var(--k-text); text-decoration: none; transition: transform .15s var(--k-ease);
}
.k-friend-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 16px; }
.k-friend:active { transform: scale(.97); }
.k-friend-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.k-friend-name { font-size: 1.45rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-presence { display: inline-flex; align-items: center; gap: 8px; color: var(--k-text-2); font-size: 1.05rem; }
.k-presence::before { content: ""; width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--k-line); }
.k-presence.is-online::before { background: var(--k-live); }
.k-unread { min-width: 40px; height: 40px; padding: 0 10px; display: grid; place-items: center; border-radius: 999px; background: var(--k-amber); color: var(--k-amber-ink); font-weight: 700; }
.k-friends-empty { margin: 0 0 8px; font-size: 4rem; line-height: 1; }

.k-chat { gap: 14px; }
.k-chat-head { display: flex; align-items: center; gap: 16px; }
.k-chat-head .k-title { line-height: 1.1; }
.k-messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.k-message { display: flex; align-items: flex-end; gap: 8px; max-width: min(85%, 640px); }
.k-message.is-mine { align-self: flex-end; flex-direction: row-reverse; }
.k-message-text { padding: 12px 18px; border-radius: var(--k-r) var(--k-r) var(--k-r) 6px; background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-line); font-size: 1.3rem; overflow-wrap: anywhere; }
.k-message.is-mine .k-message-text { border-radius: var(--k-r) var(--k-r) 6px var(--k-r); background: #dff1ff; box-shadow: inset 0 0 0 3px #b9defb; }
.k-message.is-emoji .k-message-text { padding: 4px 8px; background: none; box-shadow: none; font-size: 3rem; line-height: 1.1; }
.k-message-meta { display: flex; align-items: center; gap: 6px; color: var(--k-text-2); font-size: .9rem; }
.k-message.is-mine .k-message-meta { flex-direction: row-reverse; }
/* Stays at the bottom of the screen while the messages scroll. */
.k-composer-dock {
  position: sticky; bottom: 0; z-index: 2;
  margin: 0 calc(-1 * var(--k-pad)) calc(-1 * var(--k-pad) - 8px); padding: 12px var(--k-pad) calc(12px + env(safe-area-inset-bottom));
  background: var(--k-bg); box-shadow: 0 -3px 0 var(--k-line);
}
.k-composer { display: flex; flex-direction: column; gap: 10px; }
/* One row each, scrolling sideways inside (not the page). */
.k-quick, .k-emojis { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.k-quick-btn, .k-emoji-btn { flex: none; min-height: var(--k-touch); border: 0; border-radius: 999px; background: var(--k-surface); color: var(--k-text); box-shadow: inset 0 0 0 3px var(--k-line); font-weight: 700; }
.k-quick-btn { padding: 0 20px; font-size: 1.1rem; white-space: nowrap; }
/* Colour emojis of the device, not the outlines some text fonts have. */
.k-emoji-btn, .k-message.is-emoji .k-message-text { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", var(--k-font); }
.k-emoji-btn { width: var(--k-touch); font-size: 2rem; line-height: 1; }
.k-quick-btn:active, .k-emoji-btn:active { transform: scale(.95); }
.k-chat-form { display: flex; gap: 10px; }
.k-chat-form input { flex: 1; min-width: 0; min-height: var(--k-touch); padding: 0 18px; border: 3px solid var(--k-line); border-radius: 999px; background: #fffdf8; font-size: 1.2rem; }
.k-chat-form input:focus { border-color: var(--k-amber); outline: none; }

/* Parents: the buttons go below the name when the panel is narrow. */
[data-friend-row], [data-code-row] { flex-wrap: wrap; }
[data-friend-row] .k-row-main, [data-code-row] .k-row-main { min-width: min(100%, 200px); }
.k-code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.5rem; font-weight: 700; letter-spacing: .08em; }
.k-select input { min-height: 48px; padding: 0 12px; border: 3px solid var(--k-line); border-radius: var(--k-r-s); background: #fffdf8; font-size: 1.1rem; }
[data-friend-code-form] input { text-transform: uppercase; letter-spacing: .06em; max-width: 16ch; }
.k-chat-read { width: min(560px, calc(100vw - 32px)); max-height: min(80vh, 720px); overflow-y: auto; box-shadow: none; }
.k-chat-log li { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: var(--k-r-s); background: var(--k-surface-2); overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .k-friend:active, .k-quick-btn:active, .k-emoji-btn:active { transform: none; } }
:root[data-animations="off"] .k-friend:active, :root[data-animations="off"] .k-quick-btn:active, :root[data-animations="off"] .k-emoji-btn:active { transform: none; }

/* ---------- Party ---------- */
.k-party { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; border-radius: var(--k-r); background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-sun), var(--k-shadow); }
.k-party h2 { font-size: 1.5rem; }
.k-party-members { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px 20px; }
.k-party-members li { display: flex; align-items: center; gap: 10px; font-weight: 700; }
/* Mint only for "live": the microphone is on. */
.k-btn.is-live, .k-icon-btn.is-live { background: var(--k-live); color: #fff; box-shadow: inset 0 0 0 3px #168a60; }
.k-btn .icon { vertical-align: -5px; }
.k-party-cards {
  position: fixed; z-index: 41; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: min(calc(100% - 32px), 520px); display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.k-party-card {
  pointer-events: auto; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px 14px; padding: 14px 16px;
  border-radius: var(--k-r); background: var(--k-surface); box-shadow: inset 0 0 0 3px var(--k-sun), 0 18px 50px rgba(42, 34, 56, .3);
  animation: k-drop-in .3s var(--k-ease);
}
.k-party-card .k-actions { grid-column: 1 / -1; }
.k-party-card-text { font-size: 1.2rem; }
@keyframes k-drop-in { from { transform: translateY(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .k-party-card { animation: none; } }

/* ---------- Gamepad ---------- */
/* The focus moved by the pad is always visible (browsers show :focus-visible only after keys). */
:root[data-input="gamepad"] :focus { outline: 4px solid #4b7bff; outline-offset: 3px; }
:root[data-input="gamepad"] .k-tile:focus, :root[data-input="gamepad"] .k-game:focus, :root[data-input="gamepad"] .k-profile:focus { outline-width: 6px; }

/* ---------- Task types: build a word, put in order, connect pairs ---------- */
[data-build-host] { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.k-word { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 72px; }
.k-slot {
  display: grid; place-items: center; width: clamp(44px, 9vw, 64px); height: clamp(56px, 11vw, 76px);
  border-radius: var(--k-r-s); background: var(--k-surface); box-shadow: inset 0 -4px 0 var(--k-line), inset 0 0 0 3px var(--k-line);
  font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.6rem); font-weight: 700;
}
.k-slot.is-filled { box-shadow: inset 0 -4px 0 var(--k-amber), inset 0 0 0 3px var(--k-amber); }
.k-letters { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.k-letter {
  min-width: var(--k-touch); min-height: var(--k-touch); padding: 0 10px; border: 0; border-radius: var(--k-r-s);
  background: var(--k-sky); color: var(--k-text); font-size: 2rem; font-weight: 700; box-shadow: 0 5px 0 rgba(42, 34, 56, .18);
  transition: transform .12s var(--k-ease);
}
.k-letter:active { transform: scale(.94); }
.k-letter:disabled { opacity: .25; box-shadow: none; }
.k-build-actions { display: flex; gap: 12px; }
.k-order-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.k-order-items .k-choice, .k-match-item { position: relative; }
.k-choice.is-placed { opacity: 1; background: #fff3dc; box-shadow: inset 0 0 0 3px var(--k-amber); }
.k-place {
  display: inline-grid; place-items: center; min-width: 32px; height: 32px; margin-right: 10px; padding: 0 6px;
  border-radius: 999px; background: var(--k-ink); color: #fff; font-size: 1.1rem; font-weight: 700;
}
.k-match { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.k-match-side { display: flex; flex-direction: column; gap: 10px; }
.k-match-item { width: 100%; justify-content: flex-start; }
.k-match-item.is-chosen { box-shadow: inset 0 0 0 4px #4b7bff; }
.k-match-item.is-paired { box-shadow: none; }
.k-pair-0 { background: var(--k-sun); } .k-pair-1 { background: var(--k-sky); } .k-pair-2 { background: var(--k-grass); }
.k-pair-3 { background: var(--k-berry); } .k-pair-4 { background: var(--k-lilac); }
[data-build-host].is-right .k-slot.is-filled, [data-build-host].is-right .k-choice { box-shadow: inset 0 0 0 3px var(--k-live); }
[data-build-host].is-wrong .k-slot.is-filled, [data-build-host].is-wrong .k-choice { box-shadow: inset 0 0 0 3px var(--k-danger); }
[data-build-host].is-right button, [data-build-host].is-wrong button { pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .k-letter:active { transform: none; } }
:root[data-animations="off"] .k-letter:active { transform: none; }
