:root {
  --fond: #EEF46C;
  --carte: #F6F8EC;
  --encre: #1E2B13;
  --encre-douce: #4A5634;
  --trait: #1E2B13;
  --accent: #0E9E78;
  --famille: var(--accent);
  --display: "Bricolage Grotesque", ui-sans-serif, -apple-system, sans-serif;
  --large: "Unbounded", ui-sans-serif, -apple-system, sans-serif;
  --sans: "Bricolage Grotesque", ui-sans-serif, -apple-system, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.gros-bouton:active, .bouton-clair:active, .seg button:active { transform: scale(.97); }

.vue {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(28px, env(safe-area-inset-top)) 22px 40px;
}
.vue[hidden] { display: none; }

/* ---------- Accueil ---------- */
.accueil { overflow: hidden; padding-bottom: 0; }
.entete {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--trait);
}
.etoile { width: 34px; height: 34px; fill: var(--encre); }
.entete-titre {
  font-family: var(--large);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  border: 1px solid var(--trait);
  border-radius: 50%;
  padding: 10px 22px;
}
.hero {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 0 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "titre titre titre" "chapo portrait reglages";
  column-gap: clamp(24px, 4vw, 56px);
}
.hero > * { animation: monte .5s cubic-bezier(.2,.7,.3,1) backwards; }
.hero > .portrait { animation-delay: .08s; }
.hero > .chapo { animation-delay: .16s; }
.hero > .reglages { animation: apparait .5s .16s ease-out backwards; }
h1 {
  grid-area: titre;
  position: relative;
  z-index: 2;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(64px, 15.5vw, 216px);
  font-weight: 800;
  font-variation-settings: "opsz" 96;
  line-height: .8;
  letter-spacing: -0.06em;
  margin: 0;
  white-space: nowrap;
}
h1 span { color: var(--accent); }
.portrait {
  grid-area: portrait;
  position: relative;
  width: min(26vw, 36vh, 380px);
  margin: 18px 0 150px;
}
.portrait img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: 50% 30%;
  border-radius: 12px;
  background: var(--accent);
}
.chapo {
  grid-area: chapo;
  align-self: start;
  justify-self: end;
  max-width: 280px;
  margin: 32px 0 0;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--encre);
}

.reglages {
  grid-area: reglages;
  align-self: start;
  justify-self: start;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
  margin-top: 32px;
}
.reglage { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.etiquette {
  font-family: var(--large);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--encre);
}
.aide { font-size: 12.5px; color: var(--encre-douce); min-height: 18px; }

.seg {
  display: inline-flex;
  border: 1px solid var(--trait);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.seg button {
  border: none;
  background: none;
  color: var(--encre);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  transition: background .18s, color .18s;
}
.seg button:hover { background: rgba(30,43,19,.08); }
.seg button[aria-pressed="true"] { background: var(--encre); color: var(--fond); }

.gros-bouton {
  border: none;
  background: var(--encre);
  color: var(--fond);
  font-family: var(--large);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 18px 36px;
  border-radius: 999px;
  transition: transform .15s cubic-bezier(.2,.7,.3,1), background .18s;
}
.gros-bouton:hover { background: var(--accent); transform: translateY(-1px); }
.gros-bouton:active { transform: translateY(0); }
.bouton-clair {
  border: 1px solid var(--trait);
  background: none;
  color: var(--encre);
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 999px;
  transition: border-color .18s, transform .15s;
}
.bouton-clair:hover { background: var(--encre); color: var(--fond); transform: translateY(-1px); }
.lien {
  border: none; background: none; color: var(--encre-douce);
  font-size: 13.5px; padding: 6px 2px;
  text-decoration: underline; text-underline-offset: 3px;
  transition: color .18s;
}
.lien:hover { color: var(--accent); }
.reglages .gros-bouton { margin-top: 6px; }
.raccourci { display: block; margin-top: 14px; font-size: 12.5px; font-weight: 400; color: var(--encre-douce); }

.bandes {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: -150px;
  width: 140vw;
  height: 150px;
  transform: translateX(-50%);
  pointer-events: none;
}
.bande {
  position: absolute;
  left: 0;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--large);
  font-size: clamp(18px, 3vw, 28px);
  padding: 14px 0;
}
.bande.sombre { top: 34px; background: var(--encre); color: var(--fond); transform: rotate(-4deg); }
.bande.claire { top: 64px; background: var(--carte); color: var(--encre); transform: rotate(3deg); }
.defile { display: inline-block; animation: defile 70s linear infinite; }
.bande.claire .defile { animation-direction: reverse; }
@keyframes defile { to { transform: translateX(-50%); } }

/* ---------- Scène ---------- */
.scene { max-width: 760px; margin: 0 auto; width: 100%; }
.barre-haut {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(18px, 5vh, 44px);
}
.compteur { font-family: var(--large); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--encre-douce); font-variant-numeric: tabular-nums; }

.phrase {
  font-family: var(--display);
  font-size: clamp(32px, 6.4vw, 54px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.04em;
  text-align: center;
  margin: 0 0 clamp(26px, 6vh, 52px);
  max-width: 17ch;
  align-self: center;
}
.phrase.change { animation: monte .45s cubic-bezier(.2,.7,.3,1); }

.plateau {
  display: flex;
  width: 100%;
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: 6px;
  padding: 24px 26px;
}
.rang {
  display: block;
  font-family: var(--large);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--encre-douce);
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}
.rang b { color: var(--encre); font-weight: 500; }

.consigne { min-width: 0; flex: 1; }
.emotion {
  font-family: var(--display);
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0 0 6px;
  color: var(--famille);
  animation: monte .3s cubic-bezier(.2,.7,.3,1);
}
.indice {
  font-size: 15px;
  line-height: 1.5;
  color: var(--encre-douce);
  margin: 0 0 18px;
  min-height: 44px;
}
.actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.pastilles {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 0;
  margin: 22px 0 0;
}
.pastilles li {
  font-size: 13px;
  font-weight: 500;
  color: var(--encre);
  border: 1px solid var(--trait);
  border-radius: 999px;
  padding: 7px 14px;
  transition: all .2s;
}
.pastilles li.faite { opacity: .45; text-decoration: line-through; }
.pastilles li.active {
  color: var(--carte);
  background: var(--pastille, var(--encre));
  border-color: transparent;
}

.fin { text-align: center; margin-top: 30px; animation: monte .45s cubic-bezier(.2,.7,.3,1); }
.fin[hidden] { display: none; }
.bravo { font-family: var(--display); font-weight: 800; font-size: clamp(40px, 8vw, 72px); letter-spacing: -0.05em; line-height: 1; margin: 0 0 22px; }
.choix-fin { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

@keyframes apparait { from { opacity: 0; } }
@keyframes monte { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 860px) {
  .accueil {
    height: 100dvh;
    min-height: 0;
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .entete { padding-bottom: 10px; }
  .etoile { width: 26px; height: 26px; }
  .entete-titre { font-size: 9.5px; padding: 7px 16px; }
  .hero {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding-top: 12px;
  }
  h1 { font-size: min(22vw, 11dvh); white-space: normal; flex: none; }
  h1 span { display: block; }
  .portrait {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    margin: 12px 0 0;
  }
  .portrait img { height: 100%; aspect-ratio: auto; object-position: 50% 28%; }
  .bandes { bottom: 6px; height: 84px; }
  .bande { font-size: 14px; padding: 8px 0; }
  .bande.sombre { top: 10px; }
  .bande.claire { top: 34px; }
  .chapo {
    flex: none;
    text-align: center;
    max-width: none;
    margin: 12px 0 0;
    font-size: 14.5px;
    line-height: 1.4;
  }
  .reglages {
    flex: none;
    align-items: stretch;
    margin: 14px 0 0;
    gap: 10px;
  }
  .reglage {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
  }
  .seg button { padding: 9px 16px; font-size: 14px; }
  .aide { flex-basis: 100%; text-align: right; min-height: 0; font-size: 12px; }
  .raccourci { display: none; }
  #commencer { width: 100%; margin: 4px 0 0; padding: 19px; }
}

@media (max-width: 860px) and (max-height: 640px) {
  .chapo { display: none; }
  .aide { display: none; }
}

@media (hover: none) {
  .gros-bouton:hover { background: var(--encre); transform: none; }
  .bouton-clair:hover { background: none; color: var(--encre); transform: none; }
  .seg button:hover { background: none; }
  .seg button[aria-pressed="true"]:hover { background: var(--encre); }
}

@media (max-width: 620px) {
  .vue { padding-left: 16px; padding-right: 16px; }
  .scene { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .scene .phrase { margin-top: auto; }
  .scene .pastilles { margin-top: auto; padding-top: 18px; }
  .actions .gros-bouton {
    position: fixed;
    z-index: 10;
    left: 16px;
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
    width: auto;
    padding: 22px;
    background: var(--famille);
    color: #fff;
    box-shadow: 0 10px 30px rgba(30,43,19,.25);
    transition: background .25s;
  }
  .fin { width: 100%; margin-top: auto; padding-top: 24px; }
  .barre-haut { margin-bottom: 22px; }
  .phrase { max-width: 100%; font-size: clamp(30px, 9vw, 40px); margin-bottom: 22px; }
  .plateau { text-align: center; padding: 26px 18px 18px; }
  .emotion { font-size: clamp(38px, 11.5vw, 52px); }
  .indice { min-height: 0; margin-bottom: 18px; }
  .actions { flex-direction: column; gap: 6px; }
  .pastilles { gap: 6px; margin-top: 18px; }
  .pastilles li { font-size: 12.5px; padding: 6px 12px; }
  .choix-fin { flex-direction: column; align-items: stretch; }
  .choix-fin button { width: 100%; padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
