/* Activity-specific styles. Sizes use container units (cq*) so content
   scales with the space it actually has on phones, tablets and laptops. */

.pic {
  object-fit: contain;
}

.glyph {
  line-height: 1;
  font-weight: 700;
}

/* ---------- Letters ---------- */
.letter-card {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  gap: 4cqmin;
}

.letter-glyphs {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.12em;
  min-width: max(44px, 0.9em);
  font-size: 30vmin;
  font-size: min(32cqw, 60cqh);
  color: var(--brand-2);
  text-shadow: 0 0.04em 0 rgba(0, 0, 0, 0.08);
}

.glyph.lower {
  color: var(--brand);
  font-size: 0.82em;
}

.letter-picture {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2cqmin;
}

.card-pic {
  width: 30vmin;
  width: min(36cqw, 58cqh);
  aspect-ratio: 1;
}

.word-text {
  font-size: min(7.5cqw, 10cqh);
  white-space: nowrap;
}

/* APPLE + "Apple · apple": the big word plus smaller title/lower case forms. */
.word-forms {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15em;
  min-width: 0;
  max-width: 100%;
}

.word-forms .card-title,
.word-forms .word-text {
  letter-spacing: 0.04em;
}

.word-variants {
  max-width: 100%;
  font-size: min(4cqw, 5cqh);
  color: var(--ink-soft);
  text-align: center;
  overflow-wrap: anywhere;
}

@container (aspect-ratio < 1.15) {
  .letter-card {
    flex-direction: column;
    gap: 2cqmin;
  }

  .letter-glyphs {
    font-size: min(46cqw, 30cqh);
  }

  .card-pic {
    width: min(54cqw, 30cqh);
  }

  .word-text {
    font-size: min(11cqw, 7cqh);
  }
}

/* ---------- Simple cards (shapes, colors, animals, words, calendar) ---------- */
.simple-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.4cqmin;
  text-align: center;
}

.big-art {
  width: 40vmin;
  width: min(62cqw, 52cqh);
  aspect-ratio: 1;
}

.mid-art {
  width: min(46cqw, 38cqh);
}

.card-title {
  font-size: min(10cqw, 11cqh);
  line-height: 1.1;
}

.card-title.huge {
  font-size: min(14cqw, 20cqh);
}

.card-fact {
  max-width: 30ch;
  font-size: min(5cqw, 5.6cqh);
  color: var(--ink-soft);
}

.sound-word {
  font-size: min(7cqw, 8cqh);
  color: var(--brand);
}

@container (aspect-ratio > 1.5) {
  .simple-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 1fr auto auto 1fr;
    column-gap: 5cqw;
    text-align: start;
    justify-content: center;
  }

  .simple-card > .big-art,
  .simple-card > .mid-art,
  .simple-card > .color-blob {
    grid-row: 1 / -1;
    width: min(42cqw, 82cqh);
  }

  .simple-card > .card-title,
  .simple-card > .word-forms {
    grid-row: 2;
  }

  .simple-card > .card-title,
  .simple-card > .word-forms .card-title {
    font-size: min(8cqw, 18cqh);
  }

  .simple-card > .word-forms {
    align-items: flex-start;
  }

  .simple-card > .card-fact,
  .simple-card > .example-row {
    grid-row: 3;
  }

  .simple-card > .card-fact {
    font-size: min(3.6cqw, 7.5cqh);
  }

  .simple-card > .today-badge,
  .simple-card > .week-dots {
    grid-row: 1;
    align-self: end;
  }
}

.shape-art svg {
  overflow: visible;
}

.example-row {
  display: flex;
  justify-content: center;
  gap: 3cqmin;
}

.example {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 44px;
  font-size: min(4cqw, 4.5cqh);
}

.example-pic {
  width: max(40px, min(16cqw, 15cqh));
  aspect-ratio: 1;
}

.today-badge {
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--good);
  color: #fff;
  font-size: min(3cqw, 3.6cqh);
}

.week-dots {
  display: flex;
  gap: 1.6cqmin;
}

.week-dots span {
  width: min(9cqw, 10cqh);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ece6f6;
  font-size: min(4cqw, 5cqh);
}

.week-dots span.on {
  background: var(--brand);
  color: #fff;
}

.calendar-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

/* Calendar: explorer on top, small "Today: ..." line at the bottom. */
.calendar-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 4px;
}

.today-line {
  justify-self: center;
  margin: 0;
  padding: 2px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  font-size: clamp(0.8rem, 1.8vmin, 1rem);
}

/* ---------- Numbers ---------- */
.number-card {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  align-items: center;
  gap: 3cqmin;
}

.number-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1cqmin;
}

.numeral {
  font-size: min(24cqw, 48cqh);
  color: var(--brand-2);
}

.latin-numeral {
  font-family: "Andika", system-ui, sans-serif;
  font-size: min(5cqw, 8cqh);
  color: var(--ink-soft);
}

.number-word {
  font-size: min(6cqw, 10cqh);
}

.number-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2cqmin;
}

.hint {
  font-size: min(3.2cqw, 5cqh);
  color: var(--ink-soft);
  text-align: center;
}

.count-bubble {
  position: absolute;
  top: -2cqmin;
  inset-inline-end: 0;
  min-width: 1.6em;
  padding: 0 0.3em;
  border-radius: 999px;
  background: var(--sun);
  font-size: min(6cqw, 9cqh);
  text-align: center;
}

.count-bubble:empty {
  display: none;
}

.ten-frames {
  --cell: min(9cqw, 22cqh);
  display: flex;
  flex-direction: column;
  gap: calc(var(--cell) * 0.25);
}

.ten-frames.frames-2 {
  --cell: min(9cqw, 8.5cqh);
}

.ten-frame {
  display: grid;
  grid-template-columns: repeat(5, var(--cell));
  grid-auto-rows: var(--cell);
  gap: calc(var(--cell) * 0.1);
  padding: calc(var(--cell) * 0.12);
  border-radius: calc(var(--cell) * 0.25);
  background: #fff;
  border: 3px solid #d9d0ec;
}

.frame-cell {
  display: grid;
  place-items: center;
  border-radius: 22%;
  background: #f5f1fc;
  transition: transform 0.15s ease, background 0.15s ease;
}

.frame-cell.empty {
  background: transparent;
  outline: 2px dashed #e4dcf3;
  outline-offset: -4px;
}

.frame-pic {
  width: 88%;
  height: 88%;
}

/* 11-20: number on top, both ten-frames side by side across the full width. */
.number-card.many {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1.5cqmin;
}

.number-card.many .number-head {
  flex-direction: row;
  justify-content: center;
  gap: 4cqw;
}

.number-card.many .numeral {
  font-size: min(16cqw, 22cqh);
}

.number-card.many .ten-frames {
  --cell: min(7.4cqw, 19cqh);
  flex-direction: row;
}

.frame-cell:not(.empty) {
  position: relative;
  cursor: pointer;
}

/* Hover/focus lifts the object you are about to count. */
@media (hover: hover) {
  .frame-cell:not(.empty):not(.counted):hover {
    transform: translateY(-6%) scale(1.08);
    background: #fff4c2;
    box-shadow: 0 0 0 3px var(--sun), 0 6px 12px rgba(43, 35, 64, 0.18);
    z-index: 1;
  }
}

.frame-cell:not(.empty):focus-visible {
  box-shadow: 0 0 0 3px var(--brand);
}

.frame-cell.counted {
  background: #c9f2dc;
  transform: scale(0.9);
}

/* Count number badge on each counted object. */
.frame-cell.counted::after {
  content: attr(data-count);
  position: absolute;
  top: -10%;
  inset-inline-end: -10%;
  min-width: 1.5em;
  padding: 0 0.25em;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: calc(var(--cell) * 0.3);
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: count-pop 0.25s ease-out;
}

@keyframes count-pop {
  from { transform: scale(0.3); }
  to { transform: scale(1); }
}

@container (aspect-ratio < 1.15) {
  .number-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .number-head {
    flex-direction: row;
    justify-content: center;
    gap: 4cqw;
  }

  .numeral {
    font-size: min(30cqw, 24cqh);
  }

  .number-word {
    font-size: min(9cqw, 7cqh);
  }

  .ten-frames {
    --cell: min(15cqw, 10cqh);
  }

  .ten-frames.frames-2 {
    --cell: min(15cqw, 6.6cqh);
  }

  .hint {
    font-size: min(4.6cqw, 3.4cqh);
  }

  /* Tall screens: stack the two frames, shrink the numeral, grow the objects. */
  .number-card.many .numeral {
    font-size: min(24cqw, 15cqh);
  }

  .number-card.many .ten-frames {
    --cell: min(16cqw, 9cqh);
    flex-direction: column;
  }
}

/* ---------- Trace ---------- */
.trace-card {
  padding: 0;
  cursor: default;
}

.trace-board {
  position: absolute;
  inset: 0 0 44px;
}

.trace-board canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.trace-paint {
  touch-action: none;
  cursor: crosshair;
}

.trace-overlay {
  pointer-events: none;
}

.trace-progress {
  position: absolute;
  inset: auto 16px 10px;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-fill {
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--good) calc(var(--p, 0) * 100%), #ece6f6 0);
}

[dir="rtl"] .progress-fill {
  background: linear-gradient(270deg, var(--good) calc(var(--p, 0) * 100%), #ece6f6 0);
}

.trace-progress .star {
  width: 30px;
  height: 30px;
}

.trace-progress.full .star {
  animation: pulse 0.8s ease-in-out 3;
}

/* ---------- Pop ---------- */
.pop {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 6px;
}

.pop-bar {
  display: flex;
  align-items: center;
  gap: var(--gap);
}

.pop-target {
  min-width: calc(var(--touch) * 1.2);
  height: calc(var(--touch) * 1.1);
  padding: 0 14px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-size: calc(var(--touch) * 0.8);
}

.pop-target .bubble-shape {
  width: calc(var(--touch) * 0.8);
  height: calc(var(--touch) * 0.8);
}

.pop-swatch {
  width: calc(var(--touch) * 0.75);
  height: calc(var(--touch) * 0.75);
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.18);
}

.pop-score {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 999px;
  background: #fff;
  font-size: clamp(1.2rem, 3vmin, 1.6rem);
  box-shadow: var(--shadow-sm);
}

.pop-field {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(rgba(215, 241, 255, 0.55), rgba(255, 255, 255, 0.35));
  container-type: size;
}

.bubble {
  position: absolute;
  top: 100%;
  left: var(--x);
  width: clamp(70px, 19cqmin, 140px);
  aspect-ratio: 1;
  transform: translate(-50%, 0);
}

[dir="rtl"] .bubble {
  left: auto;
  right: var(--x);
  transform: translate(50%, 0);
}

.bubble.floating {
  animation: float-up var(--dur) linear var(--delay) 1 forwards;
}

/* Balloon string: a wavy line under the knot that sways gently. */
.bubble::after {
  content: "";
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  width: 16px;
  height: 75%;
  margin-left: -8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 100' preserveAspectRatio='none'%3E%3Cpath d='M8 0 C 2 16, 14 30, 8 46 S 2 76, 8 100' fill='none' stroke='%237a6f8f' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  transform-origin: top center;
  animation: string-sway 1.8s ease-in-out infinite alternate;
  pointer-events: none;
}

.bubble.popped::after {
  animation: string-drop 0.6s ease-in forwards;
}

@keyframes string-sway {
  from { transform: rotate(-7deg); }
  to { transform: rotate(7deg); }
}

@keyframes string-drop {
  to { transform: translateY(40%) rotate(20deg); opacity: 0; }
}

[dir="rtl"] .bubble.floating {
  animation-name: float-up-rtl;
}

.skin {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 50% 50% 47% 47% / 54% 54% 46% 46%;
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.95) 0 10%, transparent 11%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.55), var(--tint) 92%);
  border: 3px solid rgba(255, 255, 255, 0.8);
  box-shadow: inset 0 -6px 14px rgba(0, 0, 0, 0.08), 0 6px 16px rgba(43, 35, 64, 0.15);
  font-size: clamp(36px, 10cqmin, 76px);
  color: var(--ink);
}

/* Balloon knot. */
.skin::after {
  content: "";
  position: absolute;
  top: calc(100% - 2px);
  left: 50%;
  width: 14px;
  height: 10px;
  margin-left: -7px;
  background: var(--tint);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  filter: brightness(0.85);
}

.color-bubble .skin {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.9) 0 10%, transparent 11%),
    var(--tint);
}

.bubble-shape {
  width: 60%;
  height: 60%;
}

.bubble.popped .skin {
  animation: burst 0.35s ease-out forwards;
}

.bubble.wobble .skin {
  animation: wobble 0.45s ease;
}

@keyframes float-up {
  to { transform: translate(-50%, calc(-100cqh - 200%)); }
}

@keyframes float-up-rtl {
  to { transform: translate(50%, calc(-100cqh - 200%)); }
}

@keyframes burst {
  60% { transform: scale(1.35); opacity: 0.6; }
  to { transform: scale(1.6); opacity: 0; }
}

/* ---------- Memory ---------- */
.memory {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
}

.memory-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
}

.memory-options .tabs {
  max-width: 100%;
}

.memory-board {
  min-height: 0;
  display: grid;
  place-items: center;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), var(--size, 100px));
  gap: 10px;
}

.memory-card {
  position: relative;
  width: var(--size, 100px);
  height: var(--size, 100px);
  perspective: 800px;
}

.memory-card .face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 18%;
  backface-visibility: hidden;
  transition: transform 0.4s ease;
  box-shadow: var(--shadow-sm);
}

.memory-card .back {
  background: repeating-linear-gradient(45deg, #8f6ee0 0 12px, #7b58d6 12px 24px);
  border: 4px solid #fff;
}

.back-pic {
  width: 46%;
  opacity: 0.9;
}

.memory-card .front {
  background: #fff;
  transform: rotateY(180deg);
}

.memory-card .front .pic {
  width: 74%;
  height: 74%;
}

.memory-card.flipped .back {
  transform: rotateY(180deg);
}

.memory-card.flipped .front {
  transform: rotateY(360deg);
}

.memory-card.matched .front {
  background: #d8f5e4;
  box-shadow: 0 0 0 4px var(--good);
}

/* ---------- Quiz / tests ---------- */
.quiz {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
}

.quiz-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
}

/* Previous best score in this test (per child). */
.quiz-best,
.result-best {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 14px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-size: clamp(0.95rem, 2.4vmin, 1.2rem);
}

.result-best {
  margin: 0;
}

.result-best.new {
  background: var(--sun);
  font-weight: 800;
  animation: boing 0.6s ease 0.3s;
}

.quiz-best .star,
.result-best .star {
  width: 1.2em;
  height: 1.2em;
}

.test-best {
  font-size: clamp(0.85rem, 2vmin, 1.05rem);
  color: var(--ink-soft);
}

.quiz-top .pop-score {
  margin-inline-start: 0;
}

.progress-dots {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--card);
}

.progress-dots span {
  width: clamp(12px, 2.2vmin, 18px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ddd5ec;
}

.progress-dots .done {
  background: var(--good);
}

.progress-dots .now {
  background: var(--brand);
  transform: scale(1.3);
}

.question {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.6vmin, 16px);
}

.question > * {
  flex: none;
  min-width: 0;
}

.question > .q-options {
  flex: 1 1 0;
}

.q-prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
}

.q-text {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-size: clamp(1.1rem, 3.2vmin, 2rem);
  text-align: center;
}

.q-visual {
  display: grid;
  place-items: center;
  max-height: 38cqh;
  min-height: 0;
}

.q-visual .ten-frames {
  --cell: min(8cqw, 12cqh);
}

@media (orientation: portrait) {
  .q-visual .ten-frames {
    --cell: min(15cqw, 10cqh);
  }
}

.q-visual-pic {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  border-radius: var(--radius);
  background: var(--card);
  font-size: min(5cqw, 6cqh);
}

.q-visual-pic .q-pic {
  width: min(22cqw, 24cqh);
}

.pattern-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1.4cqmin;
  padding: 1.6cqmin 2.4cqmin;
  border-radius: var(--radius);
  background: var(--card);
}

.pattern-pic {
  width: min(9.5cqw, 13cqh);
  aspect-ratio: 1;
}

.pattern-slot {
  width: min(9.5cqw, 13cqh);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 20%;
  border: 4px dashed var(--brand);
  color: var(--brand);
  font-size: min(6cqw, 8cqh);
}

.q-options {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

.q-options.count-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.q-options.count-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.q-option {
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow), inset 0 -8px 0 rgba(43, 35, 64, 0.07);
  border: 4px solid transparent;
  container-type: size;
  transition: transform 0.12s ease;
}

.q-option:active {
  transform: scale(0.96);
}

.q-option .glyph {
  font-size: 62cqmin;
}

.q-option .q-pic,
.q-option .q-shape,
.q-option .q-blob {
  width: 72cqmin;
  height: 72cqmin;
}

.q-option.correct {
  border-color: var(--good);
  background: #dcf7e8;
  animation: pulse 0.5s ease 2;
}

.q-option.reveal {
  border-color: var(--good);
  border-style: dashed;
}

.q-option.wrong {
  border-color: var(--bad);
  background: #ffe3e8;
}

.compare-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 2cqmin;
  padding: 4cqmin;
}

.compare-pic {
  width: 20cqmin;
  height: 20cqmin;
}

@media (orientation: portrait) {
  .q-options.count-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.result-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.4vmin, 22px);
  text-align: center;
}

.result-card .stars-row {
  font-size: clamp(3rem, 14vmin, 8rem);
}

.result-score {
  font-size: clamp(2.6rem, 10vmin, 6rem);
  color: var(--brand);
}

.result-line {
  font-size: clamp(1.1rem, 3vmin, 1.6rem);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
}

/* ---------- Coloring ---------- */
.coloring {
  height: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "pages art tools";
  gap: var(--gap);
}

.coloring-pages {
  grid-area: pages;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  scrollbar-width: none;
}

.page-thumb {
  flex: none;
  width: clamp(52px, 9vmin, 76px);
  aspect-ratio: 1;
  padding: 8px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.page-thumb.active {
  background: var(--brand);
}

.coloring-art {
  grid-area: art;
  min-height: 0;
  display: grid;
  place-items: center;
}

.coloring-art svg {
  height: 100%;
  width: auto;
  max-width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.coloring-art .r {
  fill: #fff;
  stroke: #2b2340;
  stroke-width: 2.5;
  stroke-linejoin: round;
  cursor: pointer;
  transition: fill 0.15s ease;
}

.coloring-art .l {
  fill: none;
  stroke: #2b2340;
  stroke-width: 2.5;
  stroke-linecap: round;
  pointer-events: none;
}

.coloring-tools {
  grid-area: tools;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
  min-height: 0;
}

.palette {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 8px;
}

.swatch {
  width: clamp(44px, 7.6vmin, 64px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--swatch);
  border: 4px solid #fff;
  box-shadow: var(--shadow-sm);
}

.swatch.active {
  outline: 4px solid var(--ink);
  transform: scale(1.1);
}

.coloring-actions {
  display: flex;
  gap: 8px;
}

@media (orientation: portrait) {
  .coloring {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "pages" "art" "tools";
  }

  .coloring-pages {
    flex-direction: row;
    justify-content: center;
  }

  .coloring-art svg {
    width: 100%;
    height: auto;
    max-height: 100%;
  }

  .coloring-tools {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
  }

  .palette {
    grid-template-columns: repeat(6, auto);
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .palette {
    grid-template-columns: repeat(3, auto);
  }
}

@media print {
  body::before,
  .topbar,
  .coloring-pages,
  .coloring-tools,
  #overlay-root,
  #fx-layer {
    display: none !important;
  }

  html,
  body,
  .app,
  .stage {
    height: auto;
    overflow: visible;
  }

  .coloring {
    display: block;
  }

  .coloring-art svg {
    width: 100%;
    height: auto;
    box-shadow: none;
  }
}

/* ---------- Letters: big centre theme picker ---------- */
.theme-picker {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5cqmin;
  overflow-y: auto;
  padding: 1cqmin;
}

.theme-picker-title {
  margin: 0;
  padding: 4px 20px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-size: clamp(1.2rem, 4.5cqmin, 2.2rem);
}

.theme-grid {
  --size: clamp(104px, min(21cqw, 30cqh), 210px);
  display: grid;
  grid-template-columns: repeat(auto-fit, var(--size));
  justify-content: center;
  gap: clamp(10px, 2.4cqmin, 22px);
  width: 100%;
}

.theme-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: var(--size);
  aspect-ratio: 1;
  padding: 8px;
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  border: 4px solid transparent;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.theme-choice.active {
  border-color: var(--brand);
}

.theme-pic {
  width: 58%;
  height: 58%;
}

.theme-label {
  max-width: 100%;
  font-size: calc(var(--size) * 0.13);
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}

/* Small "current theme" button above the letter cards; tap to pick again. */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: center;
  min-height: 48px;
  padding: 4px 14px 4px 8px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-size: clamp(1rem, 2.6vmin, 1.3rem);
}

.theme-switch-pic {
  width: 36px;
  height: 36px;
}

.theme-switch-icon {
  width: 1em;
  height: 1em;
  color: var(--brand);
}

[dir="rtl"] .theme-switch-icon {
  transform: scaleX(-1);
}

/* Picture-only prompt (first-sound test). */
.q-visual-pic.solo {
  padding: 10px;
}

.q-visual-pic.solo .q-pic {
  width: min(30cqw, 28cqh);
}

/* Listening questions: big ear with pulsing sound waves. */
.q-listen {
  position: relative;
  display: grid;
  place-items: center;
  width: min(26cqw, 24cqh);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.q-listen-pic {
  width: 62%;
  height: 62%;
  animation: bob 2.4s ease-in-out infinite;
}

.q-wave {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid var(--brand);
  opacity: 0;
  animation: wave-out 2s ease-out infinite;
  pointer-events: none;
}

.q-wave.w2 {
  animation-delay: 1s;
}

@keyframes wave-out {
  from { transform: scale(0.8); opacity: 0.55; }
  to { transform: scale(1.35); opacity: 0; }
}

/* ---------- Drag & Match ---------- */
.match {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 2cqmin;
}

.match-places,
.match-tray {
  --piece: clamp(64px, min(19cqw, 24cqh), 170px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3cqmin, 30px);
}

.match-tray {
  padding: 1.5cqmin;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  min-height: calc(var(--piece) + 3cqmin);
}

.match-place,
.match-piece {
  display: grid;
  place-items: center;
  width: var(--piece);
  height: var(--piece);
  border-radius: 24px;
}

.match-place {
  background: rgba(255, 255, 255, 0.7);
  border: 4px dashed #cfc4e6;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.match-place.filled {
  border-style: solid;
  border-color: var(--good);
  background: #e5f8ec;
}

.match-piece {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow-sm);
  touch-action: none;
  cursor: grab;
}

.match-piece.dragging {
  z-index: 20;
  cursor: grabbing;
  box-shadow: 0 16px 30px rgba(43, 35, 64, 0.28);
  transition: none;
}

.match-piece:not(.dragging) {
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.3, 1.3);
}

.match-piece.selected {
  outline: 4px solid var(--brand);
  transform: scale(1.06);
}

.match-shape {
  width: 74%;
  height: 74%;
  display: grid;
}

/* Outline places: the shape as a soft grey silhouette. */
.match-shape.outline svg {
  fill: #ddd6ea;
  stroke: #b9aed2;
  stroke-dasharray: 6 5;
}

.match-pic {
  width: 78%;
  height: 78%;
}

/* Shadow places: the picture as a dark silhouette. */
.match-pic.shadow {
  filter: brightness(0);
  opacity: 0.28;
}

/* Stack: a tower from the bottom up. */
.stack-mode .match-places {
  --piece: clamp(52px, min(26cqw, 13cqh), 120px);
  flex-direction: column-reverse;
  flex-wrap: nowrap;
  gap: 4px;
}

.stack-mode .match-place {
  width: calc(var(--piece) * 1.8);
  height: var(--piece);
  border-radius: 14px;
}

.stack-mode .match-tray .match-piece {
  width: calc(var(--piece) * 1.3);
  height: var(--piece);
}

.stack-hint {
  font-size: calc(var(--piece) * 0.45);
  color: #cfc4e6;
}

.stack-block {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background: hsl(var(--hue) 85% 62%);
  color: #fff;
  font-size: calc(var(--piece) * 0.5);
  font-weight: 800;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.15);
}

.match-place.filled .stack-block {
  border-radius: 10px;
}

.stack-mode .match-tray {
  --piece: clamp(48px, min(14cqw, 13cqh), 110px);
}

/* ---------- Add & Take picture sums ---------- */
.math-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1cqmin;
}

.math-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.5cqmin 2.5cqmin;
}

.math-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6cqmin;
  max-width: min(46cqw, 330px);
  padding: 1cqmin 1.4cqmin;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.math-pic {
  width: min(6.5cqw, 7.5cqh);
  height: min(6.5cqw, 7.5cqh);
}

/* Taken away: faded with a red cross. */
.math-pic.gone {
  opacity: 0.3;
  background: linear-gradient(45deg, transparent 46%, #e63946 46% 54%, transparent 54%);
}

.math-op {
  font-size: min(8cqw, 9cqh);
  font-weight: 800;
  color: var(--brand);
}

.math-equation {
  font-size: min(5.5cqw, 6.5cqh);
  font-weight: 800;
  letter-spacing: 0.06em;
}

/* ---------- Clock ---------- */
.clock-card {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5cqw;
}

.clock-face {
  display: grid;
}

.clock-face.big-art {
  width: min(48cqw, 80cqh);
  aspect-ratio: 1;
}

.clock-rim { fill: var(--brand); }
.clock-dial { fill: #fff; }
.tick { stroke: #c9bfe0; stroke-width: 1.5; }
.tick.major { stroke: var(--ink); stroke-width: 3; }
.clock-num { font-size: 17px; font-weight: 800; fill: var(--ink); text-anchor: middle; dominant-baseline: central; font-family: "Andika", "Baloo Da 2", "Baloo Bhaijaan 2", sans-serif; }
.clock-pin { fill: var(--ink); }

.hand {
  stroke-linecap: round;
  transform-origin: 100px 100px;
  transform-box: view-box;
  transition: transform 0.6s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.hand.hour { stroke: #ef476f; stroke-width: 8; }
.hand.minute { stroke: #118ab2; stroke-width: 5; }

.clock-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2cqmin;
  min-width: 0;
}

.clock-digital {
  margin: 0;
  padding: 0.1em 0.5em;
  border-radius: 18px;
  background: var(--ink);
  color: #7cf5b0;
  font-size: min(10cqw, 16cqh);
  font-weight: 800;
  letter-spacing: 0.06em;
}

@container (aspect-ratio < 1.15) {
  .clock-card {
    flex-direction: column;
    gap: 2cqh;
  }

  .clock-face.big-art {
    width: min(70cqw, 48cqh);
  }

  .clock-digital {
    font-size: min(12cqw, 8cqh);
  }
}

.q-clock {
  width: min(26cqw, 30cqh);
  aspect-ratio: 1;
}

.q-option .glyph.clock-option {
  font-size: min(5.5cqw, 7cqh);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ---------- Quran corner ---------- */
.qaida-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2cqmin;
}

.qaida-big {
  font-size: min(34cqw, 50cqh);
  color: var(--brand-2);
}

.qaida-name {
  margin: 0;
  font-size: min(7cqw, 9cqh);
}

.qaida-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2.5cqmin;
  width: 100%;
}

.qaida-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1cqmin;
  width: min(26cqw, 40cqh);
  min-height: min(26cqw, 40cqh);
  padding: 1.5cqmin;
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.qaida-row .qaida-box.static {
  width: min(20cqw, 34cqh);
  min-height: min(20cqw, 34cqh);
}

.qaida-glyph {
  font-family: "Baloo Bhaijaan 2", "Noto Naskh Arabic", "Geeza Pro", sans-serif;
  font-size: min(13cqw, 20cqh);
  line-height: 1.3;
  color: var(--ink);
}

.qaida-label {
  font-size: min(3cqw, 4cqh);
  color: var(--ink-soft);
  text-align: center;
}

.quran-screen {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 2cqmin;
}

.surah-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  align-content: center;
  gap: 2.5cqmin;
  overflow-y: auto;
}

.surah-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 14px;
  min-height: 92px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
  text-align: start;
}

.surah-number {
  grid-row: 1 / -1;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #2a9d8f;
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
}

.surah-name,
.surah-title,
.ayah {
  font-family: "Noto Naskh Arabic", "Geeza Pro", "Traditional Arabic", "Arabic Typesetting", "Baloo Bhaijaan 2", serif;
}

.surah-name {
  font-size: 1.7rem;
}

.surah-english {
  color: var(--ink-soft);
}

.surah-reader {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 1.5cqmin;
}

.surah-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.surah-title {
  margin: 0 8px;
  font-size: clamp(1.5rem, 4cqmin, 2.4rem);
}

.surah-text {
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 1.2cqmin;
  padding: 1cqmin;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.85);
}

.ayah {
  display: block;
  width: 100%;
  padding: 0.35em 0.6em;
  border-radius: 16px;
  font-size: clamp(1.6rem, 5.2cqmin, 3rem);
  line-height: 2;
  text-align: right;
  transition: background 0.25s ease, transform 0.25s ease;
}

.ayah.basmala {
  text-align: center;
  color: #2a9d8f;
}

.ayah.playing {
  background: #fff4c2;
  box-shadow: 0 0 0 3px var(--sun);
}

.ayah-number {
  margin-inline-start: 0.4em;
  color: #2a9d8f;
}

.quran-credit {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
}

/* English pronunciation under Arabic letters, sounds and ayahs. */
.qaida-translit {
  font-family: "Andika", system-ui, sans-serif;
  font-size: min(4.2cqw, 5.5cqh);
  font-weight: 700;
  color: #2a9d8f;
}

.qaida-translit.big {
  margin: 0;
  font-size: min(6cqw, 8cqh);
}

.ayah-translit {
  display: block;
  margin-top: 0.15em;
  font-family: "Andika", system-ui, sans-serif;
  font-size: 0.42em;
  line-height: 1.4;
  color: #2a9d8f;
  text-align: left;
}

.ayah.basmala .ayah-translit {
  text-align: center;
}
