:root {
  color-scheme: dark;
  --bg: #111314;
  --panel: #1b1f21;
  --panel-soft: #24292b;
  --text: #f7f4ee;
  --muted: #a8b0ad;
  --accent: #00c2a8;
  --accent-strong: #15e2c4;
  --coral: #ff6b57;
  --gold: #ffd166;
  --cream: #fff8e1;
  --track: #30383a;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 20% 15%, rgba(0, 194, 168, 0.2), transparent 28rem),
    radial-gradient(circle at 86% 12%, rgba(255, 107, 87, 0.18), transparent 24rem),
    linear-gradient(145deg, #101112, #171b1c 52%, #101414);
  color: var(--text);
  overflow: hidden;
}

button {
  border: 0;
  font: inherit;
}

.game-shell {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.play-area {
  width: min(100%, 430px);
  min-height: min(760px, calc(100svh - 32px));
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  gap: 18px;
}

.top-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric {
  min-height: 78px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(27, 31, 33, 0.82);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.24);
}

.metric-label,
.metric-sub,
.hint,
.dialog-kicker {
  color: var(--muted);
}

.metric-label,
.dialog-kicker {
  display: block;
  font-size: 12px;
  letter-spacing: 0;
}

.metric strong {
  display: inline-block;
  margin-top: 5px;
  font-size: clamp(28px, 12vw, 42px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-sub {
  margin-left: 2px;
  font-size: 15px;
}

.stage {
  position: relative;
  min-height: 420px;
  display: grid;
  place-items: end center;
  isolation: isolate;
  overflow: visible;
}

.motion-prompt {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  width: min(82%, 330px);
  min-height: 70px;
  padding: 0 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: var(--text);
  font-size: clamp(21px, 6vw, 30px);
  font-weight: 850;
  letter-spacing: 0;
  background: rgba(27, 31, 33, 0.82);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(6px);
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.motion-prompt.hidden {
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.96);
  transition: opacity 160ms ease, transform 160ms ease;
}

.figure {
  --shake-y: 0px;
  position: relative;
  width: min(54vw, 230px);
  display: grid;
  justify-items: center;
  align-items: end;
  transform: translateY(var(--shake-y));
  transform-origin: 50% 88%;
  transition: transform 90ms ease-out;
  z-index: 2;
}

.cylinder {
  position: relative;
  width: min(32vw, 132px);
  height: min(52vh, 385px);
  max-height: 385px;
  min-height: 255px;
  background: transparent;
  filter: drop-shadow(0 22px 42px rgba(0, 0, 0, 0.34));
  overflow: visible;
  z-index: 3;
}

.cylinder::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 100%;
  height: 72px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 32%, rgba(255, 255, 255, 0.64), rgba(255, 255, 255, 0.16) 36%, transparent 37%),
    linear-gradient(180deg, #ffc3ad, #f97d73 72%);
  box-shadow:
    inset 0 9px 18px rgba(255, 255, 255, 0.24),
    inset 0 -18px 26px rgba(112, 34, 35, 0.18);
  transform: translateX(-50%);
  z-index: 4;
}

.cylinder::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 36px;
  bottom: 34px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.34), transparent 16% 74%, rgba(0, 0, 0, 0.18)),
    linear-gradient(180deg, #ff9b84, #ffb092 45%, #ef6966 100%);
  box-shadow:
    inset 24px 0 34px rgba(255, 255, 255, 0.18),
    inset -24px 0 42px rgba(89, 24, 23, 0.24);
  z-index: 1;
}

.cap {
  position: absolute;
  left: 50%;
  top: 12px;
  width: 54%;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 236, 216, 0.44);
  transform: translateX(-50%);
  z-index: 2;
}

.shine {
  position: absolute;
  left: 22%;
  top: 52px;
  width: 16px;
  height: calc(100% - 104px);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0.02));
  filter: blur(1px);
  z-index: 2;
}

.base {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100%;
  height: 62px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 255, 255, 0.22), transparent 52%),
    linear-gradient(180deg, rgba(255, 173, 150, 0.7), rgba(123, 32, 39, 0.26));
  transform: translateX(-50%);
  z-index: 4;
}

.egg-supports {
  position: relative;
  width: min(53vw, 210px);
  height: min(23vw, 88px);
  min-height: 64px;
  margin-top: -13px;
  z-index: 2;
}

.egg {
  position: absolute;
  bottom: 0;
  width: 54%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 34% 24%, rgba(255, 255, 255, 0.36), transparent 26%),
    linear-gradient(145deg, #ff9b84, #f37670 58%, #c94d5b);
  box-shadow:
    inset 13px 10px 22px rgba(255, 255, 255, 0.14),
    inset -15px -14px 26px rgba(83, 19, 29, 0.22),
    0 16px 36px rgba(0, 0, 0, 0.25);
}

.left-egg {
  left: 8px;
  transform: rotate(-8deg);
}

.right-egg {
  right: 8px;
  transform: rotate(8deg);
}

.shadow {
  position: absolute;
  bottom: -2px;
  width: min(58vw, 244px);
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.36);
  filter: blur(11px);
  z-index: 1;
}

.figure.bump {
  animation: bump 160ms ease-out;
}

.figure.finish {
  animation: finale-wobble 950ms ease-in-out both;
}

.burst {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 18px;
  height: 18px;
  pointer-events: none;
  transform: translateX(-50%);
  z-index: 5;
  opacity: 0;
}

.burst span {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 18px;
  height: 42px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 18%, #ffffff, var(--cream) 54%, #ece1c2);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.48);
  transform: translate(-50%, 0) scale(0.2);
  opacity: 0;
}

.burst.active {
  opacity: 1;
}

.burst.active span {
  animation: spray 1100ms cubic-bezier(0.16, 0.72, 0.2, 1) both;
}

.burst span:nth-child(1) { --x: -105px; --y: -250px; --r: -22deg; animation-delay: 0ms; }
.burst span:nth-child(2) { --x: -62px; --y: -300px; --r: -12deg; animation-delay: 50ms; }
.burst span:nth-child(3) { --x: -24px; --y: -340px; --r: -4deg; animation-delay: 15ms; }
.burst span:nth-child(4) { --x: 0px; --y: -365px; --r: 2deg; animation-delay: 80ms; }
.burst span:nth-child(5) { --x: 38px; --y: -322px; --r: 8deg; animation-delay: 35ms; }
.burst span:nth-child(6) { --x: 72px; --y: -286px; --r: 16deg; animation-delay: 65ms; }
.burst span:nth-child(7) { --x: 112px; --y: -230px; --r: 24deg; animation-delay: 20ms; }
.burst span:nth-child(8) { --x: 16px; --y: -250px; --r: -8deg; animation-delay: 120ms; }

.progress-wrap {
  padding: 0 3px;
}

.progress-track {
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--coral));
  transition: width 140ms ease-out;
}

.controls {
  display: grid;
}

.primary-button,
.ghost-button {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.primary-button {
  color: #071311;
  font-weight: 800;
  background: var(--accent-strong);
  box-shadow: 0 14px 34px rgba(0, 194, 168, 0.28);
}

.ghost-button {
  color: var(--text);
  background: var(--panel-soft);
}

.primary-button:active,
.ghost-button:active,
.motion-prompt:active {
  transform: translateY(1px) scale(0.99);
}

.motion-prompt:active {
  transform: translate(-50%, calc(-50% + 1px)) scale(0.99);
}

.hint {
  min-height: 42px;
  margin: 0;
  text-align: center;
  font-size: 14px;
  line-height: 1.55;
}

.result-dialog {
  width: min(calc(100vw - 30px), 390px);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--text);
  background: rgba(27, 31, 33, 0.98);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.result-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(4px);
}

.dialog-body {
  padding: 24px;
  text-align: center;
}

.dialog-body h1 {
  margin: 8px 0 12px;
  font-size: clamp(24px, 8vw, 34px);
  line-height: 1.15;
}

.dialog-body p {
  margin: 0 0 18px;
  color: var(--muted);
}

.dialog-body .primary-button {
  width: 100%;
}

@keyframes bump {
  0% { transform: translateY(var(--shake-y)) scaleY(1); }
  50% { transform: translateY(var(--shake-y)) scaleY(1.028); }
  100% { transform: translateY(var(--shake-y)) scaleY(1); }
}

@keyframes finale-wobble {
  0%, 100% { transform: translateY(0) scaleY(1); }
  18% { transform: translateY(-12px) scaleY(1.04); }
  36% { transform: translateY(8px) scaleY(0.98); }
  54% { transform: translateY(-9px) scaleY(1.035); }
  72% { transform: translateY(5px) scaleY(0.99); }
}

@keyframes spray {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) rotate(var(--r)) scale(0.12);
  }

  16% {
    opacity: 1;
  }

  76% {
    opacity: 1;
    transform: translate(calc(-50% + var(--x)), var(--y)) rotate(var(--r)) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x) * 1.05), calc(var(--y) + 52px)) rotate(var(--r)) scale(0.82);
  }
}

@media (max-height: 680px) {
  .play-area {
    gap: 12px;
  }

  .stage {
    min-height: 330px;
  }

  .cylinder {
    min-height: 225px;
    height: min(43vh, 330px);
  }

  .egg-supports {
    min-height: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
