/*
 * Hifz Quiz — direction : « mushaf enluminé ».
 * Émeraude profond + feuille d'or sur papier ivoire, motif géométrique (étoile à 8 branches),
 * calligraphie Amiri Quran pour l'arabe, Inter pour l'interface.
 */

/* ===== Thème ===== */
:root {
  --paper: #f7f2e7;
  --paper-2: #efe7d4;
  --card: #fffdf7;
  --ink: #17251f;
  --muted: #66736c;
  --line: #e4d9c1;
  --emerald: #0d3b2c;
  --emerald-2: #145a42;
  --emerald-3: #1f7a5a;
  --gold: #c39a2e;
  --gold-2: #e2c46b;
  --gold-soft: #f6edcf;
  --ok: #17824a;
  --ok-bg: #e2f4e9;
  --ko: #be3a2c;
  --ko-bg: #fbe5e1;
  --hero-ink: #f6eedb;
  --shadow-sm: 0 1px 2px rgba(13, 59, 44, 0.06), 0 2px 8px rgba(13, 59, 44, 0.05);
  --shadow: 0 2px 4px rgba(13, 59, 44, 0.05), 0 10px 30px rgba(13, 59, 44, 0.09);
  --radius: 18px;
  --radius-sm: 12px;
  --ar: 'Amiri Quran', 'Amiri', 'Scheherazade New', serif;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23e2c46b' stroke-opacity='.16' stroke-width='1'%3E%3Crect x='16' y='16' width='24' height='24'/%3E%3Crect x='16' y='16' width='24' height='24' transform='rotate(45 28 28)'/%3E%3Ccircle cx='28' cy='28' r='5'/%3E%3Cpath d='M0 0l8 8M56 0l-8 8M0 56l8-8M56 56l-8-8'/%3E%3C/g%3E%3C/svg%3E");
  --paper-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23c39a2e' stroke-opacity='.08' stroke-width='1'%3E%3Crect x='16' y='16' width='24' height='24'/%3E%3Crect x='16' y='16' width='24' height='24' transform='rotate(45 28 28)'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0b1511;
    --paper-2: #101d18;
    --card: #12211b;
    --ink: #ece4d0;
    --muted: #93a49b;
    --line: #22372e;
    --emerald: #0a2a20;
    --emerald-2: #1a6b4f;
    --emerald-3: #2f9a73;
    --gold: #d8b453;
    --gold-2: #ecd38a;
    --gold-soft: #2a2512;
    --ok: #4cc683;
    --ok-bg: #12301f;
    --ko: #f07264;
    --ko-bg: #3a1915;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--ui);
  font-size: 16px;
  background: var(--paper) var(--paper-pattern);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, .chip, .panel-title, .stat, .pill { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.bg-pattern { display: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
h1, h2 { text-wrap: balance; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ===== Écrans ===== */
.screen {
  display: none; max-width: 720px; margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.screen.active { display: block; animation: rise 0.35s cubic-bezier(.2, .7, .2, 1); }
#screen-home { padding-top: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Accueil : bandeau ===== */
.hero {
  margin: 0 calc(-1 * max(16px, env(safe-area-inset-left))) 6px;
  padding: calc(28px + env(safe-area-inset-top)) 20px 34px;
  background: var(--pattern), radial-gradient(120% 90% at 50% 0%, var(--emerald-2) 0%, var(--emerald) 70%);
  color: var(--hero-ink);
  border-radius: 0 0 32px 32px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow);
}
.hero::after {
  content: ''; position: absolute; left: 50%; bottom: -1px; width: 120px; height: 3px; transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--gold-2), transparent); border-radius: 3px;
}
.hero-inner { max-width: 560px; margin: 0 auto; display: grid; gap: 6px; justify-items: center; }
.hero-badge img { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(226, 196, 107, 0.4); display: block; }
.hero h1 { margin: 10px 0 0; font-size: clamp(2rem, 7vw, 2.6rem); letter-spacing: -0.02em; font-weight: 700; color: #fff8e6; }
.hero-sub { margin: 0; color: rgba(246, 238, 219, 0.8); font-size: 0.98rem; }
.hero-verse { margin: 16px 0 0; padding: 14px 16px 12px; border-top: 1px solid rgba(226, 196, 107, 0.25); width: 100%; }
.hero-ar { font-family: var(--ar); font-size: clamp(1.5rem, 5.5vw, 1.9rem); color: var(--gold-2); margin: 0; line-height: 2; }
.hero-verse figcaption { font-size: 0.78rem; color: rgba(246, 238, 219, 0.65); font-style: italic; line-height: 1.5; }

/* Sélecteur de langue (haut de l'accueil) */
.hero { position: relative; }
.lang-switch {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); inset-inline-end: 14px; z-index: 2;
  display: flex; align-items: center; gap: 4px; background: rgba(0, 0, 0, 0.22); border: 1px solid rgba(226, 196, 107, 0.35);
  border-radius: 999px; padding: 2px 4px 2px 10px; color: #fff8e6; font-size: 0.85rem;
}
.lang-switch select { width: auto; background: transparent; border: 0; color: #fff8e6; padding: 6px 4px; font-size: 0.85rem; }
.lang-switch select option { color: #17251f; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== Panneaux ===== */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 14px 0; box-shadow: var(--shadow-sm);
}
.panel-title { margin: 0 0 14px; font-size: 1rem; font-weight: 650; display: flex; align-items: center; gap: 10px; }
.panel-title > span:first-child {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--gold-soft); color: var(--emerald-2); font-size: 0.8rem; font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--gold);
}
@media (prefers-color-scheme: dark) { .panel-title > span:first-child { color: var(--gold-2); } }

/* Cartes de mode / niveau */
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.level-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .mode-grid, .level-grid { grid-template-columns: 1fr; } }
.mode-card, .level-card {
  position: relative; text-align: start; border: 1.5px solid var(--line); background: var(--paper);
  color: var(--ink); border-radius: 14px; padding: 14px; cursor: pointer; font: inherit;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.mode-card { display: flex; gap: 12px; align-items: flex-start; }
.level-card { display: grid; gap: 4px; padding-inline-end: 36px; }
.mode-card:hover, .level-card:hover { border-color: var(--gold); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.mode-card.selected, .level-card.selected { border-color: var(--emerald-3); background: var(--card); box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald-3) 18%, transparent); }
.mode-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--gold-soft); color: var(--emerald-2);
}
@media (prefers-color-scheme: dark) { .mode-icon { color: var(--gold-2); } }
.mode-card.selected .mode-icon { background: var(--emerald-2); color: #fff8e6; }
.mode-text { display: grid; gap: 3px; min-width: 0; padding-inline-end: 18px; }
.mode-card strong, .level-card strong { font-size: 0.98rem; }
.mode-card small, .level-card small { color: var(--muted); line-height: 1.4; font-size: 0.82rem; }
.check {
  position: absolute; top: 10px; inset-inline-end: 10px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.7rem; font-weight: 800; color: #fff; background: var(--emerald-3); opacity: 0; transform: scale(0.6); transition: 0.15s;
}
.selected .check { opacity: 1; transform: scale(1); }
.level-card strong::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 8px; vertical-align: 2px; }
.lvl-facile strong::before { background: #2eaa62; }
.lvl-moyen strong::before { background: #e0a100; }
.lvl-difficile strong::before { background: #d0453a; }

/* Portée : onglets + puces sélectionnables */
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--paper-2); border-radius: 14px; }
.seg button {
  font: inherit; font-size: 0.84rem; font-weight: 600; border: 0; border-radius: 10px; padding: 9px 4px; cursor: pointer;
  background: transparent; color: var(--muted); transition: background 0.15s, color 0.15s;
}
.seg button[aria-selected='true'] { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.scope-body { margin-top: 12px; display: grid; gap: 10px; }
.scope-search { font: inherit; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--paper); color: var(--ink); width: 100%; }
.scope-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 260px; overflow-y: auto; padding: 2px; }
.scope-list:empty { display: none; }
.scope-chip {
  font: inherit; font-size: 0.82rem; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 999px; padding: 6px 11px; cursor: pointer; display: inline-flex; gap: 6px; align-items: baseline; transition: 0.12s;
}
.scope-chip b { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.scope-chip .ar { font-family: var(--ar); font-size: 0.98rem; }
.scope-chip[aria-pressed='true'] { background: var(--emerald-2); border-color: var(--emerald-2); color: #fff8e6; }
.scope-chip[aria-pressed='true'] b { color: var(--gold-2); }
.scope-grid-num .scope-chip { min-width: 52px; justify-content: center; }
.scope-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.84rem; min-height: 22px; }
.scope-note { margin: 0; font-size: 0.86rem; color: var(--muted); line-height: 1.5; }

/* Options */
.options { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; font-size: 0.9rem; font-weight: 550; }
.field small { font-weight: 400; }
.field-row { display: flex; gap: 8px; }
select {
  font: inherit; font-weight: 450; padding: 11px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); width: 100%; min-width: 0;
}
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 0.9rem; }
.switch input { position: absolute; opacity: 0; }
.switch-ui { width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; flex: none; transition: background 0.2s; }
.switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.2s; }
.switch input:checked + .switch-ui { background: var(--emerald-3); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Bouton Commencer : collé en bas de l'écran sur mobile */
.start-bar {
  position: sticky; bottom: 0; z-index: 5; margin: 6px calc(-1 * max(16px, env(safe-area-inset-left))) 0;
  padding: 12px max(16px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 70%, transparent);
}

/* Statistiques */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 8px; text-align: center; display: grid; gap: 2px; }
.stat b { font-size: 1.35rem; color: var(--emerald-3); font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.72rem; color: var(--muted); line-height: 1.3; }

.foot { text-align: center; color: var(--muted); font-size: 0.74rem; margin-top: 22px; line-height: 1.5; }
.foot p { margin: 4px 0; }
.foot a { color: inherit; }

/* ===== Boutons ===== */
.btn {
  font: inherit; font-weight: 650; border: 0; border-radius: 14px; padding: 12px 18px; cursor: pointer;
  transition: transform 0.1s, background 0.15s, opacity 0.15s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, var(--emerald-2), var(--emerald)); color: #fff8e6; box-shadow: 0 4px 14px rgba(13, 59, 44, 0.25); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--paper-2); }
.btn-lg { width: 100%; padding: 16px; font-size: 1.05rem; }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; border-radius: 12px; }
.btn-icon { width: 46px; flex: none; padding: 0; }
.btn-ghost[aria-pressed='true'] { background: var(--gold-soft); border-color: var(--gold); }
.btn-quit { width: 40px; height: 40px; padding: 0; border-radius: 50%; }
.link-btn { background: none; border: 0; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; color: var(--emerald-3); }

/* ===== Jeu ===== */
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-meta { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; flex: 1; min-width: 0; }
.chip { font-size: 0.76rem; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); white-space: nowrap; }
.chip-facile { background: #e2f4e9; color: #17703f; border-color: transparent; }
.chip-moyen { background: #fbefcf; color: #85600a; border-color: transparent; }
.chip-difficile { background: #fbe1dc; color: #9f3127; border-color: transparent; }
.scorebox { display: flex; gap: 6px; }
.pill { font-size: 0.85rem; padding: 6px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.pill-gold { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.progress { height: 6px; background: var(--paper-2); border-radius: 3px; margin: 16px 0 8px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--emerald-3), var(--gold)); border-radius: 3px; transition: width 0.45s cubic-bezier(.2, .7, .2, 1); }
.q-count { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.timer { font-weight: 700; color: var(--ink); }
.timer-low { color: var(--ko); animation: pulse 0.8s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.loading { text-align: center; padding: 70px 0; color: var(--muted); }
.spinner { width: 42px; height: 42px; margin: 0 auto 14px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { text-align: center; padding: 36px 16px; background: var(--ko-bg); border-radius: var(--radius); margin-top: 20px; }

.instruction { font-weight: 650; margin: 18px 2px 10px; font-size: 1.02rem; }

/* Cadre du verset façon mushaf */
.verse-card {
  position: relative; background: var(--card); border-radius: var(--radius); padding: 22px 18px 18px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.verse-card::before {
  content: ''; position: absolute; inset: 7px; border-radius: 13px; pointer-events: none;
  border: 1.5px solid color-mix(in srgb, var(--gold) 55%, transparent);
  box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 4px color-mix(in srgb, var(--gold) 25%, transparent);
}
.verse-ref { position: relative; text-align: center; font-size: 0.78rem; color: var(--muted); margin-bottom: 8px; }
.ref-ar { font-family: var(--ar); font-size: 1.05rem; color: var(--emerald-3); }
.verse {
  position: relative; font-family: var(--ar); font-size: clamp(1.65rem, 5.6vw, 2.2rem); line-height: 2.35;
  text-align: center; word-spacing: 0.06em; padding: 4px 6px;
}
.verse-hidden { font-family: var(--ui); font-size: 1rem; line-height: 1.6; padding: 26px 0; color: var(--muted); }
.word-hl { color: var(--ok); background: var(--ok-bg); border-radius: 8px; padding: 0 5px; }
.mark { color: var(--gold); font-size: 0.8em; }
.ayah-end { color: var(--gold); font-size: 0.95em; padding: 0 4px; white-space: nowrap; }
.blank {
  display: inline-block; min-width: 3.6em; line-height: 1.3; margin: 0 4px; padding: 0 6px; color: var(--gold);
  background: var(--gold-soft); border-bottom: 3px dashed var(--gold); border-radius: 8px 8px 2px 2px;
}
.ellipsis { color: var(--gold); padding: 0 6px; }
.translation {
  position: relative; margin: 12px 0 0; padding-top: 12px; border-top: 1px dashed var(--line);
  font-size: 0.93rem; color: var(--muted); font-style: italic; text-align: center; line-height: 1.6;
}
.translation[dir='rtl'] { font-style: normal; font-size: 1.05rem; }
#hint-btn { position: relative; display: block; margin: 12px auto 0; }

/* Lecteur */
.audio-bar {
  display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); flex-wrap: wrap; box-shadow: var(--shadow-sm);
}
.btn-audio {
  width: 48px; height: 48px; border-radius: 50%; padding: 0; flex: none; font-size: 1rem;
  background: radial-gradient(circle at 30% 30%, var(--gold-2), var(--gold)); color: #1d1606; box-shadow: 0 4px 12px rgba(195, 154, 46, 0.35);
}
.btn-audio:disabled { background: var(--paper-2); color: var(--muted); box-shadow: none; opacity: 1; }
.audio-info { flex: 1; min-width: 110px; display: grid; font-size: 0.84rem; }
.audio-info span:first-child { font-weight: 650; }
.mini-select { width: auto; max-width: 190px; padding: 8px 10px; font-size: 0.82rem; }
@media (max-width: 560px) { .mini-select { max-width: none; width: 100%; } }
.audio-hint { margin: 0 4px 12px; font-size: 0.8rem; color: var(--muted); line-height: 1.45; }

/* Réponses */
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 4px; }
.choices-long { grid-template-columns: 1fr; }
@media (max-width: 480px) { .choices { grid-template-columns: 1fr; } }
.choice {
  position: relative; font: inherit; display: flex; align-items: center; gap: 12px; text-align: right; cursor: pointer;
  background: var(--card); color: var(--ink); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 10px 14px; min-height: 66px; box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.12s, background 0.15s, box-shadow 0.15s;
}
.choice:hover:not(:disabled) { border-color: var(--gold); transform: translateY(-1px); box-shadow: var(--shadow); }
.choice kbd {
  font-family: var(--ui); font-size: 0.72rem; font-weight: 700; color: var(--muted); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; width: 26px; height: 26px; display: grid; place-items: center; flex: none;
}
.choice-ar { font-family: var(--ar); font-size: 1.5rem; line-height: 1.9; flex: 1; direction: rtl; }
.choices-long .choice-ar { font-size: 1.32rem; }
.choices-surah .choice { text-align: start; }
.choice-main { flex: 1; font-weight: 650; }
.choices-surah .choice-ar { flex: none; font-size: 1.15rem; color: var(--emerald-3); }
.choice.correct { border-color: var(--ok); background: var(--ok-bg); }
.choice.correct kbd { background: var(--ok); color: #fff; border-color: var(--ok); }
.choice.wrong { border-color: var(--ko); background: var(--ko-bg); animation: shake 0.35s; }
.choice.wrong kbd { background: var(--ko); color: #fff; border-color: var(--ko); }
.choice:disabled { cursor: default; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Reconstitution */
.order-zone { position: relative; display: grid; gap: 14px; }
.order-answer, .order-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 64px; align-items: center; }
.order-answer { border: 2px dashed var(--line); border-radius: 14px; padding: 10px; background: var(--paper); }
.order-answer.ok { border-color: var(--ok); background: var(--ok-bg); }
.order-answer.ko { border-color: var(--ko); background: var(--ko-bg); }
.placeholder { font-family: var(--ui); color: var(--muted); font-size: 0.88rem; }
.tile {
  font-family: var(--ar); font-size: 1.42rem; line-height: 1.8; padding: 4px 14px; border-radius: 12px; cursor: pointer;
  background: var(--card); color: var(--ink); border: 1.5px solid var(--line); box-shadow: var(--shadow-sm); transition: transform 0.1s, opacity 0.15s;
}
.tile:hover:not(:disabled) { border-color: var(--gold); transform: translateY(-2px); }
.tile-used { opacity: 0.22; box-shadow: none; }
.tile-locked { background: var(--gold-soft); border-color: var(--gold); cursor: default; }
.tile:disabled { cursor: default; }
#validate-btn { width: 100%; margin-top: 12px; }

/* Retour */
.feedback {
  margin: 14px 0; padding: 13px 16px; border-radius: 14px; font-weight: 650; display: flex; gap: 8px; align-items: center;
  animation: rise 0.25s ease;
}
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.ko { background: var(--ko-bg); color: var(--ko); }

/* ===== Résultats ===== */
.results-card {
  text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 18px 22px; box-shadow: var(--shadow); margin-top: 6px; display: grid; justify-items: center; gap: 6px;
  background-image: var(--paper-pattern);
}
.results-ring {
  --pct: 0; width: 148px; height: 148px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--gold) calc(var(--pct) * 1%), var(--paper-2) 0);
  box-shadow: var(--shadow-sm);
}
.ring-inner { width: 120px; height: 120px; border-radius: 50%; background: var(--card); display: grid; place-content: center; gap: 0; }
.results-emoji { font-size: 2.1rem; line-height: 1.1; }
.ring-inner b { font-size: 1.15rem; font-variant-numeric: tabular-nums; color: var(--emerald-3); }
.results-card h2 { margin: 10px 0 0; font-size: 1.35rem; }
.results-score b { font-size: 2.6rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.results-score span { display: block; color: var(--muted); font-size: 0.85rem; margin-top: -4px; }
#results-detail { margin: 4px 0 0; font-size: 0.88rem; line-height: 1.5; }
.best { color: var(--gold); font-weight: 700; margin: 4px 0 0; }
.results-actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; width: 100%; max-width: 360px; }
.results-actions .btn { flex: 1; }
.review { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.review li { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--paper); border: 1px solid var(--line); font-size: 0.88rem; align-items: center; }
.review a { color: inherit; text-underline-offset: 3px; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 120px);
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 14px; font-size: 0.9rem;
  max-width: calc(100% - 32px); transition: transform 0.3s; z-index: 40; visibility: hidden; box-shadow: var(--shadow);
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

/* ===== Hors ligne ===== */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; text-align: center; font-size: 0.82rem;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: #5c4400; color: #fff6da;
}

/* ===== Fenêtres ===== */
.modal {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  background: rgba(6, 20, 15, 0.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-box { background: var(--card); border-radius: 20px; padding: 22px; width: 100%; max-width: 360px; box-shadow: var(--shadow); text-align: center; animation: rise 0.25s ease; }
.modal-box p { margin: 0 0 18px; font-weight: 600; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* Mot du créateur */
.help-link { margin-top: 2px; font-size: 0.78rem; font-weight: 500; color: var(--muted); opacity: 0.85; }
.help-link:hover { opacity: 1; }
.creator-box {
  position: relative; max-width: 440px; text-align: start; display: grid; gap: 10px; justify-items: center;
  max-height: calc(100vh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto;
}
.modal-close { position: absolute; top: 10px; inset-inline-end: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--paper-2); color: var(--ink); font: inherit; cursor: pointer; }
.donation-icon { font-size: 2rem; line-height: 1; }
.donation-body { display: grid; gap: 12px; min-width: 0; width: 100%; }
.donation-title { margin: 0; font-size: 1.1rem; text-align: center; }
.donation-text { margin: 0 !important; line-height: 1.65; font-weight: 400 !important; }
.donation-note { margin: 0 !important; font-size: 0.76rem; text-align: center; font-weight: 400 !important; }
.btn-gold { background: radial-gradient(circle at 30% 20%, var(--gold-2), var(--gold)); color: #1d1606; justify-self: stretch; }
.btn-gold:hover:not(:disabled) { filter: brightness(1.05); }
.donation-body[dir='rtl'] { text-align: right; }

/* Grands écrans : un peu plus d'air */
@media (min-width: 720px) {
  .hero { margin: 0 0 6px; border-radius: 0 0 36px 36px; }
  .start-bar { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
}

/* Interface de droite à gauche (arabe, ourdou) : la police de l'interface reste lisible */
html[dir='rtl'] body { font-family: var(--ui), 'Noto Naskh Arabic', 'Segoe UI', Tahoma, sans-serif; }
html[dir='rtl'] .choice { text-align: left; }
html[dir='rtl'] .choices-surah .choice { text-align: start; }
