:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --text: #1c1f2b;
  --muted: #6b7185;
  --line: #e2e5ee;
  --accent: #e3350d;
  --accent-text: #ffffff;
  --ok: #1f9d55;
  --ok-bg: #e7f7ee;
  --missing: #c5c9d6;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 14px rgba(20, 24, 40, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c;
    --surface: #1b1e29;
    --text: #e9ebf3;
    --muted: #9aa0b5;
    --line: #2b2f3d;
    --accent: #ff5a36;
    --ok: #3ccf7c;
    --ok-bg: #173325;
    --missing: #3a3f50;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select { font: inherit; color: inherit; }

/* ── En-tête ─────────────────────────────────────────────────────────────── */
.entete {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--accent); color: var(--accent-text);
}
.entete h1 { margin: 0; font-size: 1.5rem; letter-spacing: .02em; }
.sous-titre { margin: 0; opacity: .85; font-size: .9rem; }
.compte { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.compte form { margin: 0; }
.badge-admin { background: rgba(255,255,255,.18); padding: 4px 10px; border-radius: 999px; font-size: .82rem; }
.lien { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; }

/* ── Progression ─────────────────────────────────────────────────────────── */
.progression {
  max-width: 1200px; margin: 16px auto 0; padding: 16px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 18px;
  margin-inline: 16px;
}
@media (min-width: 1232px) { .progression { margin-inline: auto; } }
.chiffres { font-size: 1.1rem; }
.chiffres strong { font-size: 2rem; color: var(--ok); font-variant-numeric: tabular-nums; }
.pct { color: var(--muted); margin-left: 6px; }
.manquants { color: var(--muted); font-size: .9rem; margin-top: 6px; }
.barre { display: block; height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.barre > span { display: block; height: 100%; width: var(--p, 0%); background: var(--ok); border-radius: inherit; transition: width .3s; }
.barre.petite { height: 7px; margin: 0; }
.gens { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 18px; }
.gens li { display: grid; grid-template-columns: 7.5em 1fr 4.5em; align-items: center; gap: 8px; font-size: .88rem; }
.gen-nom { color: var(--muted); white-space: nowrap; }
.gen-chiffres { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.gen-chiffres b { color: var(--text); }
@media (max-width: 700px) { .progression { grid-template-columns: 1fr; } }

/* ── Filtres ─────────────────────────────────────────────────────────────── */
.filtres {
  position: sticky; top: 0; z-index: 5;
  max-width: 1200px; margin: 12px auto 0; padding: 10px 16px;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
}
.filtres input, .filtres select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.filtres input { flex: 1 1 200px; min-width: 0; }
.filtres select { flex: 0 1 auto; max-width: 100%; }
.compteur { color: var(--muted); font-size: .88rem; margin-left: auto; }

.message { max-width: 1200px; margin: 8px auto; padding: 8px 16px; border-radius: 10px; background: #fdecea; color: #9b1c1c; }
.message.erreur { margin: 8px 0; }

/* ── Grille ──────────────────────────────────────────────────────────────── */
main { max-width: 1200px; margin: 0 auto; padding: 0 16px 24px; }
.gen-titre { font-size: 1.05rem; margin: 22px 0 10px; color: var(--muted); font-weight: 600; }
.grille { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.pk[hidden], .gen-titre[hidden], .grille[hidden] { display: none; }

.carte {
  position: relative; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 6px 10px; border: 2px solid transparent; border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow); text-align: center;
}
button.carte { cursor: pointer; }
button.carte:hover { border-color: var(--line); }
button.carte:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.carte img { width: 96px; height: 96px; image-rendering: pixelated; }
.num { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.nom { font-weight: 600; font-size: .9rem; line-height: 1.2; overflow-wrap: anywhere; }
.types { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.t { font-size: .68rem; padding: 1px 6px; border-radius: 999px; background: var(--line); color: var(--muted); }
.coche {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  display: none; place-items: center; font-size: .8rem; font-weight: 700;
  background: var(--ok); color: #fff;
}

/* Manquant : grisé ; possédé : couleur + coche */
.pk:not(.possede) img { filter: grayscale(1) brightness(1.1); opacity: .35; }
.pk:not(.possede) .nom { color: var(--muted); }
.pk.possede .carte { border-color: var(--ok); background: var(--ok-bg); }
.pk.possede .coche { display: grid; }
.pk.en-cours .carte { opacity: .6; }

.vide { text-align: center; color: var(--muted); padding: 30px 0; }
.pied { text-align: center; color: var(--muted); font-size: .78rem; padding: 16px; }

/* ── Connexion ───────────────────────────────────────────────────────────── */
.page-login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.boite-login {
  width: min(360px, 100%); padding: 24px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow); max-width: none;
}
.boite-login h1 { margin: 0; color: var(--accent); }
.boite-login .sous-titre { color: var(--muted); margin-bottom: 16px; }
.boite-login label { display: block; font-size: .9rem; margin-bottom: 4px; }
.boite-login input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.boite-login button[type=submit] {
  margin-top: 12px; width: 100%; padding: 10px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-weight: 600; cursor: pointer;
}
.boite-login .lien { color: var(--muted); font-size: .9rem; }

@media (max-width: 480px) {
  .grille { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .carte img { width: 72px; height: 72px; }
  .compteur { width: 100%; margin-left: 0; }
}

/* ── Scan de cartes ──────────────────────────────────────────────────────── */
.bouton-scan {
  background: #fff; color: var(--accent); font-weight: 700; text-decoration: none;
  padding: 6px 12px; border-radius: 999px;
}
.scan { max-width: 640px; }
.scan-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; box-shadow: var(--shadow);
}
.bouton.principal { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.bouton:disabled { opacity: .6; cursor: default; }
.scan-actions .bouton { flex: 1 1 200px; }
.conseil { color: var(--muted); font-size: .88rem; }
.statut { min-height: 1.4em; font-weight: 600; }
.statut.erreur { color: #c0392b; }
#apercu { display: block; width: 100%; max-height: 40vh; object-fit: contain; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
#apercu[hidden] { display: none; }
#resultats h2 { font-size: 1.1rem; margin: 18px 0 8px; }
.candidats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.candidat {
  display: grid; grid-template-columns: 72px 1fr auto; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
}
.candidat img { image-rendering: pixelated; }
.candidat-texte { display: flex; flex-direction: column; min-width: 0; }
.candidat-texte strong { font-size: 1.05rem; overflow-wrap: anywhere; }
.candidat.deja { background: var(--ok-bg); }
.etat { color: var(--muted); font-size: .88rem; text-align: right; }
.etat.ok { color: var(--ok); font-weight: 700; }
.candidats .vide { color: var(--muted); padding: 8px 0; }
.manuel { margin-top: 16px; }
.manuel label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
.manuel input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 8px; }
.texte-lu { margin-top: 16px; color: var(--muted); font-size: .85rem; }
.texte-lu pre { white-space: pre-wrap; word-break: break-word; background: var(--surface); padding: 8px; border-radius: 8px; }
@media (max-width: 480px) {
  .candidat { grid-template-columns: 56px 1fr; }
  .candidat img { width: 56px; height: 56px; }
  .candidat > :last-child { grid-column: 1 / -1; text-align: left; }
  .candidat .bouton { width: 100%; }
}
