:root {
  --vert: #1d4d3f;
  --vert-clair: #2f6f5c;
  --or: #c8963e;
  --sable: #f7f1e6;
  --carte: #ffffff;
  --texte: #1f2a26;
  --doux: #5d6b65;
  --trait: #e6dcc8;
  --ok: #2f7d4f;
  --faux: #b3412e;
  --rayon: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Mulish", system-ui, -apple-system, sans-serif;
  background: var(--sable);
  color: var(--texte);
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }
.ar { font-family: "Amiri", serif; direction: rtl; }
.coran { font-family: "Amiri Quran", "Amiri", serif; direction: rtl; }

/* Barre du haut */
.barre {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  padding-left: calc(env(safe-area-inset-left) + 16px);
  padding-right: calc(env(safe-area-inset-right) + 16px);
  background: var(--vert); color: #fff;
}
.barre h1 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: .2px; }
.retour {
  border: 0; background: rgba(255,255,255,.15); color: #fff;
  width: 40px; height: 40px; border-radius: 50%; font-size: 20px; flex: none;
}
main {
  max-width: 760px; margin: 0 auto;
  padding: 18px 16px 40px;
  padding-left: calc(env(safe-area-inset-left) + 16px);
  padding-right: calc(env(safe-area-inset-right) + 16px);
  outline: none;
}

/* Éléments communs */
.carte {
  background: var(--carte); border-radius: var(--rayon);
  padding: 18px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(40,30,10,.08);
}
.intro { color: var(--doux); margin: 0 0 16px; }
h2 { font-size: 21px; margin: 0 0 10px; }
h3 { font-size: 17px; margin: 0 0 6px; }
.pilule {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 11px 20px;
  background: var(--vert); color: #fff; font-weight: 700; min-height: 46px;
}
.pilule.claire { background: #fff; color: var(--vert); border: 2px solid var(--vert); }
.pilule.or { background: var(--or); }
.pilule:disabled { opacity: .45; }
.rangee { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.rangee.entre { justify-content: space-between; }
.petit { font-size: 14px; color: var(--doux); }
.savais {
  background: #fbf5e8; border-left: 5px solid var(--or);
  border-radius: 12px; padding: 14px 16px; margin-top: 14px;
}
.savais h3 { color: #8a6420; }
.source { font-size: 13px; color: var(--doux); margin-top: 8px; }
.source a { color: var(--vert-clair); }

/* Accueil */
.parcours { display: grid; gap: 14px; }
.etape {
  display: flex; align-items: center; gap: 16px; text-align: left;
  border: 0; width: 100%; background: var(--carte);
  border-radius: var(--rayon); padding: 18px;
  box-shadow: 0 1px 3px rgba(40,30,10,.08);
}
.etape .num {
  flex: none; width: 54px; height: 54px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--vert); color: #fff; font-size: 30px;
}
.etape .txt { flex: 1; }
.etape .txt b { display: block; font-size: 18px; }
.barre-prog { height: 8px; background: var(--trait); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.barre-prog i { display: block; height: 100%; background: var(--or); border-radius: 99px; }

/* Grille des lettres */
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; direction: rtl; }
.case {
  position: relative; border: 0; background: var(--carte);
  border-radius: 16px; padding: 8px 4px 6px; direction: ltr;
  box-shadow: 0 1px 3px rgba(40,30,10,.08);
}
.case .ar { font-size: 38px; line-height: 1.6; display: block; }
.case small { font-size: 12px; color: var(--doux); display: block; }
.case.su { background: #e9f3ee; }
.case.su::after {
  content: "✓"; position: absolute; top: 4px; left: 8px;
  color: var(--ok); font-weight: 800; font-size: 14px;
}

/* Fiche lettre */
.grande { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.grande .ar { font-size: 120px; line-height: 1.35; color: var(--vert); display: block; }
.nom-lettre { font-size: 26px; font-weight: 800; }
.ecouter {
  border: 0; border-radius: 999px; background: var(--or); color: #fff;
  font-weight: 800; padding: 12px 22px; min-height: 48px;
}
.formes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; direction: rtl; }
.forme { background: var(--sable); border-radius: 14px; text-align: center; padding: 6px 2px; direction: ltr; }
.forme .ar { font-size: 44px; line-height: 1.4; display: block; }
.forme small { font-size: 12px; color: var(--doux); }
.exemple { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.exemple .coran { font-size: 40px; color: var(--vert); }

/* Zone d'écriture */
.ardoise-cadre { position: relative; border-radius: 16px; overflow: hidden; background: #fffdf8; border: 2px dashed var(--trait); }
canvas.ardoise { display: block; width: 100%; height: 260px; touch-action: none; }

/* Quiz */
.question { text-align: center; }
.question .ar { font-size: 90px; color: var(--vert); line-height: 1.3; }
.choix { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.choix button {
  border: 2px solid var(--trait); background: #fff; border-radius: 16px;
  padding: 12px; min-height: 64px; font-weight: 700;
}
.choix button .ar { font-size: 40px; line-height: 1.2; }
.choix button.bon { border-color: var(--ok); background: #e7f4ec; }
.choix button.mauvais { border-color: var(--faux); background: #fbeae6; }
.score { font-weight: 800; color: var(--vert); }

/* Voyelles */
.syllabes { display: grid; gap: 10px; }
.syl-ligne { display: flex; align-items: center; gap: 8px; background: var(--carte); border-radius: 16px; padding: 8px 12px; direction: rtl; }
.syl-ligne .lettre { font-size: 34px; width: 54px; text-align: center; color: var(--doux); }
.syl-ligne button {
  flex: 1; border: 0; background: var(--sable); border-radius: 12px;
  padding: 4px 0; direction: ltr;
}
.syl-ligne button .ar { font-size: 36px; line-height: 1.4; display: block; }
.syl-ligne button small { font-size: 12px; color: var(--doux); }
.signes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.signe { background: var(--sable); border-radius: 14px; padding: 12px; }
.signe .ar { font-size: 48px; line-height: 1.9; color: var(--vert); display: block; }

/* Sourates */
.sourate-btn {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  border: 0; background: var(--carte); border-radius: var(--rayon);
  padding: 14px 16px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(40,30,10,.08);
}
.sourate-btn .rang {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--sable); display: grid; place-items: center; font-weight: 800; color: var(--vert);
}
.sourate-btn .txt { flex: 1; }
.sourate-btn .coran { font-size: 28px; color: var(--vert); }
.sourate-btn.su .rang { background: var(--ok); color: #fff; }
.entete-sourate { text-align: center; }
.entete-sourate .coran { font-size: 46px; color: var(--vert); line-height: 1.5; }
.reglages { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.bascule {
  border: 2px solid var(--trait); background: #fff; border-radius: 999px;
  padding: 7px 14px; font-size: 14px; font-weight: 700;
}
.bascule.actif { border-color: var(--vert); background: var(--vert); color: #fff; }
.verset { background: var(--carte); border-radius: var(--rayon); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(40,30,10,.08); }
.verset.joue { outline: 3px solid var(--or); }
.mots { display: flex; flex-wrap: wrap; gap: 8px; direction: rtl; }
.mot {
  border: 0; background: var(--sable); border-radius: 14px;
  padding: 6px 10px 8px; text-align: center; direction: ltr; min-width: 64px;
}
.mot .coran { font-size: 34px; line-height: 2.1; display: block; }
.mot .tr, .mot .fr { margin-top: 2px; }
#bism .fr { margin-top: 10px; }
.mot .tr { font-size: 13px; color: var(--vert-clair); font-style: italic; display: block; }
.mot .fr { font-size: 13px; color: var(--doux); display: block; max-width: 140px; }
.mot.note { box-shadow: inset 0 -3px 0 var(--or); }
.mot.joue { background: #f3e3c3; }
.mot.cache .coran { color: transparent; text-shadow: 0 0 14px rgba(29,77,63,.55); }
.mot.cache .tr, .mot.cache .fr { visibility: hidden; }
.trad { margin: 10px 0 0; color: var(--doux); font-size: 15px; }
.num-verset {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--or); color: #8a6420; font-weight: 800; font-size: 13px;
}
.fenetre {
  position: fixed; z-index: 30;
  left: calc(env(safe-area-inset-left) + 12px); right: calc(env(safe-area-inset-right) + 12px);
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  max-width: 640px; margin: 0 auto; max-height: 60%; overflow: auto;
  background: #fff; border-radius: 20px; padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.fenetre .fermer { float: right; border: 0; background: var(--sable); border-radius: 50%; width: 36px; height: 36px; }

@media (max-width: 420px) {
  .grande .ar { font-size: 96px; }
  .mot .coran { font-size: 30px; }
  .grande .ar { line-height: 1.35; }
  .formes .forme .ar { font-size: 38px; }
}
