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

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

.bp {
  position: relative;
  width: min(92vw, 160vh - 12.8vw);
  aspect-ratio: 480/300;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
  background: #17141a;
}

.fd {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(#cdbfff, #fbe3ec);
}

.fd__floor {
  position: absolute;
  left: 0;
  bottom: 0;
  width: calc(100% + 5 * 128px);
  height: 34%;
  background: repeating-linear-gradient(90deg, #a8e0c8 0 64px, #84cbae 64px 128px);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.5);
}

.fd__shadow {
  position: absolute;
  left: 50%;
  bottom: calc(22% - 8px);
  width: 80px;
  height: 16px;
  margin-left: -40px;
  border-radius: 50%;
  background: rgba(30, 60, 60, 0.5);
  opacity: 0.5;
}

.fd__hop {
  position: absolute;
  left: 50%;
  bottom: 22%;
  width: 80px;
  height: 80px;
  margin-left: -40px;
}

.fd__squeeze {
  width: 100%;
  height: 100%;
}

.fd__die {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: #fff1f5;
  box-shadow: inset 0 -6px 0 rgba(200, 120, 160, 0.28), inset 0 0 0 3px #f2b4c8;
}

.fd__face {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 12px;
  opacity: 0;
}

.pip {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #4b3a63;
  place-self: center;
}

.r1 {
  grid-row: 1;
}

.r2 {
  grid-row: 2;
}

.r3 {
  grid-row: 3;
}

.c1 {
  grid-column: 1;
}

.c2 {
  grid-column: 2;
}

.c3 {
  grid-column: 3;
}

[data-face="1"] .fd__face--1,
[data-face="2"] .fd__face--2,
[data-face="3"] .fd__face--3,
[data-face="4"] .fd__face--4,
[data-face="5"] .fd__face--5,
[data-face="6"] .fd__face--6 {
  opacity: 1;
}

@keyframes fd-floor {
  0% {
    transform: translateX(0);
    animation-timing-function: cubic-bezier(0.45, 0, 0.2, 1);
  }
  20% {
    transform: translateX(-128px);
    animation-timing-function: cubic-bezier(0.45, 0, 0.2, 1);
  }
  40% {
    transform: translateX(-256px);
    animation-timing-function: cubic-bezier(0.45, 0, 0.2, 1);
  }
  60% {
    transform: translateX(-384px);
    animation-timing-function: cubic-bezier(0.45, 0, 0.2, 1);
  }
  80% {
    transform: translateX(-512px);
    animation-timing-function: cubic-bezier(0.45, 0, 0.2, 1);
  }
  100% {
    transform: translateX(-640px);
  }
}
@keyframes fd-hop {
  0% {
    transform: translateY(0);
    animation-timing-function: ease-out;
  }
  50% {
    transform: translateY(-28px);
    animation-timing-function: ease-in;
  }
  100% {
    transform: translateY(0);
  }
}
@keyframes fd-squeeze {
  0% {
    transform: scaleX(1);
    animation-timing-function: ease-in;
  }
  50% {
    transform: scaleX(0.18);
    animation-timing-function: ease-out;
  }
  100% {
    transform: scaleX(1);
  }
}
@keyframes fd-shadow {
  0% {
    transform: scale(1);
    opacity: 0.5;
    animation-timing-function: ease-out;
  }
  50% {
    transform: scale(0.6);
    opacity: 0.25;
    animation-timing-function: ease-in;
  }
  100% {
    transform: scale(1);
    opacity: 0.5;
  }
}
@keyframes fd-face-1 {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  70% {
    opacity: 0;
  }
}
@keyframes fd-face-2 {
  0% {
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  30% {
    opacity: 0;
  }
}
@keyframes fd-face-4 {
  0% {
    opacity: 0;
  }
  70% {
    opacity: 1;
  }
  90% {
    opacity: 0;
  }
}
@keyframes fd-face-5 {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}
@keyframes fd-face-6 {
  0% {
    opacity: 1;
  }
  10% {
    opacity: 0;
  }
  90% {
    opacity: 1;
  }
}
.is-demo .fd__floor {
  animation: fd-floor 2s linear infinite;
}

.is-demo .fd__hop {
  animation: fd-hop 0.4s linear infinite;
}

.is-demo .fd__squeeze {
  animation: fd-squeeze 0.4s linear infinite;
}

.is-demo .fd__shadow {
  animation: fd-shadow 0.4s linear infinite;
}

.is-demo .fd__face--2 {
  animation: fd-face-2 2s steps(1, end) infinite;
}

.is-demo .fd__face--5 {
  animation: fd-face-5 2s steps(1, end) infinite;
}

.is-demo .fd__face--1 {
  animation: fd-face-1 2s steps(1, end) infinite;
}

.is-demo .fd__face--4 {
  animation: fd-face-4 2s steps(1, end) infinite;
}

.is-demo .fd__face--6 {
  animation: fd-face-6 2s steps(1, end) infinite;
}

.bp__status {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #17141a;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.4;
}

.bp__status b {
  min-width: 1ch;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bp__btn {
  position: absolute;
  right: 12px;
  top: 12px;
  min-height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: #fff7e6;
  color: #17141a;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
  transition: transform 140ms ease-out;
}

.bp__btn:hover {
  transform: translateY(-1px);
}

.bp__btn:active {
  transform: translateY(1px);
}

.bp__btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
}

.bp__caption {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: 80%;
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #17141a;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
}

@media (max-width: 340px) {
  .bp__caption {
    font-size: 10px;
    padding: 4px 8px;
  }
  .bp__status {
    font-size: 10px;
    padding: 4px 8px;
  }
  .bp__btn {
    font-size: 11px;
    padding: 0 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .bp {
    cursor: default;
  }
  .bp__btn {
    transition: none;
  }
  .fd__floor, .fd__hop, .fd__squeeze, .fd__shadow, .fd__face {
    animation: none !important;
  }
}
