/* ==========================================================================
   6oal Juniors — kids.css
   Bright, chunky, pre-reader theme. Shared classes used by kidscore.js and
   activities.js. Every interactive class honours --k-c (the element colour).
   ========================================================================== */

/* --------------------------------------------------------------- tokens -- */
:root {
  --k-cream: #fdf7ef;
  --k-cream-2: #fff3e2;
  --k-paper: #fffdfa;
  --k-ink: #2f2748;
  --k-ink-soft: #6f6689;
  --k-line: rgba(47, 39, 72, 0.12);

  --k-red: #ff6b6b;
  --k-orange: #ffa62b;
  --k-green: #4dd4ac;
  --k-blue: #5aa9ff;
  --k-purple: #c86bff;
  --k-yellow: #ffd166;
  --k-pink: #ff8ecb;
  --k-gold: #ffb703;

  /* default element colour — override per element with style="--k-c:#..." */
  --k-c: #5aa9ff;

  --k-r-sm: 16px;
  --k-r: 24px;
  --k-r-lg: 32px;
  --k-tap: 88px;

  --k-shadow: 0 6px 0 rgba(47, 39, 72, 0.13), 0 14px 26px rgba(47, 39, 72, 0.11);
  --k-shadow-lg: 0 10px 0 rgba(47, 39, 72, 0.14), 0 22px 40px rgba(47, 39, 72, 0.14);
  --k-shadow-soft: 0 6px 18px rgba(47, 39, 72, 0.12);

  --k-font: system-ui, -apple-system, "Segoe UI Variable Display", "Segoe UI",
            Roboto, "Helvetica Neue", Arial, "Nunito", sans-serif;

  --k-safe-t: env(safe-area-inset-top, 0px);
  --k-safe-b: env(safe-area-inset-bottom, 0px);
  --k-safe-l: env(safe-area-inset-left, 0px);
  --k-safe-r: env(safe-area-inset-right, 0px);
}

/* ---------------------------------------------------------------- reset -- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--k-font);
  font-weight: 800;
  color: var(--k-ink);
  background-color: var(--k-cream);
  background-image:
    radial-gradient(38vmax 38vmax at 8% -6%, rgba(255, 209, 102, 0.34), transparent 62%),
    radial-gradient(34vmax 34vmax at 100% 8%, rgba(90, 169, 255, 0.28), transparent 60%),
    radial-gradient(40vmax 40vmax at 88% 102%, rgba(200, 107, 255, 0.24), transparent 62%),
    radial-gradient(32vmax 32vmax at -8% 96%, rgba(77, 212, 172, 0.28), transparent 60%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior-y: contain;
}

button, input, select, textarea { font: inherit; color: inherit; }

button {
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

img, svg { display: block; max-width: 100%; }

:focus { outline: none; }
:focus-visible {
  outline: 4px solid rgba(47, 39, 72, 0.55);
  outline-offset: 3px;
}

.k-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}

/* --------------------------------------------------------------- header -- */
#k-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(8px + var(--k-safe-t)) calc(12px + var(--k-safe-r)) 8px calc(12px + var(--k-safe-l));
  background: rgba(255, 253, 250, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 3px solid rgba(47, 39, 72, 0.08);
  position: sticky;
  top: 0;
  z-index: 40;
}

.k-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: 18px;
  min-height: 56px;
  transition: transform 0.12s ease;
}
.k-brand:active { transform: scale(0.95); }

.k-brand-mark svg {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(47, 39, 72, 0.22);
}

.k-brand-name {
  font-size: clamp(17px, 4.4vw, 24px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.k-brand-name em {
  font-style: normal;
  font-size: 0.62em;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--k-ink-soft);
  margin-top: 2px;
}

.k-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.k-total {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: clamp(18px, 4.6vw, 22px);
  font-weight: 900;
  color: #7a4d00;
  background: linear-gradient(180deg, #ffe39a, #ffcf5c);
  box-shadow: 0 4px 0 rgba(200, 138, 0, 0.45), 0 8px 18px rgba(255, 183, 3, 0.32);
}
.k-total-star { font-size: 1.05em; line-height: 1; }
.k-total.is-bump { animation: k-bump 0.55s ease; }

.k-cog {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--k-ink-soft);
  background: var(--k-paper);
  box-shadow: 0 4px 0 rgba(47, 39, 72, 0.14), 0 8px 16px rgba(47, 39, 72, 0.1);
  transition: transform 0.15s ease;
}
.k-cog:active { transform: translateY(3px) rotate(35deg); }

/* ----------------------------------------------------------------- main -- */
#screen {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 10px calc(12px + var(--k-safe-r)) 6px calc(12px + var(--k-safe-l));
  min-height: 0;
}

#k-footer {
  flex: 0 0 auto;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--k-ink-soft);
  opacity: 0.75;
  padding: 8px 12px calc(10px + var(--k-safe-b));
}

.k-foot-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  justify-content: center;
  margin: 0 0 4px;
}

.k-foot-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 2px solid rgba(122, 100, 84, 0.28);
  padding: 2px 0;
}
.k-foot-link:hover,
.k-foot-link:focus-visible { color: var(--k-ink); border-bottom-color: currentColor; }

.k-foot-credit { display: inline-block; }

/* --------------------------------------------------------------- screen -- */
.k-screen {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  min-height: 0;
  /* On short screens the activity content is taller than its flex box, and it
     used to spill out and paint over the footer (rainbow keys ran under the
     credit line on a 360x640 phone). Scroll inside the screen instead. */
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: k-screen-in 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes k-screen-in {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.k-topline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.k-back {
  flex: 0 0 auto;
  width: 60px;
  height: 60px;
  font-size: 30px;
  line-height: 1;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: var(--k-paper);
  box-shadow: var(--k-shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.k-back:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(47, 39, 72, 0.13);
}

.k-title {
  flex: 1 1 auto;
  margin: 0;
  font-size: clamp(22px, 6vw, 40px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--k-ink);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.8);
}
.k-title::first-letter { color: var(--k-c); }

.k-sub {
  margin: 0;
  font-size: clamp(14px, 3.6vw, 18px);
  font-weight: 700;
  color: var(--k-ink-soft);
}

.k-hint {
  margin: 0;
  text-align: center;
  font-size: clamp(14px, 3.8vw, 19px);
  font-weight: 800;
  color: var(--k-ink-soft);
}

/* the container passed to activity.build(root) */
.k-root {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

/* ------------------------------------------------------------ home ring -- */
.k-home {
  justify-content: center;
  justify-content: safe center; /* never hide overflow above the fold */
}

.k-ring {
  position: relative;
  width: min(94vw, 74vh, 760px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  flex: 0 0 auto;
}

.k-ring-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 10px 20px rgba(47, 39, 72, 0.28));
  animation: k-float 5.6s ease-in-out infinite;
  pointer-events: none;
}
.k-ring-logo svg { width: 100%; height: auto; border-radius: 22%; }

.k-bubble {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 30%;
  min-width: 96px;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px;
  border-radius: 50%;
  color: #fff;
  background: radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 46%),
              var(--k-c);
  box-shadow: 0 10px 0 rgba(47, 39, 72, 0.16), 0 18px 34px rgba(47, 39, 72, 0.2),
              inset 0 -10px 22px rgba(0, 0, 0, 0.12);
  animation: k-float 4.4s ease-in-out infinite;
  transition: transform 0.14s ease;
}
.k-bubble:nth-child(2) { animation-delay: 0s; }
.k-bubble:nth-child(3) { animation-delay: 0.5s; }
.k-bubble:nth-child(4) { animation-delay: 1s; }
.k-bubble:nth-child(5) { animation-delay: 1.5s; }
.k-bubble:nth-child(6) { animation-delay: 2s; }
.k-bubble:nth-child(7) { animation-delay: 2.5s; }
.k-bubble:active {
  transform: translate(-50%, -50%) scale(0.92);
  animation-play-state: paused;
}

.k-bubble-emoji {
  font-size: clamp(30px, 8.4vmin, 62px);
  line-height: 1;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.22));
}
.k-bubble-label {
  font-size: clamp(11px, 2.5vmin, 18px);
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  max-width: 94%;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.k-pips {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 14px;
  font-size: clamp(9px, 1.9vmin, 13px);
  line-height: 1;
}
.k-pip { opacity: 0.3; filter: grayscale(1); }
.k-pip.is-on { opacity: 1; filter: none; }
.k-pip-more { font-weight: 900; margin-left: 2px; }

/* narrow phones / small screens — ring becomes a friendly grid */
@media (max-width: 620px), (max-height: 430px) and (orientation: portrait) {
  .k-ring {
    width: 100%;
    aspect-ratio: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    place-items: stretch;
  }
  .k-ring-logo {
    position: static;
    transform: none;
    width: 84px;
    grid-column: 1 / -1;
    justify-self: center;
    margin-bottom: 2px;
  }
  .k-bubble {
    position: static;
    transform: none;
    width: min(100%, 46vw, 21vh);
    min-width: 0;
    aspect-ratio: 1 / 1;
    justify-self: center;
    align-self: center;
  }
  .k-bubble:active { transform: scale(0.94); }
  .k-bubble-emoji { font-size: clamp(34px, 13vw, 62px); }
  .k-bubble-label { font-size: clamp(13px, 4.2vw, 21px); }
  .k-pips { font-size: clamp(10px, 3vw, 14px); }
}

/* phone landscape — ring stays, but tighter */
@media (max-height: 480px) and (orientation: landscape) {
  .k-ring { width: min(94vw, 76vh, 540px); }
  .k-bubble { width: 31%; min-width: 78px; }
  .k-bubble-emoji { font-size: clamp(24px, 8vh, 46px); }
  .k-bubble-label { font-size: clamp(10px, 3.1vh, 15px); }
  .k-ring-logo { width: 23%; }
  #k-header { padding-top: calc(4px + var(--k-safe-t)); padding-bottom: 4px; }
  .k-brand-mark svg { width: 34px; height: 34px; }
  #k-footer { display: none; }
}

/* --------------------------------------------------------- big buttons -- */
.k-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 96px;
  min-height: 96px;
  padding: 12px 16px;
  border-radius: var(--k-r-lg);
  color: #fff;
  font-weight: 900;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 52%),
              var(--k-c);
  box-shadow: 0 7px 0 rgba(47, 39, 72, 0.18), 0 14px 26px rgba(47, 39, 72, 0.16);
  transition: transform 0.11s ease, box-shadow 0.11s ease, filter 0.15s ease;
}
.k-btn:active,
.k-btn.is-down {
  transform: translateY(5px);
  box-shadow: 0 2px 0 rgba(47, 39, 72, 0.18), 0 6px 12px rgba(47, 39, 72, 0.14);
  filter: brightness(1.06);
}
.k-btn[disabled] { opacity: 0.45; }
.k-btn.is-on {
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.9), 0 7px 0 rgba(47, 39, 72, 0.18),
              0 14px 26px rgba(47, 39, 72, 0.16);
}

.k-btn-emoji {
  font-size: clamp(30px, 7.4vmin, 46px);
  line-height: 1;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.2));
}
.k-btn-label {
  font-size: clamp(13px, 3.2vmin, 19px);
  line-height: 1.1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
}

.k-btn--wide { width: 100%; }
.k-btn--round { border-radius: 999px; aspect-ratio: 1 / 1; padding: 8px; }
.k-btn--small {
  min-width: 72px;
  min-height: 72px;
  border-radius: var(--k-r);
  padding: 8px 12px;
}
.k-btn--ghost {
  color: var(--k-ink);
  background: var(--k-paper);
  box-shadow: var(--k-shadow);
}

/* ---------------------------------------------------------- cards/grids -- */
.k-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 44%), 1fr));
}
.k-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.k-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.k-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.k-grid--8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }

.k-cards {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(140px, 45%), 1fr));
}

.k-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: max(var(--k-tap), 108px);
  padding: 12px 8px;
  border-radius: var(--k-r-lg);
  color: #fff;
  text-align: center;
  background: radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 52%),
              var(--k-c);
  box-shadow: 0 7px 0 rgba(47, 39, 72, 0.16), 0 14px 26px rgba(47, 39, 72, 0.15);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.k-card:active {
  transform: translateY(5px) scale(0.98);
  box-shadow: 0 2px 0 rgba(47, 39, 72, 0.16);
}
.k-card.is-active {
  box-shadow: 0 0 0 6px #fff, 0 0 0 11px var(--k-c), 0 12px 26px rgba(47, 39, 72, 0.2);
}
.k-card.is-done { filter: saturate(0.65) brightness(1.05); }
.k-card-emoji {
  font-size: clamp(34px, 9vmin, 60px);
  line-height: 1;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.22));
}
.k-card-label {
  font-size: clamp(13px, 3vmin, 19px);
  font-weight: 900;
  line-height: 1.1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.24);
}

.k-panelcard {
  background: var(--k-paper);
  border-radius: var(--k-r-lg);
  box-shadow: var(--k-shadow-soft);
  padding: 14px;
}

/* --------------------------------------------------------------- pads --- */
.k-pads {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  flex: 1 1 auto;
  min-height: 0;
}
.k-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: max(var(--k-tap), 96px);
  border-radius: var(--k-r-lg);
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 55%),
              var(--k-c);
  box-shadow: 0 8px 0 rgba(47, 39, 72, 0.18), 0 16px 28px rgba(47, 39, 72, 0.16);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
}
.k-pad-emoji { font-size: clamp(30px, 8vmin, 52px); line-height: 1; }
.k-pad-label { font-size: clamp(12px, 2.8vmin, 17px); font-weight: 900; }
.k-pad:active,
.k-pad.is-hit {
  transform: translateY(6px) scale(0.97);
  box-shadow: 0 2px 0 rgba(47, 39, 72, 0.18);
  filter: brightness(1.25);
}

/* --------------------------------------------------------------- keys --- */
.k-keys {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  flex: 1 1 auto;
  min-height: 132px;
  align-items: stretch;
}
.k-key {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 2px 14px;
  min-height: max(var(--k-tap), 120px);
  border-radius: 18px 18px 26px 26px;
  color: rgba(255, 255, 255, 0.96);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 46%),
              var(--k-c);
  box-shadow: 0 8px 0 rgba(47, 39, 72, 0.2), 0 16px 26px rgba(47, 39, 72, 0.16);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.1s ease;
}
.k-key-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.15);
}
.k-key-label {
  font-size: clamp(13px, 3vmin, 20px);
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}
.k-key:active,
.k-key.is-down {
  transform: translateY(7px);
  box-shadow: 0 1px 0 rgba(47, 39, 72, 0.2);
  filter: brightness(1.2);
}
.k-key.is-glow {
  animation: k-glow 1.05s ease-in-out infinite;
  z-index: 2;
}
.k-key.is-done { filter: saturate(0.6); }

/* --------------------------------------------------- step sequencer grid -- */
.k-seq {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
}
.k-seq-row {
  display: grid;
  grid-template-columns: minmax(58px, 74px) repeat(8, minmax(0, 1fr));
  gap: 6px;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
}
.k-seq-label {
  display: grid;
  place-items: center;
  font-size: clamp(26px, 6vmin, 40px);
  border-radius: var(--k-r);
  background: var(--k-paper);
  box-shadow: var(--k-shadow-soft);
}
.k-step {
  position: relative;
  display: grid;
  place-items: center;
  min-height: max(56px, 9vmin);
  font-size: clamp(20px, 5vmin, 34px);
  border-radius: 18px;
  color: rgba(255, 255, 255, 0);
  background: rgba(47, 39, 72, 0.08);
  box-shadow: inset 0 3px 8px rgba(47, 39, 72, 0.08);
  transition: transform 0.1s ease, background 0.14s ease, box-shadow 0.14s ease;
}
.k-step.is-on {
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 55%),
              var(--k-c);
  box-shadow: 0 5px 0 rgba(47, 39, 72, 0.18), 0 10px 20px rgba(47, 39, 72, 0.15);
}
.k-step:active { transform: scale(0.93); }
.k-step.is-play { outline: 5px solid var(--k-gold); outline-offset: -2px; }
.k-step.is-play.is-on { animation: k-pop 0.24s ease; }

.k-playhead {
  display: grid;
  grid-template-columns: minmax(58px, 74px) repeat(8, minmax(0, 1fr));
  gap: 6px;
  flex: 0 0 auto;
}
.k-playhead span {
  height: 12px;
  border-radius: 999px;
  background: rgba(47, 39, 72, 0.1);
}
.k-playhead span.is-play { background: var(--k-gold); box-shadow: 0 0 12px rgba(255, 183, 3, 0.8); }

/* ---------------------------------------------------- glowing shapes ----- */
.k-shapes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3vw, 24px);
  flex: 1 1 auto;
}
.k-shape {
  width: clamp(96px, 26vmin, 190px);
  height: clamp(96px, 26vmin, 190px);
  display: grid;
  place-items: center;
  font-size: clamp(38px, 11vmin, 76px);
  border-radius: 50%;
  color: #fff;
  background: radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 50%),
              var(--k-c);
  box-shadow: 0 9px 0 rgba(47, 39, 72, 0.18), 0 18px 30px rgba(47, 39, 72, 0.18);
  filter: saturate(0.78) brightness(0.94);
  transition: transform 0.12s ease, filter 0.16s ease, box-shadow 0.16s ease;
}
.k-shape--square { border-radius: 30px; }
.k-shape--squish { border-radius: 44% 56% 52% 48% / 50% 46% 54% 50%; }
.k-shape:active { transform: translateY(6px) scale(0.95); }
.k-shape.is-lit {
  filter: saturate(1.35) brightness(1.15);
  transform: scale(1.07);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.85), 0 0 34px 8px var(--k-c),
              0 12px 26px rgba(47, 39, 72, 0.2);
}

/* ------------------------------------------------------------- toolbar --- */
.k-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 0 0 auto;
}

.k-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.k-col { display: flex; flex-direction: column; gap: 10px; }
.k-center { display: flex; align-items: center; justify-content: center; }
.k-spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.k-fill { flex: 1 1 auto; min-height: 0; }

.k-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: clamp(14px, 3.4vmin, 19px);
  font-weight: 900;
  color: var(--k-ink);
  background: var(--k-paper);
  box-shadow: var(--k-shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.k-chip:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(47, 39, 72, 0.13); }
.k-chip.is-on {
  color: #fff;
  background: var(--k-c);
}

.k-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 900;
  color: #7a4d00;
  background: linear-gradient(180deg, #ffe39a, #ffcf5c);
  box-shadow: 0 3px 0 rgba(200, 138, 0, 0.4);
}

/* --------------------------------------------------------- star display -- */
.k-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: clamp(20px, 5vmin, 32px);
  line-height: 1;
}
.k-star { opacity: 0.28; filter: grayscale(1); transition: opacity 0.2s ease, transform 0.2s ease; }
.k-star.is-on { opacity: 1; filter: none; animation: k-pop 0.4s ease; }

/* ------------------------------------------------------------- overlays -- */
.k-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--k-safe-t)) 16px calc(16px + var(--k-safe-b));
  background: rgba(47, 39, 72, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: k-fade-in 0.2s ease both;
  overflow-y: auto;
}

.k-sheet {
  width: min(520px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: var(--k-paper);
  border-radius: var(--k-r-lg);
  box-shadow: var(--k-shadow-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: k-rise 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.k-sheet h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.k-sheet p {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--k-ink-soft);
  line-height: 1.45;
}

.k-sheet-close {
  align-self: center;
  min-height: 56px;
  padding: 0 26px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  background: var(--k-ink);
  box-shadow: 0 4px 0 rgba(47, 39, 72, 0.35);
}
.k-sheet-close:active { transform: translateY(3px); box-shadow: none; }

.k-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 8px 12px;
  border-radius: var(--k-r);
  background: var(--k-cream);
}
.k-setting-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 900;
}

.k-toggle {
  flex: 0 0 auto;
  width: 84px;
  height: 48px;
  border-radius: 999px;
  background: rgba(47, 39, 72, 0.18);
  position: relative;
  transition: background 0.2s ease;
}
.k-toggle::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(47, 39, 72, 0.3);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.k-toggle.is-on { background: var(--k-green); }
.k-toggle.is-on::after { transform: translateX(36px); }

.k-danger {
  min-height: 60px;
  border-radius: var(--k-r);
  font-size: 17px;
  font-weight: 900;
  color: #8a2b2b;
  background: #ffe3e3;
  box-shadow: 0 4px 0 rgba(138, 43, 43, 0.18);
}
.k-danger:active { transform: translateY(3px); box-shadow: none; }
.k-danger.is-armed { color: #fff; background: var(--k-red); }

.k-links { display: flex; gap: 10px; flex-wrap: wrap; }
.k-link {
  flex: 1 1 150px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 60px;
  padding: 0 16px;
  border-radius: var(--k-r);
  font-size: 16px;
  font-weight: 900;
  text-decoration: none;
  color: var(--k-ink);
  background: var(--k-cream);
  box-shadow: 0 4px 0 rgba(47, 39, 72, 0.12);
}
.k-link:active { transform: translateY(3px); box-shadow: none; }

/* ----------------------------------------------------------- parent gate -- */
.k-gate {
  width: min(420px, 100%);
  text-align: center;
  background: var(--k-paper);
  border-radius: var(--k-r-lg);
  box-shadow: var(--k-shadow-lg);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: k-rise 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.k-gate h2 { margin: 0; font-size: 22px; font-weight: 900; }
.k-gate p { margin: 0; font-size: 15px; font-weight: 700; color: var(--k-ink-soft); }

.k-gate-btn {
  position: relative;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--k-cream);
  box-shadow: inset 0 4px 12px rgba(47, 39, 72, 0.12);
}
.k-gate-btn .k-gate-emoji {
  font-size: 56px;
  line-height: 1;
  pointer-events: none;
  transition: transform 0.2s ease;
}
.k-gate-btn.is-holding .k-gate-emoji { transform: scale(1.12); }

.k-gate-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}
.k-gate-ring circle { fill: none; stroke-linecap: round; }
.k-gate-ring .k-gate-track { stroke: rgba(47, 39, 72, 0.12); stroke-width: 12; }
.k-gate-ring .k-gate-fill { stroke: var(--k-green); stroke-width: 12; transition: stroke-dashoffset 0.08s linear; }

/* --------------------------------------------------------------- confetti */
#k-confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 200;
}

/* ------------------------------------------------------------ animations -- */
@keyframes k-float {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -12px; }
}
@keyframes k-spin  { to { rotate: 360deg; } }
@keyframes k-pop   { 0% { scale: 1; } 45% { scale: 1.16; } 100% { scale: 1; } }
@keyframes k-bump  { 0% { scale: 1; } 35% { scale: 1.22; } 100% { scale: 1; } }
@keyframes k-wiggle {
  0%, 100% { rotate: 0deg; }
  20% { rotate: -9deg; }
  40% { rotate: 8deg; }
  60% { rotate: -6deg; }
  80% { rotate: 4deg; }
}
@keyframes k-glow {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.85), 0 0 16px 4px var(--k-c), 0 8px 0 rgba(47, 39, 72, 0.2); scale: 1; }
  50%      { box-shadow: 0 0 0 9px rgba(255, 255, 255, 0.95), 0 0 42px 12px var(--k-c), 0 8px 0 rgba(47, 39, 72, 0.2); scale: 1.05; }
}
@keyframes k-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes k-rise { from { opacity: 0; transform: translateY(22px) scale(0.97); } to { opacity: 1; transform: none; } }

/* utility animation classes activities can toggle */
.k-wiggle { animation: k-wiggle 0.55s ease; }
.k-pop    { animation: k-pop 0.34s ease; }
.k-float  { animation: k-float 4s ease-in-out infinite; }
.k-pulse  { animation: k-glow 1.05s ease-in-out infinite; }
.k-spin   { animation: k-spin 6s linear infinite; }

/* --------------------------------------------------------- big screens --- */
@media (min-width: 900px) {
  :root { --k-tap: 100px; }
  #screen { padding: 18px 24px 10px; }
  .k-screen { gap: 16px; }
}

/* iPad-ish: keep the ring big and centred */
@media (min-width: 700px) and (min-height: 800px) {
  .k-ring { width: min(88vw, 68vh, 720px); }
}

/* ------------------------------------------------- reduced motion ------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .k-screen { animation: none; }
  .k-ring-logo, .k-bubble, .k-float, .k-spin, .k-pulse { animation: none !important; }
  .k-key.is-glow {
    box-shadow: 0 0 0 8px #fff, 0 0 0 14px var(--k-c), 0 8px 0 rgba(47, 39, 72, 0.2);
  }
  .k-shape.is-lit { transform: none; }
}

/* --------------------------------------------------- print (harmless) --- */
@media print {
  #k-header, #k-footer, #k-confetti { display: none; }
}

/* Kid Lock indicator — shows a child (and a grown-up) that leaving is gated. */
.k-lock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 17px;
  background: rgba(255, 214, 102, 0.35);
  border: 2px solid rgba(122, 100, 84, 0.22);
}
.k-lock-badge[hidden] { display: none; }
.k-note {
  margin: -2px 0 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--k-ink-soft);
}

/* ---------------------------------------------------------- grown-up PIN -- */
.k-pin .k-pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 4px 0 14px;
}
.k-pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(47, 39, 72, 0.14);
  transition: transform 0.12s ease, background-color 0.12s ease;
}
.k-pin-dot.is-on { background: var(--k-gold); transform: scale(1.15); }

.k-pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(300px, 78vw);
  margin: 0 auto 6px;
}
.k-pin-key {
  min-height: 62px;
  border-radius: 18px;
  font-size: 26px;
  font-weight: 900;
  color: var(--k-ink);
  background: var(--k-paper);
  box-shadow: 0 5px 0 rgba(47, 39, 72, 0.14), 0 10px 18px rgba(47, 39, 72, 0.1);
}
.k-pin-key:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(47, 39, 72, 0.14); }
.k-pin-key.is-alt { background: #f0e6d8; }
.k-pin-key.is-ok { background: linear-gradient(180deg, #7fe3c2, #4dd4ac); color: #0f3b30; }

.k-gate.is-wrong { animation: k-shake 0.4s ease; }
@keyframes k-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.k-pinbox {
  border: 3px solid var(--k-line);
  border-radius: var(--k-r);
  padding: 12px 14px;
  margin: 4px 0 10px;
}
.k-pinrow { display: flex; flex-wrap: wrap; gap: 8px; }
.k-pinbtn {
  flex: 1 1 auto;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 800;
  color: #0f3b30;
  background: linear-gradient(180deg, #7fe3c2, #4dd4ac);
  box-shadow: 0 4px 0 rgba(24, 106, 86, 0.4);
}
.k-pinbtn.is-alt {
  color: var(--k-ink);
  background: #f0e6d8;
  box-shadow: 0 4px 0 rgba(47, 39, 72, 0.16);
}
.k-pinbtn:active { transform: translateY(3px); box-shadow: none; }

.k-credit {
  margin: 10px 0 4px;
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
  color: var(--k-ink-soft);
}
.k-credit a { color: inherit; font-weight: 800; }
