/* ===== Fonts (bundled locally, SIL Open Font License) ===== */
@font-face { font-family: "Naskh"; src: url("../fonts/NotoNaskhArabic-Regular.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("../fonts/Tajawal-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("../fonts/Tajawal-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("../fonts/Tajawal-ExtraBold.woff2") format("woff2"); font-weight: 800; font-display: swap; }

/* ===== Design tokens ===== */
:root {
  --bg: #fff8ec;
  --paper: #ffffff;
  --ink: #3a2e2a;
  --ink-soft: #6d5d55;
  --line: #f0e2cc;
  --sun: #ffc845;
  --sun-deep: #e8a200;
  --coral: #ff7a59;
  --coral-deep: #e0563a;
  --teal: #22b3a0;
  --teal-deep: #178c7c;
  --sky: #5aaef0;
  --hl: #d6336c;          /* the coloured letter inside a word */
  --radius: 22px;
  --tap: 64px;            /* minimum tap target */
  --gutter: 16px;
  --shadow: 0 3px 0 rgba(58, 46, 42, .08), 0 8px 24px rgba(58, 46, 42, .06);
  --font-ui: "Tajawal", system-ui, sans-serif;
  --font-ar: "Naskh", "Noto Naskh Arabic", serif;
  --scale: 1;
}
html.classroom { --scale: 1.25; }
html.classroom .stars { display: none !important; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* never let a display rule show a hidden element */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-weight: 500;
  font-size: calc(18px * var(--scale)); line-height: 1.6;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; }
button { font: inherit; color: inherit; }
.ar { font-family: var(--font-ar); line-height: 1.9; }
.hl { color: var(--hl); }
.wrap { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: var(--gutter); }
.icon { width: 1.6em; height: 1.6em; display: inline-block; vertical-align: middle; pointer-events: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: var(--tap); min-width: var(--tap); padding: .4em 1.1em;
  border: 0; border-radius: 999px; cursor: pointer; text-decoration: none;
  background: var(--sun); color: var(--ink); font-weight: 800; font-size: 1.1em;
  box-shadow: 0 5px 0 var(--sun-deep);
  transition: transform .12s ease, box-shadow .12s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--sun-deep); }
.btn.teal { background: var(--teal); color: #fff; box-shadow: 0 5px 0 var(--teal-deep); }
.btn.teal:active { box-shadow: 0 1px 0 var(--teal-deep); }
.btn.coral { background: var(--coral); color: #fff; box-shadow: 0 5px 0 var(--coral-deep); }
.btn.coral:active { box-shadow: 0 1px 0 var(--coral-deep); }
.btn.round { padding: 0; width: var(--tap); border-radius: 50%; }
.btn .icon { width: 1.9em; height: 1.9em; }
:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }

.speak {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); flex: none;
  border: 0; border-radius: 50%; cursor: pointer;
  background: #fff; box-shadow: 0 4px 0 var(--line), 0 0 0 3px var(--line) inset;
  touch-action: manipulation;
}
.speak .icon { width: 36px; height: 36px; }
.speak:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line), 0 0 0 3px var(--line) inset; }
.speak.playing { background: #fff3c4; animation: pulse 1s ease-in-out infinite; }
.speak.small { --tap: 52px; }
.speak.small .icon { width: 30px; height: 30px; }

/* ===== Top bar ===== */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 14px; }
.topbar .title { font-weight: 800; font-size: 1.3em; }

/* ===== Home ===== */
.hero-home { text-align: center; padding-block: 18px 8px; }
.hero-home .logo { display: inline-flex; align-items: center; gap: 12px; margin: 0; }
.hero-home .logo img { width: clamp(56px, 12vw, 96px); height: auto; }
.hero-home h1 { margin: 0; font-weight: 800; font-size: clamp(56px, 14vw, 110px); line-height: 1.1; letter-spacing: 0; }
.hero-home h1 span:nth-child(1) { color: var(--coral); }
.hero-home h1 span:nth-child(2) { color: var(--teal); }
.hero-home h1 span:nth-child(3) { color: var(--sun-deep); }
.hero-home h1 span:nth-child(4) { color: var(--sky); }
.hero-home h1 span:nth-child(5) { color: var(--hl); }
.home-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-block: 8px 22px; }

.letter-grid {
  list-style: none; margin: 0; padding: 0 0 24px;
  display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (min-width: 600px) { .letter-grid { gap: 16px; grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 900px) { .letter-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.letter-card {
  --h: 30;
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  aspect-ratio: 1 / 1.1; min-height: 80px; padding: 4px 4px 8px;
  border-radius: var(--radius); text-decoration: none; color: hsl(var(--h) 55% 28%);
  background: hsl(var(--h) 90% 90%);
  box-shadow: 0 6px 0 hsl(var(--h) 55% 74%);
  transition: transform .15s ease, box-shadow .15s ease;
  touch-action: manipulation;
}
.letter-card:hover { transform: translateY(-3px); box-shadow: 0 9px 0 hsl(var(--h) 55% 74%); }
.letter-card:active { transform: translateY(5px); box-shadow: 0 1px 0 hsl(var(--h) 55% 74%); }
.letter-card .glyph { font-family: var(--font-ar); font-size: clamp(38px, 10vw, 76px); line-height: 1.25; }
html.classroom .letter-card .glyph { font-size: clamp(44px, 11vw, 96px); }
.letter-card .stars { position: absolute; inset-block-end: 6px; }
.stars { display: inline-flex; gap: 2px; justify-content: center; }
.stars .star .icon { width: 16px; height: 16px; }
.stars .star:not(.on) .icon { filter: grayscale(1); opacity: .25; }
@media (min-width: 600px) { .stars .star .icon { width: 20px; height: 20px; } }
.stars-big .star .icon { width: 44px; height: 44px; }

/* ===== Letter page ===== */
.letter-page { --h: 30; }
.section-nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--line);
}
.section-nav ul { list-style: none; margin: 0; padding: 8px 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.section-nav ul::-webkit-scrollbar { display: none; }
.section-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 72px; min-height: var(--tap); padding: 4px 8px; border-radius: 16px;
  color: var(--ink); text-decoration: none; font-size: .78em; font-weight: 700; white-space: nowrap;
  background: var(--paper); box-shadow: 0 3px 0 var(--line);
}
.section-nav a .icon { width: 30px; height: 30px; }
.section-nav a.active { background: hsl(var(--h) 90% 88%); box-shadow: 0 3px 0 hsl(var(--h) 55% 74%); }

.block {
  background: var(--paper); border-radius: 28px; box-shadow: var(--shadow);
  padding: 20px var(--gutter) 24px; margin-block: 20px; scroll-margin-top: 96px;
}
@media (min-width: 700px) { .block { padding: 28px 32px 32px; } }
.block > h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 1.35em; font-weight: 800; }
.block > h2 .icon { width: 44px; height: 44px; }

.meet { display: grid; gap: 20px; align-items: center; justify-items: center; text-align: center; }
@media (min-width: 760px) { .meet { grid-template-columns: auto 1fr; text-align: start; justify-items: start; } }
.big-letter {
  display: grid; place-items: center;
  width: clamp(200px, 56vw, 300px); aspect-ratio: 1; border-radius: 50%;
  background: hsl(var(--h) 90% 90%); color: hsl(var(--h) 55% 30%);
  box-shadow: 0 8px 0 hsl(var(--h) 55% 76%);
  font-family: var(--font-ar); font-size: clamp(130px, 36vw, 210px); line-height: 1;
  border: 0; cursor: pointer; padding: 0 0 .18em;
}
html.classroom .big-letter { width: clamp(240px, 60vw, 380px); font-size: clamp(150px, 40vw, 270px); }
.name-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
@media (min-width: 760px) { .name-row { justify-content: flex-start; } }
.name-row .name { font-family: var(--font-ar); font-size: clamp(44px, 10vw, 64px); line-height: 1.5; font-weight: 700; }
.desc { display: flex; align-items: flex-start; gap: 14px; margin-top: 8px; }
.desc p { margin: 0; font-family: var(--font-ar); font-size: clamp(22px, 4.6vw, 30px); line-height: 2; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; justify-content: center; }
@media (min-width: 760px) { .facts { justify-content: flex-start; } }
.fact { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: hsl(var(--h) 90% 94%); font-weight: 700; font-size: .9em; }

.forms-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .forms-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.forms-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 620px; }
.form-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 8px; border-radius: var(--radius); background: hsl(var(--h) 90% 95%);
  border: 3px solid hsl(var(--h) 70% 86%); text-align: center;
}
.form-card .label { font-weight: 800; font-size: .9em; color: var(--ink-soft); }
.form-card .shape { font-family: var(--font-ar); font-size: clamp(64px, 16vw, 96px); line-height: 1.4; color: hsl(var(--h) 55% 30%); }
.form-card .example { display: flex; align-items: center; gap: 8px; }
.form-card .example .word { font-family: var(--font-ar); font-size: clamp(26px, 6vw, 34px); line-height: 1.8; }
.note { margin: 16px 0 0; padding: 12px 16px; border-radius: 16px; background: #fff3c4; font-weight: 700; display: flex; gap: 10px; align-items: center; }

.vowel-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (min-width: 760px) { .vowel-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.vowel-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 110px; border: 0; border-radius: var(--radius); cursor: pointer;
  background: hsl(var(--h) 90% 92%); box-shadow: 0 5px 0 hsl(var(--h) 55% 76%);
  touch-action: manipulation;
}
.vowel-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 hsl(var(--h) 55% 76%); }
.vowel-btn.long { background: hsl(calc(var(--h) + 40) 90% 92%); box-shadow: 0 5px 0 hsl(calc(var(--h) + 40) 55% 76%); }
.vowel-btn .syl { font-family: var(--font-ar); font-size: clamp(44px, 11vw, 64px); line-height: 1.7; }
.vowel-btn .vname { font-size: .78em; font-weight: 700; color: var(--ink-soft); }
.vowel-btn.playing { outline: 4px solid var(--sun); }

.word-groups { display: grid; gap: 18px; }
@media (min-width: 900px) { .word-groups { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.word-group h3 { margin: 0 0 10px; font-size: 1em; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.pos-dots { display: inline-flex; gap: 3px; direction: rtl; }
.pos-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.pos-dots i.on { background: var(--hl); }
.word-list { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.word-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 8px 10px; border-radius: var(--radius); background: var(--bg);
  border: 3px solid var(--line); cursor: pointer; text-align: center;
  touch-action: manipulation;
}
.word-card img.pic { width: min(110px, 80%); aspect-ratio: 1; }
.word-card .word { font-family: var(--font-ar); font-size: clamp(28px, 6.4vw, 38px); line-height: 1.8; }
.word-card:active { transform: scale(.97); }

.video-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.video-card { display: flex; flex-direction: column; gap: 8px; }
.video-thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; cursor: pointer;
  border-radius: 20px; overflow: hidden; background: #2d2521;
}
.video-thumb img.thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-thumb .play {
  position: absolute; inset: 0; margin: auto; width: 88px; height: 88px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(255, 255, 255, .92); box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.video-thumb .play .icon { width: 52px; height: 52px; }
.video-card iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 20px; background: #000; }
.video-card .vtitle { font-weight: 700; font-size: .95em; }

.practice-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .practice-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.practice-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 130px; padding: 14px 8px; border-radius: var(--radius); text-decoration: none; color: var(--ink);
  background: hsl(var(--h) 90% 92%); box-shadow: 0 6px 0 hsl(var(--h) 55% 76%); font-weight: 800; text-align: center;
}
.practice-tile .icon { width: 56px; height: 56px; }
.practice-tile[aria-disabled="true"] { filter: grayscale(.8); opacity: .6; cursor: default; box-shadow: none; }
.badge { position: absolute; inset-block-start: 8px; inset-inline-start: 8px; padding: 2px 10px; border-radius: 999px; background: var(--paper); font-size: .7em; font-weight: 800; }

.letter-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 8px 32px; }
.letter-nav .btn { font-family: var(--font-ar); font-size: 1.5em; font-weight: 700; }
.letter-nav .btn .icon { width: 1.4em; height: 1.4em; }
.letter-nav .spacer { flex: 1; }

/* ===== Small screens ===== */
@media (max-width: 420px) {
  .block > h2 { font-size: 1.15em; }
  .word-card img.pic { width: 84px; }
}

/* ===== Motion ===== */
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
.pop { animation: pop .35s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ===== Print (teacher content review) ===== */
@media print {
  body { background: #fff; }
  .no-print, .section-nav, .topbar .btn, .speak { display: none !important; }
  .block { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}

/* ===== Exercises ===== */
.exercise-page { --h: 30; }
.ex-top .ex-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15em; text-align: center; }
.ex-top .ex-title .icon { width: 40px; height: 40px; }
.back-letter { font-size: 34px; line-height: 1; font-weight: 700; }
.ex-dots { display: flex; justify-content: center; gap: 10px; padding-bottom: 6px; }
.ex-dots i { width: 16px; height: 16px; border-radius: 50%; background: var(--line); transition: background .3s, transform .3s; }
.ex-dots i.done { background: var(--sun); transform: scale(1.15); }
.ex-stage { padding-bottom: 32px; }
.ex-center { display: flex; flex-direction: column; align-items: center; gap: 22px; padding-top: 8px; }

/* Listen and choose */
.ear-btn {
  width: 132px; height: 132px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--paper); box-shadow: 0 7px 0 var(--line), 0 0 0 5px hsl(var(--h) 80% 88%) inset;
  display: grid; place-items: center; touch-action: manipulation;
}
.ear-btn .icon { width: 84px; height: 84px; }
.ear-btn.playing { animation: pulse 1s ease-in-out infinite; background: #fff3c4; }
.choices { display: grid; gap: 14px; width: 100%; max-width: 640px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choices.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .choices.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 820px; } }
.choice {
  aspect-ratio: 1; border: 0; border-radius: 28px; cursor: pointer;
  background: hsl(var(--h) 90% 92%); box-shadow: 0 7px 0 hsl(var(--h) 55% 76%);
  font-size: clamp(64px, 18vw, 120px); line-height: 1; padding-bottom: .15em; color: var(--ink);
  touch-action: manipulation;
}
.choice:active { transform: translateY(5px); box-shadow: 0 2px 0 hsl(var(--h) 55% 76%); }
.choice.tried { opacity: .55; }
.choice.right { background: #d9f5e6; box-shadow: 0 7px 0 #8fd6b0; opacity: 1; }

/* Tracing */
.trace-wrap { background: var(--paper); border-radius: 28px; box-shadow: var(--shadow); padding: 10px; }
.trace-canvas { display: block; touch-action: none; border-radius: 20px; background: #fffdf8; cursor: crosshair; }
.tool-row { display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; }
.btn.big { --tap: 84px; min-height: 84px; min-width: 84px; }
.btn.big .icon { width: 2.4em; height: 2.4em; }

/* Matching */
.ex-center.match { gap: 28px; }
.match-letters, .match-pics { display: grid; gap: 14px; width: 100%; max-width: 720px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.match-tile {
  aspect-ratio: 1.15; border: 0; border-radius: 26px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  background: hsl(var(--h) 90% 90%); box-shadow: 0 7px 0 hsl(var(--h) 55% 74%);
  font-size: clamp(56px, 15vw, 100px); line-height: 1; padding-bottom: .15em; color: var(--ink);
}
.match-tile.selected { outline: 5px solid var(--sun); transform: translateY(-4px); }
.match-tile.lifted { opacity: .35; }
.match-tile.used { visibility: hidden; }
.match-tile.ghost { position: fixed; z-index: 50; pointer-events: none; margin: 0; transform: scale(1.08); box-shadow: 0 16px 30px rgba(0,0,0,.18); }
.match-pic {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 150px; padding: 10px 6px; border-radius: 26px; cursor: pointer;
  background: var(--paper); border: 4px dashed var(--line); touch-action: manipulation;
}
.match-pic img { width: min(110px, 80%); aspect-ratio: 1; pointer-events: none; }
.match-pic .mword { font-size: clamp(24px, 6vw, 36px); line-height: 1.7; min-height: 1.7em; }
.match-pic.matched { border: 4px solid #8fd6b0; background: #effbf4; }

/* Find the letter */
.target-chip {
  display: grid; place-items: center; width: 110px; height: 110px; border-radius: 50%;
  background: hsl(var(--h) 90% 90%); box-shadow: 0 6px 0 hsl(var(--h) 55% 76%);
  font-size: 72px; line-height: 1; padding-bottom: .12em; color: hsl(var(--h) 55% 30%);
}
.find-grid { display: grid; gap: 14px; width: 100%; max-width: 640px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .find-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 960px; } }
.find-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px;
  border-radius: 26px; border: 4px solid var(--line); background: var(--paper); cursor: pointer; touch-action: manipulation;
}
.find-card img { width: min(110px, 75%); aspect-ratio: 1; pointer-events: none; }
.find-card .fword { font-size: clamp(28px, 7vw, 40px); line-height: 1.8; }
.find-card.found { border-color: #8fd6b0; background: #effbf4; }
.find-pic { width: min(170px, 45vw); aspect-ratio: 1; }
.tap-word {
  font-size: clamp(72px, 22vw, 150px); line-height: 1.6; padding: 0 24px; cursor: pointer;
  background: var(--paper); border-radius: 28px; box-shadow: var(--shadow); user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.tap-word .hl { color: var(--hl); }
.pos-row { display: grid; gap: 12px; width: 100%; max-width: 640px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pos-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 96px; border: 0; border-radius: 24px; cursor: pointer; font-weight: 800;
  background: var(--paper); box-shadow: 0 6px 0 var(--line); touch-action: manipulation;
}
.pos-btn .pos-dots i { width: 22px; height: 22px; }
.pos-btn.playing { outline: 5px solid var(--sun); }
.pos-btn.right { background: #d9f5e6; }

/* Start overlay (browsers that block sound until the first tap) */
.start-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(255, 248, 236, .82); backdrop-filter: blur(3px); }
.start-btn {
  width: 180px; height: 180px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--teal); box-shadow: 0 10px 0 var(--teal-deep); display: grid; place-items: center;
  animation: pulse 1.4s ease-in-out infinite;
}
.start-btn .icon { width: 110px; height: 110px; filter: brightness(0) invert(1); }

/* End of round */
.ex-end { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px 0 40px; text-align: center; }
.ex-end .party { width: 140px; height: 140px; animation: pop .5s ease-out both; }
.ex-end .stars-big .star .icon { width: clamp(64px, 18vw, 96px); height: clamp(64px, 18vw, 96px); }
.end-actions { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }

/* Feedback animations */
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes win { 0% { transform: scale(1); } 35% { transform: scale(1.1) rotate(-2deg); } 70% { transform: scale(.97); } 100% { transform: scale(1); } }
.shake { animation: shake .45s ease-in-out; }
.win { animation: win .5s ease-out; }

/* ===== Review page ===== */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tab {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 76px; padding: 8px 12px;
  border: 0; border-radius: 22px; cursor: pointer; font-weight: 800; background: var(--paper); box-shadow: 0 5px 0 var(--line);
}
.tab .icon { width: 40px; height: 40px; }
.tab .tab-glyph { font-size: 30px; line-height: 1; }
.tab.active { background: #fff3c4; box-shadow: 0 5px 0 var(--sun-deep); }
.pick-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (min-width: 600px) { .pick-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.pick {
  --h: 30; width: 100%; min-height: 72px; border: 3px solid transparent; border-radius: 18px; cursor: pointer;
  font-family: var(--font-ar); font-size: 40px; line-height: 1.3; color: var(--ink-soft);
  background: #f3ede4; opacity: .7; touch-action: manipulation;
}
.pick.on { opacity: 1; color: hsl(var(--h) 55% 28%); background: hsl(var(--h) 90% 88%); border-color: hsl(var(--h) 55% 60%); box-shadow: 0 4px 0 hsl(var(--h) 55% 74%); }
.pick-tools { display: flex; gap: 12px; justify-content: center; margin-top: 14px; }
.pick-tools .btn { font-size: .95em; }
.group-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.group-card {
  min-height: 96px; border: 3px solid transparent; border-radius: 22px; cursor: pointer; font-size: clamp(32px, 8vw, 42px); line-height: 1.4; white-space: nowrap;
  background: var(--bg); box-shadow: 0 5px 0 var(--line); touch-action: manipulation; word-spacing: .2em;
}
.group-card.on { background: #fff3c4; border-color: var(--sun-deep); box-shadow: 0 5px 0 var(--sun-deep); }
.chosen { text-align: center; font-size: 36px; line-height: 1.6; min-height: 1.6em; margin-bottom: 12px; word-spacing: .25em; }
.practice-tile[aria-disabled="true"] { filter: grayscale(.8); opacity: .5; box-shadow: none; }

/* ===== Grown-up gate ===== */
html.gated body > *:not(.gate) { visibility: hidden; }
.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: var(--gutter); background: var(--bg); }
.gate-card { width: min(420px, 100%); background: var(--paper); border-radius: 28px; box-shadow: var(--shadow); padding: 28px 24px; text-align: center; }
.gate-title { margin: 0 0 6px; font-weight: 800; font-size: 1.3em; }
.gate-q { display: block; font-size: 1.6em; font-weight: 800; margin: 10px 0 14px; }
.gate-in { width: 160px; min-height: var(--tap); font: inherit; font-size: 1.6em; text-align: center; border: 3px solid var(--line); border-radius: 18px; }
.gate-actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
.gate-note { color: var(--ink-soft); font-size: .85em; margin: 16px 0 0; }

/* ===== Teacher page ===== */
.teacher-page .block h3 { font-size: 1.05em; margin: 18px 0 8px; }
.muted { color: var(--ink-soft); }
.setting-row { display: flex; gap: 16px; align-items: center; }
.switch { flex: none; position: relative; width: 96px; height: 56px; border: 0; border-radius: 999px; background: #d9d0c3; cursor: pointer; }
.switch span { position: absolute; top: 6px; inset-inline-start: 6px; width: 44px; height: 44px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: inset-inline-start .2s; }
.switch[aria-checked="true"] { background: var(--teal); }
.switch[aria-checked="true"] span { inset-inline-start: 46px; }
.table-wrap { overflow-x: auto; }
.progress-table { border-collapse: collapse; width: 100%; font-size: .9em; }
.progress-table th, .progress-table td { border-bottom: 1px solid var(--line); padding: 4px 8px; text-align: center; white-space: nowrap; }
.progress-table th.ar { font-size: 1.6em; line-height: 1.4; }
.reset-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; }
.confirm { width: 100%; margin: 0; font-weight: 700; }
.link-list { padding-inline-start: 1.2em; }
.link-list li { margin-bottom: 8px; }
.voices { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.voices audio { display: block; width: 100%; margin-top: 6px; }
.steps { padding-inline-start: 1.4em; }
.steps li { margin-bottom: 6px; }
.vid-tool { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .vid-tool { grid-template-columns: 2fr 1fr 2fr; } }
.vid-tool input, .vid-tool select { min-height: 56px; font: inherit; padding: 0 12px; border: 3px solid var(--line); border-radius: 14px; background: #fff; width: 100%; }
.vid-out { display: grid; gap: 14px; margin-top: 14px; align-items: start; }
@media (min-width: 760px) { .vid-out { grid-template-columns: 240px 1fr; } }
.vid-out img { width: 100%; border-radius: 14px; }
pre { background: #f6f1e8; padding: 10px 12px; border-radius: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; font-size: .85em; }
code { background: #f6f1e8; padding: 1px 5px; border-radius: 6px; font-size: .9em; }

/* ===== Content review (printable) ===== */
.print-only { display: none; }
.print-letter { --h: 30; background: var(--paper); border-radius: 22px; box-shadow: var(--shadow); padding: 16px; margin-block: 16px; border-top: 8px solid hsl(var(--h) 70% 80%); }
.pl-head { display: flex; gap: 16px; align-items: flex-start; }
.pl-glyph { flex: none; display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%; background: hsl(var(--h) 90% 90%); font-size: 64px; line-height: 1; padding-bottom: .12em; }
.pl-head h2 { margin: 0; font-size: 1.2em; }
.pl-facts { margin: 2px 0; color: var(--ink-soft); font-weight: 700; font-size: .9em; }
.pl-desc { margin: 4px 0 0; font-size: 1.15em; }
.pl-forms { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin-top: 12px; }
.pl-form { display: flex; flex-direction: column; align-items: center; padding: 6px; border-radius: 14px; background: hsl(var(--h) 90% 96%); font-size: 1.1em; }
.pl-shape { font-size: 2em; line-height: 1.4; }
.pl-words { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); margin-top: 12px; }
.pl-word { display: flex; flex-direction: column; align-items: center; text-align: center; font-size: 1.15em; }
.pl-word img { width: 56px; height: 56px; }
.pl-word .muted { font-size: .7em; }
.pl-videos { margin: 10px 0 0; padding-inline-start: 1.2em; font-size: .9em; }
.pl-videos code { margin-inline-start: 8px; }
@media print {
  .print-only { display: block; font-size: 16pt; }
  .content-page { font-size: 11pt; }
  .print-letter { box-shadow: none; border: 1px solid #ccc; border-top: 6px solid hsl(var(--h) 60% 70%); break-inside: avoid; margin-block: 8px; padding: 10px; }
  .gate { display: none; }
}

/* ===== Who is playing? (child profiles) ===== */
.who-overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: var(--gutter); background: var(--bg); overflow-y: auto; }
.who-card { width: min(900px, 100%); text-align: center; }
.who-title { display: flex; align-items: center; justify-content: center; gap: 14px; font-weight: 800; font-size: 1.6em; margin-bottom: 18px; }
.who-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); margin-bottom: 18px; }
.who-btn { aspect-ratio: 1; border: 0; border-radius: 28px; cursor: pointer; background: var(--paper); box-shadow: 0 7px 0 var(--line); display: grid; place-items: center; touch-action: manipulation; }
.who-btn img { width: 78%; height: 78%; pointer-events: none; }
.who-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--line); }
.who-badge { width: var(--tap); height: var(--tap); border-radius: 50%; border: 3px solid var(--sun); background: var(--paper); padding: 6px; cursor: pointer; }
.who-badge img { width: 100%; height: 100%; }
.kids { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.kid { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; border-radius: 20px; background: var(--bg); min-width: 110px; font-weight: 800; }
.kid img { width: 72px; height: 72px; }
.kid .btn { min-height: 48px; font-size: .85em; padding: 0 14px; }
.avatar-pick { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.avatar-add { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 16px; background: #fff; cursor: pointer; padding: 6px; }
.avatar-add img { width: 100%; height: 100%; }
.kid-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.kid-tab { width: 64px; height: 64px; border-radius: 16px; border: 3px solid var(--line); background: #fff; padding: 6px; cursor: pointer; opacity: .6; }
.kid-tab.on { border-color: var(--sun-deep); opacity: 1; background: #fff3c4; }
.kid-tab img { width: 100%; height: 100%; }
/* The home title is also the hidden teacher entrance (hold 3 s): no text selection or callout on long press. */
#logo { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }

/* ===== Parent and teacher accounts (js/cloud.js, account.html, teacher.html «صفّي») ===== */
.who-btn.named { grid-template-rows: 1fr auto; padding-bottom: 8px; }
.who-btn.named img { width: 70%; height: 70%; align-self: end; }
.who-name { font-weight: 800; font-size: 1.05em; }
.acct-btn { background: var(--paper); box-shadow: 0 5px 0 var(--line); }
.acct-btn .icon { width: 2.2em; height: 2.2em; }
.welcome-card { max-width: 560px; }
.welcome-card h2 { margin: .2em 0 .6em; font-size: 1.7em; }
.welcome-logo { width: 96px; height: 96px; }
.welcome-choices { display: grid; gap: 16px; margin-block: 8px 14px; }
.btn.wchoice { justify-content: flex-start; text-align: start; padding: .6em 1.1em; border-radius: 26px; }
.btn.wchoice .icon { width: 2.6em; height: 2.6em; flex: none; }
.btn.wchoice span { display: flex; flex-direction: column; line-height: 1.35; }
.btn.wchoice b { font-size: 1.15em; }
.btn.wchoice small { font-weight: 500; font-size: .78em; opacity: .9; }
.welcome-msg { min-height: 1.6em; font-weight: 700; color: var(--coral-deep); }
.acct-kids { display: grid; gap: 12px; margin-block: 8px 14px; }
.acct-kid { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px; border-radius: 20px; background: var(--bg); }
.acct-kid > img { width: 64px; height: 64px; flex: none; }
.acct-kid-info { display: flex; flex-direction: column; gap: 2px; flex: 1 1 180px; min-width: 0; }
.acct-kid-info b { font-size: 1.15em; }
.acct-kid-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.acct-kid-actions .btn, .acct-join .btn, .acct-kid > .btn { min-height: 48px; font-size: .9em; padding: 0 16px; }
.acct-join { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex-basis: 100%; }
.acct-join input, .acct-form input { font: inherit; min-height: 52px; padding: 0 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; }
.acct-form { display: grid; gap: 10px; max-width: 640px; }
.acct-form .btn { justify-self: start; }
.avatar-add.on { border: 3px solid var(--teal); background: #e3f7f3; }
.avatar-add:disabled { opacity: .25; cursor: default; }
.tag { align-self: flex-start; font-size: .82em; font-weight: 700; padding: 1px 10px; border-radius: 999px; background: var(--line); }
.tag.ok { background: #d8f3ec; color: var(--teal-deep); }
.tag.wait { background: #fff1c9; color: #8a5a00; }
.invite-box { display: grid; gap: 10px; padding: 14px; border-radius: 18px; background: var(--bg); margin-bottom: 10px; }
.invite-box code { word-break: break-all; font-size: .95em; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.invite-actions .btn, #t-sign-out { min-height: 48px; font-size: .9em; padding: 0 16px; }
.kid-name { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; font-weight: 800; padding: 4px; border-radius: 12px; text-align: start; }
.kid-name img { width: 40px; height: 40px; flex: none; max-width: none; }
.kid-name.on { background: #fff3c4; }
.class-table td.ar { font-size: 1.2em; letter-spacing: .15em; }
#child-detail h3 { display: flex; align-items: center; gap: 8px; }
#child-detail h3 img { width: 48px; height: 48px; }
.class-table th, .class-table td { white-space: nowrap; }
.class-table .kid-name span { white-space: nowrap; flex: none; }
