/* Shared components: buttons, home cards, tabs, explorer, overlays. */

/* ---------- Buttons ---------- */
.icon-btn {
  position: relative;
  flex: none;
  width: var(--touch);
  height: var(--touch);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--brand);
  box-shadow: var(--shadow-sm), inset 0 -4px 0 rgba(43, 35, 64, 0.08);
  transition: transform 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn .icon {
  width: 52%;
  height: 52%;
}

.home-btn {
  background: var(--brand);
  color: #fff;
}

.sound-btn.off {
  color: #9a93ad;
}

.parent-btn {
  width: max(44px, calc(var(--touch) * 0.8));
  height: max(44px, calc(var(--touch) * 0.8));
  color: #9a93ad;
}

.hold-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 4px solid transparent;
}

.parent-btn.holding .hold-ring {
  border-color: var(--brand);
  animation: hold-fill 1.3s linear forwards;
}

.parent-btn.hint::after {
  content: attr(data-hint);
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 0.85rem;
  z-index: 5;
}

@keyframes hold-fill {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* Active child: picture + name (picture only on phones). */
.profile-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  height: max(44px, calc(var(--touch) * 0.8));
  min-width: 44px;
  max-width: 13rem;
  padding: 0 14px 0 6px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-size: clamp(1rem, 2.4vmin, 1.25rem);
}

.profile-chip-pic {
  width: 34px;
  height: 34px;
  flex: none;
}

.profile-chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .profile-chip {
    justify-content: center;
    padding: 0 5px;
  }

  .profile-chip-name {
    display: none;
  }
}

/* Profile picker + form */
.profile-card {
  width: min(640px, 100%);
  text-align: center;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.profile-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 128px;
  padding: 10px 6px;
  border-radius: 22px;
  background: #fff;
  border: 4px solid transparent;
  box-shadow: var(--shadow-sm);
}

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

.profile-pic {
  width: 64px;
  height: 64px;
}

.profile-label {
  max-width: 100%;
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.profile-choice.add {
  border: 3px dashed #d9d0ec;
  box-shadow: none;
}

.add-plus {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 2.2rem;
  line-height: 1;
}

.profile-form {
  display: grid;
  gap: 12px;
  text-align: start;
}

.profile-field {
  display: grid;
  gap: 6px;
  font-size: 1.05rem;
}

.profile-name-input {
  min-height: 52px;
  padding: 8px 14px;
  border: 3px solid #d9d0ec;
  border-radius: 14px;
  font: inherit;
  font-size: 1.2rem;
}

.profile-name-input:focus {
  outline: none;
  border-color: var(--brand);
}

.profile-field-title {
  margin: 0;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
}

.avatar-choice {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 52px;
  border-radius: 16px;
  background: #fff;
  border: 3px solid transparent;
  box-shadow: var(--shadow-sm);
}

.avatar-choice.active {
  border-color: var(--brand);
  background: #f1eafd;
}

.avatar-pic {
  width: 70%;
  height: 70%;
}

.profile-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.star {
  width: 1.3em;
  height: 1.3em;
  color: #d9d4e6;
}

.star.on {
  color: #ffb703;
}

.stars-row {
  display: inline-flex;
  gap: 2px;
  font-size: clamp(1rem, 2.4vmin, 1.4rem);
}

.big-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--touch);
  padding: 8px 22px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: clamp(1.05rem, 2.6vmin, 1.5rem);
  box-shadow: var(--shadow-sm), inset 0 -5px 0 rgba(43, 35, 64, 0.08);
}

.big-btn .icon {
  width: 1.3em;
  height: 1.3em;
}

.big-btn.primary {
  background: var(--brand);
  color: #fff;
}

.big-btn.small {
  min-height: 48px;
  font-size: 1rem;
  margin-top: 8px;
}

.big-btn.danger {
  background: #ffe3e8;
  color: #b3133b;
}

.big-btn:active {
  transform: scale(0.96);
}

/* ---------- Home ---------- */
.home {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.4vmin, 14px);
  padding: 4px 4px 6px;
}

/* Cards fill the free space exactly (sizes set by fittedCardGrid). */
.card-fit {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card-fit.scroll {
  place-items: start center;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), var(--size, 160px));
  grid-auto-rows: var(--size, 160px);
  gap: var(--gap, 12px);
  justify-content: center;
}

/* Contact line: Home footer and Parents > About. */
.contact-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0;
  font-size: clamp(1rem, 2.4vmin, 1.2rem);
}

.contact-line .mail-icon {
  width: 1.4em;
  height: 1.4em;
  flex: none;
  color: var(--brand);
}

.contact-line a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--brand-2);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.home-contact {
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  flex: none;
  margin: 0 auto;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.home-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--size, 160px) * 0.05);
  min-width: 0;
  padding: 6px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow), inset 0 -8px 0 var(--accent, #ddd);
  border: 4px solid var(--accent, #ddd);
  transition: transform 0.15s ease;
}

.home-card:active,
.home-card.kbd-focus {
  transform: scale(0.95);
}

.home-card.kbd-focus {
  outline: 5px solid var(--brand);
}

.home-pic {
  width: 50%;
  height: auto;
  aspect-ratio: 1;
}

.home-label {
  max-width: 100%;
  font-size: max(0.95rem, calc(var(--size, 160px) * 0.12));
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}

/* ---------- Tabs and chips ---------- */
.tabs {
  min-width: 0;
  max-width: 100%;
  display: flex;
  justify-content: safe center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar,
.ex-strip::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--card);
  font-size: clamp(0.95rem, 2.4vmin, 1.25rem);
  box-shadow: var(--shadow-sm);
}

.tab.active {
  background: var(--brand);
  color: #fff;
}

.tab-pic {
  width: 30px;
  height: 30px;
}

.ex-strip {
  display: flex;
  align-items: center;
  justify-content: safe center;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 4px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.chip {
  --chip-size: clamp(48px, 7.5vmin, 64px);
  flex: none;
  min-width: var(--chip-size);
  height: var(--chip-size);
  padding: 0 10px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--card);
  font-size: clamp(1.25rem, 3.4vmin, 1.8rem);
  box-shadow: var(--shadow-sm);
  scroll-snap-align: center;
}

.chip.active {
  background: var(--brand);
  color: #fff;
  transform: scale(1.08);
}

.chip-group-title {
  flex: none;
  padding: 0 6px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* Sized from the chip height (not %), so pictures cannot stretch the chip. */
.chip-pic,
.chip-shape {
  width: calc(var(--chip-size) * 0.72);
  height: calc(var(--chip-size) * 0.72);
}

.chip-shape {
  display: grid;
}

.chip-swatch {
  width: 64%;
  height: 64%;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.15);
}

/* ---------- Explorer (flash cards) ---------- */
.explorer {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1vmin, 10px);
}

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

.explorer > .ex-main {
  flex: 1 1 0;
}

.ex-main {
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "prev card next"
    "prev actions next";
  align-items: center;
  gap: clamp(6px, 1.4vmin, 16px);
}

.nav-btn {
  width: clamp(56px, 10vmin, 104px);
  height: clamp(56px, 10vmin, 104px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-2);
  color: #fff;
  box-shadow: var(--shadow), inset 0 -6px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease;
}

.nav-btn.next {
  grid-area: next;
  background: var(--good);
}

.nav-btn.prev {
  grid-area: prev;
}

.nav-btn .icon {
  width: 50%;
  height: 50%;
}

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

.nav-btn:active {
  transform: scale(0.9);
}

.nav-btn.pulse {
  animation: pulse 1s ease-in-out infinite;
}

.ex-card {
  grid-area: card;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2cqmin, 24px);
  border-radius: calc(var(--radius) + 6px);
  background: var(--card);
  box-shadow: var(--shadow);
  container-type: size;
  overflow: hidden;
  cursor: pointer;
}

.ex-card.enter-forward {
  animation: card-in-forward 0.45s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.ex-card.enter-back {
  animation: card-in-back 0.45s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.ex-actions {
  grid-area: actions;
  display: flex;
  justify-content: center;
  gap: var(--gap);
}

.listen-btn {
  background: var(--sun);
  color: var(--ink);
}

/* Portrait: card on top, arrows beside the action buttons below it. */
@media (orientation: portrait) {
  .ex-main {
    grid-template-areas:
      "card card card"
      "prev actions next";
  }
}

/* ---------- Start overlay ---------- */
.start-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: linear-gradient(160deg, rgba(255, 243, 196, 0.96), rgba(255, 225, 236, 0.96) 55%, rgba(215, 241, 255, 0.96));
  overflow-y: auto;
  transition: opacity 0.3s ease;
}

.start-overlay.leaving {
  opacity: 0;
}

.start-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2.4vmin, 22px);
  width: min(720px, 100%);
  text-align: center;
}

.start-art {
  display: flex;
  gap: clamp(6px, 2vmin, 16px);
}

.start-pic {
  width: clamp(44px, 10vmin, 92px);
  animation: bob 2.4s ease-in-out infinite;
}

.start-pic:nth-child(2) { animation-delay: 0.2s; }
.start-pic:nth-child(3) { animation-delay: 0.4s; }
.start-pic:nth-child(4) { animation-delay: 0.6s; }
.start-pic:nth-child(5) { animation-delay: 0.8s; }

.start-title {
  font-size: clamp(2rem, 7vmin, 4rem);
  color: var(--brand);
}

.start-tagline {
  font-size: clamp(1rem, 2.8vmin, 1.5rem);
  color: var(--ink-soft);
}

.lang-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  min-width: 120px;
  padding: 6px 18px;
  border-radius: 999px;
  background: #fff;
  font-size: clamp(1.05rem, 2.6vmin, 1.35rem);
  box-shadow: var(--shadow-sm);
}

.lang-btn .icon {
  width: 1em;
  height: 1em;
}

/* Top-bar language button: globe + current language (globe only on phones). */
.lang-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  height: max(44px, calc(var(--touch) * 0.8));
  min-width: 44px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-size: clamp(1rem, 2.4vmin, 1.25rem);
}

.lang-chip .icon {
  width: 1.4em;
  height: 1.4em;
  flex: none;
  color: var(--brand);
}

@media (max-width: 720px) {
  .lang-chip {
    justify-content: center;
    padding: 0 10px;
  }

  .lang-chip-name {
    display: none;
  }
}

.lang-btn.active {
  background: var(--brand);
  color: #fff;
}

.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: clamp(12px, 2.4vmin, 22px) clamp(36px, 7vmin, 64px);
  border-radius: 999px;
  background: var(--good);
  color: #fff;
  font-size: clamp(1.6rem, 5vmin, 2.8rem);
  box-shadow: var(--shadow), inset 0 -8px 0 rgba(0, 0, 0, 0.15);
  animation: pulse 1.6s ease-in-out infinite;
}

.play-btn .icon {
  width: 1.1em;
  height: 1.1em;
}

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

.start-note {
  max-width: 34ch;
  color: #a4161a;
  font-size: 1rem;
}

@media (max-height: 480px) and (orientation: landscape) {
  .start-art {
    display: none;
  }
}

/* ---------- Modals (parents) ---------- */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(12px, var(--safe-top)) 12px max(12px, var(--safe-bottom));
  background: rgba(43, 35, 64, 0.45);
  overflow-y: auto;
}

.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(18px, 3vmin, 32px);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
  font-weight: 600;
}

.modal-card h2 {
  font-size: 1.6rem;
  margin-bottom: 12px;
  padding-inline-end: 60px;
}

.modal-close {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  width: 52px;
  height: 52px;
}

/* ---------- Language picker ---------- */
.language-card {
  width: min(480px, 100%);
  text-align: center;
}

.language-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}

.language-title .icon {
  width: 1.3em;
  height: 1.3em;
  color: var(--brand);
}

.language-card .lang-row {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.language-card .lang-btn {
  min-height: 64px;
  font-size: clamp(1.3rem, 3.4vmin, 1.6rem);
}

/* Short landscape phones: 2 × 2 grid so all languages fit without scrolling. */
@media (max-height: 480px) and (orientation: landscape) {
  .language-card {
    width: min(560px, 100%);
  }

  .language-title {
    margin-bottom: 10px;
  }

  .language-card .lang-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .language-card .lang-btn {
    min-height: 56px;
  }
}

/* ---------- Parents area: tabs + one short page at a time ---------- */
.parent-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.parent-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.parent-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 64px;
  padding: 6px 4px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-size: 0.95rem;
  line-height: 1.15;
  text-align: center;
}

.parent-tab .icon {
  width: 26px;
  height: 26px;
  color: var(--brand);
}

.parent-tab.active {
  background: var(--brand);
  color: #fff;
}

.parent-tab.active .icon {
  color: #fff;
}

.panel-page {
  padding-top: 14px;
  border-top: 2px dashed #e7e0f3;
}

.panel-page h3 {
  font-size: 1.25rem;
  margin: 0 0 10px;
}

.panel-page h3:not(:first-child) {
  margin-top: 22px;
}

.panel-page h4 {
  margin: 14px 0 6px;
}

.panel-page p,
.tips {
  line-height: 1.5;
}

.panel-page .lang-row {
  justify-content: flex-start;
}

.shortcut-list {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.shortcut-list li {
  display: grid;
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.key-caps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

kbd {
  min-width: 2.2em;
  padding: 4px 10px;
  border: 2px solid #d9d0ec;
  border-bottom-width: 4px;
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-weight: 700;
  text-align: center;
}

/* Phones: 3 × 2 tab grid; shortcut keys above their description. */
@media (max-width: 680px) {
  .parent-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .shortcut-list li {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

.setting-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 6px 0;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: #ece6f6;
}

.segmented button {
  min-height: 44px;
  min-width: 60px;
  padding: 4px 14px;
  border-radius: 999px;
}

.segmented button.active {
  background: var(--brand);
  color: #fff;
}

.voice-select {
  max-width: 100%;
  min-height: 44px;
  padding: 4px 10px;
  border-radius: 12px;
  border: 2px solid #d5cce8;
  font: inherit;
  background: #fff;
}

.muted {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.warning {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff3cd;
  color: #7a5200;
}

.report {
  width: 100%;
  border-collapse: collapse;
}

.report th,
.report td {
  padding: 8px 6px;
  text-align: start;
  border-bottom: 1px solid #ece6f6;
}

.practice-list {
  font-size: 1.3rem;
}

.tips {
  margin: 0;
  padding-inline-start: 22px;
}

.tips li + li {
  margin-top: 6px;
}

.modal a {
  color: var(--brand);
}

/* ---------- Effects ---------- */
.confetti {
  position: absolute;
  top: -20px;
  left: var(--x);
  width: 12px;
  height: 18px;
  border-radius: 3px;
  animation: confetti var(--dur) ease-in var(--delay) forwards;
}

.confetti.round {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

@keyframes confetti {
  to {
    transform: translate(var(--drift), 110vh) rotate(var(--spin));
  }
}

@keyframes card-in-forward {
  0% { opacity: 0; transform: translateX(26%) rotate(3deg) scale(0.9); }
  65% { opacity: 1; transform: translateX(-2%) rotate(-0.5deg) scale(1.01); }
  100% { transform: none; }
}

@keyframes card-in-back {
  0% { opacity: 0; transform: translateX(-26%) rotate(-3deg) scale(0.9); }
  65% { opacity: 1; transform: translateX(2%) rotate(0.5deg) scale(1.01); }
  100% { transform: none; }
}

[dir="rtl"] .ex-card.enter-forward {
  animation-name: card-in-back;
}

[dir="rtl"] .ex-card.enter-back {
  animation-name: card-in-forward;
}

@keyframes pulse {
  50% { transform: scale(1.06); }
}

@keyframes bob {
  50% { transform: translateY(-10%); }
}

@keyframes wobble {
  20% { transform: translateX(-8px) rotate(-3deg); }
  40% { transform: translateX(8px) rotate(3deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.wobble,
.wrong {
  animation: wobble 0.45s ease;
}

/* Clapping hands for wins: rise from the bottom, bounce, then fade. */
.clap-hand {
  position: fixed;
  left: var(--x);
  bottom: -14vmin;
  width: clamp(64px, 14vmin, 140px);
  height: clamp(64px, 14vmin, 140px);
  margin-left: calc(clamp(64px, 14vmin, 140px) / -2);
  animation: clap-rise 1.8s ease-out var(--delay) forwards;
  pointer-events: none;
}

@keyframes clap-rise {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  20% { opacity: 1; }
  35% { transform: translateY(-38vh) scale(1.1); }
  45% { transform: translateY(-38vh) scale(0.92); }
  55% { transform: translateY(-38vh) scale(1.08); }
  65% { transform: translateY(-38vh) scale(0.95); }
  100% { transform: translateY(-52vh) scale(1); opacity: 0; }
}

/* ---------- Gentle interaction effects (hover lift, press squish, boing) ---------- */
.home-card,
.theme-choice,
.q-option,
.chip,
.tab,
.lang-btn,
.parent-tab,
.memory-card,
.letter-picture,
.letter-glyphs {
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

@media (hover: hover) {
  .home-card:hover,
  .theme-choice:hover,
  .q-option:hover,
  .lang-btn:hover,
  .parent-tab:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 22px rgba(43, 35, 64, 0.18);
  }

  .chip:hover,
  .tab:hover {
    transform: translateY(-2px);
  }

  .home-card:hover .home-pic,
  .theme-choice:hover .theme-pic {
    animation: boing 0.5s ease;
  }
}

.theme-choice:active,
.chip:active,
.tab:active,
.lang-btn:active,
.parent-tab:active {
  transform: scale(0.95);
}

/* Added from JS when a picture or letter is tapped and spoken. */
.boing {
  animation: boing 0.5s ease;
}

@keyframes boing {
  0% { transform: scale(1); }
  30% { transform: scale(1.12, 0.9); }
  55% { transform: scale(0.94, 1.06); }
  80% { transform: scale(1.03, 0.98); }
  100% { transform: scale(1); }
}

/* Parents > Children list and the child picker on the progress page. */
.child-list {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.child-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.child-list li.active {
  outline: 3px solid var(--brand);
}

.child-main {
  display: flex;
  flex: 1 1 10rem;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  min-width: 0;
  padding: 2px 8px;
  border-radius: 14px;
  font-size: 1.15rem;
  text-align: start;
}

.child-main span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.child-check {
  width: 1.2em;
  height: 1.2em;
  color: var(--good);
}

.child-pick-pic {
  width: 40px;
  height: 40px;
  flex: none;
}

.child-picker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  margin-bottom: 8px;
}

.child-pick {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-height: 52px;
  padding: 4px 14px 4px 6px;
  border-radius: 999px;
  background: #fff;
  border: 3px solid transparent;
  box-shadow: var(--shadow-sm);
}

.child-pick.active {
  border-color: var(--brand);
}

.add-plus.small {
  width: 28px;
  height: 28px;
  font-size: 1.3rem;
}

/* Test cards hold picture, name, stars and best score: smaller parts. */
.test-card {
  gap: calc(var(--size, 160px) * 0.03);
}

.test-card .home-pic {
  width: calc(var(--size, 160px) * 0.36 - 10px);
}

.test-card .home-label {
  font-size: max(0.8rem, calc(var(--size, 160px) * 0.095));
}

.test-card .stars-row {
  font-size: max(0.8rem, calc(var(--size, 160px) * 0.09));
}

.test-card .test-best {
  font-size: max(0.75rem, calc(var(--size, 160px) * 0.08));
  line-height: 1.1;
}

/* ---------- Start screen: brand logo, name, who is playing ---------- */
.start-logo {
  width: clamp(72px, 16vmin, 140px);
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(43, 35, 64, 0.18));
  animation: bob 3s ease-in-out infinite;
}

.start-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(420px, 100%);
  padding: 6px 8px 6px 6px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.start-name {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: clamp(1.1rem, 3vmin, 1.4rem);
  text-align: center;
}

.start-name:focus {
  outline: none;
}

.start-name-row:focus-within {
  box-shadow: 0 0 0 3px var(--brand), var(--shadow-sm);
}

.start-profile-pic {
  width: 44px;
  height: 44px;
  flex: none;
}

.start-profiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
}

.start-profile {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 56px;
  padding: 4px 16px 4px 6px;
  border-radius: 999px;
  background: #fff;
  border: 3px solid transparent;
  box-shadow: var(--shadow-sm);
  font-size: 1.1rem;
}

.start-profile.active {
  border-color: var(--brand);
}

/* Short landscape phones: drop the decorative pictures to make room. */
@media (max-height: 480px) and (orientation: landscape) {
  .start-art {
    display: none;
  }

  .start-logo {
    width: 56px;
  }
}

/* ---------- Content-change transitions ---------- */
/* Every new screen fades up. */
.screen-enter > * {
  animation: screen-in 0.4s ease both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
}

/* Test questions: prompt drops in, answers pop in one after another. */
.question.q-enter .q-prompt {
  animation: q-drop 0.45s cubic-bezier(0.2, 0.8, 0.3, 1.2) both;
}

.question.q-enter .q-visual {
  animation: q-pop 0.45s cubic-bezier(0.2, 0.8, 0.3, 1.3) 0.1s both;
}

.question.q-enter .q-option {
  animation: q-pop 0.4s cubic-bezier(0.2, 0.8, 0.3, 1.3) calc(0.15s + var(--i, 0) * 0.08s) both;
}

.question.q-leave {
  animation: q-leave 0.28s ease-in forwards;
}

@keyframes q-drop {
  from { opacity: 0; transform: translateY(-30px); }
}

@keyframes q-pop {
  from { opacity: 0; transform: scale(0.6); }
}

@keyframes q-leave {
  to { opacity: 0; transform: translateX(-12%) scale(0.96); }
}

[dir="rtl"] .question.q-leave {
  animation-name: q-leave-rtl;
}

@keyframes q-leave-rtl {
  to { opacity: 0; transform: translateX(12%) scale(0.96); }
}

/* Theme cards pop in one after another. */
.theme-choice {
  animation: q-pop 0.4s cubic-bezier(0.2, 0.8, 0.3, 1.3) calc(var(--i, 0) * 0.05s) both;
}

.result-card {
  animation: q-pop 0.5s cubic-bezier(0.2, 0.8, 0.3, 1.3) both;
}

/* Switching inside a screen (theme grid ↔ letter cards, Memory decks). */
.explorer,
.theme-picker,
.memory-board {
  animation: screen-in 0.35s ease both;
}

/* ---------- Home footer: contact + share ---------- */
.home-footer {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: clamp(1rem, 2.4vmin, 1.2rem);
  box-shadow: var(--shadow-sm);
}

.share-btn .icon {
  width: 1.2em;
  height: 1.2em;
}

.share-card {
  width: min(520px, 100%);
  text-align: center;
}

.share-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.share-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 14px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.share-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
}

.share-link.facebook .share-mark { background: #1877f2; }
.share-link.whatsapp .share-mark { background: #25d366; }
.share-link.x .share-mark { background: #111; }
.share-link.telegram .share-mark { background: #229ed9; }
.share-link.email .share-mark { background: #ff8a3d; }
.share-link.copy .share-mark { background: var(--brand); }

.share-status {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--good);
  font-weight: 700;
}

/* Theme splash: pictures burst out from the centre and fade. */
.splash-pic {
  position: fixed;
  left: 50%;
  top: 50%;
  width: clamp(48px, 11vmin, 110px);
  height: clamp(48px, 11vmin, 110px);
  margin: calc(clamp(48px, 11vmin, 110px) / -2) 0 0 calc(clamp(48px, 11vmin, 110px) / -2);
  animation: splash-out 1.1s cubic-bezier(0.15, 0.8, 0.3, 1) var(--delay) both;
  pointer-events: none;
}

@keyframes splash-out {
  0% { transform: translate(0, 0) scale(0.2) rotate(0deg); opacity: 0; }
  15% { opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(var(--spin)); opacity: 0; }
}
