:root {
  --bg: #16132e; --bg2: #241f4a;
  --ink: #fff8ec; --muted: #b9b3d9;
  --accent: #ffd23f; --accent-ink: #2a1d00;
  --go: #2fd66b; --stop: #c81d32; --warn: #ffc61a; --idle: #4a4570;
  --miroir: #5a0f1e; --miroir2: #8a1a2e;
  --font: 'Fredoka', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg) 70%) fixed, var(--bg);
  color: var(--ink); font-family: var(--font); font-weight: 500;
  overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  transition: background-color .25s;
}
body.miroir { background: radial-gradient(120% 80% at 50% 0%, var(--miroir2), var(--miroir) 70%) fixed, var(--miroir); }
button { font-family: var(--font); color: var(--ink); background: transparent; border: 0; cursor: pointer; }

.ecran {
  display: none; position: fixed; inset: 0; max-width: 480px; margin: 0 auto;
  flex-direction: column; align-items: center; gap: 12px; text-align: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.ecran.actif { display: flex; }

h1 { margin: 24px 0 0; font-size: clamp(54px, 16vw, 76px); line-height: .95; font-weight: 700; color: var(--accent); transform: rotate(-3deg); text-shadow: 0 4px 0 rgba(0,0,0,.35); }
h2 { margin: 0; font-size: 34px; font-weight: 700; color: var(--accent); transform: rotate(-2deg); text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.sub { margin: 0; color: var(--muted); font-size: 18px; }
.regles { margin: 4px 0; padding: 14px 18px 14px 36px; text-align: left; font-size: 17px; line-height: 1.35; color: var(--ink);
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); border-radius: 20px; }
.regles li { margin: 4px 0; }
.regles b { color: var(--accent); }
.touches { margin: 0; font-size: 14px; color: var(--muted); }
.cta { min-width: 220px; padding: 14px 28px; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: 26px; font-weight: 700; box-shadow: 0 6px 0 rgba(0,0,0,.35); }
.cta:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.ghost { min-width: 180px; padding: 10px 22px; border-radius: 999px; background: rgba(255,255,255,.12); color: var(--ink); font-size: 20px; }
.pastille { display: inline-block; margin: 0; padding: 4px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.2); font-size: 14px; color: var(--muted); }
#manche.feu { color: #ffe27a; border-color: #ffb43a; background: #1a1233; text-shadow: 0 0 8px #ff5a00; font-weight: 800; box-shadow: 0 0 14px #ff7a1a; }
#manche { position: relative; z-index: 1; }
.mw { position: relative; display: inline-block; }
/* Flammes de la pastille (3 manches parfaites) : SVG inline, langues animées en CSS + bruit SVG pour les bords */
.mw .feux { position: absolute; left: -19px; top: -31px; width: calc(100% + 38px); height: calc(100% + 31px); overflow: visible; z-index: 0; pointer-events: none; display: none; }
.mw.feu .feux { display: block; }
.feux .fx { filter: url(#fflA); }
.feux .t { transform-box: fill-box; transform-origin: 50% 100%; animation: danse .9s ease-in-out infinite; }
.feux .r { fill: url(#fgR); opacity: .92; }
.feux .o { fill: url(#fgO); }
.feux .c { fill: url(#fgC); animation-name: danseC; animation-duration: .6s; }
.feux .d1 { animation-delay: -.13s; animation-duration: .8s; } .feux .d2 { animation-delay: -.41s; animation-duration: 1.05s; }
.feux .d3 { animation-delay: -.27s; animation-duration: .72s; } .feux .d4 { animation-delay: -.66s; animation-duration: .95s; }
.feux .d5 { animation-delay: -.52s; animation-duration: .84s; } .feux .d6 { animation-delay: -.08s; animation-duration: 1.12s; }
.feux .c.d1, .feux .c.d4 { animation-duration: .5s; } .feux .c.d2, .feux .c.d5 { animation-duration: .68s; }
@keyframes danse { 0%,100% { transform: scale(1,1) skewX(0); } 22% { transform: scale(.86,1.3) skewX(9deg); } 48% { transform: scale(1.12,.82) skewX(-3deg); } 74% { transform: scale(.92,1.18) skewX(-10deg); } }
@keyframes danseC { 0%,100% { transform: scale(1,1); opacity: 1; } 35% { transform: scale(.85,1.25) skewX(5deg); opacity: .85; } 70% { transform: scale(1.08,.9) skewX(-5deg); opacity: 1; } }
.mw .et { position: absolute; top: 2px; left: var(--x); width: 3px; height: 3px; margin-left: -1.5px; border-radius: 50%; background: #ffe9a0; box-shadow: 0 0 4px 1px #ff8a1a; opacity: 0; z-index: 2; pointer-events: none; display: none; }
.mw.feu .et { display: block; animation: braise 1.8s ease-out infinite; animation-delay: var(--d); }
@keyframes braise { 0% { transform: translate(0,4px) scale(1); opacity: 0; } 12% { opacity: 1; } 60% { opacity: .9; } 100% { transform: translate(var(--dx),-30px) scale(.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .feux .t { animation: none; } .feux .fx { filter: url(#fflS); } .mw.feu .et { display: none; } }
footer { margin-top: auto; font-size: 12px; color: var(--muted); opacity: .7; }
.rond { position: fixed; top: max(10px, env(safe-area-inset-top)); right: 10px; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.12); color: var(--ink); font-size: 20px; z-index: 5; }
.rond.off { opacity: .4; }

/* JEU */
.hud { padding-top: 24px; width: 100%; display: flex; align-items: center; justify-content: space-between; padding-right: 50px; min-height: 44px; }
.vies { font-size: 40px; line-height: 1; letter-spacing: 2px; color: var(--stop); text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.vies .perdue { color: var(--idle); }
.score { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.bandeau { font-size: 30px; font-weight: 700; min-height: 44px; color: var(--ink); text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.bandeau.toi { color: var(--accent); transform: rotate(-2deg); }
.bandeau.alerte { color: var(--ink); background: var(--stop); padding: 2px 16px; border-radius: 999px; }
.points { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 40px; max-width: 100%; }
.pt { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; font-weight: 700;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); color: var(--muted); }
.pt.vu { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pt.bombe { background: var(--stop); color: var(--ink); border-color: var(--stop); }
.pt.ok { background: var(--go); color: #062a12; border-color: var(--go); }
.pt.ko { background: var(--stop); color: var(--ink); border-color: var(--stop); }
.pt.cur { outline: 3px solid var(--ink); outline-offset: 1px; }
.zone-centre { position: relative; flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.pulse { position: absolute; width: 186px; height: 186px; border-radius: 50%; border: 8px solid rgba(255,255,255,.2); box-shadow: 0 0 0 0 rgba(255,210,63,0), inset 0 0 30px rgba(255,255,255,.05); }
.pulse::after { content: ''; position: absolute; inset: -8px; border-radius: 50%; border: 4px solid var(--accent); opacity: 0; }
.pulse.bat { animation: bat .3s ease-out; }
.pulse.bat::after { animation: onde .45s ease-out; }
.pulse.fort { animation-name: batfort; }
.pulse.fort::after { animation-duration: .6s; border-width: 7px; }
@keyframes bat { 0% { transform: scale(1.12); border-color: rgba(255,210,63,.95); box-shadow: 0 0 28px rgba(255,210,63,.7), inset 0 0 40px rgba(255,210,63,.35); } 100% { transform: scale(1); } }
@keyframes batfort { 0% { transform: scale(1.2); border-color: #fff; box-shadow: 0 0 46px rgba(255,210,63,.95), inset 0 0 60px rgba(255,210,63,.5); } 100% { transform: scale(1); } }
@keyframes onde { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(1.7); opacity: 0; } }
.retour { position: relative; font-size: 40px; font-weight: 700; min-height: 50px; color: var(--ink); text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.retour.parfait { color: var(--accent); }
.retour.bien { color: var(--go); }
.retour.go { color: var(--go); font-size: 56px; }
.retour.rate { color: #ff6b7d; }
.retour.pop { animation: pop .3s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { from { transform: scale(.5); opacity: .2; } to { transform: scale(1); opacity: 1; } }
.combo { position: relative; font-size: 22px; font-weight: 700; color: var(--muted); min-height: 30px; font-variant-numeric: tabular-nums; }
.combo.chaud { color: var(--accent); }

.pads { position: relative; z-index: 2; width: 100%; height: 40vh; min-height: 220px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pad { border-radius: 28px; background: #2b2852; border: 2px solid rgba(255,255,255,.22); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 8px 0 rgba(0,0,0,.35); transition: background-color .08s, transform .05s; touch-action: none; }
.pad .fleche { font-size: 64px; line-height: 1; }
.pad .nom { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.pad.appui { transform: translateY(4px); box-shadow: 0 4px 0 rgba(0,0,0,.35); }
.pad.allume { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pad.bombe { background: var(--stop); color: var(--ink); border-color: var(--ink); }
.pad.bon { background: var(--go); color: #062a12; border-color: var(--go); }
.pad.faux { background: var(--stop); color: var(--ink); }
body.miroir .pad { border-color: #ff8a9a; }

/* FIN */
.gros { font-size: clamp(96px, 30vw, 150px); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); text-shadow: 0 6px 0 rgba(0,0,0,.35); }
.record { margin: 0 0 8px; font-size: 18px; color: var(--accent); }
#ecran-fin { justify-content: center; }
#ecran-fin footer { margin-top: 24px; }

@media (prefers-reduced-motion: reduce) {
  .pulse.bat, .retour.pop { animation: none; }
  .pad, body { transition: none; }
}

/* indice de départ : cadre vert sur tout l'écran à la première note à taper */
body.go { box-shadow: inset 0 0 0 12px var(--go); }

.vies.critique { animation: danger .6s ease-in-out infinite; }
@keyframes danger { 0%,100% { color: var(--stop); transform: scale(1); filter: none; } 50% { color: #ff1a1a; transform: scale(1.18); filter: drop-shadow(0 0 10px #ff1a1a); } }

/* grains de braise : positions (ex-attributs style, interdits par la CSP du build) */
.mw .et:nth-of-type(1) { --x: 12%; --d: -0.2s; --dx: -7px; }
.mw .et:nth-of-type(2) { --x: 30%; --d: -0.9s; --dx: 5px; }
.mw .et:nth-of-type(3) { --x: 47%; --d: -0.5s; --dx: -3px; }
.mw .et:nth-of-type(4) { --x: 60%; --d: -1.3s; --dx: 6px; }
.mw .et:nth-of-type(5) { --x: 76%; --d: -0.1s; --dx: -5px; }
.mw .et:nth-of-type(6) { --x: 90%; --d: -0.7s; --dx: 4px; }
.mw .et:nth-of-type(7) { --x: 40%; --d: -1.6s; --dx: 8px; }

/* Texte de référencement : sous l'accueil, accessible en faisant défiler */
#ecran-accueil { overflow-y: auto; justify-content: flex-start; }
#ecran-accueil > * { flex-shrink: 0; }
.seo { max-width: 440px; margin: 24px 0 8px; text-align: left; font-size: 15px; line-height: 1.45; color: var(--muted); user-select: text; -webkit-user-select: text; }
.seo h2 { font-size: 22px; transform: none; text-shadow: none; margin: 0 0 8px; }
.seo p { margin: 0; }
.seo p + p { margin-top: 10px; }
.seo a { color: var(--accent); }
