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

.sg {
  box-sizing: border-box;
  display: grid;
  gap: 12px;
  width: min(320px, 88vw);
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}

.sg__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
}

.sg__slot {
  position: relative;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background-color: #fff7e6;
  color: #17141a;
  font-family: inherit;
  font-size: clamp(11px, 3.2vw, 13px);
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
}

.sg__slot:focus-visible {
  outline: 3px solid #17141a;
  outline-offset: 2px;
}

.sg__slot[disabled] {
  background-color: rgba(255, 247, 230, 0.48);
  background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgba(23, 20, 26, 0.18) 4px 8px);
  color: #17141a;
  cursor: not-allowed;
}

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

.sg:not(.is-demo) .sg__slot[aria-pressed=true] {
  background-color: #17141a;
  color: #fff7e6;
}

.sg__out {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.sg__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-sizing: border-box;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background-color: #fff7e6;
  color: #ff4d1f;
  font-size: 11px;
  line-height: 1;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
}

.sg__badge svg {
  display: block;
}

.sg:not(.is-demo).is-picked .sg__badge {
  opacity: 1;
}

.sg:not(.is-demo):not(.is-picked) .sg__badge {
  display: none;
}

.sg__box {
  position: relative;
  display: block;
  width: 8.6em;
  height: 20px;
}

.sg__txt {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  text-align: center;
  font-size: clamp(11px, 3.2vw, 13px);
  line-height: 20px;
  font-weight: 700;
  color: #fff7e6;
  white-space: nowrap;
  opacity: 0;
}

.sg__txt[data-live] {
  opacity: 1;
}

.sg.is-demo .sg__slot:not([data-pick]) {
  animation-name: sg-rise;
  animation-duration: 2s;
  animation-timing-function: cubic-bezier(0.2, 1.4, 0.4, 1);
  animation-iteration-count: infinite;
  animation-delay: calc(var(--i) * 0.07s);
  animation-fill-mode: backwards;
}

@keyframes sg-rise {
  0% {
    transform: translateY(0);
  }
  5% {
    transform: translateY(-5px);
  }
  11% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(0);
  }
}
.sg.is-demo .sg__slot[data-pick] {
  animation-name: sg-pick, sg-pop;
  animation-duration: 2s, 2s;
  animation-timing-function: steps(1, end), cubic-bezier(0.2, 1.4, 0.4, 1);
  animation-iteration-count: infinite, infinite;
}

@keyframes sg-pick {
  0% {
    background-color: #fff7e6;
    color: #17141a;
  }
  40% {
    background-color: #17141a;
    color: #fff7e6;
  }
  86% {
    background-color: #fff7e6;
    color: #17141a;
  }
  100% {
    background-color: #fff7e6;
    color: #17141a;
  }
}
@keyframes sg-pop {
  0% {
    transform: scale(1);
  }
  38% {
    transform: scale(1);
  }
  42% {
    transform: scale(0.93);
  }
  50% {
    transform: scale(1.04);
  }
  58% {
    transform: scale(1);
  }
  100% {
    transform: scale(1);
  }
}
.sg.is-demo .sg__badge,
.sg.is-demo .sg__txt {
  animation-duration: 2s;
  animation-timing-function: steps(1, end);
  animation-iteration-count: infinite;
}

.sg.is-demo .sg__badge {
  animation-name: sg-badge;
}

.sg.is-demo .sg__txt[data-live] {
  animation-name: sg-t1;
}

.sg.is-demo .sg__txt[data-v="2"] {
  animation-name: sg-t2;
}

@keyframes sg-badge {
  0% {
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  78% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
@keyframes sg-t1 {
  0% {
    opacity: 1;
  }
  40% {
    opacity: 0;
  }
  82% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}
@keyframes sg-t2 {
  0% {
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  82% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
@media (max-width: 340px) {
  .sg {
    gap: 8px;
  }
  .sg__grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }
  .sg__slot {
    height: 28px;
  }
  .sg__badge {
    height: 18px;
    padding: 0 4px;
  }
  .sg__box {
    height: 18px;
  }
  .sg__txt {
    line-height: 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .sg.is-demo .sg__slot,
  .sg.is-demo .sg__badge,
  .sg.is-demo .sg__txt {
    animation: none !important;
  }
  .sg.is-demo .sg__txt[data-live] {
    opacity: 1;
  }
}
