:root {
  --bg: #fff6f9;
  --surface: #ffffff;
  --text: #2b1a22;
  --muted: #6b535e;
  --pink: #c2185b;
  --pink-strong: #a0134a;
  --on-pink: #ffffff;
  --pink-soft: #fde4ee;
  --border: #f0cfdc;
  --ok: #17673a;
  --ok-bg: #e3f6ea;
  --bad: #a8201a;
  --bad-bg: #fde7e5;
  --focus: #1d4ed8;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(80 20 45 / 8%), 0 4px 14px rgb(80 20 45 / 6%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1217;
    --surface: #271a21;
    --text: #f8eaf0;
    --muted: #c7acb8;
    --pink: #f06292;
    --pink-strong: #f48fb1;
    --on-pink: #2b0a17;
    --pink-soft: #3a2230;
    --border: #4a2f3c;
    --ok: #7fdca4;
    --ok-bg: #16301f;
    --bad: #ff9a92;
    --bad-bg: #3a1c1a;
    --focus: #93b4ff;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
  flex: 1;
  outline: none;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--pink-strong); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.skip {
  position: absolute; left: -999px; top: 0; background: var(--pink); color: var(--on-pink);
  padding: .5rem 1rem; z-index: 10;
}
.skip:focus { left: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- header / footer ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); text-decoration: none; }
.brand img { border-radius: 8px; }
#nav { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; }
#nav a, #nav button {
  background: none; border: 0; font: inherit; color: var(--pink-strong); padding: .5rem .6rem; border-radius: 8px;
  cursor: pointer; text-decoration: none; min-height: 44px;
}
#nav a:hover, #nav button:hover { background: var(--pink-soft); }

.site-footer {
  max-width: 42rem; margin: 0 auto; padding: 1rem; font-size: .85rem; color: var(--muted); text-align: center;
}

/* ---------- building blocks ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card > :last-child { margin-bottom: 0; }

.hero { padding: .5rem 0 1rem; }
.hero p { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: .6rem 1.25rem; border-radius: 999px; border: 2px solid var(--pink);
  background: var(--pink); color: var(--on-pink); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--pink-strong); border-color: var(--pink-strong); }
.btn.secondary { background: transparent; color: var(--pink-strong); }
.btn.secondary:hover { background: var(--pink-soft); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }

label { display: block; font-weight: 600; margin-bottom: .25rem; }
input[type="text"], input[type="email"], select {
  width: 100%; min-height: 48px; padding: .6rem .8rem; font: inherit; color: var(--text);
  background: var(--surface); border: 2px solid var(--border); border-radius: 10px;
}
input.code { letter-spacing: .4em; font-size: 1.5rem; text-align: center; }
.field { margin-bottom: 1rem; }
.check { display: flex; gap: .65rem; align-items: flex-start; font-weight: 400; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: .2rem; accent-color: var(--pink); flex: none; }

.error, .notice {
  border-radius: 10px; padding: .65rem .85rem; margin: 0 0 1rem; font-weight: 600;
}
.error { background: var(--bad-bg); color: var(--bad); }
.notice { background: var(--ok-bg); color: var(--ok); }

.chip {
  display: inline-block; font-size: .78rem; font-weight: 700; padding: .15rem .6rem; border-radius: 999px;
  background: var(--pink-soft); color: var(--pink-strong); white-space: nowrap;
}
.chip.open { background: var(--ok-bg); color: var(--ok); }

details { margin-bottom: 1rem; }
summary { cursor: pointer; font-weight: 600; padding: .4rem 0; min-height: 44px; display: flex; align-items: center; }
details ul { margin: .25rem 0 0; padding-left: 1.25rem; }

/* ---------- weeks ---------- */
.week { display: grid; gap: .5rem; }
.week-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.week h3 { margin: 0; }
.week .when { font-size: .88rem; color: var(--muted); margin: 0; }
.week .score { font-weight: 700; }

.winner-row { display: flex; justify-content: space-between; gap: .75rem; padding: .5rem 0; border-top: 1px solid var(--border); }
.winner-row:first-of-type { border-top: 0; }

/* ---------- quiz ---------- */
.q-meta { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-weight: 600; margin-bottom: .5rem; }
.timer { margin-bottom: 1rem; }
.timer-track { height: 12px; border-radius: 999px; background: var(--pink-soft); overflow: hidden; }
.timer-fill { height: 100%; background: var(--pink); transform-origin: left center; border-radius: 999px; }
.timer-text { display: flex; justify-content: flex-end; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .25rem; }
.timer.urgent .timer-fill { background: var(--bad); }
.timer.urgent .timer-text { color: var(--bad); }

.question { font-size: 1.3rem; margin-bottom: 1rem; outline: none; }
.choices { display: grid; gap: .65rem; }
.choice {
  display: flex; align-items: center; gap: .75rem; text-align: left; width: 100%;
  min-height: 56px; padding: .75rem .9rem; font: inherit; color: var(--text); cursor: pointer;
  background: var(--surface); border: 2px solid var(--border); border-radius: 12px;
}
.choice:hover:not([disabled]) { border-color: var(--pink); background: var(--pink-soft); }
.choice[disabled] { cursor: default; }
.choice-key {
  flex: none; display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  background: var(--pink-soft); color: var(--pink-strong); font-weight: 700; font-size: .9rem;
}
.choice.correct { border-color: var(--ok); background: var(--ok-bg); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.choice .mark { margin-left: auto; font-weight: 700; flex: none; }
.choice.correct .mark { color: var(--ok); }
.choice.wrong .mark { color: var(--bad); }

.feedback { margin-top: 1rem; }
.feedback h3 { outline: none; }
.feedback.good h3 { color: var(--ok); }
.feedback.bad h3 { color: var(--bad); }

.big-score { font-size: 2.6rem; font-weight: 800; color: var(--pink-strong); line-height: 1.1; margin: .25rem 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .75rem; margin: 1rem 0; }
.stat { background: var(--pink-soft); border-radius: 12px; padding: .6rem .8rem; }
.stat b { display: block; font-size: 1.25rem; }
.stat span { font-size: .85rem; color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
caption { text-align: left; font-weight: 700; padding-bottom: .5rem; }
th, td { padding: .55rem .5rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: .82rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.me { background: var(--pink-soft); font-weight: 700; }
tr.gap td { text-align: center; color: var(--muted); border-bottom: 0; padding: .2rem; }

.resources { margin: 0; padding-left: 1.2rem; }
.resources li { margin-bottom: .35rem; }

.noscript { padding: 1rem; text-align: center; }

/* ---------- Google sign-in ---------- */
.google-box { display: flex; justify-content: center; min-height: 44px; }
.google-block.pending { visibility: hidden; height: 0; overflow: hidden; margin: 0; }
.divider { display: flex; align-items: center; gap: .75rem; margin: .9rem 0 1rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

textarea {
  width: 100%; padding: .6rem .8rem; font: inherit; color: var(--text); background: var(--surface);
  border: 2px solid var(--border); border-radius: 10px; resize: vertical;
}

/* ---------- poster (Partager) ---------- */
.poster { text-align: center; padding: 1.5rem 1rem; }
.poster-kicker { color: var(--pink-strong); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin: 0; }
.poster-title { font-size: 2rem; margin: .1rem 0 .5rem; }
.poster-lead { font-size: 1.3rem; font-weight: 700; margin: 0 0 .5rem; }
.poster-qr { width: min(280px, 70vw); height: auto; background: #fff; border-radius: 12px; padding: .25rem; }
.poster-url { font-weight: 700; word-break: break-all; margin: .5rem 0; }
.poster-when { margin: .15rem 0; color: var(--muted); }

/* ---------- owner area ---------- */
.btn.small { min-height: 36px; padding: .25rem .8rem; font-size: .88rem; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin: 0 0 1rem; border-bottom: 2px solid var(--border); }
.tabs a {
  padding: .55rem .9rem; text-decoration: none; font-weight: 600; border-radius: 8px 8px 0 0; color: var(--muted);
  min-height: 44px; display: inline-flex; align-items: center;
}
.tabs a[aria-current="page"] { color: var(--pink-strong); box-shadow: inset 0 -3px 0 var(--pink); }
.tabs a:hover { background: var(--pink-soft); }

.health { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.health-item { display: flex; gap: .75rem; align-items: flex-start; padding: .6rem .75rem; border-radius: 10px; border: 1px solid var(--border); }
.health-item p { margin: .1rem 0 0; }
.health-badge { flex: none; font-size: .75rem; font-weight: 800; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.health-item.ok .health-badge { background: var(--ok-bg); color: var(--ok); }
.health-item.warn { border-color: #d97706; }
.health-item.warn .health-badge { background: #fef3c7; color: #92400e; }
.health-item.error { border-color: var(--bad); }
.health-item.error .health-badge { background: var(--bad-bg); color: var(--bad); }
@media (prefers-color-scheme: dark) {
  .health-item.warn .health-badge { background: #422006; color: #fcd34d; }
}

tr.excluded { opacity: .6; }
tr.excluded td:first-child .chip, td .chip { margin-left: .4rem; }
input[type="search"] {
  width: 100%; min-height: 48px; padding: .6rem .8rem; font: inherit; color: var(--text);
  background: var(--surface); border: 2px solid var(--border); border-radius: 10px;
}
.review h3 { font-size: 1.05rem; }
.choices-review { margin: .25rem 0 .75rem; padding-left: 1.25rem; }
.choices-review li.right { color: var(--ok); }

@media print {
  .site-header, .site-footer, .skip, .no-print, .tabs, .sim-banner { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; break-inside: avoid; border-color: #bbb; }
  /* "Imprimer l'affiche" prints the poster alone, large, on a clean page. */
  body.print-poster .no-poster, body.print-poster h1 { display: none !important; }
  body.print-poster .poster { border: 0; padding-top: 3rem; }
  body.print-poster .poster-title { font-size: 3rem; }
  body.print-poster .poster-lead { font-size: 1.8rem; }
  body.print-poster .poster-qr { width: 420px; }
  body.print-poster .poster-url, body.print-poster .poster-when { font-size: 1.2rem; color: #000; }
}

.sim-banner {
  background: #b45309; color: #fff; text-align: center; font-weight: 700; font-size: .85rem; padding: .35rem 1rem;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (min-width: 40rem) {
  main { padding-top: 1.5rem; }
  h1 { font-size: 1.9rem; }
  .question { font-size: 1.45rem; }
}
