* {
  box-sizing: border-box;
}

:root {
  --sky-0: #071018;
  --sky-1: #10253a;
  --sky-2: #17324d;
  --gold: #f4c14e;
  --gold-2: #ffe08a;
  --mint: #7ee0c8;
  --coral: #ff8b7a;
  --cream: #fff6e0;
  --ink: #102033;
  --muted: rgba(255, 246, 224, 0.72);
  --card: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 246, 224, 0.14);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --nav: 76px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-ui: "Nunito", "Avenir Next", sans-serif;
  --font-display: "Fredoka", "Nunito", sans-serif;
  --font-arabic: "Noto Naskh Arabic", "Amiri", "Geeza Pro", serif;
  --arabic-size: 2rem;
  --arabic-size-xl: 2.35rem;
  --arabic-size-choice: 1.05rem;
  --arabic-size-prompt: 1.7rem;
  --arabic-size-tile: 1.25rem;
  --arabic-line: 1.8;
  --arabic-weight: 700;
  --arabic-word-space: 0em;
}

html.clear-arabic {
  --font-arabic: "Scheherazade New", "Noto Naskh Arabic", "Amiri", "Geeza Pro", serif;
  --arabic-size: 2.65rem;
  --arabic-size-xl: 3.2rem;
  --arabic-size-choice: 1.55rem;
  --arabic-size-prompt: 2.25rem;
  --arabic-size-tile: 1.7rem;
  --arabic-line: 2.2;
  --arabic-weight: 700;
  --arabic-word-space: 0.22em;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  background: var(--sky-0);
  color: var(--cream);
  font-family: var(--font-ui);
  overflow: hidden;
  overscroll-behavior: none;
}

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

button {
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: pan-y;
}

img {
  max-width: 100%;
}

#app,
.sky,
.shell {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
}

.sky {
  background:
    radial-gradient(circle at 12% 8%, rgba(244, 193, 78, 0.18), transparent 22%),
    radial-gradient(circle at 88% 0%, rgba(126, 224, 200, 0.12), transparent 24%),
    radial-gradient(circle at 50% 100%, rgba(155, 140, 255, 0.16), transparent 32%),
    linear-gradient(180deg, #071018 0%, #10253a 58%, #0b1c2c 100%);
}

.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(255, 246, 224, 0.9), transparent),
    radial-gradient(1.5px 1.5px at 28% 72%, rgba(255, 246, 224, 0.55), transparent),
    radial-gradient(2px 2px at 80% 22%, rgba(255, 224, 138, 0.9), transparent),
    radial-gradient(1px 1px at 62% 40%, rgba(255, 246, 224, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 90% 78%, rgba(126, 224, 200, 0.8), transparent),
    radial-gradient(1px 1px at 40% 12%, rgba(255, 246, 224, 0.65), transparent);
  opacity: 0.8;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding-top: calc(12px + var(--safe-top));
}

.screen-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 18px 28px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.topbar,
.lesson-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 18px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand h1,
.screen-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}

.moon {
  width: 42px;
  height: 42px;
  filter: drop-shadow(0 0 10px rgba(244, 193, 78, 0.45));
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 0.92rem;
}

.child-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.chip.switch {
  min-height: 44px;
  cursor: pointer;
}

.chip.switch.on {
  background: rgba(244, 193, 78, 0.22);
  border-color: var(--gold);
  color: var(--gold-2);
}

.greeting {
  margin: 0 0 6px;
  font-size: 1.7rem;
  font-family: var(--font-display);
}

.muted {
  color: var(--muted);
  margin: 0;
}

.hero-card,
.card,
.setup-card,
.badge-card,
.ayah-row,
.parent-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.hero-card {
  padding: 22px 20px 18px;
  background:
    radial-gradient(circle at 90% 10%, rgba(244, 193, 78, 0.28), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(16, 37, 58, 0.35));
}

.kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--gold-2);
}

.arabic {
  font-family: var(--font-arabic);
  font-size: var(--arabic-size);
  font-weight: var(--arabic-weight);
  line-height: var(--arabic-line);
  word-spacing: var(--arabic-word-space);
  direction: rtl;
  text-align: right;
  margin: 8px 0 10px;
}

.arabic.xl {
  font-size: var(--arabic-size-xl);
}

.ar-word {
  display: inline;
  border-radius: 0.35em;
  padding: 0 0.08em;
}

.ar-word.on {
  background: rgba(244, 193, 78, 0.45);
  color: #fffdf4;
  box-shadow: 0 0 0 2px rgba(244, 193, 78, 0.18);
}

.transliteration {
  margin: 0 0 8px;
  color: var(--gold-2);
  font-weight: 700;
}

.meaning {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.row-actions,
.stats,
.week,
.setup-actions,
.choice-grid {
  display: grid;
  gap: 10px;
}

.stats {
  grid-template-columns: repeat(3, 1fr);
  margin: 14px 0 18px;
}

.stat {
  text-align: center;
  padding: 12px 8px;
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--line);
}

.stat b {
  display: block;
  font-size: 1.35rem;
  font-family: var(--font-display);
}

.stat span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.btn {
  min-height: 58px;
  padding: 0 18px;
  border-radius: 20px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: var(--ink);
  width: 100%;
  box-shadow: 0 10px 24px rgba(244, 193, 78, 0.28);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  width: 100%;
}

.btn.ghost {
  min-height: 44px;
  padding: 0 10px;
  color: var(--cream);
}

.btn.good {
  background: linear-gradient(180deg, #b8f4d8, var(--mint));
  color: var(--ink);
  width: 100%;
}

.btn.warn {
  background: rgba(255, 139, 122, 0.16);
  border: 1px solid rgba(255, 139, 122, 0.4);
}

.week {
  grid-template-columns: repeat(7, 1fr);
  margin: 16px 0 8px;
}

.day {
  text-align: center;
  padding: 8px 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.75rem;
  font-weight: 800;
}

.day.on {
  background: rgba(244, 193, 78, 0.2);
  color: var(--gold-2);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 8px 2px 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 1.1rem;
  font-family: var(--font-display);
}

.path {
  display: grid;
  gap: 12px;
  padding-bottom: 8px;
}

.path-node,
.ayah-row,
.pick {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  color: inherit;
  text-decoration: none;
  touch-action: pan-y;
}

.path-node {
  padding: 14px;
  border-radius: 24px;
  background: var(--card);
  border: 1px solid var(--line);
}

.path-node.locked {
  opacity: 0.55;
}

.path-orb {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid var(--line);
}

.path-node.today {
  border-color: var(--gold);
  background: rgba(244, 193, 78, 0.16);
  box-shadow: 0 0 0 1px var(--gold);
}

.path-node.done {
  border-color: rgba(126, 224, 200, 0.55);
}

.path-node.upcoming:not(.today):not(.done) {
  opacity: 0.72;
}

.path-node.today .path-orb,
.path-node.done .path-orb {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(244, 193, 78, 0.35);
}

.path-node.done .path-orb {
  border-color: var(--mint);
  box-shadow: 0 0 16px rgba(126, 224, 200, 0.28);
}

.path-copy {
  flex: 1;
  min-width: 0;
}

.path-copy h3,
.ayah-row h3 {
  margin: 0 0 2px;
  font-size: 1.05rem;
}

.path-copy p,
.ayah-row p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.nav {
  flex-shrink: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: rgba(7, 16, 24, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
  z-index: 5;
}

.nav button {
  min-height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.nav button.on {
  color: var(--gold-2);
  background: rgba(244, 193, 78, 0.1);
}

.nav svg {
  width: 22px;
  height: 22px;
}

.setup-card {
  margin-top: 8px;
}

.pick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 8px;
}

.pick {
  min-height: 78px;
  padding: 12px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  display: block;
}

.pick b {
  display: block;
  font-size: 0.95rem;
}

.pick span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.pick.on {
  border-color: var(--gold);
  background: rgba(244, 193, 78, 0.18);
  box-shadow: 0 0 0 1px var(--gold);
}

.pick.known {
  border-color: var(--mint);
}

.pronoun-grid {
  grid-template-columns: 1fr 1fr;
}

.pronoun-grid .pick {
  min-height: 72px;
  text-align: center;
}

.setup-card {
  margin-top: 24px;
}

.setup-card h1 {
  font-family: var(--font-display);
  font-size: 2.1rem;
  margin: 10px 0 8px;
}

.name-input {
  width: 100%;
  min-height: 58px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  padding: 0 16px;
  font-size: 1.15rem;
  margin: 16px 0;
}

.play-wrap {
  display: grid;
  justify-items: center;
  margin: 8px 0 16px;
}

.play {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: var(--ink);
  font-size: 2rem;
  box-shadow: 0 12px 30px rgba(244, 193, 78, 0.35);
}

.play.mini {
  width: 64px;
  height: 64px;
  font-size: 1.4rem;
  flex: 0 0 auto;
}

.listen-list {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.listen-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: stretch;
}

.listen-card .choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 4px;
}

.choice-arabic {
  font-family: var(--font-arabic);
  font-size: var(--arabic-size-choice);
  font-weight: var(--arabic-weight);
  line-height: var(--arabic-line);
  word-spacing: var(--arabic-word-space);
  opacity: 0.95;
}

.btn.skip {
  width: 100%;
  margin-top: 8px;
  opacity: 0.8;
}

.bead-wrap {
  margin: 8px 0 12px;
}

.bead-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.beads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ayah-stepper {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}

.ayah-stepper .greeting {
  margin: 0;
  text-align: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn.secondary:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn.ghost.ayah-step {
  width: 52px;
  min-height: 52px;
  padding: 0;
  position: relative;
  z-index: 1;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: var(--ink);
  border: 0;
  font-size: 1.35rem;
  box-shadow: 0 8px 18px rgba(244, 193, 78, 0.28);
}

.btn.ghost.ayah-step:disabled {
  opacity: 1;
  cursor: default;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  box-shadow: none;
}

.bead {
  min-width: 44px;
  height: 44px;
  padding: 0 8px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.bead:focus-visible,
.ayah-step:focus-visible {
  outline: 2px solid var(--gold-2);
  outline-offset: 2px;
}

.bead.on {
  background: rgba(126, 224, 200, 0.2);
  border-color: var(--mint);
  color: var(--mint);
}

.bead.now {
  background: rgba(244, 193, 78, 0.22);
  border-color: var(--gold);
  color: var(--gold-2);
}

.passage-list {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.passage-ayah {
  padding: 14px 16px;
}

.passage-ayah .arabic {
  font-size: var(--arabic-size);
  margin: 4px 0;
}

.passage-index {
  margin: 0;
  font-weight: 800;
  color: var(--gold-2);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.passage-ayah.now {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
}

.tiles,
.picked {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  direction: rtl;
}

.tile {
  min-height: 56px;
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  font-family: var(--font-arabic);
  font-size: var(--arabic-size-tile);
  font-weight: var(--arabic-weight);
}

.tile.used {
  opacity: 0.35;
}

.prompt-arabic {
  font-family: var(--font-arabic);
  font-size: var(--arabic-size-prompt);
  font-weight: var(--arabic-weight);
  direction: rtl;
  text-align: center;
  line-height: var(--arabic-line);
  word-spacing: var(--arabic-word-space);
  margin: 0 0 16px;
}

.blank {
  display: inline-block;
  min-width: 70px;
  border-bottom: 3px dashed var(--gold);
}

.choice-grid {
  grid-template-columns: 1fr;
}

.choice {
  min-height: 64px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  font-family: var(--font-arabic);
  font-size: var(--arabic-size-choice);
  font-weight: var(--arabic-weight);
  padding: 12px;
}

.choice.correct {
  background: rgba(126, 224, 200, 0.25);
  border-color: var(--mint);
}

.choice.wrong {
  animation: shake 0.4s ease;
  background: rgba(255, 139, 122, 0.18);
}

.celebrate {
  text-align: center;
  padding-top: 18px;
}

.star-row {
  font-size: 2.6rem;
  letter-spacing: 8px;
  margin: 10px 0 16px;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.badge-card {
  min-height: 150px;
}

.badge-card.locked {
  opacity: 0.45;
}

.badge-card h3 {
  margin: 10px 0 6px;
  font-size: 1rem;
}

.ios-tip {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(126, 224, 200, 0.12);
  border: 1px solid rgba(126, 224, 200, 0.28);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav) + 18px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--cream);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 16px;
  font-weight: 800;
  z-index: 10;
  box-shadow: var(--shadow);
}

.confetti i {
  position: fixed;
  top: -10px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: fall 1.1s ease-in forwards;
  z-index: 8;
  pointer-events: none;
}

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

@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes fall {
  to {
    transform: translateY(110dvh) rotate(220deg);
    opacity: 0.2;
  }
}

@media (min-width: 800px) {
  .choice-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .arabic.xl { font-size: calc(var(--arabic-size-xl) * 0.78); }
  .play { width: 72px; height: 72px; }
  .greeting { font-size: 1.3rem; }
}
