/* Lecteur de quiz générique. Les couleurs et polices viennent du thème (variables posées par app.js). */
:root {
  --bg1: #0b0221; --bg2: #2a0845; --fg: #fdf6ff; --muted: #d9c6f2;
  --accent: #ff3ea5; --accent2: #22e4ff; --card: rgba(20, 6, 48, .78); --border: rgba(34, 228, 255, .55);
  --btn: #1c0a3d; --btn-fg: #fff; --good: #19d98b; --bad: #ff5470; --cta: #ff3ea5; --cta-fg: #1a0028;
  --font-title: system-ui, sans-serif; --font-body: system-ui, -apple-system, sans-serif;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body); color: var(--fg);
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%) fixed;
  -webkit-text-size-adjust: 100%; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, a { font: inherit; }
[hidden] { display: none !important; }

.app {
  position: relative; z-index: 2;
  max-width: 600px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.screen { display: none; flex: 1; flex-direction: column; min-width: 0; }
.screen.active { display: flex; animation: enter .45s cubic-bezier(.2, .8, .2, 1); }
.screen.center { justify-content: center; align-items: center; text-align: center; gap: 14px; }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.muted { color: var(--muted); }
.small { font-size: .9rem; }
.badge, .onair {
  display: inline-block; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: .9rem;
  border: 1.5px solid var(--border); background: var(--card); color: var(--fg); letter-spacing: .02em;
}
.onair { color: #fff; background: #d6123f; border-color: #ff7a93; animation: blink 1.6s infinite; }
@keyframes blink { 50% { box-shadow: 0 0 0 8px rgba(214, 18, 63, 0); } 0% { box-shadow: 0 0 0 0 rgba(214, 18, 63, .6); } }

.title {
  font-family: var(--font-title); font-weight: var(--title-weight, 400); margin: 6px 0 0; line-height: 1.12;
  font-size: clamp(2.1rem, 10vw, 3.6rem); overflow-wrap: anywhere; max-width: 100%; word-spacing: var(--title-ws, normal);
}
#i-text { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--fg); }
.title.small { font-size: clamp(1.6rem, 7vw, 2.4rem); }
.title.plain { word-spacing: normal; font-family: var(--font-body); font-weight: 900; font-size: clamp(1.5rem, 6.4vw, 2.1rem); }
.subtitle { margin: 0; font-size: 1.12rem; color: var(--muted); max-width: 30em; line-height: 1.45; }
.hello { margin: 0; font-size: 1.3rem; font-weight: 700; }
.subtitle, .hint, .switch { text-shadow: 0 1px 8px var(--bg1), 0 0 2px var(--bg1); }
.hint { margin: 0; font-size: .92rem; color: var(--muted); }
.facts { list-style: none; padding: 0; margin: 4px 0; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.facts li { padding: 6px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--border); font-size: .92rem; }

.cta, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 12px 22px; border-radius: var(--radius); border: 0; cursor: pointer;
  font-weight: 800; font-size: 1.1rem; text-decoration: none; width: 100%; max-width: 420px;
  transition: transform .12s ease, filter .12s ease;
}
.cta { background: var(--cta); color: var(--cta-fg); box-shadow: 0 6px 0 rgba(0, 0, 0, .28), 0 0 26px color-mix(in srgb, var(--cta) 55%, transparent); }
.cta.big { min-height: 68px; font-size: 1.35rem; margin-top: 8px; }
.btn { background: var(--btn); color: var(--btn-fg); border: 2px solid var(--border); }
.btn.ghost { background: transparent; color: var(--fg); } /* GO 401 : lisible sur le fond du thème, pas sur celui des boutons */
.cta:active, .btn:active { transform: translateY(3px) scale(.99); }
.cta:focus-visible, .btn:focus-visible, .ans:focus-visible, .icon:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent2); outline-offset: 3px;
}

.switch { display: inline-flex; align-items: center; gap: 10px; font-size: .95rem; color: var(--muted); cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 28px; border-radius: 99px; background: var(--card); border: 2px solid var(--border); position: relative; flex: none; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch input:checked + .track { background: var(--accent2); }
.switch input:checked + .track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .track { outline: 3px solid var(--accent2); outline-offset: 2px; }

/* Égaliseur de l'intro */
.eq { display: flex; gap: 6px; align-items: flex-end; height: 56px; }
.eq i { width: 10px; border-radius: 4px; background: linear-gradient(var(--accent2), var(--accent)); animation: eq 1s ease-in-out infinite; height: 20%; }
.eq i:nth-child(2) { animation-delay: .15s } .eq i:nth-child(3) { animation-delay: .3s } .eq i:nth-child(4) { animation-delay: .05s }
.eq i:nth-child(5) { animation-delay: .4s } .eq i:nth-child(6) { animation-delay: .2s } .eq i:nth-child(7) { animation-delay: .35s }
@keyframes eq { 50% { height: 100%; } }
.eq.still i { animation-play-state: paused; }

/* HUD */
.hud { display: flex; flex-direction: column; gap: 10px; }
.progress { height: 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--border); overflow: hidden; }
.bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 99px; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.hudrow { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.count { font-weight: 800; font-size: 1.05rem; }
.streak { font-weight: 800; font-size: 1.05rem; color: var(--accent2); white-space: nowrap; }
.streak.pop { animation: pop .5s; }
.spacer { flex: 1; }
.icon {
  width: 48px; height: 48px; border-radius: 14px; border: 2px solid var(--border); background: var(--card);
  color: var(--fg); font-size: 1.35rem; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.icon.pill { width: auto; padding: 0 12px; font-size: 1rem; font-weight: 800; gap: 6px; display: inline-flex; align-items: center; }
.icon[aria-pressed="true"] { background: var(--accent2); color: #04131a; border-color: var(--accent2); }

.qwrap { flex: 1; display: flex; flex-direction: column; gap: 14px; padding-top: 10px; }
.qmeta { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.tag { font-size: .85rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--accent2); }
.timer { position: relative; width: 44px; height: 44px; display: grid; place-items: center; }
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 4; }
.t-bg { stroke: var(--card); }
.t-fg { stroke: var(--accent2); stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear; }
.timer span { font-weight: 800; font-size: .9rem; }
.timer.off, .timer.done { visibility: hidden; }
.calm { margin: 0; color: var(--muted); font-size: .95rem; }
.qtext {
  margin: 0; font-size: clamp(1.45rem, 6.4vw, 2.1rem); line-height: 1.25; font-weight: 800;
  padding: 18px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--border);
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent2) 22%, transparent);
  overflow-wrap: anywhere;
}
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answers.one { grid-template-columns: 1fr; }
.ans {
  min-height: 64px; padding: 12px 14px; border-radius: var(--radius); cursor: pointer;
  background: var(--btn); color: var(--btn-fg); border: 2px solid var(--border);
  font-size: 1.25rem; font-weight: 800; overflow-wrap: anywhere; position: relative;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .28); transition: transform .1s, background .2s, border-color .2s;
}
.ans .k { position: absolute; top: 6px; left: 10px; font-size: .72rem; opacity: .6; font-weight: 700; }
.ans:active { transform: translateY(3px); }
.ans:disabled { cursor: default; }
.ans.good { background: var(--good); border-color: var(--good); color: var(--good-fg, #04130c); animation: pop .45s; }
.ans.bad { background: var(--bad); border-color: var(--bad); color: var(--bad-fg, #1d0006); animation: shake .45s; }
.ans.dim { opacity: .45; }
.vf .ans { min-height: 88px; font-size: 1.5rem; }
.typein { display: flex; flex-direction: column; gap: 12px; }
.typein input {
  min-height: 60px; width: 100%; padding: 12px 16px; border-radius: var(--radius); font-size: 1.4rem; font-weight: 700;
  background: var(--btn); color: var(--btn-fg); border: 2px solid var(--border); text-align: center;
}
.typein input.good { border-color: var(--good); box-shadow: 0 0 0 3px var(--good); }
.typein input.bad { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad); animation: shake .45s; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* Feuille de retour */
.sheet {
  position: sticky; bottom: 0; margin: 16px -16px calc(-1 * max(16px, env(safe-area-inset-bottom)));
  padding: 16px 16px max(16px, env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0;
  background: var(--bg1); border-top: 3px solid var(--good); box-shadow: 0 -10px 30px rgba(0, 0, 0, .35);
  animation: up .35s cubic-bezier(.2, .8, .2, 1);
  display: flex; flex-direction: column; gap: 6px;
}
.sheet.bad { border-top-color: var(--bad); }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.verdict { margin: 0; font-size: 1.35rem; font-weight: 900; color: var(--good); }
.sheet.bad .verdict { color: var(--bad); }
.forms { margin: 0; font-size: 1.2rem; font-weight: 800; letter-spacing: .02em; }
.expl { margin: 0 0 8px; color: var(--muted); line-height: 1.4; }
.sheet .cta { max-width: none; }

/* Fin */
.scorebox { font-family: var(--font-title); line-height: 1; display: flex; align-items: baseline; gap: 6px; }
.score { font-size: clamp(4rem, 20vw, 6.5rem); color: var(--accent); text-shadow: 0 0 22px color-mix(in srgb, var(--accent) 60%, transparent); }
.total { font-size: clamp(1.8rem, 9vw, 2.6rem); color: var(--muted); }
.stars-row { margin: 0; font-size: 2rem; letter-spacing: 6px; min-height: 2.4rem; }
.review { width: 100%; max-width: 420px; text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.review-h { margin: 0 0 6px; font-weight: 800; }
.review ul { margin: 0; padding-left: 18px; line-height: 1.5; }
.actions { display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: center; }
/* GO 401 : « Copier » et « Recommencer tout le quiz » côte à côte, au-dessus du pli en 375x667 */
.actions-row { display: flex; gap: 10px; width: 100%; max-width: 420px; }
.actions-row .btn { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; font-size: 1rem; white-space: nowrap; }
.alt-link { color: var(--fg); opacity: .85; font-size: .95rem; text-decoration: underline; min-height: 44px; display: inline-flex; align-items: center; }

/* Décors */
.decor { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.decor > * { display: none; }
#confetti { position: fixed; inset: 0; z-index: 5; pointer-events: none; width: 100%; height: 100%; }

.decor.synthwave .stars, .decor.synthwave .sun, .decor.synthwave .grid { display: block; }
.stars {
  position: absolute; inset: 0 0 40% 0; opacity: .8;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 28% 42%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 47% 12%, #ffd6f5 50%, transparent 51%), radial-gradient(1px 1px at 63% 35%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 82% 22%, #bff6ff 50%, transparent 51%), radial-gradient(1px 1px at 91% 52%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 60%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 38% 66%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 8%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 55% 55%, #ffd6f5 50%, transparent 51%);
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { to { opacity: .45; } }
.sun {
  position: absolute; left: 50%; bottom: 34%; width: min(70vw, 420px); aspect-ratio: 1; transform: translateX(-50%);
  border-radius: 50%; opacity: .55; overflow: hidden;
  background: linear-gradient(180deg, #ffe66d 0%, #ff8a3d 40%, #ff3ea5 75%);
  filter: drop-shadow(0 0 40px rgba(255, 62, 165, .6));
}
.sun::after { content: ""; position: absolute; inset: 50% 0 0 0; background: repeating-linear-gradient(180deg, transparent 0 9px, #1d0638 9px 14px); }
.grid { position: absolute; left: -50%; right: -50%; bottom: 0; height: 36%; perspective: 520px; perspective-origin: 50% 0; overflow: hidden; }
.grid::before { content: ""; position: absolute; left: 0; right: 0; top: -2px; height: 3px; background: var(--accent2); box-shadow: 0 0 18px var(--accent2), 0 0 40px var(--accent); }
.grid-lines {
  position: absolute; inset: 0 0 -15% 0; transform: rotateX(58deg); transform-origin: top center;
  background-image:
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 85%, transparent) 2px, transparent 2px),
    linear-gradient(0deg, color-mix(in srgb, var(--accent2) 85%, transparent) 2px, transparent 2px);
  background-size: 48px 48px; animation: drive 1.6s linear infinite;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 30%); mask-image: linear-gradient(180deg, transparent 0%, #000 30%);
}
@keyframes drive { to { background-position: 0 48px; } }
.decor.synthwave::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(11, 2, 33, .55) 100%); }

.decor.manga .halftone, .decor.manga .speed { display: block; }
.halftone { position: absolute; inset: 0; background-image: radial-gradient(color-mix(in srgb, var(--accent) 22%, transparent) 2px, transparent 2.5px); background-size: 16px 16px; -webkit-mask-image: linear-gradient(160deg, #000, transparent 70%); mask-image: linear-gradient(160deg, #000, transparent 70%); }
.speed { position: absolute; inset: -40%; background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(20, 20, 20, .07) 0deg 2deg, transparent 2deg 9deg); animation: spin 60s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.decor.doux .blob { display: block; position: absolute; border-radius: 50%; filter: blur(60px); opacity: .45; }
.b1 { width: 60vmax; height: 60vmax; background: var(--accent); top: -30vmax; right: -20vmax; opacity: .18 !important; }
.b2 { width: 50vmax; height: 50vmax; background: var(--accent2); bottom: -25vmax; left: -20vmax; opacity: .2 !important; }

@media (min-width: 700px) {
  .app { padding-top: 32px; }
  .qwrap { padding-top: 24px; }
}
@media (max-width: 400px) {
  #btn-replay span { display: none; }
  #btn-replay { width: 48px; padding: 0; justify-content: center; }
  .hudrow { gap: 6px; }
}
@media (max-height: 620px) {
  .screen.center { gap: 10px; }
  .cta.big { min-height: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
