:root {
  --case-w: min(68vw, 360px);
  --case-h: calc(var(--case-w) * 0.62);
  --white: #fbfcff;
  --edge: #dfe8f1;
  --ink: #263241;
  --mint: #76f2c2;
  --coral: #ff7b78;
  --blue: #74b7ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  overflow: hidden;
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.96), transparent 34%),
    linear-gradient(135deg, #edf8ff 0%, #fff7ec 48%, #eefcf4 100%);
}

.stage {
  min-height: 100%;
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  padding: 28px;
}

.ambient {
  position: absolute;
  width: 34vmin;
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0.55;
  filter: blur(18px);
  z-index: -1;
}

.ambient-a {
  left: 10%;
  top: 14%;
  background: rgba(116, 183, 255, 0.38);
}

.ambient-b {
  right: 8%;
  bottom: 12%;
  background: rgba(255, 123, 120, 0.28);
}

.toy {
  position: relative;
  width: min(92vw, 680px);
  height: min(78vh, 620px);
  min-height: 430px;
  display: grid;
  place-items: center;
  perspective: 1200px;
}

.case-button {
  position: relative;
  width: var(--case-w);
  height: calc(var(--case-h) + 170px);
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  transform: translateY(42px);
  -webkit-tap-highlight-color: transparent;
}

.case-button:focus-visible {
  outline: 4px solid rgba(38, 50, 65, 0.28);
  outline-offset: 18px;
  border-radius: 28px;
}

.case {
  position: absolute;
  left: 0;
  bottom: 58px;
  width: var(--case-w);
  height: var(--case-h);
  transform-style: preserve-3d;
  filter: drop-shadow(0 18px 24px rgba(69, 88, 114, 0.18));
  animation: idle 3.6s ease-in-out infinite;
}

.shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 38px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(53, 68, 88, 0.26), transparent 72%);
  transform: scaleX(1);
  transition: transform 700ms cubic-bezier(0.2, 0.9, 0.2, 1), opacity 700ms ease;
}

.body,
.lid-face {
  position: absolute;
  inset: 20% 0 0;
  border-radius: 26% 26% 32% 32% / 36% 36% 30% 30%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(230, 239, 248, 0.96)),
    var(--white);
  border: 2px solid rgba(193, 207, 221, 0.82);
  box-shadow:
    inset -18px -22px 36px rgba(189, 205, 221, 0.34),
    inset 18px 18px 26px rgba(255, 255, 255, 0.92);
}

.body {
  overflow: hidden;
}

.seam {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 27%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(157, 176, 195, 0.62), transparent);
}

.led {
  position: absolute;
  left: 50%;
  bottom: 21%;
  width: 10px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 18px var(--mint), inset 0 1px 2px rgba(255, 255, 255, 0.9);
  transform: translateX(-50%);
}

.lid {
  position: absolute;
  inset: 0 0 43%;
  transform-origin: 50% 100%;
  transform-style: preserve-3d;
  transition: transform 900ms cubic-bezier(0.17, 0.92, 0.22, 1.2);
  z-index: 5;
}

.lid-face {
  inset: 0;
  border-radius: 34% 34% 22% 22% / 52% 52% 22% 22%;
}

.lid-glow {
  position: absolute;
  inset: 12% 18% auto;
  height: 22%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.68);
  filter: blur(8px);
}

.cups {
  position: absolute;
  left: 14%;
  right: 14%;
  top: 31%;
  height: 34%;
  display: flex;
  justify-content: space-between;
  z-index: 2;
}

.cup {
  width: 32%;
  border-radius: 46% 46% 38% 38%;
  background: linear-gradient(180deg, rgba(196, 211, 225, 0.55), rgba(255, 255, 255, 0.2));
  box-shadow: inset 0 10px 18px rgba(123, 146, 169, 0.18);
}

.pod {
  position: absolute;
  top: 26%;
  width: 22%;
  height: 55%;
  transform: translate3d(0, 0, 22px) rotate(0deg);
  transform-origin: 50% 88%;
  opacity: 0;
  z-index: 4;
}

.pod-left {
  left: 22%;
}

.pod-right {
  right: 22%;
}

.pod-bud {
  position: absolute;
  left: 7%;
  top: 0;
  width: 60%;
  aspect-ratio: 1.12;
  border-radius: 54% 46% 52% 48%;
  background: linear-gradient(145deg, #ffffff, #e7f0f8);
  border: 1px solid rgba(189, 205, 221, 0.95);
  box-shadow: inset 8px 8px 14px rgba(255, 255, 255, 0.95), inset -8px -8px 14px rgba(176, 194, 211, 0.28);
}

.pod-stem {
  position: absolute;
  left: 42%;
  top: 42%;
  width: 25%;
  height: 58%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f9fbff, #dce7f1);
  border: 1px solid rgba(188, 203, 218, 0.88);
}

.trail {
  position: absolute;
  left: 40%;
  top: 78%;
  width: 22%;
  height: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(116, 183, 255, 0.86), rgba(255, 123, 120, 0.56), transparent);
  filter: blur(1px);
  opacity: 0;
}

.sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.particle {
  position: absolute;
  left: 50%;
  top: 53%;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--color);
  opacity: 0;
  animation: pop 900ms cubic-bezier(0.16, 0.84, 0.25, 1) forwards;
}

.replay {
  position: absolute;
  bottom: 16px;
  border: 0;
  border-radius: 999px;
  padding: 13px 24px;
  font-weight: 800;
  letter-spacing: 0;
  color: #1f2b38;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(58, 78, 104, 0.16), inset 0 0 0 1px rgba(186, 205, 222, 0.8);
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.replay:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(58, 78, 104, 0.2), inset 0 0 0 1px rgba(186, 205, 222, 0.9);
}

.is-open .lid {
  transform: rotateX(-112deg) translateY(-5px);
}

.is-open .pod-left {
  animation: launch-left 1500ms cubic-bezier(0.13, 0.72, 0.13, 1) forwards;
}

.is-open .pod-right {
  animation: launch-right 1500ms cubic-bezier(0.13, 0.72, 0.13, 1) forwards;
}

.is-open .trail {
  animation: trail 950ms ease-out 260ms forwards;
}

.is-open .shadow {
  opacity: 0.68;
  transform: scaleX(0.82);
}

@keyframes idle {
  0%,
  100% {
    transform: rotateX(4deg) rotateY(-7deg) translateY(0);
  }
  50% {
    transform: rotateX(6deg) rotateY(7deg) translateY(-8px);
  }
}

@keyframes launch-left {
  0% {
    opacity: 1;
    transform: translate3d(0, 18px, 28px) rotate(-8deg) scale(0.92);
  }
  18% {
    opacity: 1;
    transform: translate3d(-24px, -74px, 56px) rotate(-24deg) scale(1.03);
  }
  62% {
    opacity: 1;
    transform: translate3d(-90px, -275px, 90px) rotate(-372deg) scale(1.08);
  }
  100% {
    opacity: 1;
    transform: translate3d(-120px, -355px, 80px) rotate(-382deg) scale(0.96);
  }
}

@keyframes launch-right {
  0% {
    opacity: 1;
    transform: translate3d(0, 18px, 28px) rotate(8deg) scale(0.92);
  }
  18% {
    opacity: 1;
    transform: translate3d(24px, -78px, 56px) rotate(24deg) scale(1.03);
  }
  62% {
    opacity: 1;
    transform: translate3d(88px, -282px, 90px) rotate(372deg) scale(1.08);
  }
  100% {
    opacity: 1;
    transform: translate3d(124px, -350px, 80px) rotate(384deg) scale(0.96);
  }
}

@keyframes trail {
  0% {
    opacity: 0;
    height: 0;
  }
  22% {
    opacity: 0.9;
    height: 120%;
  }
  100% {
    opacity: 0;
    height: 180%;
  }
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
  16% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(0.1);
  }
}

@media (max-width: 560px) {
  :root {
    --case-w: min(82vw, 300px);
  }

  .toy {
    min-height: 500px;
  }

  .case-button {
    transform: translateY(68px);
  }

  @keyframes launch-left {
    0% { opacity: 1; transform: translate3d(0, 18px, 28px) rotate(-8deg) scale(0.92); }
    18% { opacity: 1; transform: translate3d(-18px, -66px, 56px) rotate(-24deg) scale(1.03); }
    62% { opacity: 1; transform: translate3d(-58px, -250px, 90px) rotate(-372deg) scale(1.08); }
    100% { opacity: 1; transform: translate3d(-76px, -320px, 80px) rotate(-382deg) scale(0.96); }
  }

  @keyframes launch-right {
    0% { opacity: 1; transform: translate3d(0, 18px, 28px) rotate(8deg) scale(0.92); }
    18% { opacity: 1; transform: translate3d(18px, -68px, 56px) rotate(24deg) scale(1.03); }
    62% { opacity: 1; transform: translate3d(58px, -254px, 90px) rotate(372deg) scale(1.08); }
    100% { opacity: 1; transform: translate3d(78px, -318px, 80px) rotate(384deg) scale(0.96); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .case,
  .is-open .pod-left,
  .is-open .pod-right,
  .particle,
  .is-open .trail {
    animation-duration: 1ms;
  }
}
