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);
}

.pg {
  box-sizing: border-box;
  width: min(300px, 86vw);
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}

.pg__field {
  position: relative;
}

.pg__input {
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff7e6;
  font-family: inherit;
  font-size: 14px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.pg__input::placeholder {
  color: rgba(255, 255, 255, 0.38);
  font-weight: 600;
  letter-spacing: normal;
}

.pg__input:focus-visible {
  outline: 2px solid #2f6df6;
  outline-offset: 2px;
}

.pg.is-demo .pg__input::placeholder {
  color: transparent;
}

.pg__ghost {
  position: absolute;
  left: 14px;
  top: 0;
  color: #fff7e6;
  font-size: 14px;
  line-height: 40px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}

.pg__gauge {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 12px;
}

.pg__cell {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.pg__cell::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c2361a;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), background 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pg[data-score="1"] .pg__cell[data-cell="1"]::after,
.pg[data-score="2"] .pg__cell[data-cell="1"]::after,
.pg[data-score="2"] .pg__cell[data-cell="2"]::after,
.pg[data-score="3"] .pg__cell[data-cell="1"]::after,
.pg[data-score="3"] .pg__cell[data-cell="2"]::after,
.pg[data-score="3"] .pg__cell[data-cell="3"]::after,
.pg[data-score="4"] .pg__cell::after {
  transform: scaleX(1);
}

.pg[data-score="2"] .pg__cell::after,
.pg[data-score="3"] .pg__cell::after {
  background: #cab493;
}

.pg[data-score="4"] .pg__cell::after {
  background: #4cd4a6;
}

.pg__out {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 16px;
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
}

.pg__words, .pg__nums {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  height: 16px;
}

.pg__words {
  width: 28px;
}

.pg__nums {
  width: 32px;
  color: rgba(255, 255, 255, 0.52);
}

.pg__w, .pg__n {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  opacity: 0;
}

.pg__w[data-w=low] {
  color: #c2361a;
}

.pg__w[data-w=mid] {
  color: #cab493;
}

.pg__w[data-w=high] {
  color: #4cd4a6;
}

.pg[data-score="0"] .pg__w[data-w=low],
.pg[data-score="1"] .pg__w[data-w=low],
.pg[data-score="2"] .pg__w[data-w=mid],
.pg[data-score="3"] .pg__w[data-w=mid],
.pg[data-score="4"] .pg__w[data-w=high] {
  opacity: 1;
}

.pg[data-score="0"] .pg__n[data-n="0"],
.pg[data-score="1"] .pg__n[data-n="1"],
.pg[data-score="2"] .pg__n[data-n="2"],
.pg[data-score="3"] .pg__n[data-n="3"],
.pg[data-score="4"] .pg__n[data-n="4"] {
  opacity: 1;
}

.pg__say {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.pg.is-demo .pg__ghost {
  opacity: 1;
  animation-name: pg-type;
  animation-duration: 2s;
  animation-timing-function: steps(1, end);
  animation-iteration-count: infinite;
}

.pg.is-demo .pg__cell::after {
  transition: none;
  animation-duration: 2s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  animation-iteration-count: infinite;
}

.pg.is-demo .pg__cell[data-cell="1"]::after {
  animation-name: pg-c1;
}

.pg.is-demo .pg__cell[data-cell="2"]::after {
  animation-name: pg-c2;
}

.pg.is-demo .pg__cell[data-cell="3"]::after {
  animation-name: pg-c3;
}

.pg.is-demo .pg__cell[data-cell="4"]::after {
  animation-name: pg-c4;
}

.pg.is-demo .pg__w,
.pg.is-demo .pg__n {
  animation-duration: 2s;
  animation-timing-function: steps(1, end);
  animation-iteration-count: infinite;
}

.pg.is-demo .pg__w[data-w=low] {
  animation-name: pg-w-low;
}

.pg.is-demo .pg__w[data-w=mid] {
  animation-name: pg-w-mid;
}

.pg.is-demo .pg__w[data-w=high] {
  animation-name: pg-w-high;
}

.pg.is-demo .pg__n[data-n="1"] {
  animation-name: pg-n1;
}

.pg.is-demo .pg__n[data-n="2"] {
  animation-name: pg-n2;
}

.pg.is-demo .pg__n[data-n="3"] {
  animation-name: pg-n3;
}

.pg.is-demo .pg__n[data-n="4"] {
  animation-name: pg-n4;
}

@keyframes pg-type {
  0% {
    clip-path: inset(0 64% 0 0);
  }
  24% {
    clip-path: inset(0 46% 0 0);
  }
  42% {
    clip-path: inset(0 22% 0 0);
  }
  60% {
    clip-path: inset(0 0 0 0);
  }
  88% {
    clip-path: inset(0 64% 0 0);
  }
  100% {
    clip-path: inset(0 64% 0 0);
  }
}
@keyframes pg-c1 {
  0% {
    transform: scaleX(1);
    background: #c2361a;
  }
  23.4% {
    transform: scaleX(1);
    background: #c2361a;
  }
  24% {
    transform: scaleX(1);
    background: #cab493;
  }
  59.4% {
    transform: scaleX(1);
    background: #cab493;
  }
  60% {
    transform: scaleX(1);
    background: #4cd4a6;
  }
  84.4% {
    transform: scaleX(1);
    background: #4cd4a6;
  }
  85% {
    transform: scaleX(1);
    background: #c2361a;
  }
  100% {
    transform: scaleX(1);
    background: #c2361a;
  }
}
@keyframes pg-c2 {
  0% {
    transform: scaleX(0);
    background: #cab493;
  }
  20% {
    transform: scaleX(0);
    background: #cab493;
  }
  24% {
    transform: scaleX(1);
    background: #cab493;
  }
  30% {
    transform: scaleX(1);
    background: #cab493;
  }
  59.4% {
    transform: scaleX(1);
    background: #cab493;
  }
  60% {
    transform: scaleX(1);
    background: #4cd4a6;
  }
  83% {
    transform: scaleX(1);
    background: #4cd4a6;
  }
  84% {
    transform: scaleX(0);
    background: #4cd4a6;
  }
  100% {
    transform: scaleX(0);
    background: #4cd4a6;
  }
}
@keyframes pg-c3 {
  0% {
    transform: scaleX(0);
    background: #cab493;
  }
  38% {
    transform: scaleX(0);
    background: #cab493;
  }
  42% {
    transform: scaleX(1);
    background: #cab493;
  }
  59.4% {
    transform: scaleX(1);
    background: #cab493;
  }
  60% {
    transform: scaleX(1);
    background: #4cd4a6;
  }
  79% {
    transform: scaleX(1);
    background: #4cd4a6;
  }
  80% {
    transform: scaleX(0);
    background: #4cd4a6;
  }
  100% {
    transform: scaleX(0);
    background: #4cd4a6;
  }
}
@keyframes pg-c4 {
  0% {
    transform: scaleX(0);
    background: #4cd4a6;
  }
  56% {
    transform: scaleX(0);
    background: #4cd4a6;
  }
  60% {
    transform: scaleX(1);
    background: #4cd4a6;
  }
  75% {
    transform: scaleX(1);
    background: #4cd4a6;
  }
  76% {
    transform: scaleX(0);
    background: #4cd4a6;
  }
  100% {
    transform: scaleX(0);
    background: #4cd4a6;
  }
}
@keyframes pg-w-low {
  0% {
    opacity: 1;
  }
  24% {
    opacity: 0;
  }
  85% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}
@keyframes pg-w-mid {
  0% {
    opacity: 0;
  }
  24% {
    opacity: 1;
  }
  60% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
@keyframes pg-w-high {
  0% {
    opacity: 0;
  }
  60% {
    opacity: 1;
  }
  85% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
@keyframes pg-n1 {
  0% {
    opacity: 1;
  }
  24% {
    opacity: 0;
  }
  85% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}
@keyframes pg-n2 {
  0% {
    opacity: 0;
  }
  24% {
    opacity: 1;
  }
  42% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
@keyframes pg-n3 {
  0% {
    opacity: 0;
  }
  42% {
    opacity: 1;
  }
  60% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
@keyframes pg-n4 {
  0% {
    opacity: 0;
  }
  60% {
    opacity: 1;
  }
  85% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
@media (max-width: 360px) {
  .pg__input {
    height: 36px;
    line-height: 32px;
  }
  .pg__ghost {
    line-height: 36px;
  }
  .pg__gauge {
    margin-top: 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .pg.is-demo .pg__ghost,
  .pg.is-demo .pg__cell::after,
  .pg.is-demo .pg__w,
  .pg.is-demo .pg__n {
    animation: none !important;
  }
  .pg.is-demo .pg__ghost {
    opacity: 1;
    clip-path: inset(0 0 0 0);
  }
  .pg.is-demo .pg__cell::after {
    transform: scaleX(1);
    background: #4cd4a6;
  }
  .pg.is-demo .pg__w[data-w=high],
  .pg.is-demo .pg__n[data-n="4"] {
    opacity: 1;
  }
  .pg__cell::after {
    transition: none;
  }
}
