/* =========================================================
   أتعلم العربية  |  style.css
   Thème : Nuit Magique — Indigo & Or
   ========================================================= */

:root {
  /* — Backgrounds — */
  --bg:              #06091a;
  --bg-mid:          #0d1130;
  --surface:         rgba(255, 255, 255, 0.055);
  --surface-hover:   rgba(255, 255, 255, 0.10);
  --border:          rgba(255, 255, 255, 0.10);
  --border-hover:    rgba(255, 255, 255, 0.28);

  /* — Brand palette — */
  --gold:            #fbbf24;
  --gold-dk:         #d97706;
  --gold-lt:         rgba(251, 191, 36, 0.12);
  --teal:            #34d399;
  --teal-lt:         rgba(52, 211, 153, 0.12);
  --rose:            #f472b6;
  --rose-lt:         rgba(244, 114, 182, 0.12);
  --indigo:          #818cf8;
  --indigo-lt:       rgba(129, 140, 248, 0.12);

  /* — Feedback — */
  --green:           #4ade80;
  --green-lt:        rgba(74, 222, 128, 0.15);
  --red:             #f87171;
  --red-lt:          rgba(248, 113, 113, 0.15);

  /* — Text — */
  --text:            #f0e6d3;
  --text-muted:      rgba(240, 230, 211, 0.55);
  --text-dim:        rgba(240, 230, 211, 0.30);

  /* — Radii — */
  --r-sm:  10px;
  --r-md:  18px;
  --r-lg:  26px;
  --r-xl:  40px;

  /* — Shadows — */
  --shadow-sm:  0 2px 12px rgba(0, 0, 0, 0.45);
  --shadow-md:  0 8px 32px rgba(0, 0, 0, 0.55);
  --shadow-lg:  0 20px 60px rgba(0, 0, 0, 0.65);

  /* — Fonts — */
  --font:         'Baloo 2', system-ui, sans-serif;
  --font-display: 'Amiri', serif;
  --font-arabic:  'Noto Naskh Arabic', serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;       /* fallback */
  min-height: 100dvh;      /* moderne */
  overflow-x: hidden;
}

/* ── Screens ── */
.screen        { min-height: 100vh; min-height: 100dvh; }
.screen.hidden { display: none !important; }
.screen.active { display: block; }


/* ═══════════════════════════════════════════════
   PROFILE SCREEN
   ═══════════════════════════════════════════════ */

.profile-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 2rem 1.5rem 3rem;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 25% 20%,  rgba(99,  102, 241, 0.22) 0%, transparent 55%),
    radial-gradient(ellipse at 78% 75%,  rgba(139,  92, 246, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 55% 50%,  rgba( 15,  23,  42, 0.90) 0%, transparent 100%),
    linear-gradient(160deg, #07091c 0%, #0d1130 50%, #12082a 100%);
}

/* Star-dot field */
.profile-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.85) 0.5px, transparent 0.5px),
    radial-gradient(circle, rgba(255,255,255,0.55) 0.5px, transparent 0.5px),
    radial-gradient(circle, rgba(255,255,255,0.40) 0.5px, transparent 0.5px);
  background-size: 120px 120px, 175px 175px, 245px 245px;
  background-position: 18px 14px, 58px 78px, 128px 38px;
  pointer-events: none;
  animation: stars-drift 200s linear infinite;
}

/* Concentric glow rings */
.profile-container::after {
  content: '';
  position: absolute;
  width: 650px; height: 650px;
  border-radius: 50%;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(251,191,36, 0.05);
  box-shadow:
    0 0 0 80px  rgba(251,191,36, 0.025),
    0 0 0 160px rgba(251,191,36, 0.015),
    0 0 0 240px rgba(251,191,36, 0.008);
  pointer-events: none;
}

/* — Decorative floaters — */
.profile-deco { position: absolute; inset: 0; pointer-events: none; }

.deco-moon {
  position: absolute;
  font-size: 5.5rem;
  top: 4%; right: 7%;
  animation: float 7s ease-in-out infinite;
  filter: drop-shadow(0 0 24px rgba(251,191,36,0.55));
}

.deco-star {
  position: absolute;
  color: rgba(251,191,36, 0.75);
  animation: twinkle 3s ease-in-out infinite;
}
.deco-star.s1 { top:  7%; left: 11%; font-size: 1.5rem; animation-delay: 0.0s; }
.deco-star.s2 { top: 19%; right:17%; font-size: 1.0rem; animation-delay: 0.9s; }
.deco-star.s3 { top: 58%; left:  6%; font-size: 1.2rem; animation-delay: 1.7s; }
.deco-star.s4 { top: 72%; right: 9%; font-size: 0.8rem; animation-delay: 0.4s; }
.deco-star.s5 { top: 44%; left: 16%; font-size: 0.7rem; animation-delay: 2.3s; }
.deco-star.s6 { top: 85%; left: 40%; font-size: 0.9rem; animation-delay: 1.1s; }

/* Geometric arabesque circles */
.deco-geo {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(251,191,36, 0.08);
  pointer-events: none;
}
.deco-geo.g1 {
  width: 180px; height: 180px;
  top: -60px; left: -60px;
  box-shadow: inset 0 0 0 25px rgba(251,191,36,0.04),
              inset 0 0 0 50px rgba(251,191,36,0.02);
}
.deco-geo.g2 {
  width: 140px; height: 140px;
  bottom: -40px; right: -30px;
  box-shadow: inset 0 0 0 20px rgba(129,140,248,0.05),
              inset 0 0 0 45px rgba(129,140,248,0.02);
  border-color: rgba(129,140,248,0.08);
}

/* — Profile content — */
.profile-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
}

.app-title {
  font-family: var(--font-arabic);
  font-size: clamp(2.4rem, 9vw, 3.8rem);
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 50px rgba(251,191,36,0.5), 0 2px 6px rgba(0,0,0,0.6);
  margin-bottom: .25rem;
  letter-spacing: .02em;
  animation: fadeDown .7s cubic-bezier(.4,0,.2,1) both;
}

.tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  animation: fadeDown .7s .1s cubic-bezier(.4,0,.2,1) both;
}

.choose-label {
  font-size: .78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 700;
  margin-bottom: 1.2rem;
  animation: fadeDown .7s .2s cubic-bezier(.4,0,.2,1) both;
}

/* — Profile cards — */
.profile-cards {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 530px;
  animation: fadeDown .7s .3s cubic-bezier(.4,0,.2,1) both;
}

.profile-card {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.9rem 1.3rem 1.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  flex: 1 1 145px;
  max-width: 170px;
  color: var(--text);
  font-family: var(--font);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1),
              border-color .25s,
              box-shadow .25s;
  overflow: hidden;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.card-glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}

/* Couleurs cycliques pour profils dynamiques */
.profile-card--c0 { border-color: rgba(251,191,36, 0.30); }
.profile-card--c0 .card-glow { background: radial-gradient(ellipse at 50% 0%, rgba(251,191,36, 0.35) 0%, transparent 70%); }
.profile-card--c0:not(.is-editing):hover { border-color: rgba(251,191,36, 0.80); box-shadow: 0 0 45px rgba(251,191,36, 0.30), 0 14px 44px rgba(0,0,0,0.55); }

.profile-card--c1 { border-color: rgba(52, 211,153, 0.30); }
.profile-card--c1 .card-glow { background: radial-gradient(ellipse at 50% 0%, rgba(52, 211,153, 0.35) 0%, transparent 70%); }
.profile-card--c1:not(.is-editing):hover { border-color: rgba(52, 211,153, 0.80); box-shadow: 0 0 45px rgba(52, 211,153, 0.30), 0 14px 44px rgba(0,0,0,0.55); }

.profile-card--c2 { border-color: rgba(244,114,182, 0.30); }
.profile-card--c2 .card-glow { background: radial-gradient(ellipse at 50% 0%, rgba(244,114,182, 0.35) 0%, transparent 70%); }
.profile-card--c2:not(.is-editing):hover { border-color: rgba(244,114,182, 0.80); box-shadow: 0 0 45px rgba(244,114,182, 0.30), 0 14px 44px rgba(0,0,0,0.55); }

.profile-card--c3 { border-color: rgba(129,140,248, 0.30); }
.profile-card--c3 .card-glow { background: radial-gradient(ellipse at 50% 0%, rgba(129,140,248, 0.35) 0%, transparent 70%); }
.profile-card--c3:not(.is-editing):hover { border-color: rgba(129,140,248, 0.80); box-shadow: 0 0 45px rgba(129,140,248, 0.30), 0 14px 44px rgba(0,0,0,0.55); }

.profile-card:not(.is-editing):hover { transform: translateY(-7px) scale(1.05); }
.profile-card:not(.is-editing):hover .card-glow { opacity: 1; }

/* Mode édition */
.profile-card.is-editing { cursor: default; }

.card-edit-actions {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(6, 9, 26, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .9rem;
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
}

.card-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 46px; height: 46px;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.card-action.reset:hover  { border-color: rgba(251,191,36,.8);  background: var(--gold-lt); }
.card-action.delete:hover { border-color: rgba(248,113,113,.8); background: var(--red-lt); }

/* Carte Ajouter */
.add-card {
  border-style: dashed;
  border-color: rgba(255,255,255,.14) !important;
  background: rgba(255,255,255,.03) !important;
  box-shadow: none !important;
}
.add-card:hover {
  border-color: rgba(251,191,36,.45) !important;
  background: var(--gold-lt) !important;
  transform: translateY(-7px) scale(1.05) !important;
}
.add-icon { font-size: 2.2rem; color: var(--text-dim); }

/* Bouton Modifier */
.profile-manage-row {
  margin-top: 1.2rem;
  display: flex;
  justify-content: center;
  animation: fadeDown .7s .4s cubic-bezier(.4,0,.2,1) both;
}
.btn-manage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: .45rem 1.2rem;
  font-family: var(--font);
  font-size: .82rem; font-weight: 700;
  color: var(--text-muted); cursor: pointer;
  transition: all .15s;
}
.btn-manage:hover { border-color: var(--border-hover); color: var(--text); }

/* ─── Modals ─── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn .15s ease;
}
.modal-backdrop.hidden { display: none !important; }

.modal-box {
  background: #0d1130;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.8rem;
  width: 100%; max-width: 370px;
  display: flex; flex-direction: column; gap: 1rem;
  box-shadow: var(--shadow-lg);
  animation: fadeDown .2s cubic-bezier(.34,1.56,.64,1);
}

.modal-title { font-family: var(--font-display); font-size: 1.3rem; color: var(--text); }
.modal-emoji { font-size: 3.5rem; text-align: center; }
.modal-msg   { color: var(--text-muted); font-size: .9rem; line-height: 1.5; }
.modal-label { font-size: .74rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .09em; font-weight: 700; }

.modal-input {
  width: 100%;
  padding: .72rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font); font-size: 1rem; font-weight: 700;
  outline: none;
  transition: border-color .15s;
}
.modal-input:focus { border-color: rgba(251,191,36,.55); }
.modal-input::placeholder { color: var(--text-dim); font-weight: 400; }

.emoji-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: .4rem;
}
.emoji-btn {
  font-size: 1.6rem;
  padding: .28rem;
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer; transition: all .12s; line-height: 1;
}
.emoji-btn:hover   { background: var(--surface-hover); transform: scale(1.18); }
.emoji-btn.selected { border-color: var(--gold); background: var(--gold-lt); }

.modal-actions { display: flex; gap: .7rem; justify-content: flex-end; margin-top: .3rem; }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .6rem 1.4rem;
  background: linear-gradient(135deg, #f87171, #dc2626);
  color: white; border: none; border-radius: 2rem;
  font-family: var(--font); font-size: .95rem; font-weight: 800;
  cursor: pointer; transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 16px rgba(248,113,113,.35);
}
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(248,113,113,.5); }

.btn-warning {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .6rem 1.4rem;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #07091c; border: none; border-radius: 2rem;
  font-family: var(--font); font-size: .95rem; font-weight: 800;
  cursor: pointer; transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 16px rgba(251,191,36,.35);
}
.btn-warning:hover { transform: translateY(-2px); }

.profile-emoji { font-size: 3.2rem; filter: drop-shadow(0 3px 10px rgba(0,0,0,0.4)); }
.profile-name  { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.profile-age   { font-size: .8rem;  color: var(--text-muted); }
.profile-stars { font-size: .9rem;  color: var(--gold); letter-spacing: .1em; }


/* ═══════════════════════════════════════════════
   APP HEADER
   ═══════════════════════════════════════════════ */

#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  background: rgba(6, 9, 26, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

#btn-change-profile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: .35rem .9rem .35rem .55rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .45rem;
  transition: background .2s, border-color .2s;
  color: var(--text);
  font-family: var(--font);
  font-weight: 700;
}
#btn-change-profile:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}
#header-emoji { font-size: 1.5rem; }
#header-name  { font-size: .85rem; color: var(--text-muted); }

#header-title {
  font-family: var(--font-arabic);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold);
}

#header-score {
  background: var(--gold-lt);
  border: 1px solid rgba(251,191,36, 0.28);
  border-radius: 2rem;
  padding: .3rem .85rem;
  font-size: .88rem;
  font-weight: 700;
  color: var(--gold);
}


/* ═══════════════════════════════════════════════
   VIEWS
   ═══════════════════════════════════════════════ */

.view { padding: 1.2rem; max-width: 860px; margin: 0 auto; }
.view.hidden { display: none !important; }
.view.active { display: block; animation: fadeIn .25s ease; }

.view-header {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-bottom: 1.3rem;
}
.view-header h2 {
  font-family: var(--font-arabic);
  font-size: 1.6rem;
  color: var(--gold);
  font-weight: 700;
}

.btn-back {
  flex-shrink: 0;
  padding: .42rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2rem;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-back:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--text);
}


/* ═══════════════════════════════════════════════
   HOME
   ═══════════════════════════════════════════════ */

.home-welcome {
  margin-bottom: 1.2rem;
}
#home-greeting {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-style: italic;
  color: var(--text-muted);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .85rem;
  margin-bottom: 1rem;
}

.menu-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.9rem 1rem 1.6rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .38rem;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1),
              box-shadow .22s,
              border-color .22s;
  overflow: hidden;
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.menu-card-bg {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: .07;
  transition: opacity .22s;
  pointer-events: none;
}

/* Per-card gradient backgrounds */
.menu-card:nth-child(1) .menu-card-bg { background: linear-gradient(135deg, #818cf8, #6366f1); }
.menu-card:nth-child(2) .menu-card-bg { background: linear-gradient(135deg, #34d399, #059669); }
.menu-card:nth-child(3) .menu-card-bg { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.menu-card:nth-child(4) .menu-card-bg { background: linear-gradient(135deg, #f87171, #ef4444); }

/* Per-card border colors */
.menu-card:nth-child(1) { border-color: rgba(129,140,248, 0.25); }
.menu-card:nth-child(2) { border-color: rgba( 52,211,153, 0.25); }
.menu-card:nth-child(3) { border-color: rgba(251,191, 36, 0.25); }
.menu-card:nth-child(4) { border-color: rgba(248,113,113, 0.25); }

.menu-card:hover { transform: translateY(-5px) scale(1.02); }
.menu-card:hover .menu-card-bg { opacity: .20; }
.menu-card:hover .menu-icon    { transform: scale(1.25); }

.menu-card:nth-child(1):hover { border-color: rgba(129,140,248,.75); box-shadow: 0 8px 36px rgba( 99,102,241,.30); }
.menu-card:nth-child(2):hover { border-color: rgba( 52,211,153,.75); box-shadow: 0 8px 36px rgba( 52,211,153,.30); }
.menu-card:nth-child(3):hover { border-color: rgba(251,191, 36,.75); box-shadow: 0 8px 36px rgba(251,191, 36,.30); }
.menu-card:nth-child(4):hover { border-color: rgba(248,113,113,.75); box-shadow: 0 8px 36px rgba(248,113,113,.30); }

.menu-icon  { font-size: 2.8rem; transition: transform .25s cubic-bezier(.34,1.56,.64,1); position: relative; z-index: 1; }
.menu-label { font-size: 1.05rem; font-weight: 800; color: var(--text); position: relative; z-index: 1; }
.menu-sub   { font-size: .75rem; color: var(--text-muted); position: relative; z-index: 1; }

.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.2rem;
  backdrop-filter: blur(8px);
}
.progress-card h3 {
  font-size: .72rem;
  color: var(--text-dim);
  margin-bottom: .85rem;
  text-transform: uppercase;
  letter-spacing: .11em;
  font-weight: 700;
}

.progress-item      { margin-bottom: .7rem; }
.progress-label     { display: flex; justify-content: space-between; font-size: .82rem; font-weight: 600; margin-bottom: .3rem; color: var(--text-muted); }
.progress-bar-bg    { height: 6px; background: rgba(255,255,255,.08); border-radius: 99px; overflow: hidden; }
.progress-bar-fill  { height: 100%; background: linear-gradient(90deg, var(--gold), var(--teal)); border-radius: 99px; transition: width .65s cubic-bezier(.4,0,.2,1); }


/* ═══════════════════════════════════════════════
   ALPHABET
   ═══════════════════════════════════════════════ */

#alphabet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: .5rem;
}

.letter-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .7rem .3rem .6rem;
  cursor: pointer;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1),
              border-color .15s, box-shadow .15s, background .15s;
  user-select: none;
  position: relative;
}

.letter-tile:hover, .letter-tile:focus {
  transform: translateY(-4px) scale(1.08);
  border-color: rgba(251,191,36, 0.65);
  box-shadow: 0 4px 20px rgba(251,191,36, 0.22);
  background: var(--gold-lt);
  outline: none;
}

.letter-tile.mastered {
  border-color: rgba(52,211,153, 0.45);
  background: rgba(52,211,153, 0.07);
}
.letter-tile.mastered:hover {
  border-color: rgba(52,211,153, 0.80);
  box-shadow: 0 4px 20px rgba(52,211,153, 0.25);
  background: rgba(52,211,153, 0.12);
}

.letter-tile .mastered-badge {
  position: absolute;
  top: 3px; right: 5px;
  font-size: .6rem;
  color: var(--teal);
}
.tile-char     { font-family: var(--font-arabic); font-size: 2.1rem; direction: rtl; line-height: 1.1; color: var(--text); }
.tile-name     { font-size: .6rem;  color: var(--text-dim); margin-top: .15rem; }
.tile-translit { font-size: .64rem; color: var(--gold); font-weight: 700; }

/* — Letter detail — */
#letter-detail.hidden { display: none; }
#letter-detail { animation: fadeIn .2s ease; }

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  margin-top: .5rem;
  backdrop-filter: blur(14px);
}

.detail-top {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: 1.2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.detail-char-box {
  font-family: var(--font-arabic);
  font-size: 3.5rem;
  direction: rtl;
  background: var(--gold-lt);
  border: 1px solid rgba(251,191,36, 0.30);
  border-radius: var(--r-md);
  width: 90px; height: 90px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--gold);
}

.detail-meta h3    { font-size: 1.3rem; color: var(--text); margin-bottom: .2rem; font-family: var(--font-display); }
.detail-translit   { font-size: 1rem; color: var(--text-muted); }

.detail-forms {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.form-tag {
  background: rgba(129,140,248, 0.09);
  border: 1px solid rgba(129,140,248, 0.20);
  border-radius: var(--r-sm);
  padding: .4rem .7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  flex: 1;
  min-width: 60px;
}
.form-tag .form-arabic { font-family: var(--font-arabic); font-size: 1.4rem; direction: rtl; color: var(--text); }
.form-tag .form-label  { font-size: .58rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }

.detail-examples h4 {
  font-size: .7rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: .6rem; font-weight: 700;
}
.example-row {
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: .3rem .7rem; padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}
.example-row:last-child { border-bottom: none; }

.example-word     { font-family: var(--font-arabic); font-size: 1.3rem; direction: rtl; font-weight: 600; color: var(--text); }
.example-translit { font-style: italic; color: var(--gold); font-size: .88rem; }
.example-fr       { color: var(--text-muted); font-size: .88rem; }

.detail-actions { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }


/* ═══════════════════════════════════════════════
   TRACING
   ═══════════════════════════════════════════════ */

.tracing-container { display: flex; flex-direction: column; align-items: center; gap: 1rem; }

.tracing-letter-nav {
  display: flex; align-items: center; gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: .65rem 1.2rem;
  width: 100%; max-width: 320px;
  justify-content: space-between;
  backdrop-filter: blur(8px);
}

#tracing-letter-info { text-align: center; }
#tracing-letter-name    { display: block; font-family: var(--font-arabic); font-size: 2.2rem; direction: rtl; color: var(--gold); }
#tracing-letter-translit { font-size: .82rem; color: var(--text-muted); font-weight: 600; }

.btn-nav {
  background: var(--gold-lt);
  border: 1px solid rgba(251,191,36, 0.30);
  border-radius: 50%;
  width: 38px; height: 38px;
  font-size: 1rem; cursor: pointer;
  color: var(--gold); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .12s;
}
.btn-nav:hover { background: rgba(251,191,36, 0.22); transform: scale(1.12); }

.canvas-wrapper {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border), var(--shadow-md);
  touch-action: none;
}

#tracing-canvas {
  display: block;
  background: rgba(13, 17, 48, 0.80);
  cursor: crosshair;
  border-radius: var(--r-md);
}

#tracing-guide {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-arabic);
  font-size: 11rem;
  direction: rtl;
  color: rgba(251,191,36, 0.13);
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

.tracing-controls { display: flex; gap: .7rem; }
.tracing-hint { font-size: .8rem; color: var(--text-dim); text-align: center; }


/* ═══════════════════════════════════════════════
   VOCABULARY
   ═══════════════════════════════════════════════ */

.category-tabs {
  display: flex; gap: .5rem; overflow-x: auto;
  padding-bottom: .5rem; margin-bottom: .8rem;
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  flex-shrink: 0; padding: .42rem 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 2rem; font-family: var(--font); font-size: .82rem;
  font-weight: 700; cursor: pointer;
  transition: all .15s; color: var(--text-muted);
}
.cat-tab:hover  { border-color: var(--border-hover); color: var(--text); }
.cat-tab.active { background: var(--gold-lt); border-color: rgba(251,191,36,.50); color: var(--gold); }

#vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .6rem;
}

.vocab-card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 1rem .7rem;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), border-color .15s, box-shadow .15s;
  text-align: center;
  backdrop-filter: blur(6px);
}
.vocab-card:hover {
  transform: translateY(-3px) scale(1.04);
  border-color: rgba(251,191,36, 0.50);
  box-shadow: 0 6px 24px rgba(251,191,36, 0.18);
}
.vocab-emoji   { font-size: 2.5rem; }
.vocab-arabic  { font-family: var(--font-arabic); font-size: 1.3rem; direction: rtl; color: var(--text); font-weight: 600; }
.vocab-translit { font-size: .7rem; color: var(--gold); font-weight: 700; }
.vocab-fr      { font-size: .76rem; color: var(--text-muted); }


/* ═══════════════════════════════════════════════
   QUIZ
   ═══════════════════════════════════════════════ */

#quiz-score-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: .65rem 1rem;
  font-weight: 700; font-size: .9rem;
  margin-bottom: .9rem;
}

.quiz-modes { text-align: center; }
.quiz-modes p { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; color: var(--text-muted); font-family: var(--font-display); font-style: italic; }

.quiz-mode-btn {
  display: flex; align-items: center; gap: .6rem;
  width: 100%; padding: 1rem 1.2rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); font-family: var(--font);
  font-size: .95rem; font-weight: 700; cursor: pointer;
  margin-bottom: .6rem; color: var(--text-muted);
  transition: all .15s; text-align: left;
}
.quiz-mode-btn:hover { border-color: rgba(251,191,36,.50); color: var(--gold); background: var(--gold-lt); }
.quiz-mode-btn span  { font-size: 1.3rem; }

#quiz-question-area { text-align: center; margin-bottom: 1rem; }

.quiz-arabic-display {
  font-family: var(--font-arabic);
  font-size: 4rem; direction: rtl;
  color: var(--gold); line-height: 1.1;
  background: var(--gold-lt);
  border: 1px solid rgba(251,191,36, 0.25);
  border-radius: var(--r-md);
  padding: 1rem; margin-bottom: .6rem;
}

.quiz-emoji-display { font-size: 4rem; margin-bottom: .6rem; }
.quiz-prompt { font-size: 1rem; font-weight: 600; color: var(--text-muted); }

.btn-listen {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  margin: .6rem auto 0;
  padding: .65rem 1.6rem;
  background: var(--gold-lt);
  border: 1.5px solid rgba(251,191,36,.45);
  border-radius: 2rem;
  color: var(--gold); font-family: var(--font); font-size: 1rem; font-weight: 800;
  cursor: pointer; min-height: 48px;
  transition: background .15s, border-color .15s, transform .12s;
  box-shadow: 0 2px 12px rgba(251,191,36,.2);
}
.btn-listen:active { transform: scale(.95); }
@media (hover: hover) {
  .btn-listen:hover { background: rgba(251,191,36,.22); border-color: var(--gold); }
}

#quiz-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .6rem;
  margin-bottom: .8rem;
}

.quiz-opt {
  padding: .9rem .5rem;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-md); cursor: pointer;
  text-align: center; transition: all .15s;
  color: var(--text); font-family: var(--font); font-size: 1rem;
}
.quiz-opt.arabic-opt { font-family: var(--font-arabic); font-size: 1.8rem; }
.quiz-opt:hover:not(:disabled) {
  border-color: rgba(251,191,36,.60);
  background: var(--gold-lt);
  color: var(--gold);
  transform: scale(1.04);
}
.quiz-opt.correct { border-color: var(--green); background: var(--green-lt); color: var(--green); animation: pulse .35s ease; }
.quiz-opt.wrong   { border-color: var(--red);   background: var(--red-lt);   color: var(--red); }
.quiz-opt:disabled { cursor: default; transform: none; }

#quiz-feedback {
  padding: .65rem 1rem; border-radius: var(--r-sm);
  font-weight: 700; font-size: .95rem; margin-bottom: .6rem; text-align: center;
}
#quiz-feedback.success { color: var(--green); background: var(--green-lt); }
#quiz-feedback.error   { color: var(--red);   background: var(--red-lt); }
#quiz-feedback:empty   { display: none; }

.quiz-end-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 2rem; text-align: center;
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; align-items: center; gap: .85rem;
  backdrop-filter: blur(14px);
}
#quiz-end-emoji { font-size: 4.5rem; }
#quiz-end-title { font-size: 1.6rem; font-weight: 800; font-family: var(--font-display); color: var(--gold); }
#quiz-end-score { color: var(--text-muted); }
#quiz-end-stars { font-size: 2rem; letter-spacing: .2rem; color: var(--gold); }
.quiz-end-card .btn-secondary { margin-top: .2rem; }


/* ═══════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════ */

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .62rem 1.5rem;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #07091c;
  border: none; border-radius: 2rem;
  font-family: var(--font); font-size: .95rem; font-weight: 800;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 16px rgba(251,191,36, 0.40);
}
.btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(251,191,36, 0.55); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.hidden { display: none; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .57rem 1.2rem;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 2rem;
  font-family: var(--font); font-size: .9rem; font-weight: 700;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--text);
}


/* ═══════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════ */

@keyframes fadeIn    { from { opacity: 0; transform: translateY(8px);  } to { opacity: 1; transform: translateY(0);   } }
@keyframes fadeDown  { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0);   } }
@keyframes float     { 0%,100% { transform: translateY(0) rotate(-5deg);  } 50% { transform: translateY(-14px) rotate(-5deg); } }
@keyframes twinkle   { 0%,100% { opacity: .25; transform: scale(.75); } 50% { opacity: 1; transform: scale(1.35); } }
@keyframes pulse     { 0%,100% { transform: scale(1);    } 50% { transform: scale(1.07); } }
@keyframes stars-drift {
  from { background-position: 18px 14px, 58px 78px, 128px 38px; }
  to   { background-position: 138px 134px, 233px 253px, 373px 283px; }
}


/* ═══════════════════════════════════════════════
   FALLBACK — navigateurs sans backdrop-filter
   (Firefox Mobile, UC Browser, anciens Android…)
   ═══════════════════════════════════════════════ */

@supports not (backdrop-filter: blur(1px)) {
  #app-header         { background: rgba(5,  8, 24, 0.98); }
  .profile-card       { background: rgba(14, 20, 52, 0.96); }
  .menu-card          { background: rgba(14, 20, 52, 0.93); }
  .detail-card        { background: rgba(11, 16, 44, 0.99); }
  .vocab-card         { background: rgba(11, 16, 44, 0.96); }
  .letter-tile        { background: rgba(11, 16, 44, 0.96); }
  .progress-card      { background: rgba(11, 16, 44, 0.96); }
  .tracing-letter-nav { background: rgba(11, 16, 44, 0.96); }
  .quiz-end-card      { background: rgba(11, 16, 44, 0.99); }
  .modal-backdrop     { background: rgba(0,  0,  0, 0.92); }
  .modal-box          { background: #0b1030; border-color: rgba(255,255,255,.15); }
}


/* ═══════════════════════════════════════════════
   TOUCH GLOBALS
   ═══════════════════════════════════════════════ */

/* Supprime le flash bleu au tap sur mobile */
* { -webkit-tap-highlight-color: transparent; }

/* Zone de tap minimum 44px (standard Apple/Google) */
.btn-back, .cat-tab, .btn-nav, .btn-manage,
.quiz-mode-btn, .card-action, .emoji-btn { min-height: 44px; }

.btn-primary, .btn-secondary, .btn-danger, .btn-warning { min-height: 44px; }

/* Active states pour écrans tactiles (remplace :hover) */
@media (hover: none) and (pointer: coarse) {
  .menu-card:active                       { transform: scale(.96); opacity: .85; }
  .profile-card:not(.is-editing):active   { transform: scale(.96); opacity: .85; }
  .letter-tile:active                     { background: var(--gold-lt); border-color: rgba(251,191,36,.65); }
  .vocab-card:active                      { transform: scale(.97); }
  .quiz-opt:not(:disabled):active         { background: var(--gold-lt); border-color: rgba(251,191,36,.6); }
  .cat-tab:active                         { opacity: .7; }
  /* Désactive les effets hover sur touch */
  .menu-card:hover,
  .letter-tile:hover,
  .vocab-card:hover                       { transform: none !important; box-shadow: none !important; }
  .menu-card:hover .menu-icon             { transform: none !important; }
  .profile-card:not(.is-editing):hover    { transform: none !important; box-shadow: none !important; }
  .profile-card:not(.is-editing):hover .card-glow { opacity: 0 !important; }
}

/* Réduit les animations si l'utilisateur le préfère */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:        .01ms !important;
    animation-iteration-count: 1    !important;
    transition-duration:       .01ms !important;
  }
}


/* ═══════════════════════════════════════════════
   TRÈS PETITS TÉLÉPHONES  (< 380px — iPhone SE…)
   ═══════════════════════════════════════════════ */

@media (max-width: 380px) {
  .app-title    { font-size: 2rem; }
  .tagline      { font-size: 1rem; margin-bottom: 1.8rem; }
  .profile-card { padding: 1.3rem .9rem 1.1rem; flex: 1 1 110px; max-width: 135px; }
  .profile-emoji { font-size: 2.4rem; }
  .profile-name  { font-size: .9rem; }
  .deco-moon     { font-size: 3.5rem; }

  .home-grid { gap: .55rem; }
  .menu-card { padding: 1.3rem .7rem 1.1rem; }
  .menu-icon { font-size: 2.2rem; }
  .menu-label { font-size: .88rem; }

  .emoji-picker { grid-template-columns: repeat(5, 1fr); }
  .modal-box    { padding: 1.2rem; gap: .8rem; }
}


/* ═══════════════════════════════════════════════
   CANVAS RESPONSIVE (tous mobiles < 480px)
   ═══════════════════════════════════════════════ */

@media (max-width: 480px) {
  /* Masque le nom dans le header (trop étroit) */
  #header-name { display: none; }

  /* Canvas adaptatif à la largeur d'écran */
  .canvas-wrapper {
    width: min(300px, calc(100vw - 2.4rem));
    aspect-ratio: 1;
  }
  #tracing-canvas {
    width:  100% !important;
    height: 100% !important;
  }

  /* Guide lettre suit la taille du canvas */
  #tracing-guide { font-size: min(11rem, calc(100vw - 4rem)); }

  /* Quiz: lettre plus petite */
  .quiz-arabic-display { font-size: 3rem; padding: .8rem; }

  /* Détail lettre: boîte compacte */
  .detail-char-box { width: 72px; height: 72px; font-size: 2.6rem; }
}


/* ═══════════════════════════════════════════════
   TÉLÉPHONES MOYENS  (480px+)
   ═══════════════════════════════════════════════ */

@media (min-width: 480px) {
  #alphabet-grid { grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); }
  #vocab-grid    { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}


/* ═══════════════════════════════════════════════
   GRANDS TÉLÉPHONES / PETITES TABLETTES  (640px+)
   ═══════════════════════════════════════════════ */

@media (min-width: 640px) {
  .home-grid     { grid-template-columns: repeat(4, 1fr); }
  .view          { padding: 1.5rem 2rem; }
  #alphabet-grid { grid-template-columns: repeat(7, 1fr); }
  .profile-cards { gap: 1.2rem; }
  #header-name   { display: inline; }
}


/* ═══════════════════════════════════════════════
   TABLETTES  (768px+)
   ═══════════════════════════════════════════════ */

@media (min-width: 768px) {
  /* Écran profil */
  .app-title    { font-size: 4.2rem; }
  .profile-card { padding: 2.2rem 1.8rem 1.8rem; flex: 0 1 175px; max-width: 200px; }
  .profile-emoji { font-size: 3.8rem; }
  .profile-name  { font-size: 1.2rem; }
  .deco-moon     { font-size: 6.5rem; }

  /* Header */
  #app-header   { padding: .9rem 1.8rem; }
  #header-title { font-size: 1.45rem; }

  /* Vue générale */
  .view { padding: 1.8rem 2.4rem; max-width: 860px; }

  /* Accueil */
  #home-greeting { font-size: 2rem; }
  .home-grid  { gap: 1.2rem; }
  .menu-card  { padding: 2.2rem 1.4rem; }
  .menu-icon  { font-size: 3.2rem; }
  .menu-label { font-size: 1.15rem; }

  /* Canvas agrandi */
  .canvas-wrapper { width: 360px; aspect-ratio: 1; }
  #tracing-canvas { width: 360px !important; height: 360px !important; }
  #tracing-guide  { font-size: 13rem; }
  .tracing-letter-nav { max-width: 360px; }

  /* Alphabet */
  .tile-char     { font-size: 2.4rem; }
  .tile-name     { font-size: .68rem; }
  .tile-translit { font-size: .72rem; }

  /* Vocabulaire */
  .vocab-emoji  { font-size: 3rem; }
  .vocab-arabic { font-size: 1.5rem; }

  /* Quiz */
  .quiz-arabic-display { font-size: 5rem; padding: 1.3rem; }
  .quiz-opt { padding: 1.1rem; font-size: 1.1rem; }
  .quiz-opt.arabic-opt { font-size: 2.2rem; }

  /* Modal */
  .modal-box    { max-width: 440px; padding: 2.2rem; }
  .emoji-picker { grid-template-columns: repeat(8, 1fr); }
}


/* ═══════════════════════════════════════════════
   GRANDES TABLETTES / DESKTOP  (1024px+)
   ═══════════════════════════════════════════════ */

@media (min-width: 1024px) {
  .profile-container { padding: 3rem; }
  .profile-cards { gap: 1.5rem; max-width: 680px; }
  .profile-card  { flex: 0 1 190px; max-width: 215px; padding: 2.5rem 2rem 2rem; }

  .view { padding: 2rem 2.5rem; max-width: 960px; }
  .home-grid { gap: 1.4rem; }
  .menu-card { padding: 2.4rem 1.6rem; }

  #alphabet-grid { gap: .7rem; }

  /* Canvas pleine taille */
  .canvas-wrapper { width: 380px; }
  #tracing-canvas { width: 380px !important; height: 380px !important; }
  #tracing-guide  { font-size: 14rem; }

  .quiz-arabic-display { font-size: 5.5rem; }
  .quiz-opt { padding: 1.2rem; font-size: 1.15rem; }
}


/* ═══════════════════════════════════════════════
   ORIENTATION PAYSAGE SUR TÉLÉPHONE
   ═══════════════════════════════════════════════ */

@media (max-height: 520px) and (orientation: landscape) {
  .profile-container {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 1rem 2rem;
    min-height: 100dvh;
  }
  .profile-content {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    max-width: 100%;
  }
  .app-title   { font-size: 1.9rem; margin-bottom: 0; }
  .tagline     { display: none; }
  .choose-label { display: none; }
  .deco-moon, .deco-star, .deco-geo { display: none; }
  .profile-cards   { gap: .7rem; }
  .profile-card    { padding: .9rem .9rem .8rem; flex: 0 1 110px; }
  .profile-emoji   { font-size: 2rem; }
  .profile-name    { font-size: .85rem; }
  .profile-manage-row { margin-top: .5rem; }
}


/* ═══════════════════════════════════════════════
   ENCOCHE / HOME INDICATOR (iPhone X+, Android)
   ═══════════════════════════════════════════════ */

@supports (padding: env(safe-area-inset-bottom)) {
  #app-header {
    padding-left:  max(1rem,  env(safe-area-inset-left));
    padding-right: max(1rem,  env(safe-area-inset-right));
  }
  .profile-container {
    padding-bottom: max(3rem, env(safe-area-inset-bottom));
    padding-left:   max(1.5rem, env(safe-area-inset-left));
    padding-right:  max(1.5rem, env(safe-area-inset-right));
  }
  .view {
    padding-bottom: max(1.2rem, env(safe-area-inset-bottom));
  }
}
