html, body {
  margin: 0;
  overflow: hidden;
}

.stage {
  box-sizing: border-box;
  min-height: 100vh;
  display: grid;
  place-items: center;
  margin: 0;
  background: #ff4d1f;
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
  padding: clamp(8px, 4vw, 24px);
}

.bn {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.bn__hit {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bn__hit:focus-visible {
  outline: 2px solid #17141a;
  outline-offset: 4px;
  border-radius: 16px;
}

.bn__scene {
  position: relative;
  display: block;
  box-sizing: border-box;
  width: clamp(140px, 44vw, 196px);
  height: clamp(120px, 38vw, 168px);
}

.bn__shadow {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 58%;
  height: 12px;
  background: rgba(23, 20, 26, 0.2);
  border-radius: 50%;
  transform: translateX(-50%);
}

.bn__bean {
  --tilt: 4deg;
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 52%;
  aspect-ratio: 1/1.18;
  background: #b9a0ff;
  border: 3px solid #17141a;
  border-radius: 50% 50% 46% 46%/42% 42% 58% 58%;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
}

.bn__arm {
  position: absolute;
  top: 46%;
  width: 26%;
  height: 10%;
  background: #b9a0ff;
  border: 3px solid #17141a;
  border-radius: 999px;
}

.bn__arm--l {
  left: -12%;
  transform: rotate(38deg);
}

.bn__arm--r {
  right: -12%;
  transform: rotate(-38deg);
}

.bn__eye {
  position: absolute;
  top: 30%;
  width: 18%;
  height: 10%;
  border-top: 4px solid #17141a;
  border-radius: 50%;
}

.bn__eye--l {
  left: 22%;
}

.bn__eye--r {
  right: 22%;
}

.bn__mouth {
  position: absolute;
  top: 46%;
  left: 50%;
  width: 30%;
  aspect-ratio: 1/0.8;
  background: #17141a;
  border-radius: 50%;
  transform: translateX(-50%);
  overflow: hidden;
}

.bn__tongue {
  position: absolute;
  bottom: -22%;
  left: 50%;
  width: 74%;
  aspect-ratio: 1/0.6;
  background: #ff9ebb;
  border-radius: 50%;
  transform: translateX(-50%);
}

.bn__level {
  margin: 0;
  padding: 0 12px;
  background: #17141a;
  color: #ffd23f;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  line-height: 20px;
}

.bn__bean {
  animation-name: bnTilt;
  animation-duration: 2s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

.bn__mouth {
  animation-name: bnMouth;
  animation-duration: 2s;
  animation-timing-function: cubic-bezier(0.2, 1.4, 0.4, 1);
  animation-iteration-count: infinite;
}

@keyframes bnTilt {
  0%, 100% {
    transform: translateX(-50%) rotate(calc(var(--tilt) * -1));
  }
  50% {
    transform: translateX(-50%) rotate(var(--tilt));
  }
}
@keyframes bnMouth {
  0%, 100% {
    transform: translateX(-50%) scale(1, 0.8);
  }
  50% {
    transform: translateX(-50%) scale(1, 1.2);
  }
}
.bn[data-level="1"] .bn__bean {
  --tilt: 8deg;
}

.bn[data-level="2"] .bn__bean {
  --tilt: 13deg;
}

.bn[data-level="3"] .bn__bean {
  --tilt: 4deg;
  animation: bnFold 700ms cubic-bezier(0.2, 1.4, 0.4, 1) 1 forwards;
}

@keyframes bnFold {
  0% {
    transform: translateX(-50%) rotate(0deg) scale(1, 1);
  }
  40% {
    transform: translateX(-50%) rotate(16deg) scale(1.06, 0.82);
  }
  70% {
    transform: translateX(-50%) rotate(20deg) scale(1.1, 0.68);
  }
  100% {
    transform: translateX(-50%) rotate(19deg) scale(1.08, 0.7);
  }
}
.bn.is-demo .bn__bean {
  animation-name: bnLaughShow;
  animation-duration: 2s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

@keyframes bnLaughShow {
  0%, 8% {
    transform: translateX(-50%) rotate(-3deg) scaleX(1);
  }
  16% {
    transform: translateX(-50%) rotate(3deg) scaleX(1.04);
  }
  24% {
    transform: translateX(-50%) rotate(-3deg) scaleX(1);
  }
  32% {
    transform: translateX(-50%) rotate(5deg) scaleX(1.06);
  }
  40% {
    transform: translateX(-50%) rotate(-5deg) scaleX(1);
  }
  48% {
    transform: translateX(-50%) rotate(5deg) scaleX(1.06);
  }
  56% {
    transform: translateX(-50%) rotate(-5deg) scaleX(1);
  }
  64% {
    transform: translateX(-50%) rotate(15deg) scale(1.06, 0.8);
  }
  72%, 84% {
    transform: translateX(-50%) rotate(19deg) scale(1.08, 0.7);
  }
  90%, 100% {
    transform: translateX(-50%) rotate(0deg) scale(1, 1);
  }
}
@media (max-width: 340px) {
  .bn {
    gap: 4px;
  }
  .bn__level {
    font-size: 11px;
    line-height: 16px;
  }
  .bn__bean {
    border-width: 2px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .bn__bean,
  .bn__mouth,
  .bn.is-demo .bn__bean {
    animation: none !important;
  }
}
