:root {
  --espresso: #24150e;
  --walnut: #3b2417;
  --paper: #f1e2c4;
  --orange: #e2582b;
  --mustard: #e9a93a;
  --rust: #a8431f;
  --olive: #6f6a24;

  --bg: var(--espresso);
  --text: var(--paper);
  --accent: var(--mustard);

  --display: 'Fraunces', Georgia, serif;
  --text-face: 'Rubik', system-ui, sans-serif;

  --step-small: 0.875rem;
  --step-body: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --step-head: clamp(2.5rem, 1.6rem + 4vw, 5rem);
  --step-giant: clamp(5.5rem, 2rem + 17vw, 16rem);

  --margin: clamp(16px, 4vw, 48px);
  --gap-section: clamp(96px, 12vw, 200px);
  --outline: 3px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-press: cubic-bezier(0.23, 1, 0.32, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--text-face);
  font-size: var(--step-body);
  line-height: 1.55;
  overflow-x: hidden;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--mustard); outline-offset: 3px; }

.display {
  font-family: var(--display);
  font-weight: 900;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}

h1, h2, h3, .over-title, .back-name, .dist {
  font-family: var(--display);
  font-weight: 900;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  letter-spacing: -0.02em;
}
h2 { font-size: var(--step-head); line-height: 0.95; margin: 0 0 16px; }
h3 { font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem); line-height: 1; margin: 0 0 12px; }

/* ——— En-tête ——— */
.top {
  position: absolute;
  inset: 0 0 auto;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px var(--margin);
}
.badge { width: 88px; height: 88px; flex: none; display: block; }
.badge svg { width: 100%; height: 100%; overflow: visible; }
.badge-text {
  fill: var(--paper);
  font-family: var(--text-face);
  font-weight: 700;
  font-size: 12.4px;
  letter-spacing: 0.03em;
  transform-origin: 60px 60px;
  animation: spin 22s linear infinite;
}
.badge-disc { fill: var(--espresso); stroke: var(--orange); stroke-width: 3; }
.badge-label { fill: var(--orange); }
.badge-hole { fill: var(--espresso); }

.nav {
  flex: 1;
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  padding: 12px 28px;
  border: var(--outline) solid var(--orange);
  border-radius: 999px;
  background: var(--espresso);
  font-weight: 500;
}
.nav a { text-decoration: none; position: relative; padding: 4px 0; }
.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 3px;
  background: var(--mustard);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 220ms var(--ease-out);
}
.nav-day { margin-left: auto; color: var(--mustard); }

@media (hover: hover) and (pointer: fine) {
  .nav a:hover::after { transform: scaleX(1); }
}

/* ——— Héros ——— */
.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  align-items: center;
  padding: 140px var(--margin) 80px;
  overflow: hidden;
}
.hero-copy { position: relative; z-index: 2; }
.hero-kicker {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-size: clamp(2rem, 1.2rem + 3.6vw, 4.5rem);
  line-height: 1;
  color: var(--orange);
}
.stack {
  position: relative;
  isolation: isolate;
  margin: 0.05em 0 0.32em;
  font-size: var(--step-giant);
  line-height: 0.88;
  color: var(--paper);
  -webkit-text-stroke: var(--outline) var(--orange);
  paint-order: stroke fill;
}
.stack::before,
.stack::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  z-index: -1;
  -webkit-text-stroke: var(--outline) var(--orange);
  paint-order: stroke fill;
}
.stack::after { color: var(--mustard); transform: translate(0.045em, 0.045em); }
.stack::before { color: var(--orange); transform: translate(0.09em, 0.09em); }
.hero-tag {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-variation-settings: "SOFT" 100, "WONK" 0;
  font-size: clamp(1.75rem, 1.1rem + 2.6vw, 3.25rem);
  line-height: 1.05;
  color: var(--paper);
}
.hero-lead { max-width: 44ch; margin: 20px 0 0; font-size: var(--step-lead); line-height: 1.4; }

.cta {
  position: relative;
  z-index: 3;
  justify-self: start;
  display: grid;
  place-items: center;
  width: clamp(150px, 15vw, 210px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--mustard);
  color: var(--espresso);
  border: var(--outline) solid var(--orange);
  text-align: center;
  text-decoration: none;
  font-family: var(--display);
  font-weight: 900;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-size: clamp(1.25rem, 0.9rem + 1vw, 1.75rem);
  line-height: 1;
  padding: 24px;
  transition: transform 220ms var(--ease-out);
}
.cta:active { transform: scale(0.96) rotate(-4deg); transition-duration: 120ms; }
@media (hover: hover) and (pointer: fine) {
  .cta:hover { transform: scale(1.05) rotate(-6deg); }
}

.waves {
  position: absolute;
  top: 0;
  right: -8vw;
  width: min(52vw, 760px);
  height: 100%;
  z-index: 1;
  fill: none;
  stroke-linecap: round;
  overflow: visible;
}
.w { stroke-dasharray: 1; stroke-dashoffset: 0; }
.w1 { stroke: var(--orange); stroke-width: 190px; }
.w2 { stroke: var(--paper); stroke-width: 150px; }
.w3 { stroke: var(--rust); stroke-width: 112px; }
.w4 { stroke: var(--mustard); stroke-width: 74px; }
.w5 { stroke: var(--paper); stroke-width: 20px; }

/* ——— Sections ——— */
.play, .rules, .daily, .trophies { padding: 0 var(--margin); margin-top: var(--gap-section); }
.section-head { max-width: 760px; }
.section-head p { margin: 0 0 32px; font-size: var(--step-lead); line-height: 1.4; }

.sleeve { background: var(--paper); padding: clamp(8px, 1.4vw, 16px); }
.stage { position: relative; }
canvas {
  display: block;
  width: 100%;
  height: auto;
  background: var(--espresso);
  touch-action: none;
  cursor: pointer;
}
canvas:focus-visible { outline-offset: -3px; }

.hud { position: absolute; left: 24px; top: 18px; pointer-events: none; }
.dist { font-size: clamp(1.75rem, 1rem + 3vw, 2.75rem); line-height: 1; color: var(--paper); }
.bpm { color: var(--mustard); font-weight: 500; font-variant-numeric: tabular-nums; }

.over {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  padding: 16px;
  background: rgba(36, 21, 14, 0.78);
  pointer-events: none;
  transition: opacity 300ms var(--ease-out);
}
.over[hidden] { display: grid; opacity: 0; transition-duration: 150ms; }
.over-title { margin: 0; font-size: clamp(2.25rem, 1.4rem + 4vw, 4.5rem); line-height: 1; color: var(--paper); }
.best { color: var(--paper); opacity: .75; font-size: .875rem; font-variant-numeric: tabular-nums; }
.ach-count { margin: 0; font-family: var(--display); font-size: 2rem; color: var(--mustard); }
.ach-stats { margin: 0 0 32px; color: var(--paper); opacity: .8; }
.ach-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.ach-list li { background: var(--paper); color: var(--espresso); padding: 16px 18px; display: grid; gap: 4px; }
.ach-list li.got { background: var(--mustard); }
.ach-list li.locked { background: #d4c19c; }
.ach-list .bar { display: block; height: 6px; margin-top: 6px; border-radius: 3px; background: rgba(36, 21, 14, 0.15); overflow: hidden; }
.ach-list .bar::after { content: ""; display: block; height: 100%; width: calc(var(--p) * 100%); background: var(--orange); }
.ach-more { display: inline-block; margin-top: 24px; color: var(--mustard); font-weight: 700; }
.ach-intro { max-width: 640px; margin: 0 0 32px; font-size: var(--step-lead); line-height: 1.4; }
.ach-empty { margin: 24px 0 0; }
.trophies-page { padding: 140px var(--margin) 96px; }
.trophies-title { margin: 0 0 8px; font-size: var(--step-head); line-height: 1; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.filters + .filters { margin-bottom: 32px; }
.filter {
  font: inherit;
  font-weight: 700;
  font-size: var(--step-small);
  padding: 8px 14px;
  border: 2px solid var(--paper);
  border-radius: 999px;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
}
.filter[aria-pressed="true"] { background: var(--paper); color: var(--espresso); }
.levels { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; border: 0; }
.levels legend { float: left; width: 100%; margin: 0 0 8px; padding: 0; font-weight: 700; color: var(--mustard); }
.levels label { cursor: pointer; }
.levels input { position: absolute; opacity: 0; pointer-events: none; }
.levels span { display: inline-block; padding: 10px 16px; border: 2px solid var(--paper); border-radius: 999px; color: var(--paper); font-weight: 700; }
.levels small { margin-left: 4px; font-weight: 500; opacity: .75; }
.levels input:checked + span { background: var(--paper); color: var(--espresso); }
.levels input:focus-visible + span { outline: 3px solid var(--mustard); outline-offset: 2px; }
.ach-list strong { font-family: var(--display); font-size: 1.25rem; font-weight: 900; }
.ach-list span { font-size: var(--step-small); }
.ach-list em { font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; }
.over-stats { margin: 0; color: var(--paper); font-variant-numeric: tabular-nums; }
.over-hint { margin: 0; color: var(--mustard); font-size: var(--step-body); }

.keys { margin: 20px 0 0; }
kbd {
  font-family: var(--text-face);
  font-weight: 500;
  background: var(--walnut);
  color: var(--paper);
  padding: 1px 8px;
  border-radius: 6px;
}

/* Comment jouer */
.rules {
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: start;
}
.rules-copy > p { margin: 0 0 32px; font-size: var(--step-lead); line-height: 1.4; }
.obstacles { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
.obstacles li { display: grid; grid-template-columns: 72px 1fr; gap: 4px 20px; align-items: center; }
.obstacles strong { display: block; font-size: 1.25rem; color: var(--mustard); }
.ob {
  grid-row: span 2;
  width: 72px;
  height: 72px;
  background: var(--walnut);
  border-radius: 16px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 10px;
}
.ob img { display: block; }
/* Suspendu : corde en haut, caisse puis barrière, sans toucher le bas de la vignette. */
.ob-hang { flex-direction: column; justify-content: flex-start; padding: 0 0 16px; }
.ob-hang::before { content: ""; width: 4px; flex: 1; background: var(--paper); }

.slip {
  background: var(--paper);
  color: var(--espresso);
  padding: 32px 32px 56px;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 18px), 95% 100%, 90% calc(100% - 18px), 85% 100%, 80% calc(100% - 18px), 75% 100%, 70% calc(100% - 18px), 65% 100%, 60% calc(100% - 18px), 55% 100%, 50% calc(100% - 18px), 45% 100%, 40% calc(100% - 18px), 35% 100%, 30% calc(100% - 18px), 25% 100%, 20% calc(100% - 18px), 15% 100%, 10% calc(100% - 18px), 5% 100%, 0 calc(100% - 18px));
  transform: rotate(1.5deg);
}
.slip-title {
  margin: 0 0 20px;
  font-family: var(--display);
  font-weight: 900;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-size: 1.75rem;
  line-height: 1;
}
.slip-b { margin-top: 32px; }
.tracks { margin: 0; display: grid; gap: 12px; font-variant-numeric: tabular-nums; }
.tracks div { display: flex; align-items: baseline; gap: 8px; }
.tracks dt { font-weight: 700; }
.tracks dd { margin: 0; order: 2; text-align: right; }
.tracks div::after {
  content: "";
  order: 1;
  flex: 1;
  height: 4px;
  background: radial-gradient(circle, var(--espresso) 1.5px, transparent 2px) 0 50% / 8px 4px repeat-x;
}
.slip-total {
  margin: 24px -32px 0;
  padding: 10px 32px;
  background: var(--espresso);
  color: var(--paper);
  font-weight: 700;
}

/* Défis du jour */
.cards { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(16px, 3vw, 32px); }
.card { padding: clamp(24px, 3vw, 40px); border-radius: 28px; }
.card p { margin: 0 0 24px; }
.card-score { background: var(--orange); color: var(--espresso); }
.card-run { background: var(--walnut); color: var(--paper); }
.score-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; max-width: 360px; }
.score-grid span { aspect-ratio: 1; border-radius: 6px; background: var(--paper); }
.score-grid .hit { background: var(--mustard); }
.score-grid .miss { background: var(--espresso); }
.run-result {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-family: var(--display);
  font-weight: 900;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-size: clamp(2.25rem, 1.4rem + 3vw, 3.75rem);
  line-height: 1;
}
.run-result span + span { color: var(--mustard); }
.score-grid .todo { background: transparent; box-shadow: inset 0 0 0 2px currentColor; opacity: .4; }
.streak { margin: 16px 0 0; color: var(--mustard); font-weight: 700; }
.daily-status { margin: 16px 0 16px; min-height: 1.5em; font-variant-numeric: tabular-nums; }
.daily-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.daily-btn {
  font: inherit;
  font-weight: 700;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  color: var(--espresso);
  cursor: pointer;
}
.daily-btn:disabled { opacity: .5; cursor: default; }
.daily-btn[hidden] { display: none; }
.card-run .daily-btn { background: var(--mustard); }

/* Pied de page : le verso de la pochette */
.back {
  margin-top: var(--gap-section);
  background: var(--orange);
  color: var(--espresso);
  padding: 56px var(--margin) 40px;
  clip-path: polygon(0 24px, 4% 0, 8% 24px, 12% 0, 16% 24px, 20% 0, 24% 24px, 28% 0, 32% 24px, 36% 0, 40% 24px, 44% 0, 48% 24px, 52% 0, 56% 24px, 60% 0, 64% 24px, 68% 0, 72% 24px, 76% 0, 80% 24px, 84% 0, 88% 24px, 92% 0, 96% 24px, 100% 0, 100% 100%, 0 100%);
}
.back-name { margin: 0; font-size: var(--step-giant); line-height: 0.85; color: var(--paper); -webkit-text-stroke: var(--outline) var(--espresso); paint-order: stroke fill; }
.back-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin-top: 0.3em; padding-top: clamp(32px, 6vw, 72px); }
.back-cols p { margin: 0; }
.back a { font-weight: 700; }
.credits { font-size: var(--step-small); }

.grain {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ——— Mouvement ——— */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes drift { from { transform: translateY(-12px) rotate(-1deg); } to { transform: translateY(12px) rotate(1deg); } }
@keyframes peel-1 { from { transform: translate(0, 0); } }
@keyframes peel-2 { from { transform: translate(0, 0); } }
@keyframes rise { from { opacity: 0; transform: translateY(28px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.85) rotate(-12deg); } }

.js .w { animation: draw 1400ms var(--ease-out) both; }
.js .w1 { animation-delay: 100ms; }
.js .w2 { animation-delay: 180ms; }
.js .w3 { animation-delay: 260ms; }
.js .w4 { animation-delay: 340ms; }
.js .w5 { animation-delay: 420ms; }
.js .waves { animation: drift 7s ease-in-out 1.6s infinite alternate; }
.js .stack::after { animation: peel-1 700ms var(--ease-out) 450ms both; }
.js .stack::before { animation: peel-2 700ms var(--ease-out) 550ms both; }
.js .hero-kicker { animation: rise 600ms var(--ease-out) 100ms both; }
.js .stack { animation: rise 700ms var(--ease-out) 200ms both; }
.js .hero-tag { animation: rise 600ms var(--ease-out) 320ms both; }
.js .hero-lead { animation: rise 600ms var(--ease-out) 400ms both; }
.js .cta { animation: pop 600ms var(--ease-out) 700ms both; }

/* Entrées des sections : les éléments restent visibles si le script ne tourne pas. */
.js [data-reveal] { opacity: 0; transform: translateY(28px); transition: opacity 700ms var(--ease-out), transform 700ms var(--ease-out); transition-delay: calc(var(--i, 0) * 80ms); }
.js [data-reveal].in { opacity: 1; transform: none; }
.js .slip[data-reveal].in { transform: rotate(1.5deg); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .badge-text, .js .waves, .js .w, .js .stack, .js .stack::before, .js .stack::after,
  .js .hero-kicker, .js .hero-tag, .js .hero-lead, .js .cta { animation: none; }
  .js [data-reveal] { transform: none; transition: opacity 300ms ease; }
  .js .slip[data-reveal] { transform: rotate(1.5deg); }
  .cta, .nav a::after { transition: none; }
}

/* ——— Téléphone ——— */
@media (max-width: 820px) {
  .top { gap: 12px; padding-top: 14px; }
  .badge { width: 64px; height: 64px; }
  .nav { gap: 14px; padding: 8px 16px; font-size: 0.9375rem; }
  .nav-day { display: none; }
  .hero { grid-template-columns: 1fr; padding-top: 120px; align-content: start; gap: 32px; min-height: auto; }
  .waves { width: 90vw; right: -40vw; opacity: 0.9; }
  .rules, .cards { grid-template-columns: 1fr; }
  .back-cols { grid-template-columns: 1fr; gap: 16px; }
  .hud { left: 12px; top: 10px; }
}
@media (max-width: 480px) {
  .nav a:nth-child(3) { display: none; }
  .over { gap: 2px; padding: 8px; }
  .over-title { font-size: 1.75rem; }
  .over-stats, .over-hint { font-size: 0.8125rem; }
}
