/* La traversée RECO — interface. Couleurs neutres (noir, crème) qui laissent
   la place au jeu. Polices système seulement (la CSP bloque les polices
   externes). Mobile d'abord (390 px de large). */

:root {
  --noir: #121110;
  --noir-2: #1d1b19;
  --creme: #f3ede1;
  --creme-2: #e6dece;
  --gris: #aaa293;
  --ligne: rgba(243, 237, 225, 0.16);
  --voile: rgba(18, 17, 16, 0.74);
  --or: #d9a636;
  --or-fonce: #9c7419;
  --rayon: 16px;
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  --gauche: env(safe-area-inset-left, 0px);
  --droite: env(safe-area-inset-right, 0px);
}

/* Pas de flash bleu au toucher ; le contour clavier (:focus-visible) reste */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Tout l'écran, sans défilement ni zoom au double toucher */
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background: var(--noir);
  color: var(--creme);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.4;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }

/* Toute la fenêtre. container-type : les tailles de texte suivent le cadre (cqi). */
#cadre {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--noir);
  container-type: inline-size;
}

#jeu {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: var(--noir);
  touch-action: none;
  cursor: pointer;
}

.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; padding: 20px; text-align: center; }

/* ── Écrans par-dessus le jeu ─────────────────────────── */
.ecran {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(16px + var(--haut)) calc(16px + var(--droite)) calc(16px + var(--bas)) calc(16px + var(--gauche));
  background: var(--voile);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: center;
}
/* margin auto : centré verticalement, sans couper le haut si ça déborde */
.carte {
  width: 100%;
  max-width: 440px;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.carte p { margin: 0; }

.marque {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gris);
}
.titre {
  margin: 0;
  font-size: clamp(2rem, 9.5vw, 2.6rem);
  font-size: clamp(1.8rem, 10cqi, 2.6rem);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.sous-titre { color: var(--creme-2); font-size: 1rem; }
.surtitre {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gris);
}
.titre-palier { margin: 0; font-size: clamp(1.6rem, 7vw, 2rem); font-size: clamp(1.5rem, 7.5cqi, 2rem); line-height: 1.1; font-weight: 800; }

.avatar { display: block; }
.avatar-accueil {
  width: min(140px, 18dvh);
  height: min(140px, 18dvh);
  margin: 8px 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(243, 237, 225, 0.14) 0%, rgba(243, 237, 225, 0) 70%);
}
.avatar-fin {
  width: min(110px, 14dvh);
  height: min(110px, 14dvh);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(243, 237, 225, 0.2) 0%, rgba(243, 237, 225, 0) 70%);
}

.aide { color: var(--gris); font-size: 0.9rem; max-width: 320px; }
.aide { display: flex; flex-direction: column; gap: 4px; }
.aide-fort { color: var(--creme-2); font-weight: 700; }

/* ── Boutons ──────────────────────────────────────────── */
.boutons {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  min-height: 50px;
  padding: 12px 20px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--creme);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .btn-icone:focus-visible { outline: 2px solid rgba(243, 237, 225, 0.7); outline-offset: 3px; }
.btn-principal { background: var(--creme); color: var(--noir); }
.btn-principal:hover { background: #fff; }
.btn-secondaire { border-color: var(--ligne); background: rgba(243, 237, 225, 0.06); }
.btn-secondaire:hover { background: rgba(243, 237, 225, 0.12); }
.btn-discret { min-height: 44px; color: var(--gris); font-weight: 600; font-size: 0.95rem; }
.btn-discret:hover { color: var(--creme); }
.btn-son { width: auto; }
.ico { width: 22px; height: 22px; flex: none; }

.confirmer { color: var(--creme-2); max-width: 300px; }

/* ── Intro de palier ──────────────────────────────────── */
.bandeau {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--or);
  color: var(--noir);
  font-weight: 800;
  font-size: 0.95rem;
}
.points { display: flex; gap: 8px; margin-top: 2px; }
.point { width: 9px; height: 9px; border-radius: 50%; background: var(--ligne); }
.point.fait { background: var(--gris); }
.point.actuel { background: var(--creme); box-shadow: 0 0 0 3px rgba(243, 237, 225, 0.25); }

/* Les dessins ont un fond blanc (ou transparent) : on les pose sur du blanc */
.cadre-image {
  width: min(100%, 36dvh, 290px);
  aspect-ratio: 1;
  margin: 4px 0;
  border-radius: var(--rayon);
  background: #fff;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.image-collection { display: block; width: 100%; height: 100%; object-fit: contain; }
.intro-texte { display: flex; flex-direction: column; gap: 8px; color: var(--creme-2); font-size: 1rem; max-width: 360px; }
.intro-texte p:first-child { color: var(--creme); font-weight: 600; }
.ecran-intro .btn-principal { margin-top: 6px; }

/* ── Fin ──────────────────────────────────────────────── */
.titre-fin { font-size: clamp(1.6rem, 7.4vw, 2.2rem); font-size: clamp(1.5rem, 7.6cqi, 2.2rem); max-width: 11em; }
.stats { display: flex; gap: 10px; justify-content: center; }
.stats:empty { display: none; }
.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--ligne);
  border-radius: 999px;
  background: rgba(243, 237, 225, 0.06);
}
.stat-nb { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stat-mot { color: var(--gris); }
.recompense {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  padding: 18px 16px;
  border-radius: var(--rayon);
  background: var(--creme);
  color: var(--noir);
}
.recompense-titre { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; color: var(--or-fonce); }
.recompense-texte { font-size: 1.15rem; font-weight: 800; line-height: 1.25; max-width: 19em; }
.recompense .btn-principal { background: var(--noir); color: var(--creme); }
.recompense .btn-principal:hover { background: #000; }
.bientot { color: #6b6457; font-style: italic; }
.code-ligne { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.code {
  padding: 6px 12px;
  border: 1.5px dashed var(--or-fonce);
  border-radius: 10px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  -webkit-user-select: all;
  user-select: all;
  word-break: break-all;
}
.btn-copier { width: auto; min-height: 40px; padding: 8px 16px; font-size: 0.95rem; color: var(--noir); border-color: rgba(18, 17, 16, 0.3); }

/* ── Barre d'infos en jeu (flottante) ─────────────────── */
.hud {
  position: absolute;
  z-index: 10;
  top: calc(8px + var(--haut));
  left: calc(8px + var(--gauche));
  right: calc(8px + var(--droite));
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 8px 8px 14px;
  border-radius: var(--rayon);
  /* pas de flou derrière le HUD : il coûtait cher à chaque image (audit du 4 nov.) */
  background: rgba(18, 17, 16, 0.86);
  pointer-events: none;   /* les touchers passent au jeu, sauf sur les boutons */
}
.hud-ligne { display: flex; align-items: center; gap: 8px; }
.hud-titre { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.15; }
.hud-num { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gris); }
.hud-nom { font-weight: 800; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-infos { display: flex; align-items: center; gap: 6px; flex: none; }
.pastille {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(243, 237, 225, 0.08);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.etiquette { font-size: 0.72rem; font-weight: 600; color: var(--gris); }
.btn-icone {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(243, 237, 225, 0.1);
  color: var(--creme);
  cursor: pointer;
  pointer-events: auto;
}
.btn-icone:active { background: rgba(243, 237, 225, 0.2); }
.btn-icone .ico { width: 20px; height: 20px; }
.barre {
  height: 5px;
  margin: 8px 6px 2px 0;
  border-radius: 999px;
  background: rgba(243, 237, 225, 0.14);
  overflow: hidden;
}
.barre-remplie {
  height: 100%;
  background: var(--creme);
  border-radius: inherit;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s ease;
}

/* Une piastre */
.piece {
  display: inline-block;
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f6d77a 0%, var(--or) 55%, var(--or-fonce) 100%);
  box-shadow: inset 0 0 0 1.5px rgba(90, 62, 10, 0.45);
}
.stat .piece { width: 16px; height: 16px; }

/* ── Message de chute ─────────────────────────────────── */
.chute {
  position: absolute;
  z-index: 12;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  padding: 14px 26px;
  border-radius: var(--rayon);
  background: rgba(18, 17, 16, 0.85);
  text-align: center;
  pointer-events: none;
  animation: apparait 0.18s ease-out;
}
.chute p { margin: 0; }
.chute-titre { font-size: 1.8rem; font-weight: 800; white-space: nowrap; }
.chute-sous { font-size: 0.85rem; color: var(--gris); white-space: nowrap; }
@keyframes apparait {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ── Téléphone à l'horizontale : « tourne ton téléphone » ─ */
.tourner { display: none; }
@media (pointer: coarse) and (orientation: landscape) {
  .tourner {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    background: var(--noir);
    text-align: center;
  }
  .tourner p { margin: 0; }
  .tourner-titre { font-size: 1.4rem; font-weight: 800; }
  .tourner-texte { color: var(--gris); }
  .tourner-icone {
    width: 34px;
    height: 56px;
    margin-bottom: 10px;
    border: 3px solid var(--creme);
    border-radius: 8px;
    animation: tourne 1.8s ease-in-out infinite;
  }
  .btn-dev { display: none; }
}
@keyframes tourne {
  0%, 30% { transform: rotate(90deg); }
  60%, 100% { transform: rotate(0deg); }
}

/* ── Mode dev (?dev) ──────────────────────────────────── */
.btn-dev {
  position: fixed;
  z-index: 50;
  left: calc(8px + var(--gauche));
  bottom: calc(8px + var(--bas));
  padding: 6px 10px;
  border: 1px dashed var(--or);
  border-radius: 8px;
  background: rgba(18, 17, 16, 0.85);
  color: var(--or);
  font: 600 0.8rem system-ui, sans-serif;
  cursor: pointer;
}

/* Grands écrans d'ordinateur : tout un peu plus grand pour rester lisible */
@media (min-width: 1600px) and (min-height: 900px) {
  html { font-size: 118%; }
  .hud { max-width: 680px; }
  .carte { max-width: 500px; }
}

/* Écrans bas (téléphone couché, petit portable) : on resserre */
@media (max-height: 640px) {
  .carte { gap: 7px; }
  .titre { font-size: clamp(1.6rem, 6vw, 2rem); }
  .btn { min-height: 44px; padding: 9px 18px; }
  /* petits iPhone (SE) : « C'est parti » doit rester visible sans défiler */
  .cadre-image { width: min(100%, 28dvh, 290px); }
  .intro-texte { font-size: 0.92rem; gap: 4px; }
}

/* Accueil avec une progression (« Continuer », « Revoir ta récompense ») :
   on resserre pour que tout tienne sur un iPhone dans Safari */
@media (max-height: 700px) {
  .avatar-accueil { width: min(140px, 13dvh); height: min(140px, 13dvh); margin: 4px 0; }
  .carte { gap: 6px; }
  .mode-challenge { padding-top: 6px; }
}

/* Pas de zoom par pincement sur les écrans par-dessus le jeu (Android) */
.ecran { touch-action: pan-y; }
.tourner { touch-action: none; }

@media (prefers-reduced-motion: reduce) {
  .chute, .btn, .tourner-icone { animation: none; transition: none; }
}

/* ── Mode challenge (infini) ──────────────────────────── */
/* Accueil : le titre du mode histoire, puis le bouton du challenge */
.mode-titre {
  margin-top: 2px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gris);
}
.mode-challenge {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--ligne);
  max-width: 320px;
}
.btn-challenge { border-color: var(--or); color: #f6d77a; }
.btn-challenge:hover { background: rgba(217, 166, 54, 0.14); }
.record { color: var(--creme-2); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

/* En jeu : le score en grand à la place du nom du palier */
.hud-challenge .hud-nom { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.hud-challenge .hud-num { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pastille .ico { width: 15px; height: 15px; }
.pastille-distance { order: -1; }   /* la distance avant les piastres */

/* Bandeau « Collection : … » qui s'efface tout seul */
.annonce {
  position: absolute;
  z-index: 11;
  left: 50%;
  top: calc(84px + var(--haut));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 8px 18px;
  border-radius: var(--rayon);
  background: var(--or);
  color: var(--noir);
  text-align: center;
  pointer-events: none;
  animation: annonce 2.4s ease-out both;
}
.annonce:has(.annonce-sous:not([hidden])) { animation-duration: 3.2s; }
.annonce p { margin: 0; }
.annonce-titre { font-weight: 800; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.annonce-sous { font-size: 0.85rem; font-weight: 600; }
@keyframes annonce {
  0% { opacity: 0; transform: translate(-50%, -8px); }
  8%, 85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); }
}

/* Fin de partie */
.score-grand {
  font-size: clamp(2.2rem, 12cqi, 3rem);
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.nouveau-record { animation: apparait-record 0.5s ease-out; }
@keyframes apparait-record {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}
.stat .ico { width: 16px; height: 16px; color: var(--creme-2); }
.bilan-ligne { color: var(--creme-2); }
.bilan-record { color: var(--gris); font-size: 0.9rem; }

@media (prefers-reduced-motion: reduce) {
  .annonce, .nouveau-record { animation: none; }
}
