@property --t-sw {
  syntax: "<integer>";
  inherits: true;
  initial-value: 3;
}
@property --t-fill {
  syntax: "<integer>";
  inherits: true;
  initial-value: 100;
}
html, body {
  margin: 0;
  overflow: hidden;
}

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

.gen {
  min-width: 0;
  --t-sw: 3;
  --t-fill: 100;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
  width: min(100%, 400px);
  padding: 12px;
  border: 1px solid rgba(23, 20, 26, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
}

.gen__top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gen__preview {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 132px;
  height: 84px;
  background: #0a4fe8;
  border-radius: 8px;
}

.gen__word {
  color: rgba(255, 247, 230, calc(var(--t-fill) * 1%));
  -webkit-text-stroke: calc(var(--t-sw) * 1px) #17141a;
  paint-order: stroke fill;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
  font-weight: 900;
  font-size: 44px;
  line-height: 1;
  letter-spacing: 0.04em;
}

.gen__grid {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.gen__row {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.gen__lab {
  flex: 0 0 auto;
  width: 40px;
  color: #17141a;
  font-weight: 700;
  font-size: 10px;
  line-height: 1.4;
}

.gen__slot {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  align-items: center;
  height: 16px;
}

.gen__slot::before {
  content: "";
  grid-area: 1/1;
  height: 4px;
  border-radius: 999px;
  background: rgba(23, 20, 26, 0.18);
}

.gen__rng {
  grid-area: 1/1;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.gen__rng::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.gen__rng::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.gen__rng:focus-visible {
  outline: 2px solid #17141a;
  outline-offset: 2px;
  border-radius: 999px;
}

.gen__thumb {
  position: absolute;
  top: 50%;
  left: calc(var(--pct) * 1%);
  width: 12px;
  height: 12px;
  margin-top: -6px;
  margin-left: -6px;
  border-radius: 50%;
  background: #17141a;
  pointer-events: none;
}

.gen__row:nth-child(1) .gen__thumb {
  --pct: calc(var(--t-sw) / 8 * 100);
}

.gen__row:nth-child(2) .gen__thumb {
  --pct: var(--t-fill);
}

.gen__out {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.gen__code {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  background: #17141a;
  color: #fff7e6;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
  font-weight: 500;
  font-size: 10px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
}

.gen__prop {
  color: #5b8cf8;
}

.gen__v {
  font-weight: 700;
}

.gen__v--sw::after {
  counter-reset: v var(--t-sw);
  content: counter(v);
}

.gen__v--fill::after {
  counter-reset: v var(--t-fill);
  content: counter(v);
}

.gen__copy {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: #0a4fe8;
  color: #fff7e6;
  font-family: inherit;
  font-weight: 700;
  font-size: 11px;
  line-height: 1.4;
  cursor: pointer;
}

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

@keyframes tSw {
  0%, 100% {
    --t-sw: 3;
  }
  40% {
    --t-sw: 7;
  }
  80% {
    --t-sw: 1;
  }
}
@keyframes tFill {
  0%, 100% {
    --t-fill: 100;
  }
  50% {
    --t-fill: 0;
  }
}
.gen.is-demo {
  animation-name: tSw, tFill;
  animation-duration: 2s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  animation-iteration-count: infinite;
}

@media (prefers-reduced-motion: reduce) {
  .gen.is-demo {
    animation: none !important;
  }
}
@media (max-width: 340px) {
  .gen {
    gap: 8px;
    padding: 8px;
  }
  .gen__top {
    gap: 8px;
  }
  .gen__word {
    font-size: 36px;
  }
  .gen__code {
    font-size: 9px;
  }
}
