:root {
  --violet: #5b2387;
  --violet-fonce: #321b45;
  --violet-moyen: #8a3fc0;
  --rose-pale: #f6eafb;
  --citron: #d4ff3d;
  --encre: #22161f;
  --texte: #3d3140;
  --gris: #6f6473;
  --bordure: #e6dbe9;
  --fond: #faf6fc;
  --blanc: #ffffff;
  --vert: #1f9d55;
  --orange: #c26a00;
  --rouge: #c0392b;
  --titre: 'Rubik', system-ui, sans-serif;
  --corps: 'Nunito Sans', system-ui, sans-serif;
  --rayon: 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--corps);
  color: var(--texte);
  background: var(--fond);
  line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--titre); color: var(--violet-fonce); margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 800; margin: 26px 0 10px; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--violet); }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.entete {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--blanc);
  border-bottom: 1px solid var(--bordure);
}
.entete img { height: 36px; width: auto; }
.badge-amb {
  font-family: var(--titre); font-weight: 600; font-size: 0.8rem;
  background: var(--violet); color: var(--citron);
  padding: 5px 11px; border-radius: 999px;
}

.contenu { max-width: 560px; margin: 0 auto; padding: 18px 16px 24px; }
.salut { margin-bottom: 4px; }
.sous { color: var(--gris); font-size: 0.95rem; }

.carte {
  background: var(--blanc);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 16px;
  margin-top: 14px;
}
.carte-violette { background: var(--violet); border-color: var(--violet); color: #fff; }
.carte-violette h2, .carte-violette h3 { color: #fff; margin-top: 0; }
.carte-violette .sous { color: #e6d4f3; }

.puce-theme {
  display: inline-block; margin-top: 10px;
  background: var(--citron); color: var(--violet-fonce);
  font-family: var(--titre); font-weight: 600; font-size: 0.85rem;
  padding: 4px 10px; border-radius: 999px;
}

.liste-taches { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.liste-taches li { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.coche {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.9rem;
  border: 2px solid rgba(255, 255, 255, 0.6);
}
.coche.ok { background: var(--citron); border-color: var(--citron); color: var(--violet-fonce); }
.liste-taches .compte { margin-left: auto; font-family: var(--titre); }

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border-radius: 999px; border: 0;
  font-family: var(--titre); font-weight: 600; font-size: 0.95rem;
  text-decoration: none;
  background: var(--violet); color: #fff;
}
.bouton:disabled { opacity: 0.6; }
.bouton-citron { background: var(--citron); color: var(--violet-fonce); }
.bouton-contour { background: transparent; color: var(--violet); box-shadow: inset 0 0 0 2px var(--violet); }
.bouton-lien { background: transparent; color: var(--gris); padding: 0 8px; min-height: 40px; }
.bouton-large { width: 100%; margin-top: 16px; }
.boutons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.boutons .bouton { flex: 1 1 auto; }

.story { padding: 14px; }
.story-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.story-tete .sous { font-size: 0.85rem; flex: none; }
.pages {
  display: flex; gap: 8px; overflow-x: auto; margin: 12px -14px 0; padding: 0 14px 4px;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
}
.pages img {
  flex: none; width: 104px; aspect-ratio: 9 / 16; object-fit: cover;
  border-radius: 10px; background: var(--rose-pale); scroll-snap-align: start;
}
.astuce {
  margin-top: 10px; font-size: 0.88rem; color: var(--gris);
  background: var(--rose-pale); border-radius: 12px; padding: 10px 12px;
}

.vide { color: var(--gris); font-style: italic; margin-top: 8px; }

.annonce { border-left: 4px solid var(--citron); }
.annonce .date { font-size: 0.8rem; color: var(--gris); }
.annonce p { margin-top: 6px; white-space: pre-line; }

.chiffres { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.chiffre { background: rgba(255, 255, 255, 0.12); border-radius: 14px; padding: 12px; }
.chiffre b { display: block; font-family: var(--titre); font-size: 1.7rem; color: var(--citron); line-height: 1.1; }
.chiffre span { font-size: 0.85rem; color: #e6d4f3; }

.barre { margin-top: 14px; }
.barre-tete { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.95rem; }
.barre-fond { height: 10px; background: var(--rose-pale); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.barre-plein { height: 100%; background: var(--violet); border-radius: 99px; }
.barre-plein.ok { background: var(--vert); }
.objectif { margin-top: 14px; font-weight: 700; }

.declaration { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--bordure); }
.declaration:first-of-type { border-top: 0; padding-top: 4px; }
.declaration .quand { flex: none; width: 46px; font-family: var(--titre); font-weight: 600; color: var(--violet); font-size: 0.9rem; }
.declaration .quoi { flex: 1; min-width: 0; }
.declaration .detail { font-size: 0.85rem; color: var(--gris); overflow-wrap: anywhere; }
.statut { display: inline-block; margin-top: 4px; font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.statut-ok { background: #e3f6ea; color: var(--vert); }
.statut-attente { background: #fff1dc; color: var(--orange); }
.statut-refus { background: #fbe4e1; color: var(--rouge); }

.podium { list-style: none; padding: 0; margin: 0; }
.podium li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--bordure); }
.podium li:first-child { border-top: 0; }
.podium .medaille { flex: none; width: 34px; font-size: 1.5rem; text-align: center; font-family: var(--titre); font-weight: 800; color: var(--violet); }
.podium .qui { flex: 1; min-width: 0; }
.podium .qui b { display: block; color: var(--encre); }
.podium .qui span { font-size: 0.85rem; color: var(--gris); }
.podium .pts { font-family: var(--titre); font-weight: 800; color: var(--violet); }
.podium li.moi { background: var(--rose-pale); margin: 0 -16px; padding: 12px 16px; border-radius: 12px; }

.ressource { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.ressource .icone { flex: none; width: 42px; height: 42px; border-radius: 12px; background: var(--rose-pale); display: grid; place-items: center; font-size: 1.2rem; }
.ressource b { color: var(--encre); display: block; }
.ressource span { font-size: 0.88rem; color: var(--gris); }
.ressource .fleche { margin-left: auto; color: var(--violet); font-size: 1.2rem; }

details.carte summary { list-style: none; cursor: pointer; font-family: var(--titre); font-weight: 600; color: var(--violet-fonce); display: flex; justify-content: space-between; }
details.carte summary::-webkit-details-marker { display: none; }
details.carte summary::after { content: '+'; color: var(--violet); font-size: 1.2rem; line-height: 1; }
details.carte[open] summary::after { content: '–'; }

.regles { margin: 10px 0 0; padding-left: 20px; }
.regles li { margin-top: 6px; }

.invite { border: 2px dashed var(--violet-moyen); background: var(--rose-pale); }
.invite p { margin-top: 6px; }

.bandeau {
  max-width: 560px; margin: 10px auto 0; padding: 10px 14px;
  background: #fff1dc; color: var(--orange); border-radius: 12px; font-size: 0.9rem;
  width: calc(100% - 32px);
}

.chargement { text-align: center; padding: 60px 0; color: var(--gris); }
.rond { width: 36px; height: 36px; margin: 0 auto 14px; border-radius: 50%; border: 4px solid var(--rose-pale); border-top-color: var(--violet); animation: tourne 0.9s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.message-plein { text-align: center; padding: 50px 10px; }
.message-plein .grand { font-size: 3rem; }
.message-plein p { margin-top: 10px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--blanc); border-top: 1px solid var(--bordure);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  background: none; border: 0; padding: 9px 2px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--gris); font-size: 0.72rem; font-weight: 700;
}
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav button.actif { color: var(--violet); }
.nav button.actif svg { stroke-width: 2.4; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 10;
  max-width: 520px; margin: 0 auto;
  background: var(--violet-fonce); color: #fff; border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 10px 30px -10px rgba(50, 27, 69, 0.6);
  display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 0.92rem;
}
.toast a { color: var(--citron); white-space: nowrap; margin-left: auto; }

/* Connexion (numéro + code PIN, comme l'appli des sages-femmes) */
.connexion { max-width: 360px; margin: 0 auto; padding-top: 8px; text-align: center; }
.connexion .sous { margin-top: 6px; }
.champ { display: block; text-align: left; margin-top: 22px; font-weight: 700; color: var(--violet-fonce); }
.champ input {
  display: block; width: 100%; margin-top: 6px; padding: 13px 14px;
  font: inherit; font-size: 1.1rem; color: var(--encre);
  border: 2px solid var(--bordure); border-radius: 14px; background: var(--blanc);
}
.champ input:focus { outline: none; border-color: var(--violet); }
.libelle-pin { margin-top: 20px; font-weight: 700; color: var(--violet-fonce); }
.points { display: flex; justify-content: center; gap: 16px; margin: 12px 0 6px; }
.point { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--violet); }
.point.plein { background: var(--violet); }
.erreur { color: var(--rouge); font-weight: 700; margin-top: 8px; }
.clavier { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.touche {
  height: 60px; border: 0; border-radius: 16px; background: var(--blanc);
  box-shadow: inset 0 0 0 1px var(--bordure);
  font-family: var(--titre); font-weight: 600; font-size: 1.45rem; color: var(--violet-fonce);
}
.touche:active { background: var(--rose-pale); }
.touche:disabled { opacity: 0.5; }
.aide { margin-top: 18px; }

/* Classement : astuces pour gagner des places */
.astuces { list-style: none; margin: 0; padding: 0; }
.astuces li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--bordure); }
.astuces li:first-child { border-top: 0; padding-top: 0; }
.astuces .gain {
  flex: none; min-width: 46px; text-align: center; padding: 4px 6px; border-radius: 10px;
  background: var(--citron); color: var(--violet-fonce); font-family: var(--titre); font-weight: 800;
}
.astuces b { display: block; color: var(--encre); }
.astuces li span span { font-size: 0.85rem; color: var(--gris); }
.podium li.top .pts { color: var(--violet); }
.podium li:not(.top) .medaille { font-size: 1.1rem; color: var(--gris); }

/* Formations */
.formation .etiquette { font-family: var(--titre); font-weight: 600; font-size: 0.85rem; color: var(--violet); margin-bottom: 4px; }
.formation .quand-formation { font-weight: 700; color: var(--violet-moyen); }
.formation h3 { margin-top: 2px; }
.formation.accueil { border-left: 4px solid var(--violet); }

/* Mes performances */
.etiquette-perf { font-family: var(--titre); font-weight: 600; font-size: 0.85rem; color: var(--violet); margin-bottom: 4px; }
.histo { display: flex; align-items: flex-end; gap: 8px; height: 150px; margin-top: 14px; }
.histo-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.histo-barre { width: 100%; max-width: 36px; background: var(--violet); border-radius: 6px 6px 2px 2px; }
.histo-col:last-child .histo-barre { background: var(--violet-moyen); }
.histo-val { font-size: 0.7rem; font-weight: 700; color: var(--violet-fonce); white-space: nowrap; }
.histo-lib { font-size: 0.72rem; color: var(--gris); }
.abonnes { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--bordure); }
.abonnes:first-of-type { border-top: 0; }
.abonnes > span:first-child b { display: block; color: var(--encre); }
.abonnes > span:first-child span { font-size: 0.88rem; color: var(--gris); }
.gain-abonnes { font-family: var(--titre); font-weight: 800; color: var(--gris); }
.gain-abonnes.plus { color: var(--vert); }
