:root {
  --red: #e4003a;
  --red-dark: #b80030;
  --pink: #f5b5d2;
  --pink-pale: #fcf4f8;
  --pink-soft: #fde2ec;
  --ink: #221a25;
  --muted: #8b7f88;
  --white: #ffffff;
  --bg: #fcf4f8;
  --grad: linear-gradient(266deg, #F5B5D2 -30.97%, #FCF4F8 57.37%);
  --radius: 18px;
  --shadow: 0 12px 30px rgba(228, 0, 58, 0.12);
  --shadow-sm: 0 4px 16px rgba(228, 0, 58, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* L'attribut [hidden] doit toujours l'emporter sur les règles d'affichage */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

/* La scène AR est derrière l'interface */
#ar-container { position: fixed; inset: 0; z-index: 0; }
#ar-container .a-canvas, #ar-container video { object-fit: cover; }
#app { position: relative; z-index: 1; height: 100dvh; }

/* ---------- Écrans ---------- */
.screen { position: absolute; inset: 0; display: none; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.screen.is-active { display: flex; }
.screen--scan { background: transparent; pointer-events: none; }
.screen--scan .scan-topbar, .screen--scan .scan-bottom, .screen--scan .banner { pointer-events: auto; }

/* ---------- Accueil ---------- */
.screen--home { background: var(--grad); color: var(--ink); overflow-y: auto; }
.home-inner { margin: auto; width: 100%; max-width: 460px; padding: 34px 22px; text-align: center; }
.brand-logo { width: 146px; height: auto; display: block; margin: 0 auto 22px; }
.home-title { font-size: 32px; line-height: 1.12; margin: 0 0 8px; font-weight: 800; color: var(--ink); }
.home-subtitle { font-size: 16px; line-height: 1.45; margin: 0 0 24px; color: #6c5f6a; }
.card { background: var(--white); color: var(--ink); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); text-align: left; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.field { width: 100%; padding: 14px 16px; font-size: 16px; border: 2px solid #f0dde6;
  border-radius: 12px; outline: none; transition: border-color .15s; }
.field:focus { border-color: var(--red); }
.fatal-msg { background: var(--red); color: #fff; padding: 12px 14px; border-radius: 12px;
  margin-bottom: 14px; font-size: 14px; line-height: 1.45; }
.link-demo { margin: 18px auto 0; display: block; background: none; border: none;
  color: var(--red); text-decoration: underline; font-size: 14px; font-weight: 600; cursor: pointer; }
.home-foot { margin-top: 16px; font-size: 12px; color: var(--muted); }
.resume-hint { background: var(--pink-soft); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px;
  font-size: 13.5px; line-height: 1.35; color: var(--ink); display: flex; flex-direction: column; gap: 6px; }
.resume-change { align-self: flex-start; background: none; border: none; color: var(--red);
  font-weight: 700; font-size: 13px; text-decoration: underline; cursor: pointer; padding: 0; }

/* ---------- Boutons ---------- */
.btn { border: none; border-radius: 12px; font-size: 16px; font-weight: 700;
  padding: 14px 18px; cursor: pointer; transition: transform .05s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn--block { width: 100%; display: block; }
.btn--primary { background: var(--red); color: #fff; margin-top: 14px; }
.btn--primary:hover { background: var(--red-dark); }
.btn--ghost { background: transparent; color: var(--red); box-shadow: inset 0 0 0 2px var(--pink); margin-top: 10px; }
.btn--light { background: #fff; color: var(--red); box-shadow: var(--shadow); }

/* ---------- Scan ---------- */
.scan-topbar { display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: linear-gradient(180deg, rgba(34,26,37,.62), transparent); }
.icon-btn { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%; border: none;
  background: #fff; color: var(--red); font-size: 20px; cursor: pointer;
  box-shadow: var(--shadow-sm); display: grid; place-items: center; }
.progress { flex: 1; }
.progress-bar { height: 9px; background: rgba(255,255,255,.5); border-radius: 99px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0%; background: var(--red);
  border-radius: 99px; transition: width .4s ease; }
.progress-text { display: block; margin-top: 5px; font-size: 12px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.45); }
.scan-hint { margin: auto; text-align: center; color: #fff; }
.reticle { width: 210px; height: 210px; margin: 0 auto 16px; border-radius: 26px;
  border: 3px dashed rgba(255,255,255,.9);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.04); animation: pulse 2s infinite ease-in-out; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.04); opacity: 1; } }
.scan-hint p { font-size: 15px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.55); }
.scan-tip { margin: 8px auto 0; max-width: 290px; font-size: 12.5px; font-weight: 500 !important;
  line-height: 1.35; opacity: .82; }
.scan-hint.scan--init .reticle { opacity: .45; animation-duration: 1.1s; }
.scan-hint.scan--init .scan-tip { opacity: .5; }
.scan-bottom { padding: 16px; display: flex; justify-content: center; }
.scan-bottom .btn { min-width: 200px; }
.banner { position: absolute; left: 12px; right: 12px; bottom: 86px;
  background: rgba(228,0,58,.95); color: #fff; padding: 10px 14px; border-radius: 12px;
  font-size: 13px; text-align: center; box-shadow: var(--shadow); }
.banner code { background: rgba(255,255,255,.25); padding: 1px 5px; border-radius: 5px; }

/* ---------- En-têtes d'écran ---------- */
.screen--album, .screen--board { background: var(--bg); }
.screen-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 10px; }
.screen-head h2 { flex: 1; margin: 0; font-size: 20px; color: var(--ink); }
.head-count { font-weight: 800; color: var(--red); background: var(--pink-soft);
  padding: 5px 12px; border-radius: 99px; font-size: 14px; }
.head-spacer { width: 42px; flex: 0 0 42px; }

/* ---------- Album ---------- */
/* Grille 2 colonnes en ordre de lecture (1 gauche, 2 droite, 3 gauche…).
   minmax(0,1fr) empêche tout débordement horizontal ; align-items:start évite les chevauchements. */
.album-grid { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 8px 16px 16px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px;
  align-content: start; align-items: start; }
.album-card { background: #fff; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm);
  text-align: left; border: none; padding: 0; display: flex; flex-direction: column; min-width: 0; }
.album-card.found { cursor: pointer; }
/* hauteur FIXE (et non aspect-ratio) pour éviter toute superposition selon les navigateurs */
.album-card .thumb { height: 150px; width: 100%; object-fit: cover; background: var(--pink-pale); display: block; }
.album-card .meta { padding: 10px 12px 12px; }
.album-card .meta .num { font-size: 11px; font-weight: 700; color: var(--red); letter-spacing: .5px; }
.album-card .meta .name { font-size: 14px; font-weight: 700; margin: 2px 0 0; line-height: 1.2; color: var(--ink); }

/* Cartes « à trouver » : indice mis en avant, lisible */
.album-card.locked { padding: 13px 13px 15px; }
.album-card .locktag { align-self: flex-start; background: var(--pink-soft); color: var(--red);
  font-size: 10px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px; }
.album-card.locked .num { font-size: 11px; font-weight: 700; color: var(--red);
  letter-spacing: .5px; margin-top: 11px; }
.album-card .hint { margin: 5px 0 0; font-size: 14px; line-height: 1.4; color: #4a3f4d; }
.album-card .hint-label { display: inline-block; font-weight: 800; color: var(--red); }
.album-card .sim { margin: 12px 0 0; width: 100%; font-size: 12px; font-weight: 700; color: var(--red);
  background: var(--pink-soft); border: none; border-radius: 9px; padding: 9px; cursor: pointer; }
.album-cta { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--bg); }

/* ---------- Podium (top 3) ---------- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; padding: 12px 16px 2px; }
.podium-spot { flex: 1 1 0; max-width: 33%; min-width: 0; text-align: center; }
.podium-name { font-weight: 800; font-size: 13px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium-sc { font-size: 11px; color: var(--muted); font-weight: 700; margin: 1px 0 5px; }
.podium-step { border-radius: 12px 12px 0 0; display: grid; place-items: center; font-size: 22px; color: #fff; }
.podium .p1 .podium-step { height: 74px; background: var(--red); }
.podium .p2 .podium-step { height: 56px; background: #f3789f; }
.podium .p3 .podium-step { height: 42px; background: #f6a9c4; }
.podium-spot.me .podium-name { color: var(--red); }
.podium-spot.me .podium-step { outline: 3px solid #ffcf5a; outline-offset: -3px; }

/* ---------- Classement ---------- */
.result-card { margin: 4px 16px 10px; background: var(--red); color: #fff; border-radius: 14px;
  padding: 14px 16px; box-shadow: var(--shadow); }
.result-line { margin: 0; font-size: 15px; font-weight: 600; }
.board-list { list-style: none; margin: 0; padding: 0 16px; flex: 1; overflow-y: auto; }
.board-row { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 12px;
  padding: 12px 14px; margin-bottom: 9px; box-shadow: var(--shadow-sm); }
.board-row .rank { width: 28px; font-weight: 800; color: var(--muted); text-align: center; }
.board-row.me { outline: 2px solid var(--red); }
.board-row .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.board-row .who-name { font-weight: 700; color: var(--ink); }
.board-row .dev { font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 1px; }
.board-row .sc { font-weight: 800; color: var(--red); }
.board-row .tm { font-size: 12px; color: var(--muted); margin-left: 8px; }
.board-empty { text-align: center; color: var(--muted); margin: 30px 16px; }

/* ---------- Modale (centrée, dessin affiché en entier) ---------- */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(34,26,37,.5);
  display: grid; place-items: center; padding: 20px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card { background: #fff; width: 100%; max-width: 400px; border-radius: 22px;
  padding: 24px 22px; text-align: center; max-height: 86vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(34,26,37,.3); animation: pop .26s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-badge { display: inline-block; background: var(--red); color: #fff;
  font-weight: 800; font-size: 12px; padding: 5px 12px; border-radius: 99px; margin-bottom: 14px; }
.modal-badge.seen { background: var(--pink-soft); color: var(--red); }
.modal-img { display: block; max-width: 100%; max-height: 240px; width: auto; height: auto;
  margin: 0 auto 16px; border-radius: 14px; box-shadow: var(--shadow-sm); }
.modal-title { margin: 0 0 8px; font-size: 21px; color: var(--ink); }
.modal-text { margin: 0 0 18px; color: #4a3f4d; line-height: 1.5; font-size: 15px; }

/* Tutoriel */
.tuto-card { text-align: center; }
.tuto-dots { display: flex; justify-content: center; gap: 7px; margin-bottom: 14px; }
.tuto-dots .dot { width: 7px; height: 7px; border-radius: 50%; background: #e7d7df; }
.tuto-dots .dot.on { background: var(--red); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px;
  font-weight: 600; box-shadow: var(--shadow); max-width: 90%; text-align: center; }

@media (min-width: 520px) {
  .album-grid { column-count: 3; }
}
