:root {
  --vh: 1vh;
  --cake-x: 24.6667%;
  --orange: #f47734;
  --rose: #ef4d74;
  --cream: #fff1c6;
  --brown: #a95b27;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #5f5f5d;
  font-family: Arial, "Helvetica Neue", sans-serif;
  touch-action: none;
}

button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
}

.dream-app {
  width: 100%;
  height: 100%;
}

.stage {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(100vw, calc(var(--vh) * 100 * 1500 / 2667));
  aspect-ratio: 1500 / 2667;
  height: auto;
  overflow: hidden;
  background: #fff;
  transform: translate(-50%, -50%);
  transform-origin: center;
  container-type: inline-size;
}

.camera-video,
.camera-kit-canvas,
.white-wash,
.falling-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.camera-video {
  z-index: 0;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0;
}

.camera-video.is-ready {
  opacity: 0.32;
}

.camera-kit-canvas {
  z-index: 1;
  object-fit: cover;
  opacity: 0;
}

.camera-kit-lens-visible .camera-kit-canvas {
  opacity: 0.32;
}

.camera-kit-lens-visible .camera-video.is-ready {
  opacity: 0.015;
}

.white-wash {
  z-index: 2;
  background: rgba(255, 255, 255, 0.62);
}

.timer {
  position: absolute;
  left: 8.3333%;
  top: 4.4244%;
  z-index: 20;
  width: 68.2%;
  aspect-ratio: 1023 / 295;
  height: auto;
  container-type: inline-size;
}

.timer img,
.timer-bar-clip {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  pointer-events: none;
}

.timer-base,
.timer-top,
.timer-bar {
  width: 100%;
}

.timer-bar-clip {
  left: 0;
  width: 100%;
  overflow: hidden;
  clip-path: inset(0 var(--timer-trim, 0%) 0 0);
  transition: clip-path 180ms linear;
}

.timer-bar {
  transform: none;
}

.timer-cap {
  width: 13.1965%;
  height: auto !important;
  top: 11.5254% !important;
  transform: translateX(-50%);
  transition: left 180ms linear;
}

.timer-number {
  position: absolute;
  left: 5.4741%;
  top: 37.6271%;
  z-index: 6;
  width: 16.4223%;
  color: #f25a16;
  font-size: clamp(1.1rem, 7.6cqw, 5rem);
  font-weight: 950;
  line-height: 1;
  text-align: center;
  letter-spacing: 0;
  text-shadow: 0 3px 0 #fff2d5;
}

.icon-button {
  position: absolute;
  right: 6.3333%;
  z-index: 30;
  width: 11.8667%;
  aspect-ratio: 1;
  height: auto;
  cursor: pointer;
  filter: drop-shadow(0 10px 0 rgba(135, 68, 26, 0.18));
}

.icon-button img {
  width: 100%;
  height: 100%;
  display: block;
}

.info-button {
  top: 4.4244%;
}

.go-button {
  top: 11.8485%;
}

.falling-layer {
  z-index: 10;
  pointer-events: none;
}

.falling-item {
  position: absolute;
  object-fit: contain;
  contain: layout paint style;
  filter: drop-shadow(0 10px 8px rgba(120, 70, 60, 0.16));
  will-change: transform;
}

.falling-item.is-caught {
  animation: caught-pop 520ms ease-out forwards;
}

.score-pop {
  position: absolute;
  z-index: 12;
  width: 8%;
  aspect-ratio: 4 / 3;
  height: auto;
  margin-left: -4%;
  margin-top: -3%;
  display: grid;
  place-items: center;
  color: #f25a16;
  font-size: clamp(1.2rem, 4.6vw, 4.5rem);
  font-weight: 950;
  text-shadow: 0 4px 0 #fff2b8, 0 0 18px rgba(244, 119, 52, 0.5);
  animation: score-pop 760ms ease-out forwards;
}

.cake-wrap {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 15;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cake-stack {
  position: absolute;
  left: var(--cake-x);
  top: 67.8666%;
  width: 50.6667%;
  aspect-ratio: 1500 / 1169;
  height: auto;
  transform-origin: 50% 72%;
  will-change: left, transform;
  transition:
    top 900ms cubic-bezier(0.22, 1, 0.36, 1),
    width 900ms cubic-bezier(0.22, 1, 0.36, 1),
    height 900ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 900ms cubic-bezier(0.22, 1, 0.36, 1);
}

.cake-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cake-layer-base {
  z-index: 1;
}

.cake-layer-strawberry {
  z-index: 20;
}

.cake-layer-cream {
  z-index: 90;
}

.cake-topping {
  position: absolute;
  z-index: var(--z, 60);
  width: 22%;
  aspect-ratio: 1;
  height: auto;
  object-fit: contain;
  transform: translate(-50%, -50%) rotate(var(--rotate)) scale(var(--scale));
  filter: drop-shadow(0 8px 6px rgba(120, 70, 60, 0.18));
  animation: topping-land 260ms ease-out both;
}

.cake-topping-chacolate {
  width: 22%;
  z-index: 40;
}

.cake-topping-stick {
  width: 22%;
}

.cake-topping-lemon {
  width: 22%;
}

.cake-topping-cherry,
.cake-topping-heart {
  width: 22%;
}

.finish-armed .cake-stack {
  transition:
    left 980ms cubic-bezier(0.22, 1, 0.36, 1),
    top 980ms cubic-bezier(0.22, 1, 0.36, 1),
    width 980ms cubic-bezier(0.22, 1, 0.36, 1),
    height 980ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 980ms cubic-bezier(0.22, 1, 0.36, 1);
}

.is-finished .cake-stack {
  left: 15.3333%;
  top: 35.0581%;
  width: 69.3333%;
  height: auto;
  transform: scale(1);
}

.finish-panel {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: none;
  align-items: end;
  justify-content: center;
  padding-bottom: 8%;
  pointer-events: none;
}

.finish-panel.is-visible {
  display: flex;
}

.restart-button {
  width: 29%;
  aspect-ratio: 430 / 116;
  height: auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 999px;
  color: white;
  background:
    linear-gradient(rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 42%),
    linear-gradient(#ff943c, #ef5b21);
  box-shadow:
    inset 0 -0.7cqw 0 rgba(143, 62, 22, 0.34),
    0 1.1cqw 1.8cqw rgba(150, 60, 20, 0.2);
  font-size: clamp(0.7rem, 2.2cqw, 1.22rem);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  text-decoration: none;
  pointer-events: auto;
}

.help-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 60;
  width: 68%;
  min-height: auto;
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 1.6cqw;
  padding: 4.8% 5.4% 5.2%;
  border: 0.55cqw solid rgba(244, 119, 52, 0.28);
  border-radius: 4.5cqw;
  color: #803d21;
  background:
    linear-gradient(rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0) 38%),
    #fff7dc;
  box-shadow:
    0 2.4cqw 0 rgba(169, 91, 39, 0.15),
    0 4cqw 7cqw rgba(104, 55, 24, 0.24);
  transform: translate(-50%, -50%);
}

.show-help .stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 55;
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(1.2px);
}

.show-help .help-panel {
  display: flex;
}

.help-title {
  color: #f47734;
  font-size: 4.1cqw;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  text-shadow: 0 0.28cqw 0 white;
}

.help-steps {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.15cqw;
  list-style: none;
}

.help-steps li {
  min-height: 6.6cqw;
  display: flex;
  align-items: center;
  padding: 1.45cqw 1.8cqw;
  border-radius: 2.2cqw;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 0 0 0.25cqw rgba(244, 119, 52, 0.12);
  font-size: 2.35cqw;
  font-weight: 850;
  line-height: 1.24;
}

.help-close {
  position: absolute;
  right: -2.8cqw;
  top: -2.8cqw;
  width: 7.2cqw;
  aspect-ratio: 1;
  height: auto;
  border-radius: 50%;
  color: white;
  background:
    linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 45%),
    #f47734;
  box-shadow: 0 0.9cqw 0 rgba(174, 80, 30, 0.24);
  font-size: 4.4cqw;
  font-weight: 950;
  line-height: 1;
}

.status {
  position: absolute;
  left: 2.6667%;
  bottom: 1.3498%;
  z-index: 80;
  display: none;
  color: rgba(90, 60, 40, 0.7);
  font-size: clamp(0.75rem, 1.85vw, 1.75rem);
}

.is-starting .status,
.camera-booting .status {
  display: block;
}

@keyframes caught-pop {
  from {
    opacity: 1;
    transform: translate3d(var(--caught-x), var(--caught-y), 0) rotate(0deg) scale(1);
  }

  to {
    opacity: 0;
    transform: translate3d(var(--caught-x), var(--caught-y), 0) rotate(18deg) scale(1.2);
  }
}

@keyframes score-pop {
  to {
    opacity: 0;
    transform: translateY(-120px) scale(1.12);
  }
}

@keyframes topping-land {
  from {
    opacity: 0;
    transform: translate(-50%, -62%) rotate(var(--rotate)) scale(calc(var(--scale) * 1.3));
  }
}
