/* ===== Overlay umum (jeda & hasil) ===== */
.overlay {
  position: absolute;
  inset: 0;
  z-index: var(--z-overlay);
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow: auto;
  background: rgba(31, 58, 104, 0.5);
  animation: overlay-in var(--dur-med) ease both;
}

@keyframes overlay-in {
  from {
    opacity: 0;
  }
}

.overlay__panel,
.overlay .panel {
  animation: card-enter 0.4s var(--ease-bounce) both;
}

/* ===== Hasil misi ===== */
.overlay--lose {
  background: linear-gradient(rgba(59, 61, 122, 0.82), rgba(142, 90, 155, 0.72));
}

.result {
  position: relative;
  width: min(42rem, 94vw);
  padding-top: 0.6rem;
}

/* Pita judul (sprite 560 x 206): teks diletakkan di bagian muka pita yang melengkung. */
.result__banner {
  position: relative;
  width: min(19rem, 80%);
  margin: -0.2rem auto -1.4rem;
  animation: star-pop 0.5s var(--ease-bounce) 0.1s both;
}

.result__banner-image {
  display: block;
  width: 100%;
  height: auto;
}

.result__banner-text {
  position: absolute;
  inset: 10% 18% 48%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  color: #7a3b05;
  text-shadow: 0 0.08rem 0 rgba(255, 255, 255, 0.6);
}

.result--lose .result__banner-text {
  font-size: 1.6rem;
  color: #4b2a7a;
}

/* Bulan tidur di pojok kanan atas panel saat waktu habis. */
.result__moon {
  position: absolute;
  top: -2.2rem;
  right: -1.2rem;
  width: 6.5rem;
  pointer-events: none;
  animation: idle-bob 3s ease-in-out infinite;
}

.result__cast {
  position: relative;
  isolation: isolate;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 8.5rem;
  margin: 0.8rem 0 0.4rem;
}

/* Sinar perayaan berputar pelan di belakang karakter saat menang. */
.result__sunburst {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -1;
  width: 13rem;
  margin: -6.5rem 0 0 -6.5rem;
  pointer-events: none;
  animation: sunburst-spin 12s linear infinite;
}

@keyframes sunburst-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .result__sunburst,
  .result__moon {
    animation: none;
  }
}

.result__cat {
  height: 100%;
  width: auto;
}

.result__cat--side {
  height: 72%;
}

.result__cat--left {
  margin-right: -1rem;
}

.result__cat--right {
  margin-left: -1rem;
  order: 3;
}

.result__cat--hero {
  order: 2;
  z-index: 1;
}

.result--win .result__cat {
  animation: cheer-jump 0.8s ease-in-out infinite;
}

.result--win .result__cat--left {
  animation-delay: -0.2s;
}

.result--win .result__cat--right {
  animation-delay: -0.45s;
}

@keyframes cheer-jump {
  0%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-0.9rem);
  }
}

.result__badge {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 0.2rem 0.9rem;
  border-radius: var(--radius-pill);
  background: var(--color-coral);
  color: var(--color-white);
  font-weight: 700;
  animation: star-pop 0.5s var(--ease-bounce) 0.9s both;
}

.result .panel__title {
  margin-top: 0.5rem;
}

.result__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.result__stat {
  padding: 0.6rem 0.4rem;
  border-radius: 1rem;
  background: var(--color-white);
  box-shadow: 0 0.22rem 0 var(--color-cream-edge);
}

.result__stat-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--color-ink-soft);
}

.result__stat-icon svg {
  width: 1rem;
  height: 1rem;
}

.result__stat-icon .icon-sprite {
  width: 1.6rem;
  height: 1.6rem;
}

.result__stat-value {
  margin-top: 0.1rem;
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ===== Konfeti ===== */
.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti__piece {
  position: absolute;
  top: -2rem;
  width: 0.65rem;
  height: 1.1rem;
  border-radius: 0.2rem;
  animation: confetti-fall linear infinite;
}

@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotate(720deg);
  }
}

/* ===== Petunjuk putar layar (orientasi portrait di ponsel/tablet) ===== */
.rotate-hint {
  position: fixed;
  inset: 0;
  z-index: var(--z-rotate);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
  background: linear-gradient(var(--color-sky-top), var(--color-sky-bottom));
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-ink);
}

.rotate-hint__device {
  width: 4.5rem;
  height: 7.5rem;
  border: 0.5rem solid var(--color-ink);
  border-radius: 1rem;
  background: var(--color-cream);
  animation: rotate-device 2s ease-in-out infinite;
}

@keyframes rotate-device {
  40%,
  70% {
    transform: rotate(-90deg);
  }
}

@media (orientation: portrait) and (max-width: 900px) {
  .rotate-hint {
    display: flex;
  }
}
