/* ikii — victory screen. Shown at the end of every game.
   Self-contained: nothing here touches the game screen, the bubbles, the progress
   panel or Kii's in-game reaction. Load after your existing CSS.

   Every value is fixed. Do not retune sizes, colors, delays or easings — the
   staged timing is the design. Everything lands by 1.6s. */

.ikii-victory {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  background: #F4F1EA;
  font-family: 'Fredoka', system-ui, sans-serif;
}

/* ---------- the blue stage ---------- */
.ikii-victory__stage {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 468px;
  background: #4C82D9;
  border-radius: 0 0 48px 48px;
  overflow: hidden;
}

/* loose shapes drifting behind Kii — NOT a sunburst, NOT confetti that falls */
.ikii-victory__shapes { position: absolute; inset: 0; }
.ikii-victory__shape {
  position: absolute;
  background: #3A66AE;
  animation: ikii-drift 6.4s ease-in-out infinite;
}
.ikii-victory__shape--dot   { border-radius: 999px; }
.ikii-victory__shape--tile  { border-radius: 8px; }
.ikii-victory__shape--gold  { background: #F2C044; border-radius: 999px; }
.ikii-victory__shape--plus  { background: none; }
.ikii-victory__shape--plus::before,
.ikii-victory__shape--plus::after { content: ''; position: absolute; background: #3A66AE; border-radius: 5px; }
.ikii-victory__shape--plus::before { top: 14px; left: 0; width: 38px; height: 10px; }
.ikii-victory__shape--plus::after { left: 14px; top: 0; width: 10px; height: 38px; }
.ikii-victory__shape--star { background: none; }

.ikii-victory__shape:nth-child(1) { left: 24px;  top: 92px;  width: 30px; height: 30px; --r: 0deg;   animation-duration: 6.4s; }
.ikii-victory__shape:nth-child(2) { right: 30px; top: 116px; width: 24px; height: 24px; --r: 14deg;  animation-duration: 7.2s; animation-delay: .5s; }
.ikii-victory__shape:nth-child(3) { left: 62px;  top: 196px; width: 14px; height: 14px; --r: 0deg;   animation-duration: 5.6s; animation-delay: 1.1s; }
.ikii-victory__shape:nth-child(4) { right: 56px; top: 210px; width: 18px; height: 18px; --r: -12deg; animation-duration: 6.8s; animation-delay: .8s; border-radius: 6px; }
.ikii-victory__shape:nth-child(5) { left: 30px;  top: 296px; width: 38px; height: 38px; --r: 8deg;   animation-duration: 7.6s; animation-delay: .2s; }
.ikii-victory__shape:nth-child(6) { right: 26px; top: 330px; width: 26px; height: 26px; --r: 0deg;   animation-duration: 6s;   animation-delay: 1.5s; }
.ikii-victory__shape:nth-child(7) { left: 74px;  top: 392px; --r: 0deg;   animation-duration: 5.2s; animation-delay: .4s; }
.ikii-victory__shape:nth-child(8) { right: 84px; top: 404px; width: 20px; height: 20px; --r: 18deg;  animation-duration: 6.6s; animation-delay: 1.3s; border-radius: 7px; }
.ikii-victory__shape:nth-child(9) { left: 300px; top: 62px;  width: 12px; height: 12px; --r: 0deg;   animation-duration: 5.8s; animation-delay: .9s; }

/* ---------- stage content ---------- */
.ikii-victory__hero {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 74px 30px 0;
  box-sizing: border-box;
  gap: 22px;
}
.ikii-victory__game {
  /* solid paper, kept secondary by size/weight — never faded with alpha:
     paper at 72% on math blue is 2.7:1 and unreadable */
  font: 500 13px/1 'DM Mono', ui-monospace, monospace;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #FFFDF8;
  animation: ikii-up .34s cubic-bezier(.34, 1.5, .64, 1) both;
}
.ikii-victory__title {
  font: 600 44px/1.05 'Fredoka', sans-serif;
  letter-spacing: -.035em;
  color: #FFFDF8;
  text-align: center;
  margin: 0;
  animation: ikii-up .38s cubic-bezier(.34, 1.5, .64, 1) .08s both;
}
.ikii-victory__kii { position: relative; margin-top: 6px; display: grid; place-items: center; }
.ikii-victory__plinth {
  position: absolute;
  bottom: 6px;
  width: 148px; height: 22px;
  border-radius: 999px;
  background: #3A66AE;
}
.ikii-victory__face {
  position: relative;
  width: 152px; height: 152px;
  filter: drop-shadow(0 9px 0 #D64A2B);
  animation: ikii-land .5s cubic-bezier(.34, 1.5, .64, 1) .2s both,
             ikii-victory-hop 2.6s ease-in-out 1.2s infinite;
}

/* ---------- stars, straddling the stage edge ---------- */
.ikii-victory__stars {
  position: absolute;
  left: 30px; right: 30px; top: 424px;
  background: #FFFDF8;
  border-radius: 26px;
  box-shadow: 0 6px 0 #E4DFD4;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.ikii-victory__star { animation: ikii-star-rise .46s cubic-bezier(.34, 1.5, .64, 1) both; }
.ikii-victory__star:nth-child(1) { animation-delay: .62s; }
.ikii-victory__star:nth-child(2) { animation-delay: .74s; }
.ikii-victory__star:nth-child(3) { animation-delay: .86s; }

/* ---------- three stat tiles ---------- */
.ikii-victory__stats {
  position: absolute;
  left: 30px; right: 30px; top: 540px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.ikii-victory__stat {
  background: #FFFDF8;
  border-radius: 22px;
  box-shadow: 0 5px 0 #E4DFD4;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  animation: ikii-punch .3s cubic-bezier(.34, 1.5, .64, 1) both;
}
.ikii-victory__stat:nth-child(1) { animation-delay: .96s; }
.ikii-victory__stat:nth-child(2) { animation-delay: 1.06s; }
.ikii-victory__stat:nth-child(3) { animation-delay: 1.16s; }
.ikii-victory__stat i {
  width: 40px; height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
}
.ikii-victory__stat:nth-child(1) i { background: #4C82D9; }
.ikii-victory__stat:nth-child(2) i { background: #FB6340; }
.ikii-victory__stat:nth-child(3) i { background: #A874E6; }
.ikii-victory__stat b { font: 600 21px/1 'Fredoka', sans-serif; color: #1B1A24; }
.ikii-victory__stat span {
  font: 400 9px/1 'DM Mono', ui-monospace, monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #86818F;
}

/* ---------- buttons ---------- */
.ikii-victory__actions {
  position: absolute;
  left: 30px; right: 30px; bottom: 34px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: ikii-up .34s cubic-bezier(.34, 1.5, .64, 1) 1.26s both;
}
.ikii-victory__btn {
  border: 0;
  width: 100%;
  box-sizing: border-box;
  border-radius: 999px;
  cursor: pointer;
  font-family: 'Fredoka', sans-serif;
  transition: transform 90ms linear, box-shadow 90ms linear;
}
.ikii-victory__btn--primary {
  background: #FB6340;
  box-shadow: 0 6px 0 #D64A2B;
  padding: 20px;
  font-size: 22px;
  font-weight: 600;
  color: #FFFDF8;
}
.ikii-victory__btn--primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #D64A2B; }
.ikii-victory__btn--secondary {
  background: #FFFDF8;
  box-shadow: 0 5px 0 #E4DFD4;
  padding: 18px;
  font-size: 18px;
  font-weight: 600;
  color: #57525F;
}
.ikii-victory__btn--secondary:active { transform: translateY(3px); box-shadow: 0 1px 0 #E4DFD4; }

/* ---------- keyframes ---------- */
@keyframes ikii-up {
  0% { transform: translateY(30px); opacity: 0 }
  65% { transform: translateY(-5px); opacity: 1 }
  100% { transform: translateY(0); opacity: 1 }
}
@keyframes ikii-punch {
  0% { transform: scale(.6); opacity: 0 }
  60% { transform: scale(1.09); opacity: 1 }
  100% { transform: scale(1); opacity: 1 }
}
@keyframes ikii-land {
  0% { transform: translateY(-90px) scale(.82); opacity: 0 }
  52% { transform: translateY(10px) scale(1.06); opacity: 1 }
  74% { transform: translateY(-5px) scale(.99) }
  100% { transform: translateY(0) scale(1); opacity: 1 }
}
@keyframes ikii-star-rise {
  0% { transform: translateY(18px) scale(.3); opacity: 0 }
  55% { transform: translateY(-8px) scale(1.22); opacity: 1 }
  78% { transform: translateY(2px) scale(.96) }
  100% { transform: translateY(0) scale(1); opacity: 1 }
}
@keyframes ikii-victory-hop {
  0%, 100% { transform: translateY(0) }
  40% { transform: translateY(-14px) }
  70% { transform: translateY(-3px) }
}
@keyframes ikii-drift {
  0%, 100% { transform: translate(0, 0) rotate(var(--r, 0deg)) }
  50% { transform: translate(0, -16px) rotate(calc(var(--r, 0deg) + 5deg)) }
}

@media (max-width: 380px) {
  .ikii-victory__stage { height: 420px; }
  .ikii-victory__title { font-size: 38px; }
  .ikii-victory__face { width: 132px; height: 132px; }
  .ikii-victory__stars { top: 380px; }
  .ikii-victory__stats { top: 492px; }
}

@media (prefers-reduced-motion: reduce) {
  .ikii-victory * { animation: none !important; }
}
