/* ---------- Mission gâteau : 34 bougies en 12 secondes, sur toute la hauteur de l'écran ---------- */
.cake-stage {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  justify-items: center;
  padding: calc(var(--bar) + 8px + var(--safe-top)) 6px calc(var(--bar) + 1.4vh + var(--safe-bottom));
  touch-action: none;
}
.cake-stage.playing { cursor: pointer; }

.game-hud {
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .3s ease, transform .3s ease;
}
.cake-stage.show .game-hud { opacity: 1; transform: none; }
.hud-box {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 142px;
  padding: 6px 12px 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(5, 2, 14, .35), rgba(5, 2, 14, .82) 35%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
}
.hud-box span { font: 800 12px var(--ui); letter-spacing: .14em; text-transform: uppercase; color: #e9dcff; }
.hud-box strong {
  font-family: var(--display);
  font-weight: 400;
  font-size: 25px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hud-box.bump strong { animation: bump .18s ease-out; }
.hud-box.hurry strong { color: #ff4d6d; animation: hurry .5s ease-in-out infinite alternate; }

.lyrics {
  margin-top: .8vh;
  min-height: 1.3em;
  font-size: min(7vw, 4.2vh);
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .3s ease, transform .3s ease;
}
.lyrics.show { opacity: 1; transform: none; }

.objective {
  margin-top: .6vh;
  text-align: center;
  font: 800 clamp(16px, 4.6vw, 23px)/1.3 var(--ui);
  text-shadow: 0 0 4px #000, 2px 2px 0 #000;
  opacity: 0;
  transition: opacity .4s ease;
}
.objective em { font-style: normal; color: var(--hud-yellow); }
.cake-stage.playing .objective { opacity: 1; }
.cake-stage.done .lyrics,
.cake-stage.done .objective { opacity: 0; transition-delay: 0s; }

.go-count {
  position: absolute;
  left: 0;
  right: 0;
  top: 40%;
  z-index: 8;
  text-align: center;
  font-family: var(--display);
  font-size: min(24vw, 15vh);
  line-height: 1;
  text-transform: uppercase;
  color: #f7c843;
  text-shadow: 3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 0 6px 18px rgba(0, 0, 0, .6);
  pointer-events: none;
  opacity: 0;
}
.go-count.long { font-size: min(13vw, 8.5vh); }
.go-count.counting { animation: count-pop .85s cubic-bezier(.2, 1.3, .4, 1) forwards; }

/* ---------- Briefing de mission, avant « C'est parti » ---------- */
.briefing {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: calc(var(--bar) + 14px + var(--safe-top)) 20px calc(var(--bar) + 14px + var(--safe-bottom));
  text-align: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(24, 10, 48, .8), rgba(5, 2, 14, .92));
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity .35s ease;
}
.briefing.show { opacity: 1; }
.b-kicker { font-family: var(--display); font-size: 15px; letter-spacing: .45em; text-transform: uppercase; color: var(--hud-yellow); }
.b-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(40px, 12.5vw, 68px);
  line-height: 1;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ff5fc1 0%, var(--pink) 30%, var(--orange) 68%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(3px 4px 0 #2a0a3a);
}
.b-rules { display: grid; gap: 9px; width: min(100%, 380px); margin: 4px 0 6px; list-style: none; text-align: left; }
.b-rules li {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font: 600 clamp(15px, 4.2vw, 17px)/1.35 var(--ui);
  background: rgba(255, 255, 255, .07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
}
.b-rules .icon { font-size: 23px; text-align: center; }
.b-rules strong { color: var(--hud-yellow); }
.b-go { font-size: clamp(22px, 6.6vw, 30px); padding: .72em 1.7em; animation: pulse-ring 1.6s infinite; }

/* ---------- Le gâteau, aussi grand que la place le permet ---------- */
.cake-zone {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  container-type: size;
}
.cake {
  position: relative;
  width: min(96vw, 640px);
  height: calc(min(96vw, 640px) * 1.1);
  width: min(96cqw, 640px, 160cqh);
  height: min(100cqh, calc(min(96cqw, 640px, 160cqh) * 1.45));
  container-type: size;
  transform: translateY(75vh);
  transition: transform 1.3s cubic-bezier(.2, .8, .2, 1);
}
.cake:focus-visible { outline: 3px solid var(--cyan); outline-offset: 6px; border-radius: 12px; }
.cake-stage.show .cake { transform: none; }
.cake > span { position: absolute; display: block; }

.cake-glow {
  left: 50%;
  top: -24%;
  width: 150%;
  height: 110%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(255, 190, 100, .5) 0%, rgba(255, 120, 70, .16) 38%, transparent 64%);
  opacity: calc(.15 + var(--lit, 1) * .85);
  pointer-events: none;
  transition: opacity .3s ease;
  animation: glow-flicker 1.8s ease-in-out infinite alternate;
}
/* Assiette et face avant gardent leur taille selon la largeur ; le dessus prend toute la hauteur restante. */
.plate {
  left: 0;
  bottom: 0;
  width: 100%;
  height: 17vw;
  height: 17cqw;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 35%, #fff 0 38%, #ddd2f2 62%, #9a8ac2 100%);
  box-shadow: 0 14px 30px rgba(8, 5, 19, .6);
}
.cake-top,
.candles {
  left: 0;
  right: 0;
  top: 4%;
  bottom: 28vw;
  bottom: 28cqw;
}
.cake-top {
  clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%);
  background:
    radial-gradient(circle at 18% 70%, #3ef0ff 0 2.5px, transparent 3px),
    radial-gradient(circle at 34% 30%, #ffd36b 0 2.5px, transparent 3px),
    radial-gradient(circle at 47% 82%, #b15cff 0 2.5px, transparent 3px),
    radial-gradient(circle at 63% 46%, #3ef0ff 0 2.5px, transparent 3px),
    radial-gradient(circle at 76% 76%, #ff3ea5 0 2.5px, transparent 3px),
    radial-gradient(circle at 86% 36%, #ffd36b 0 2.5px, transparent 3px),
    radial-gradient(circle at 25% 48%, #fff 0 2px, transparent 2.5px),
    radial-gradient(circle at 70% 18%, #fff 0 2px, transparent 2.5px),
    linear-gradient(180deg, #ffb7da 0%, #ffd9ec 55%, #fff0f8 100%);
}
.cake-front {
  left: 0;
  bottom: 8.5vw;
  bottom: 8.5cqw;
  width: 100%;
  height: 20vw;
  height: 20cqw;
  display: grid !important;
  place-items: center;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(180deg, #ff86c4 0%, #ff5fae 50%, #d8347f 100%);
  box-shadow: inset -14px 0 20px rgba(80, 0, 40, .3), inset 12px 0 16px rgba(255, 255, 255, .18);
}
.cake-front::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -6%;
  height: 46%;
  background:
    radial-gradient(ellipse 3.5% 70% at 6% 0, #fff0f8 96%, transparent),
    radial-gradient(ellipse 3% 95% at 17% 0, #fff0f8 96%, transparent),
    radial-gradient(ellipse 3.5% 60% at 29% 0, #fff0f8 96%, transparent),
    radial-gradient(ellipse 3% 100% at 41% 0, #fff0f8 96%, transparent),
    radial-gradient(ellipse 3.5% 66% at 55% 0, #fff0f8 96%, transparent),
    radial-gradient(ellipse 3% 90% at 68% 0, #fff0f8 96%, transparent),
    radial-gradient(ellipse 3.5% 58% at 80% 0, #fff0f8 96%, transparent),
    radial-gradient(ellipse 3% 85% at 93% 0, #fff0f8 96%, transparent);
}
.piping {
  position: relative;
  font-family: var(--script);
  font-size: 11vw;
  font-size: 12cqw;
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 0 #c22d77, 0 0 10px rgba(255, 255, 255, .5);
}

/* ---------- Bougies (tailles en fraction du gâteau) ---------- */
.candle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: calc(2.3vw * var(--s));
  height: calc(9vw * var(--s));
  width: calc(2.4cqw * var(--s));
  height: calc(min(8.6cqh, 11cqw) * var(--s));
  transform: translate(-50%, -100%);
  border-radius: 2px 2px 1px 1px;
  background: repeating-linear-gradient(-55deg, var(--c1) 0 3px, var(--c2) 3px 6px);
  box-shadow: inset -2px 0 2px rgba(0, 0, 0, .22), 0 2px 2px rgba(80, 0, 40, .35);
}
.candle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(-1.3vw * var(--s));
  top: calc(-1.4cqw * var(--s));
  width: 1.5px;
  height: calc(1.5vw * var(--s));
  height: calc(1.6cqw * var(--s));
  margin-left: -.75px;
  background: #3a2416;
}
.candle .flame {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 1.1vw * var(--s));
  bottom: calc(100% + 1.2cqw * var(--s));
  width: calc(3.1vw * var(--s));
  width: calc(3.3cqw * var(--s));
  height: calc(5.6vw * var(--s));
  height: calc(6cqw * var(--s));
  margin-left: calc(-1.55vw * var(--s));
  margin-left: calc(-1.65cqw * var(--s));
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 72%, #fff 0 18%, #fff3a6 32%, #ffb347 60%, rgba(255, 110, 50, 0) 76%);
  box-shadow: 0 0 2.8vw rgba(255, 170, 80, .55);
  box-shadow: 0 0 3cqw rgba(255, 170, 80, .55);
  transform-origin: 50% 92%;
  animation: flame .14s var(--d, 0s) ease-in-out infinite alternate;
}
.candle.out .flame { animation: flame-out .32s ease-in forwards; }
.candle .smoke { position: absolute; left: 50%; bottom: calc(100% + 2.8vw * var(--s)); bottom: calc(100% + 3cqw * var(--s)); width: 0; height: 0; }
.candle .smoke::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(225, 225, 235, .6);
  filter: blur(3px);
  opacity: 0;
}
.candle.out .smoke::before { animation: smoke 1.6s .12s ease-out forwards; }

.pop {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 20;
  font-family: var(--display);
  font-size: 22px;
  font-size: max(18px, 6cqw);
  color: var(--gold);
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
  animation: pop-up .6s ease-out forwards;
}
.ripple {
  position: absolute;
  z-index: 9;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .7);
  pointer-events: none;
  animation: ripple .4s ease-out forwards;
}
.puff {
  position: absolute;
  left: 50%;
  bottom: calc(var(--bar) + 4vh);
  z-index: 5;
  width: min(96vw, 620px);
  height: 40vh;
  pointer-events: none;
  background: radial-gradient(ellipse 50% 42% at 50% 100%, rgba(255, 255, 255, .42), transparent 70%);
  animation: puff .7s ease-out forwards;
}

@keyframes flame {
  from { transform: scale(.94, 1) rotate(-3deg); }
  to { transform: scale(1, 1.1) rotate(3deg); }
}
@keyframes flame-out {
  0% { transform: none; opacity: 1; }
  40% { transform: translateX(30%) skewX(-28deg) scale(.8, 1.2); }
  100% { transform: translateX(60%) skewX(-40deg) scale(0, .2); opacity: 0; }
}
@keyframes smoke {
  0% { opacity: 0; transform: translate(0, 0) scale(.6); }
  15% { opacity: .85; }
  100% { opacity: 0; transform: translate(10px, -10vh) scale(3); }
}
@keyframes pop-up {
  from { opacity: 1; transform: translate(-50%, -150%); }
  to { opacity: 0; transform: translate(-50%, -330%); }
}
@keyframes ripple {
  from { opacity: 1; transform: scale(.4); }
  to { opacity: 0; transform: scale(1.3); }
}
@keyframes puff {
  0% { opacity: 0; transform: translate(-50%, 12vh) scale(.5); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -24vh) scale(1.35); }
}
@keyframes count-pop {
  0% { opacity: 0; transform: scale(2.2); }
  25% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.9); }
}
@keyframes bump { from { transform: scale(1.35); } to { transform: scale(1); } }
@keyframes hurry { to { opacity: .55; } }
@keyframes glow-flicker { from { filter: brightness(.9); } to { filter: brightness(1.05); } }
