@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url(../fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url(../fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 800; font-display: swap; src: url(../fonts/inter-latin-800-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fraunces'; font-weight: 600; font-display: swap; src: url(../fonts/fraunces-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fraunces'; font-weight: 800; font-display: swap; src: url(../fonts/fraunces-latin-800-normal.woff2) format('woff2'); }

:root {
  --bg: #0F1226; --card: #181C3A; --card2: #20254A; --line: rgba(255,255,255,.09);
  --text: #E8EAF6; --muted: #9AA0C7; --gold: #F5C451; --sec: #F5C451; --good: #5BE3A1; --bad: #FF7E8A;
  --vvh: 100dvh;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; -webkit-text-size-adjust: 100%; touch-action: manipulation; overscroll-behavior: none; }
body { position: fixed; inset: 0; width: 100%; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
svg { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }
.bg { position: fixed; inset: 0; pointer-events: none; background:
  radial-gradient(60vmax 40vmax at 85% -10%, rgba(245,196,81,.14), transparent 60%),
  radial-gradient(50vmax 40vmax at -10% 110%, rgba(89,211,255,.12), transparent 60%); }

.screen { position: absolute; left: 0; right: 0; top: 0; display: none; flex-direction: column; align-items: center; gap: 16px; height: var(--vvh); width: 100%; max-width: 640px; margin: 0 auto; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  padding: calc(var(--st) + 20px) 18px calc(var(--sb) + 24px); }
.screen.active { display: flex; animation: in .35s ease both; }
@keyframes in { from { opacity: 0; transform: translateY(10px); } }

h1, h2, h3, .iq b { font-family: Fraunces, Georgia, serif; }
h1 { font-size: 46px; margin: 0; letter-spacing: -1px; }
h2 { font-size: 30px; margin: 0; text-align: center; }
h3 { margin: 0 0 12px; font-size: 20px; }
.tagline { margin: 4px 0 0; color: var(--muted); }
.home-top { display: flex; flex-direction: column; align-items: center; margin-top: 10px; }
.logo { width: 92px; height: 92px; margin-bottom: 8px; filter: drop-shadow(0 8px 24px rgba(245,196,81,.35)); }
.card { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; margin-bottom: 14px; }
.facts b { display: block; font-size: 26px; font-family: Fraunces, serif; color: var(--gold); }
.facts span { font-size: 13px; color: var(--muted); }
.sections-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.sections-list li { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.sections-list i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
.sections-list small { margin-inline-start: auto; color: var(--muted); font-weight: 400; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.field input { font: inherit; font-size: 17px; color: var(--text); background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; outline: none; -webkit-user-select: text; user-select: text; }
.field input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,196,81,.2); }
.btn { width: 100%; padding: 16px; border-radius: 16px; font-weight: 800; font-size: 17px; transition: transform .1s, opacity .2s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(180deg, #FFD56E, #E9AE2C); color: #1B1606; box-shadow: 0 8px 24px rgba(245,196,81,.25); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.link { color: var(--muted); text-decoration: underline; font-size: 14px; }
.fine { color: var(--muted); font-size: 13px; line-height: 1.5; text-align: center; margin: 0; }
.history .h-row { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); color: var(--muted); }
.history .h-row b { color: var(--gold); font-family: Fraunces, serif; font-size: 20px; }

/* Intro */
.step { display: flex; gap: 6px; }
.step i { width: 28px; height: 6px; border-radius: 3px; background: var(--line); }
.step i.done { background: var(--c); opacity: .5; }
.step i.on { background: var(--c); }
.lead { color: var(--muted); text-align: center; line-height: 1.55; margin: 0; }
.lead.center { text-align: center; }
.practice .ex { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.fb { margin: 12px 0 0; font-weight: 600; text-align: center; min-height: 1.4em; }
.fb.good { color: var(--good); } .fb.bad { color: var(--bad); }

/* Question */
.quiz-bar { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.qb-left { display: flex; flex-direction: column; }
.qb-left span { font-weight: 800; }
.qb-left small { color: var(--muted); }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 20px; padding: 6px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.timer.low { color: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .5; } }
.progress { width: 100%; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--sec); transition: width .4s; }
.q-area { width: 100%; flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; animation: in .3s both; }
.q-area.mini { gap: 12px; }
.quiz-foot { width: 100%; }

.matrix { flex: 0 0 auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(100%, 340px, 38vh); background: var(--line); gap: 2px; border: 2px solid var(--line); border-radius: 16px; overflow: hidden; }
.mcell { aspect-ratio: 1; min-width: 0; min-height: 0; overflow: hidden; background: var(--card); padding: 8%; }
.mcell.missing { display: grid; place-items: center; background: var(--card2); }
.mcell.missing span { font-family: Fraunces, serif; font-size: 40px; color: var(--sec); }
.opts { width: 100%; display: grid; gap: 10px; }
.opts.six { grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(100%, 360px, 50vh); }
.opts.four { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(100%, 320px, 40vh); }
.mini .opts.six { width: min(100%, 270px, 30vh); } .mini .matrix { width: min(100%, 220px, 26vh); } .mini .opts.four { width: min(100%, 220px, 26vh); }
.opt { aspect-ratio: 1; min-width: 0; min-height: 0; overflow: hidden; background: var(--card2); border: 2px solid var(--line); border-radius: 14px; padding: 10%; transition: border-color .15s, transform .1s; }
.opt:active { transform: scale(.96); }
.opt.chosen { border-color: var(--sec); background: color-mix(in srgb, var(--sec) 18%, var(--card2)); }
.opt.right { border-color: var(--good); box-shadow: 0 0 0 3px rgba(91,227,161,.3); }
.opts.list { grid-template-columns: minmax(0, 1fr); }
.opt.text { aspect-ratio: auto; padding: 14px 16px; text-align: start; display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 16px; line-height: 1.35; }
.letter { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--line); font-size: 13px; color: var(--muted); }
.question { font-size: 19px; line-height: 1.5; font-weight: 600; text-align: center; margin: 0; max-width: 520px; }
.model { width: 140px; text-align: center; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.model svg { width: 140px; height: 140px; background: var(--card); border: 2px solid var(--sec); border-radius: 18px; margin-top: 6px; padding: 8px; }

.seq { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 6px; font-family: Fraunces, serif; font-size: clamp(26px, 7vw, 38px); }
.seq i { color: var(--muted); font-style: normal; }
.seq .blank { color: var(--sec); }
.kp-out { min-width: 160px; padding: 10px 18px; border-radius: 14px; background: var(--card2); border: 2px solid var(--sec); text-align: center; font-size: 30px; font-weight: 800; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.kp-out.empty { border-color: var(--line); }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; max-width: 320px; }
.key { padding: 14px 0; font-size: 24px; font-weight: 600; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.key:active { background: var(--card2); transform: scale(.96); }
.key.blank { visibility: hidden; }
.ok { max-width: 320px; }
.span-disp { width: 160px; height: 160px; display: grid; place-items: center; border-radius: 30px; background: var(--card); border: 2px solid var(--line); transition: border-color .15s, transform .15s; }
.span-disp b { font-family: Fraunces, serif; font-size: 90px; color: var(--sec); }
.span-disp.flash { border-color: var(--sec); transform: scale(1.04); }

/* Résultats */
.result-body { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.kicker { margin: 10px 0 0; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-size: 13px; }
.iq b { font-size: 120px; line-height: 1; color: var(--gold); text-shadow: 0 10px 40px rgba(245,196,81,.35); }
.cat { margin: 0; font-size: 22px; font-weight: 800; }
.bell { text-align: center; }
.bell p { margin: 8px 0 0; color: var(--muted); }
.bell-svg text { fill: var(--muted); font-size: 10px; font-family: Inter, sans-serif; }
.dom { margin-bottom: 12px; }
.dom-h { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }
.dom-h small { color: var(--muted); }
.bar { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--w); background: var(--c); border-radius: 5px; animation: grow 1.2s cubic-bezier(.2,.8,.2,1) both; }
@keyframes grow { from { width: 0; } }
.actions { width: 100%; display: grid; gap: 10px; }
.disclaimer { max-width: 520px; }

.modal { position: fixed; inset: 0; display: none; align-items: flex-end; justify-content: center; background: rgba(5,6,15,.6); z-index: 20; }
.modal.open { display: flex; }
.sheet { width: min(640px, 100%); max-height: 85vh; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 24px 24px 0 0; padding: 22px 20px calc(var(--sb) + 20px); line-height: 1.55; color: var(--muted); animation: up .3s both; }
.sheet h3 { color: var(--text); }
@keyframes up { from { transform: translateY(100%); } }

@media (min-height: 800px) { .opt.text { padding: 16px 18px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
.q-area, .card, .practice { min-width: 0; max-width: 100%; }
.q-area { flex: 1 0 auto; }
.model { flex: 0 0 auto; }
@media (max-height: 700px) { .screen { gap: 10px; padding-top: calc(var(--st) + 12px); } .key { padding: 10px 0; } .span-disp { width: 120px; height: 120px; } .span-disp b { font-size: 70px; } }

/* ---- Safari iPhone : cases de taille fixe, dessin posé à l'intérieur (ne peut plus pousser la case) ---- */
.mcell, .opt:not(.text) { position: relative; aspect-ratio: auto; padding: 0; height: auto; }
.mcell::before, .opt:not(.text)::before { content: ''; display: block; padding-top: 100%; }
.mcell > svg, .opt:not(.text) > svg { position: absolute; left: 9%; top: 9%; width: 82%; height: 82%; }
.mcell.missing > span { position: absolute; inset: 0; display: grid; place-items: center; }
.bell-svg { width: 100%; height: auto; }
.model svg { width: 140px; height: 140px; }
