.game-crack-the-egg {
  --egg-stage-art: none;
  --crack-progress: 0;
  --egg-shake-x: 0px;
  --egg-shake-y: 0px;
  --egg-shake-rot: 0deg;
  --egg-shake-speed: 210ms;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.portal-page.is-game-focus .mini-game-card:has(.game-crack-the-egg) {
  --game-card-play-min-height: 452px;
  --game-card-play-max-height: 780px;
  --game-stage-play-min-height: 300px;
}

.game-crack-the-egg .game-stage {
  min-height: 280px;
  border-top: 1px solid rgba(255, 255, 255, 0.72);
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 214, 94, 0.26), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 234, 191, 0.06) 44%, rgba(95, 38, 10, 0.22)),
    var(--egg-stage-art) center / cover no-repeat,
    linear-gradient(180deg, #fff6e3, #ffd4a0);
  box-shadow:
    inset 0 10px 18px rgba(255, 255, 255, 0.24),
    inset 0 -18px 28px rgba(95, 38, 10, 0.18);
}

.game-crack-the-egg .game-stage::before {
  z-index: 0;
  inset: auto 18% 24px;
  height: 28px;
  border-radius: 999px;
  background: rgba(95, 38, 10, 0.32);
  filter: blur(18px);
}

.game-crack-the-egg .game-stage::after {
  z-index: 1;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 232, 142, 0.22), transparent 22%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 60%, rgba(95, 38, 10, 0.14));
}

.portal-page.is-game-focus .game-crack-the-egg .game-stage {
  height: clamp(292px, calc(100svh - 330px), 380px);
  min-height: 292px;
}

@supports (height: 100dvh) {
  .portal-page.is-game-focus .game-crack-the-egg .game-stage {
    height: clamp(292px, calc(100dvh - 330px), 380px);
  }
}

.portal-page.is-game-focus .game-crack-the-egg:not(.is-countdown):not(.is-playing):not(.is-completing):not(.is-finished) .game-stage {
  height: clamp(376px, 58svh, 420px);
  min-height: 376px;
}

@supports (height: 100dvh) {
  .portal-page.is-game-focus .game-crack-the-egg:not(.is-countdown):not(.is-playing):not(.is-completing):not(.is-finished) .game-stage {
    height: clamp(376px, 58dvh, 420px);
  }
}

.portal-page.is-game-focus .game-crack-the-egg.is-countdown .game-stage,
.portal-page.is-game-focus .game-crack-the-egg.is-playing .game-stage,
.portal-page.is-game-focus .game-crack-the-egg.is-completing .game-stage {
  height: clamp(318px, calc(100svh - 236px), 560px);
  min-height: var(--game-stage-play-min-height);
}

@supports (height: 100dvh) {
  .portal-page.is-game-focus .game-crack-the-egg.is-countdown .game-stage,
  .portal-page.is-game-focus .game-crack-the-egg.is-playing .game-stage,
  .portal-page.is-game-focus .game-crack-the-egg.is-completing .game-stage {
    height: clamp(318px, calc(100dvh - 236px), 560px);
  }
}

@supports selector(:has(*)) {
  .portal-page.is-game-focus .game-crack-the-egg.is-countdown .game-stage,
  .portal-page.is-game-focus .game-crack-the-egg.is-playing .game-stage,
  .portal-page.is-game-focus .game-crack-the-egg.is-completing .game-stage {
    height: clamp(318px, calc(100dvh - 236px), 560px);
    min-height: var(--game-stage-play-min-height);
  }
}

.game-crack-the-egg.is-playing .game-stage {
  touch-action: manipulation;
}

.game-crack-the-egg.is-finished .game-stage {
  height: auto;
  min-height: 0;
  touch-action: auto;
  background: #ffffff;
}

.game-crack-the-egg.is-finished .game-overlay {
  position: static;
  display: block;
  padding: 12px 16px;
  background: #ffffff;
  backdrop-filter: none;
}

.game-crack-the-egg.is-finished .game-overlay-panel {
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
}

.game-crack-the-egg.is-finished .game-overlay-panel h2 {
  margin: 0;
  color: var(--color-primary);
  font-size: 14px;
  line-height: 1.2;
}

.egg-glow {
  position: absolute;
  left: 50%;
  top: 48%;
  z-index: 1;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 94, 0.46), rgba(255, 214, 94, 0));
  transform: translate(-50%, -50%) scale(calc(0.86 + (var(--crack-progress) * 0.002)));
  pointer-events: none;
}

.egg-target {
  --impact-x: 50%;
  --impact-y: 38%;
  position: absolute;
  left: 50%;
  top: 45%;
  z-index: 2;
  width: min(58vw, 230px);
  aspect-ratio: 0.78;
  border: 0;
  border-radius: 50% 50% 45% 45%;
  background: transparent;
  transform: translate(-50%, -50%) scale(calc(1 + (var(--crack-progress) * 0.0008)));
  touch-action: manipulation;
  will-change: transform;
  cursor: pointer;
}

.egg-target::after {
  content: "";
  position: absolute;
  left: var(--impact-x);
  top: var(--impact-y);
  z-index: 8;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.78);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.42);
}

.egg-target.is-impacting::after {
  animation: egg-impact-ring 360ms ease-out;
}

.game-crack-the-egg.is-playing[data-shake-active="true"] .egg-body {
  animation: egg-hatch-rattle var(--egg-shake-speed) linear infinite;
}

.egg-body,
.egg-interior,
.egg-shell,
.egg-crack-layer,
.egg-shell-piece {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.egg-body {
  z-index: 1;
  transform-origin: 50% 56%;
  will-change: transform;
}

.egg-interior {
  z-index: 1;
  overflow: hidden;
  opacity: clamp(0, calc((var(--crack-progress) - 42) / 38), 1);
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 233, 119, 0.96) 0 18%, rgba(255, 171, 26, 0.64) 28%, transparent 46%),
    radial-gradient(circle at 50% 48%, rgba(230, 33, 41, 0.44), transparent 58%),
    linear-gradient(180deg, #8e0c18, #5f0811 72%);
  box-shadow:
    inset 0 8px 20px rgba(255, 232, 142, 0.2),
    inset 0 -16px 34px rgba(49, 5, 10, 0.42);
}

.egg-interior::before {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 94, 0.68), transparent 68%);
  filter: blur(8px);
  opacity: clamp(0, calc((var(--crack-progress) - 55) / 36), 1);
}

.egg-shell,
.egg-shell-piece {
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 18%, rgba(255, 255, 255, 0.94) 0 9%, transparent 22%),
    radial-gradient(circle at 68% 70%, rgba(141, 76, 21, 0.13), transparent 26%),
    radial-gradient(circle at 38% 64%, rgba(185, 120, 52, 0.08) 0 2px, transparent 3px),
    radial-gradient(circle at 61% 30%, rgba(185, 120, 52, 0.08) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 50% 46%, rgba(255, 251, 222, 0.3), transparent 45%),
    linear-gradient(135deg, #fffcef 0%, #f9e7bd 45%, #e8b56a 72%, #c67928 100%);
  box-shadow:
    0 24px 38px rgba(82, 38, 8, 0.3),
    inset -20px -28px 38px rgba(109, 55, 11, 0.2),
    inset 12px 12px 28px rgba(255, 255, 255, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.egg-shell--whole {
  z-index: 4;
  transition: opacity 180ms ease;
}

.egg-shell--whole::after {
  content: "";
  position: absolute;
  inset: 11%;
  border-radius: inherit;
  opacity: clamp(0, calc((var(--crack-progress) - 20) / 95), 0.85);
  background:
    radial-gradient(circle at var(--impact-x) var(--impact-y), rgba(126, 52, 16, 0.18), transparent 28%),
    radial-gradient(circle at 50% 48%, rgba(230, 33, 41, 0.12), transparent 62%);
}

.egg-crack-layer {
  z-index: 6;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 130ms ease;
}

.egg-shell-piece {
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 130ms ease,
    transform 620ms cubic-bezier(0.17, 0.84, 0.29, 1.12);
}

.egg-shell-piece--top {
  clip-path: polygon(0 0, 100% 0, 100% 49%, 75% 45%, 66% 52%, 55% 43%, 45% 51%, 35% 43%, 25% 51%, 0 47%);
  transform: translate3d(0, 0, 0) rotate(0deg);
  transform-origin: 48% 52%;
}

.egg-shell-piece--bottom {
  clip-path: polygon(0 46%, 24% 50%, 35% 42%, 45% 50%, 55% 42%, 66% 51%, 75% 44%, 100% 48%, 100% 100%, 0 100%);
  transform: translate3d(0, 0, 0) rotate(0deg);
  transform-origin: 52% 46%;
}

.egg-crack {
  position: absolute;
  z-index: 1;
  width: 12px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent 18% 82%, rgba(255, 255, 255, 0.12)),
    linear-gradient(180deg, #4d1f0b, #7b310f 42%, #3e1808);
  clip-path: polygon(42% 0, 70% 9%, 46% 21%, 70% 34%, 48% 47%, 66% 60%, 38% 73%, 55% 100%, 34% 100%, 22% 73%, 42% 60%, 25% 47%, 44% 34%, 28% 21%, 46% 9%, 32% 0);
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.16));
  opacity: 0;
  transform-origin: top center;
  will-change: opacity, transform;
}

.egg-crack--main {
  left: 49%;
  top: 15%;
  height: 150px;
  opacity: clamp(0, calc((var(--crack-progress) - 12) / 28), 1);
  transform: rotate(3deg) scaleY(clamp(0.22, calc((var(--crack-progress) - 8) / 46), 1));
}

.egg-crack--left-upper {
  left: 38%;
  top: 31%;
  height: 64px;
  width: 10px;
  opacity: clamp(0, calc((var(--crack-progress) - 28) / 22), 1);
  transform: rotate(-58deg) scaleY(clamp(0, calc((var(--crack-progress) - 24) / 38), 1));
}

.egg-crack--right-upper {
  left: 56%;
  top: 34%;
  height: 70px;
  width: 10px;
  opacity: clamp(0, calc((var(--crack-progress) - 38) / 24), 1);
  transform: rotate(55deg) scaleY(clamp(0, calc((var(--crack-progress) - 34) / 38), 1));
}

.egg-crack--left-lower {
  left: 42%;
  top: 51%;
  height: 74px;
  width: 10px;
  opacity: clamp(0, calc((var(--crack-progress) - 54) / 22), 1);
  transform: rotate(-34deg) scaleY(clamp(0, calc((var(--crack-progress) - 50) / 36), 1));
}

.egg-crack--right-lower {
  left: 54%;
  top: 53%;
  height: 70px;
  width: 10px;
  opacity: clamp(0, calc((var(--crack-progress) - 64) / 22), 1);
  transform: rotate(36deg) scaleY(clamp(0, calc((var(--crack-progress) - 60) / 34), 1));
}

.egg-crack--crown-left {
  left: 31%;
  top: 44%;
  height: 50px;
  width: 9px;
  opacity: clamp(0, calc((var(--crack-progress) - 76) / 18), 1);
  transform: rotate(-82deg) scaleY(clamp(0, calc((var(--crack-progress) - 72) / 24), 1));
}

.egg-crack--crown-right {
  left: 63%;
  top: 46%;
  height: 52px;
  width: 9px;
  opacity: clamp(0, calc((var(--crack-progress) - 80) / 16), 1);
  transform: rotate(82deg) scaleY(clamp(0, calc((var(--crack-progress) - 76) / 24), 1));
}

.egg-prize {
  position: absolute;
  left: 50%;
  top: 52%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border: 4px solid rgba(255, 244, 176, 0.78);
  border-radius: 50%;
  color: #ffffff;
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.95) 0 8%, transparent 9%),
    radial-gradient(circle at 38% 32%, rgba(255, 255, 255, 0.45), transparent 20%),
    linear-gradient(145deg, #ffe86d 0%, #ffb22d 42%, #ed1c24 100%);
  box-shadow:
    0 0 32px rgba(255, 214, 94, 0.72),
    0 16px 30px rgba(72, 6, 14, 0.32),
    inset 0 0 0 2px rgba(125, 55, 0, 0.14),
    inset 0 -8px 16px rgba(141, 52, 0, 0.26);
  font-size: 22px;
  font-weight: 950;
  opacity: clamp(0, calc((var(--crack-progress) - 52) / 34), 1);
  transform: translate(-50%, -50%) scale(clamp(0.72, calc(0.72 + (var(--crack-progress) * 0.004)), 1.08));
  text-shadow: 0 2px 0 rgba(74, 7, 14, 0.24);
}

.egg-prize::before,
.egg-prize::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.egg-prize::before {
  inset: -16px;
  background: radial-gradient(circle, rgba(255, 214, 94, 0.52), transparent 68%);
  animation: egg-prize-glow 1200ms ease-in-out infinite;
}

.egg-prize::after {
  inset: 13px;
  border: 1px solid rgba(255, 255, 255, 0.38);
}

.egg-prize-core {
  position: relative;
  z-index: 1;
}

.game-crack-the-egg.is-cracked .egg-shell--whole {
  opacity: 0;
}

.game-crack-the-egg.is-cracked .egg-crack-layer {
  opacity: 0;
}

.game-crack-the-egg.is-cracked .egg-shell-piece {
  opacity: 1;
}

.game-crack-the-egg.is-cracked .egg-shell-piece--top {
  transform: translate3d(-12px, -42px, 0) rotate(-12deg);
}

.game-crack-the-egg.is-cracked .egg-shell-piece--bottom {
  transform: translate3d(12px, 42px, 0) rotate(10deg);
}

.game-crack-the-egg.is-cracked .egg-interior {
  opacity: 1;
}

@keyframes egg-impact-ring {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.35);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.6);
  }
}

@keyframes egg-hatch-rattle {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  12% {
    transform: translate3d(calc(var(--egg-shake-x) * -1), var(--egg-shake-y), 0) rotate(calc(var(--egg-shake-rot) * -1));
  }
  24% {
    transform: translate3d(calc(var(--egg-shake-x) * 0.72), calc(var(--egg-shake-y) * -0.8), 0) rotate(var(--egg-shake-rot));
  }
  38% {
    transform: translate3d(calc(var(--egg-shake-x) * -0.52), calc(var(--egg-shake-y) * -0.32), 0) rotate(calc(var(--egg-shake-rot) * -0.62));
  }
  56% {
    transform: translate3d(var(--egg-shake-x), calc(var(--egg-shake-y) * 0.48), 0) rotate(calc(var(--egg-shake-rot) * 0.8));
  }
  74% {
    transform: translate3d(calc(var(--egg-shake-x) * -0.8), calc(var(--egg-shake-y) * -1), 0) rotate(calc(var(--egg-shake-rot) * -0.9));
  }
}

@keyframes egg-prize-glow {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.92);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.08);
  }
}

.egg-meter {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 34px;
  z-index: 2;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(65, 20, 8, 0.52);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.3),
    0 1px 0 rgba(255, 255, 255, 0.22);
}

.egg-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd65e, #ff6335, #e62129);
  box-shadow: 0 0 16px rgba(255, 214, 94, 0.38);
}

.egg-tap-pop {
  position: absolute;
  z-index: 5;
  width: var(--tap-pop-size, 22px);
  height: var(--tap-pop-size, 22px);
  border: 3px solid rgba(255, 214, 94, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(255, 214, 94, 0.42);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: egg-tap-pop 420ms ease-out forwards;
}

.egg-chip {
  position: absolute;
  z-index: 7;
  width: var(--chip-size, 6px);
  height: calc(var(--chip-size, 6px) * 0.72);
  border-radius: 60% 42% 55% 40%;
  background: linear-gradient(135deg, #fff6d7, #d58b31);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.64),
    0 2px 4px rgba(72, 32, 6, 0.18);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: egg-chip-fly 520ms ease-out forwards;
}

@keyframes egg-tap-pop {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.55);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.75);
  }
}

@keyframes egg-chip-fly {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--chip-x)), calc(-50% + var(--chip-y))) rotate(var(--chip-rot)) scale(0.72);
  }
}

.game-crack-the-egg .game-overlay {
  z-index: 6;
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.58), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(95, 38, 10, 0.18));
  backdrop-filter: none;
}

.game-crack-the-egg .game-overlay-panel {
  width: min(284px, 100%);
  padding: 16px 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 248, 230, 0.86)),
    rgba(255, 255, 255, 0.9);
  box-shadow:
    0 14px 28px rgba(95, 38, 10, 0.18),
    0 0 0 6px rgba(255, 255, 255, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.egg-ready-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 11px;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(180deg, #ff4450, #bc1620);
  font-size: 11px;
  font-weight: 900;
}

.egg-ready-art {
  width: 72px;
  height: 92px;
  margin: 9px auto 3px;
  border-radius: 50% 50% 45% 45%;
  background:
    radial-gradient(circle at 32% 20%, rgba(255, 255, 255, 0.92), transparent 15%),
    linear-gradient(135deg, #fffdf1 0%, #ffe8ad 52%, #f4a936 100%);
  box-shadow: 0 14px 22px rgba(95, 38, 10, 0.16);
}
