/* Quizz thématiques — un magazine de quiz : fond clair, grandes photos, une couleur par thème. */
:root {
    --paper: #f6f4ef;
    --card: #ffffff;
    --ink: #1d1c2b;
    --muted: #6d6a7c;
    --line: #e6e2d8;
    --accent: #ff5a36;
    --good: #16a34a;
    --good-soft: #dcf5e4;
    --bad: #dc2626;
    --bad-soft: #fde2e1;
    --theme: var(--accent);
    --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
    --f-body: "Atkinson Hyperlegible", -apple-system, "Segoe UI", system-ui, sans-serif;
    --radius: 18px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --paper: #15141c; --card: #201f2b; --ink: #f1eff7; --muted: #a4a1b6; --line: #34324a;
        --good-soft: #163a25; --bad-soft: #3d1a1a; color-scheme: dark;
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { background: var(--paper); }
body {
    min-height: 100vh; background: var(--paper); color: var(--ink);
    font: 17px/1.5 var(--f-body);
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left));
}
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
.app { max-width: 820px; margin: 0 auto; }
.screen { display: flex; flex-direction: column; gap: 18px; animation: rise 0.3s ease-out; }
@keyframes rise { from { transform: translateY(6px); opacity: 0.7; } to { transform: none; opacity: 1; } }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.15; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.6rem; font-weight: 800; }

/* Boutons */
.btn { font: 700 1rem var(--f-body); border: 0; border-radius: 999px; padding: 12px 22px; cursor: pointer; background: var(--theme); color: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18); transition: transform 0.08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.btn-big { font-size: 1.1rem; padding: 14px 28px; }
.btn-soft { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.icon-btn { border: 0; background: var(--card); color: var(--ink); width: 42px; height: 42px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; box-shadow: inset 0 0 0 2px var(--line); flex: none; }
.back { align-self: flex-start; border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.btn:focus-visible, .chip:focus-visible, .quiz-card:focus-visible, .choice:focus-visible, .icon-btn:focus-visible, .back:focus-visible { outline: 3px solid var(--theme); outline-offset: 3px; }

/* Accueil */
.home-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.brand { display: flex; gap: 14px; align-items: center; }
.brand-mark { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; font: 800 2rem var(--f-display); transform: rotate(-6deg); flex: none; }
.tagline { color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 0; border-radius: 999px; padding: 8px 16px; font: 700 0.92rem var(--f-body); background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); cursor: pointer; }
.chip.active { background: var(--ink); color: var(--paper); box-shadow: none; }
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.quiz-card {
    position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: 250px; text-align: left;
    border: 0; border-radius: var(--radius); overflow: hidden; cursor: pointer; padding: 0; font: inherit; color: #fff;
    background: var(--theme) center / cover no-repeat; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); transition: transform 0.15s;
}
.quiz-card:hover { transform: translateY(-3px); }
.quiz-card .qc-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0.82)); }
.quiz-card .qc-body { position: relative; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.quiz-card h3 { font-size: 1.3rem; }
.qc-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 0.8rem; font-weight: 700; }
.pill { padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.92); color: #1d1c2b; }
.pill.theme { background: var(--theme); color: #fff; }
.level-dots { letter-spacing: 2px; }
.qc-best { font-size: 0.82rem; opacity: 0.95; }

/* Présentation */
.intro-card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08); }
.intro-cover { height: 240px; background: var(--theme) center / cover no-repeat; }
.intro-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.intro-meta { display: flex; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 0.85rem; }
.intro-meta .pill { box-shadow: inset 0 0 0 2px var(--line); background: var(--paper); color: var(--ink); }
.intro-meta .pill.theme { background: var(--theme); color: #fff; box-shadow: none; }
.intro-text { color: var(--muted); }
.best { color: var(--muted); font-size: 0.9rem; }
.seg { border: 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg legend { font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; width: 100%; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 8px 16px; border-radius: 999px; background: var(--paper); font-weight: 700; box-shadow: inset 0 0 0 2px var(--line); cursor: pointer; }
.seg input:checked + span { background: var(--ink); color: var(--paper); box-shadow: none; }
.seg input:focus-visible + span { outline: 3px solid var(--theme); }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.names input { font: inherit; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); color: var(--ink); min-width: 0; }

/* Partie */
.play-bar { display: flex; align-items: center; gap: 12px; }
.play-progress { flex: 1; min-width: 0; }
.play-label { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.9rem; color: var(--muted); margin-bottom: 5px; font-variant-numeric: tabular-nums; }
.streak { color: var(--theme); }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--theme); border-radius: 99px; transition: width 0.35s ease; }
.scoreboard { display: flex; gap: 10px; }
.score-pill { flex: 1; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line); font-weight: 700; min-width: 0; }
.score-pill.active { box-shadow: inset 0 0 0 3px var(--theme); }
.score-pill b { font: 800 1.3rem var(--f-display); font-variant-numeric: tabular-nums; }
.score-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.q-card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08); }
.q-card.shake { animation: shake 0.4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.q-media { position: relative; background: #111; display: grid; place-items: center; aspect-ratio: 16 / 9; max-height: 380px; width: 100%; overflow: hidden; }
.q-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; transition: filter 0.5s ease; }
/* Fond : la même photo, floutée, pour habiller les bandes vides quand la photo n'a pas le format du cadre. */
.q-media .q-media-bg { position: absolute; inset: -30px; background: center / cover no-repeat; filter: blur(24px) brightness(0.45); }
.q-media.hidden-img img { filter: blur(26px) brightness(0.7); }
.q-media .veil { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 700; text-align: center; padding: 16px; font-size: 0.95rem; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.q-media.broken { display: none; }
.q-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.q-tag { font: 700 0.75rem var(--f-body); letter-spacing: 0.1em; text-transform: uppercase; color: var(--theme); }
.q-text { font: 700 1.3rem/1.35 var(--f-display); }

.choices { display: flex; flex-direction: column; gap: 10px; }
.choices.vf { flex-direction: row; }
.choices.vf .choice { flex: 1; justify-content: center; font-size: 1.15rem; min-height: 64px; }
.choice {
    display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
    padding: 12px 14px; min-height: 56px; border-radius: 14px; border: 0; cursor: pointer;
    background: var(--paper); color: var(--ink); font: 600 1rem/1.35 var(--f-body); box-shadow: inset 0 0 0 2px var(--line);
    transition: transform 0.08s, background 0.2s;
}
.choice:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--theme); }
.choice:active:not(:disabled) { transform: scale(0.99); }
.choice .letter { flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font: 800 0.95rem var(--f-display); background: var(--card); box-shadow: inset 0 0 0 2px var(--line); }
.choice .mark { margin-left: auto; font-size: 1.2rem; font-weight: 800; }
.choice:disabled { cursor: default; }
.choice.right { background: var(--good-soft); box-shadow: inset 0 0 0 2px var(--good); }
.choice.right .letter { background: var(--good); color: #fff; box-shadow: none; }
.choice.wrong { background: var(--bad-soft); box-shadow: inset 0 0 0 2px var(--bad); }
.choice.wrong .letter { background: var(--bad); color: #fff; box-shadow: none; }
.choices.done .choice:not(.right):not(.wrong) { opacity: 0.55; }

.answer-box { border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; background: var(--paper); border-left: 6px solid var(--good); }
.answer-box.ko { border-left-color: var(--bad); }
.answer-box h3 { font-size: 1.1rem; }
.answer-box .credit { font-size: 0.78rem; color: var(--muted); }
.sources { font-size: 0.82rem; color: var(--muted); }
.sources a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.sources a:hover { color: var(--ink, #222); }
.next-row { display: flex; justify-content: flex-end; }

/* Résultat */
.end-card { background: var(--card); border-radius: var(--radius); padding: 26px; display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08); }
.end-medal { font-size: 3.6rem; animation: pop 0.7s ease-out; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: none; } }
.end-sub { color: var(--muted); }
.end-scores { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.end-score { background: var(--paper); border-radius: 14px; padding: 10px 18px; font-weight: 700; }
.end-score b { display: block; font: 800 2rem var(--f-display); color: var(--theme); }
.end-grid { font-size: 1.05rem; letter-spacing: 1px; display: flex; flex-direction: column; gap: 4px; }
.end-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.share-msg { color: var(--good); font-size: 0.9rem; min-height: 1.2em; }
.review { display: flex; flex-direction: column; gap: 10px; }
.review-item { display: grid; grid-template-columns: 96px 1fr; gap: 12px; background: var(--card); border-radius: 14px; padding: 12px; box-shadow: inset 0 0 0 2px var(--line); }
.review-item img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--line); }
.review-item p { font-size: 0.92rem; color: var(--muted); }
.review-item b { color: var(--ink); }

@media (max-width: 560px) {
    .names { grid-template-columns: 1fr; }
    .intro-cover { height: 180px; }
    .q-text { font-size: 1.15rem; }
    .review-item { grid-template-columns: 72px 1fr; }
    .review-item img { width: 72px; height: 56px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Difficulté de chaque question (1 à 4 points) */
.q-diff { letter-spacing: 2px; margin-left: 6px; color: var(--muted); }

.intro-notice { margin: 8px 0 0; padding: 10px 12px; border-left: 3px solid var(--theme); border-radius: 8px; background: rgba(127,127,127,.12); font-size: .92rem; }

.play-nav { display: flex; gap: 6px; flex: none; }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* Quiz de vocabulaire : le mot affiché en grand à la place d'une image. */
.q-media.q-word { background: linear-gradient(135deg, var(--theme), #1d1c2b); padding: 24px; }
.q-media.q-word span { color: #fff; font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.8rem); text-align: center; line-height: 1.15; overflow-wrap: anywhere; text-shadow: 0 2px 12px rgba(0,0,0,.35); }

/* Profils et statistiques */
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.profile-btn { border: 0; border-radius: 999px; padding: 9px 16px; font: 700 0.92rem var(--f-body); background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); cursor: pointer; white-space: nowrap; }
.profile-btn:focus-visible, .linkish:focus-visible { outline: 3px solid var(--theme); outline-offset: 3px; }
.names select { font: inherit; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); color: var(--ink); min-width: 0; }
.hint { color: var(--muted); font-size: 0.9rem; }
.hint:empty { display: none; }
.linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--theme); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.profile-list { display: flex; flex-direction: column; gap: 10px; }
.profile-card { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: inset 0 0 0 2px var(--line); flex-wrap: wrap; }
.profile-card.active { box-shadow: inset 0 0 0 3px var(--accent); }
.profile-card .avatar { font-size: 2.2rem; line-height: 1; }
.pc-main { display: flex; flex-direction: column; flex: 1; min-width: 140px; }
.pc-main b { font: 800 1.2rem var(--f-display); }
.pc-main span { color: var(--muted); font-size: 0.9rem; }
.pc-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pc-actions .btn { padding: 9px 16px; font-size: 0.92rem; }
.pc-actions .pill { box-shadow: inset 0 0 0 2px var(--line); background: var(--paper); color: var(--ink); font-weight: 700; font-size: 0.85rem; padding: 6px 12px; }
.profile-form { background: var(--card); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: inset 0 0 0 2px var(--line); }
.profile-form input[type=text] { font: inherit; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); color: var(--ink); }
.profile-form .btn { align-self: flex-start; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-pick input { position: absolute; opacity: 0; pointer-events: none; }
.emoji-pick span { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; font-size: 1.5rem; background: var(--paper); box-shadow: inset 0 0 0 2px var(--line); cursor: pointer; }
.emoji-pick input:checked + span { box-shadow: inset 0 0 0 3px var(--accent); background: var(--card); }
.emoji-pick input:focus-visible + span { outline: 3px solid var(--accent); }

.stats { display: flex; flex-direction: column; gap: 14px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06); }
.stat-card h3 { font-size: 1.15rem; }
.stat-card.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stat-card.errors { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; border-left: 6px solid var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tile { background: var(--paper); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; }
.tile b { font: 800 1.7rem var(--f-display); font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 0.85rem; }
.insight { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 12px; background: var(--paper); border-left: 4px solid var(--accent); }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 0.92rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar-val { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar-num { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 4.6em; text-align: right; }
.bar-num small { display: block; font-weight: 400; color: var(--muted); font-size: 0.75rem; }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 110px; padding-top: 6px; }
.spark span { flex: 1; max-width: 36px; border-radius: 6px 6px 2px 2px; background: var(--accent); opacity: 0.85; }
.duel { font-size: 0.95rem; }
.stats-foot { text-align: center; font-size: 0.85rem; }
.stats-foot .linkish { color: var(--muted); }
@media (max-width: 560px) {
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .stat-card.two { grid-template-columns: 1fr; }
    .bar-row { grid-template-columns: minmax(90px, 40%) 1fr auto; font-size: 0.88rem; }
}

/* ---------- Téléphone (testé aux tailles iPhone 15 Pro, 16 Pro, 16 Pro Max et SE) ---------- */
@media (max-width: 560px) {
    /* Accueil : en-tête allégé, filtres faciles à toucher, deux cartes par ligne. */
    .tagline { display: none; }
    .brand-mark { width: 46px; height: 46px; font-size: 1.6rem; }
    .chip { min-height: 40px; padding: 8px 14px; }
    .quiz-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .quiz-card { min-height: 190px; }
    .quiz-card .qc-body { padding: 10px; gap: 5px; }
    .quiz-card h3 { font-size: 0.98rem; line-height: 1.2; }
    .qc-meta { font-size: 0.68rem; gap: 4px; }
    .pill { padding: 2px 7px; }
    /* Question : la photo ne prend pas plus d'un tiers de l'écran, les réponses restent visibles. */
    .q-media { max-height: 33vh; }
    /* Après la réponse : l'explication arrive en haut, le bouton suivant reste collé en bas. */
    #after { scroll-margin-top: 12px; }
    .next-row { position: sticky; bottom: 0; z-index: 5; margin: 0 -4px; padding: 14px 4px max(12px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, var(--card) 38%); }
    .next-row .btn { width: 100%; min-height: 52px; font-size: 1.05rem; }
}

/* Défi par lien : bandeau sur l'écran de présentation. */
.challenge-banner { background: color-mix(in srgb, var(--theme) 16%, var(--card)); border: 2px solid var(--theme); border-radius: 14px; padding: 12px 14px; line-height: 1.4; }

/* Défi par lien : bandeau sur l'écran de présentation. */
.challenge-banner { background: color-mix(in srgb, var(--theme) 16%, var(--card)); border: 2px solid var(--theme); border-radius: 14px; padding: 12px 14px; line-height: 1.4; }
.share-msg { overflow-wrap: anywhere; }

/* Compte en ligne */
.account-body { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.account-body input { font: inherit; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
#accCode { letter-spacing: 6px; font-size: 1.3rem; text-align: center; }
#accountMsg { text-align: left; }
@media (max-width: 560px) { .head-actions { flex-wrap: wrap; justify-content: flex-end; } }

/* Images transparentes (SVG, PNG, GIF) : fond clair dans le cadre et dans la revue des erreurs. */
.q-media.transp { background: #f4f2ec; }
.q-media.transp .q-media-bg { display: none; }
.review-item img[src*=".svg"], .review-item img[src*=".png"], .review-item img[src*=".PNG"] { background: #f4f2ec; object-fit: contain; }
