:root {
  --red: #E30613; --red-2: #FF2B2B; --red-dark: #A3000B; --gold: #FFB703; --gold-2: #FFD166; --cream: #FFF7EE;
  --ink: #1B1718; --muted: #6E6264; --line: #EFE3D8; --card: #FFFFFF; --soft: #FBF2E9;
  --ok: #138A4B; --ok-bg: #E4F6EC; --warn: #9A5B00; --warn-bg: #FFF1D2; --bad: #B3261E; --bad-bg: #FDE8E6;
  --radius: 22px; --shadow: 0 10px 30px rgba(90, 20, 20, .10); --shadow-sm: 0 4px 12px rgba(90, 20, 20, .08);
  --display: 'Baloo 2', 'Inter', system-ui, sans-serif;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--font); }
body { min-height: 100dvh; font-size: 17px; line-height: 1.5; overscroll-behavior-y: none; }
body.lang-ar, body.lang-prs { --font: 'Noto Sans Arabic', 'Inter', sans-serif; --display: 'Baloo Bhaijaan 2', 'Noto Sans Arabic', sans-serif; }
body.lang-ur { --font: 'Noto Nastaliq Urdu', 'Noto Sans Arabic', sans-serif; --display: 'Baloo Bhaijaan 2', 'Noto Sans Arabic', sans-serif; line-height: 2.05; }
body.lang-bn { --font: 'Noto Sans Bengali', 'Inter', sans-serif; --display: 'Baloo Da 2', 'Noto Sans Bengali', sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, .display { font-family: var(--display); letter-spacing: -.01em; }
h1 { font-size: 30px; line-height: 1.15; margin: 6px 0; }
h2 { font-size: 22px; line-height: 1.2; margin: 26px 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
bdi[dir="ltr"] { direction: ltr; unicode-bidi: isolate; display: inline-block; font-family: 'Inter', system-ui, sans-serif; font-weight: 700; line-height: 1.2; }

/* ---------- barre du haut ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: rgba(255, 247, 238, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-family: 'Baloo 2', 'Inter', sans-serif; font-weight: 800; letter-spacing: .04em; color: var(--red); direction: ltr; }
.logo { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--red); font-size: 20px; box-shadow: var(--shadow-sm); }
.brand-text { font-size: 17px; }
.top-actions { display: flex; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-sm); }
.topbar.dark { background: var(--red); border-color: transparent; }
.topbar.dark .brand { color: #fff; }
.topbar.dark .logo { background: rgba(255,255,255,.18); }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(120px + var(--safe-b)); }
main.flush { padding: 0 0 calc(120px + var(--safe-b)); max-width: 560px; }

/* ---------- éléments communs ---------- */
.hero { position: relative; overflow: hidden; background: radial-gradient(120% 120% at 0% 0%, var(--red-2), var(--red) 45%, var(--red-dark)); color: #fff;
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.hero::after { content: ''; position: absolute; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 183, 3, .18); inset-inline-end: -70px; top: -80px; }
.hero > * { position: relative; z-index: 1; }
.hero h1 { margin-top: 0; }
.hero .sub, .sub { color: rgba(255,255,255,.9); margin: 4px 0 0; }
.sub { color: var(--muted); }
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 60px; padding: 14px 20px; border: 0; border-radius: 18px;
  background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff; font-size: 19px; font-weight: 800; font-family: var(--display);
  box-shadow: 0 8px 18px rgba(200, 16, 46, .30), inset 0 -3px 0 rgba(0,0,0,.15); transition: transform .08s; }
.btn:active { transform: translateY(2px); box-shadow: 0 4px 10px rgba(200, 16, 46, .25); }
.btn[disabled] { background: #D8CCC2; box-shadow: none; cursor: not-allowed; }
.btn.gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #3A2600; box-shadow: 0 8px 18px rgba(255, 183, 3, .35), inset 0 -3px 0 rgba(0,0,0,.10); }
.btn.secondary { background: #fff; color: var(--red); border: 2px solid var(--line); box-shadow: var(--shadow-sm); }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; min-height: 48px; font-weight: 700; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.alert { padding: 12px 14px; border-radius: 14px; margin: 12px 0; font-weight: 600; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.field { display: block; margin: 14px 0; }
.field span { display: block; font-weight: 700; margin-bottom: 6px; }
.input { width: 100%; min-height: 58px; padding: 12px 16px; border: 2px solid var(--line); border-radius: 16px; background: #fff; font-size: 20px; }
.input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 4px rgba(200, 16, 46, .12); }
.spinner { width: 38px; height: 38px; border: 4px solid #F1E2D4; border-top-color: var(--red); border-radius: 50%; animation: spin 1s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.bottom-bar { position: fixed; inset-inline: 0; bottom: 0; z-index: 15; background: linear-gradient(180deg, rgba(255,247,238,0), var(--cream) 30%);
  padding: 22px 16px calc(14px + var(--safe-b)); }
.bottom-bar .inner { max-width: 528px; margin: 0 auto; }
.fade-in { animation: fadeUp .35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- accueil / langue ---------- */
.welcome { min-height: calc(100dvh - 56px); display: flex; flex-direction: column; }
.welcome-hero { text-align: center; padding: 26px 20px 30px; background: radial-gradient(130% 100% at 50% 0%, var(--red-2), var(--red) 55%, var(--red-dark));
  color: #fff; border-radius: 0 0 36px 36px; box-shadow: var(--shadow); }
.mascot { width: 104px; height: 104px; margin: 6px auto 12px; border-radius: 32px; background: #fff; display: grid; place-items: center; font-size: 60px;
  box-shadow: 0 12px 26px rgba(0,0,0,.18); transform: rotate(-6deg); }
.welcome-hero h1 { font-size: 32px; margin: 0; }
.welcome-hero p { margin: 6px 0 0; opacity: .92; font-size: 15px; }
.lang-list { display: grid; gap: 12px; padding: 20px 16px; }
.lang-btn { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; padding: 12px 16px; background: #fff; border: 2px solid transparent;
  border-radius: 20px; box-shadow: var(--shadow-sm); text-align: start; }
.lang-btn:active { border-color: var(--red); }
.lang-badge { flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-family: 'Inter', sans-serif; color: #fff; font-size: 15px; }
.lang-btn .names { flex: 1; }
.lang-btn .native { display: block; font-size: 22px; font-weight: 700; line-height: 1.3; }
.lang-btn .fr { display: block; font-size: 13px; color: var(--muted); font-family: 'Inter', sans-serif; }
.lang-btn .go { color: var(--red); font-size: 22px; font-weight: 800; }

/* ---------- connexion ---------- */
.login-card { background: #fff; border-radius: 28px; padding: 22px 18px; box-shadow: var(--shadow); margin-top: -26px; position: relative; }
.who { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--soft); border-radius: 16px; margin-bottom: 8px; }
.avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #3A2600; font-weight: 800; font-size: 20px; font-family: 'Baloo 2', sans-serif; }
.who b { flex: 1; font-size: 20px; }
.link { background: none; border: 0; color: var(--red); font-weight: 700; padding: 6px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 8px; direction: ltr; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #D6C6B8; transition: all .15s; }
.pin-dots i.on { background: var(--red); border-color: var(--red); transform: scale(1.1); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; direction: ltr; }
.keypad button { min-height: 66px; border: 0; border-radius: 20px; background: var(--soft); font-size: 28px; font-weight: 700; font-family: 'Inter', sans-serif; }
.keypad button:active { background: #F1E1D2; transform: scale(.97); }
.keypad .fn { background: transparent; font-size: 24px; color: var(--muted); }

/* ---------- tableau de bord ---------- */
.dash-head { display: flex; align-items: center; gap: 16px; }
.ring { --p: 0; flex: none; width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), rgba(255,255,255,.22) 0); }
.ring > span { width: 72px; height: 72px; border-radius: 50%; background: var(--red); display: grid; place-items: center; font-weight: 800; font-size: 20px; font-family: 'Inter', sans-serif; direction: ltr; }
.prize-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.prize { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 14px; }
.cta-card { margin-top: 16px; }
.path { position: relative; margin: 8px 0 0; padding: 0; list-style: none; }
.path::before { content: ''; position: absolute; inset-inline-start: 31px; top: 30px; bottom: 30px; width: 4px; border-radius: 4px; background: repeating-linear-gradient(180deg, #E8D7C6 0 10px, transparent 10px 18px); }
.step { position: relative; display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 12px 10px 0; background: none; border: 0; text-align: start; }
.node { position: relative; z-index: 1; flex: none; width: 66px; height: 66px; border-radius: 22px; display: grid; place-items: center; font-size: 32px; color: #fff; box-shadow: var(--shadow-sm); border: 4px solid var(--cream); }
.step .body { flex: 1; min-width: 0; background: #fff; border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow-sm); border: 2px solid transparent; }
.step .body small { color: var(--muted); font-weight: 600; }
.step .body b { display: block; font-size: 18px; line-height: 1.3; font-family: var(--display); }
.step.done .node::after { content: '✓'; position: absolute; inset-inline-end: -6px; bottom: -6px; width: 24px; height: 24px; border-radius: 50%; background: var(--ok); color: #fff;
  font-size: 15px; font-weight: 800; display: grid; place-items: center; border: 3px solid var(--cream); font-family: 'Inter', sans-serif; }
.step.next .body { border-color: var(--red); }
.step.next .node { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(200,16,46,.45); } 50% { box-shadow: 0 0 0 12px rgba(200,16,46,0); } }
.step.locked .node { background: #D9CCC0 !important; filter: grayscale(1); }
.step.exam .node { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #3A2600; }
.best { display: inline-flex; gap: 6px; align-items: center; margin-top: 6px; font-weight: 800; font-size: 14px; padding: 4px 10px; border-radius: 999px; }
.best.ok { background: var(--ok-bg); color: var(--ok); } .best.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- leçon (format « story ») ---------- */
.story { position: relative; min-height: calc(100dvh - 56px); display: flex; flex-direction: column; background: var(--cream); }
.story-bars { display: flex; gap: 5px; padding: 12px 16px 6px; direction: ltr; }
.story-bars i { flex: 1; height: 5px; border-radius: 5px; background: #EADCCF; overflow: hidden; }
.story-bars i.on { background: var(--c); }
.story-bars i.cur { background: linear-gradient(90deg, var(--c) 100%, #EADCCF 0); }
.story-top { display: flex; align-items: center; gap: 10px; padding: 4px 16px 10px; }
.story-top .mini-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 20px; flex: none; }
.story-top .ttl { flex: 1; min-width: 0; }
.story-top .ttl small { color: var(--muted); font-weight: 600; display: block; line-height: 1.2; }
.story-top .ttl b { font-family: var(--display); font-size: 18px; line-height: 1.2; display: block; }
.close { width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--shadow-sm); font-size: 18px; font-weight: 800; }
.story-card { margin: 0 16px; border-radius: 28px; overflow: hidden; background: #fff; box-shadow: var(--shadow); position: relative; }
.story-visual { position: relative; height: 38vh; min-height: 210px; max-height: 330px; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(120% 90% at 30% 10%, color-mix(in srgb, var(--c) 55%, #fff), var(--c)); }
.story-visual::before, .story-visual::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,.14); }
.story-visual::before { width: 240px; height: 240px; inset-inline-start: -60px; bottom: -110px; }
.story-visual::after { width: 150px; height: 150px; inset-inline-end: -40px; top: -40px; }
.story-visual .emoji { position: relative; z-index: 1; font-size: 118px; filter: drop-shadow(0 12px 18px rgba(0,0,0,.2)); animation: pop .45s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.story-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.story-visual .num { position: absolute; z-index: 2; top: 12px; inset-inline-start: 12px; background: rgba(0,0,0,.28); color: #fff; font-weight: 800; border-radius: 999px; padding: 4px 10px; font-size: 13px; font-family: 'Inter', sans-serif; direction: ltr; }
.tap-zone { position: absolute; top: 0; bottom: 0; width: 35%; z-index: 3; background: transparent; border: 0; }
.tap-zone.back { inset-inline-start: 0; } .tap-zone.fwd { inset-inline-end: 0; }
.story-text { padding: 20px 20px 16px; font-size: 22px; line-height: 1.5; font-weight: 600; }
body.lang-ur .story-text { font-size: 21px; line-height: 2.15; font-weight: 400; }
.listen { display: inline-flex; align-items: center; gap: 8px; margin: 0 20px 20px; background: var(--soft); color: var(--ink); border: 0; border-radius: 999px; padding: 10px 16px; font-weight: 800; font-size: 15px; }
.hint { text-align: center; color: var(--muted); font-size: 13px; margin: 12px 0 0; }

/* ---------- célébration ---------- */
.celebrate { text-align: center; padding: 40px 10px 10px; }
.medal { width: 140px; height: 140px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; font-size: 76px;
  background: radial-gradient(circle at 35% 30%, #fff, var(--gold-2) 45%, var(--gold)); box-shadow: 0 16px 34px rgba(255, 183, 3, .45); animation: pop .5s cubic-bezier(.2,1.4,.4,1) both; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* ---------- examen ---------- */
.exam-intro .fact { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: 18px; padding: 14px; margin: 10px 0; box-shadow: var(--shadow-sm); font-weight: 700; }
.exam-intro .fact span:first-child { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--soft); font-size: 24px; flex: none; }
.exam-top { position: sticky; top: 56px; z-index: 5; background: var(--cream); padding: 10px 0 8px; }
.exam-meta { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-family: var(--display); font-size: 18px; }
.timer { display: inline-flex; align-items: center; gap: 6px; font-family: 'Inter', monospace; font-weight: 800; background: #fff; border-radius: 999px; padding: 6px 12px; box-shadow: var(--shadow-sm); direction: ltr; }
.timer.low { background: var(--bad-bg); color: var(--bad); }
.seg { display: flex; gap: 3px; margin-top: 10px; direction: ltr; }
.seg i { flex: 1; height: 6px; border-radius: 6px; background: #EADCCF; }
.seg i.ans { background: var(--gold); } .seg i.cur { background: var(--red); }
.qcard { background: #fff; border-radius: 24px; padding: 20px; box-shadow: var(--shadow); margin: 14px 0 6px; }
.qtext { font-size: 23px; font-weight: 800; line-height: 1.4; font-family: var(--display); margin: 0; }
body.lang-ur .qtext { line-height: 2.1; font-weight: 700; }
.option { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 66px; margin: 10px 0; padding: 12px 14px; text-align: start;
  background: #fff; border: 2px solid transparent; border-radius: 18px; font-size: 18px; font-weight: 600; box-shadow: var(--shadow-sm); transition: transform .08s; }
.option:active { transform: scale(.99); }
.option .letter { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-family: 'Inter', sans-serif; color: #fff; }
.option.sel { border-color: var(--red); background: #FFF1F1; }
.option.sel .letter { box-shadow: 0 0 0 4px rgba(200,16,46,.2); }
.qnav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 14px 0; direction: ltr; }
.qnav button { height: 48px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font-weight: 800; font-family: 'Inter', sans-serif; }
.qnav button.ans { background: var(--ok-bg); border-color: #A9DDBE; color: var(--ok); }
.qnav button.empty { background: var(--bad-bg); border-color: #F3B8B2; color: var(--bad); }

/* ---------- résultat ---------- */
.score-ring { --p: 0; width: 190px; height: 190px; margin: 10px auto; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), rgba(255,255,255,.2) 0); }
.score-ring > div { width: 158px; height: 158px; border-radius: 50%; background: var(--red); display: grid; place-items: center; text-align: center; }
.score-big { font-size: 58px; font-weight: 800; font-family: 'Inter', sans-serif; line-height: 1; direction: ltr; }
.prize-banner { display: flex; align-items: center; gap: 14px; background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #3A2600; border-radius: 20px; padding: 16px; margin-top: 16px; font-weight: 800; font-size: 18px; box-shadow: var(--shadow); }
.prize-banner .big { font-size: 40px; }
.miss { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; margin: 8px 0; background: #fff; border: 0; border-radius: 16px; box-shadow: var(--shadow-sm); text-align: start; }
.miss .mini-ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; color: #fff; flex: none; }
.miss b { flex: 1; font-family: var(--display); font-size: 17px; }

/* ---------- attestation ---------- */
.cert { background: #fff; border: 8px double var(--red); border-radius: 16px; padding: 28px 22px; text-align: center; margin-top: 16px; direction: ltr; font-family: 'Inter', sans-serif; }
.cert h2 { color: var(--red); margin-top: 6px; font-family: 'Baloo 2', sans-serif; }
.cert .name { font-size: 34px; font-weight: 800; margin: 14px 0; font-family: 'Baloo 2', sans-serif; }
.cert small { color: var(--muted); display: block; margin-top: 16px; font-size: 12px; }

@media print {
  .topbar, .bottom-bar, .no-print, #confetti { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Logo officiel Chicken Drive */
.brand-logo { height: 30px; width: auto; display: block; }
.brand-tag { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 11px; letter-spacing: .12em; color: #fff; background: #FF0000; border-radius: 6px; padding: 3px 7px; }
.hero-logo { display: block; width: min(250px, 70%); height: auto; margin: 4px auto 14px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.25)); }
