@property --dms {
  syntax: "<integer>";
  inherits: false;
  initial-value: 0;
}
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);
}

.rt {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 440px;
}

.rt__hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rt__hud > p {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}

.rt__ico {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: #fff7e6;
}

.rt__label {
  font-weight: 700;
  font-size: clamp(9px, 2.4vw, 11px);
  line-height: 1.4;
  color: rgba(255, 247, 230, 0.72);
}

.rt__num {
  font-weight: 800;
  font-size: clamp(13px, 3.6vw, 17px);
  line-height: 1;
  color: #fff7e6;
  font-variant-numeric: tabular-nums;
}

.rt__panel {
  position: relative;
  overflow: hidden;
  height: clamp(104px, 52vh, 180px);
  border: 2px solid rgba(255, 247, 230, 0.16);
  border-radius: 16px;
  background: #231f28;
  transition: background-color 220ms ease-out;
  touch-action: manipulation;
  cursor: pointer;
}

.rt__panel:focus-visible {
  outline: 2px solid #fff7e6;
  outline-offset: 2px;
}

.rt.is-signal .rt__panel {
  background: #fff7e6;
}

.rt.is-penalty .rt__panel {
  background: #ffe0d8;
}

.rt__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  padding: 8px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.rt.is-idle .rt__face--wait,
.rt.is-armed .rt__face--wait,
.rt.is-signal .rt__face--go,
.rt.is-result .rt__face--result,
.rt.is-penalty .rt__face--penalty {
  opacity: 1;
}

.rt__waitTitle, .rt__goTitle, .rt__penTitle {
  margin: 0;
  font-weight: 800;
  line-height: 1.2;
  font-size: clamp(15px, 4.4vw, 21px);
}

.rt__waitSub, .rt__penSub {
  margin: 0;
  font-weight: 700;
  line-height: 1.4;
  font-size: clamp(10px, 2.6vw, 12px);
  color: rgba(255, 247, 230, 0.72);
}

.rt__face--wait, .rt__face--result {
  color: #fff7e6;
}

.rt__face--go {
  color: #17141a;
}

.rt__face--penalty {
  color: #17141a;
}

.rt__goIco {
  width: 22px;
  height: 22px;
  color: #17141a;
}

.rt__penIco {
  width: 22px;
  height: 22px;
  color: #c2361a;
}

.rt__ms {
  margin: 0;
  font-weight: 800;
  line-height: 1;
  font-size: clamp(30px, 9vw, 44px);
  font-variant-numeric: tabular-nums;
}

.rt__restart {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  background: #0a4fe8;
  color: #fff7e6;
  cursor: pointer;
  pointer-events: auto;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(10px, 2.6vw, 12px);
  line-height: 1.6;
  transition: transform 220ms cubic-bezier(0.2, 1.4, 0.4, 1);
}

.rt__restart .rt__ico {
  color: #fff7e6;
}

.rt__restart:hover {
  transform: translateY(-2px) scale(1.04);
}

.rt__restart:active {
  transform: translateY(0) scale(0.97);
}

.rt__restart:focus-visible {
  outline: 2px solid #fff7e6;
  outline-offset: 2px;
}

.rt__face {
  visibility: hidden;
}

.rt.is-idle .rt__face--wait,
.rt.is-armed .rt__face--wait,
.rt.is-signal .rt__face--go,
.rt.is-result .rt__face--result,
.rt.is-penalty .rt__face--penalty {
  visibility: visible;
}

.rt.is-demo .rt__face {
  visibility: visible;
}

.rt__grade {
  margin: 0;
  font-weight: 800;
  font-size: clamp(11px, 3vw, 14px);
  line-height: 1.4;
}

.rt__grade--s1 {
  color: #3ddc97;
}

.rt__grade--s2 {
  color: #3ddc97;
}

.rt__grade--s3 {
  color: #fff7e6;
}

.rt__grade--s4 {
  color: #ff7a5e;
}

.rt__hint {
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: clamp(9px, 2.4vw, 11px);
  line-height: 1.4;
  color: rgba(255, 247, 230, 0.72);
}

.rt.is-demo .rt__panel {
  animation-name: rtPanelCut;
  animation-duration: 2s;
  animation-timing-function: steps(1, end);
  animation-iteration-count: infinite;
}

@keyframes rtPanelCut {
  0% {
    background-color: #231f28;
  }
  32% {
    background-color: #fff7e6;
  }
  86% {
    background-color: #231f28;
  }
  100% {
    background-color: #231f28;
  }
}
.rt.is-demo .rt__face {
  animation-name: rtFaceCut;
  animation-duration: 2s;
  animation-timing-function: steps(1, end);
  animation-iteration-count: infinite;
}

.rt.is-demo .rt__face--go {
  animation-name: rtFaceGoCut;
}

.rt.is-demo .rt__face--result,
.rt.is-demo .rt__face--penalty {
  animation-name: none;
  opacity: 0;
}

@keyframes rtFaceCut {
  0% {
    opacity: 1;
  }
  32% {
    opacity: 0;
  }
  86% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}
@keyframes rtFaceGoCut {
  0% {
    opacity: 0;
  }
  32% {
    opacity: 1;
  }
  86% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
.rt__demoMs {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  color: #17141a;
  font-weight: 800;
  line-height: 1;
  font-size: clamp(30px, 9vw, 44px);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
  counter-reset: dms var(--dms);
}

.rt__demoMs::after {
  content: counter(dms) "ms";
}

.rt.is-demo .rt__demoMs {
  animation-name: rtFaceGoCut, rtCount;
  animation-duration: 2s, 2s;
  animation-timing-function: steps(1, end), linear;
  animation-iteration-count: infinite, infinite;
}

@keyframes rtCount {
  0%, 32% {
    --dms: 0;
  }
  84%, 100% {
    --dms: 300;
  }
}
.rt__penSub {
  color: rgba(23, 20, 26, 0.72);
}

.rt.is-demo .rt__face--go {
  animation-name: rtGoTitleCut;
}

@keyframes rtGoTitleCut {
  0%, 32% {
    opacity: 0;
  }
  35%, 49% {
    opacity: 1;
  }
  52%, 100% {
    opacity: 0;
  }
}
.rt.is-demo .rt__demoMs {
  animation-name: rtDemoMsShow, rtCount;
}

@keyframes rtDemoMsShow {
  0%, 51% {
    opacity: 0;
  }
  54%, 84% {
    opacity: 1;
  }
  87%, 100% {
    opacity: 0;
  }
}
@media (max-width: 340px) {
  .rt {
    gap: 4px;
  }
  .rt__panel {
    height: clamp(96px, 46vh, 140px);
  }
  .rt__ms {
    font-size: clamp(26px, 8vw, 34px);
  }
  .rt__demoMs {
    font-size: clamp(26px, 8vw, 34px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .rt__panel, .rt__restart {
    transition: none !important;
  }
  .rt.is-demo .rt__panel,
  .rt.is-demo .rt__face,
  .rt.is-demo .rt__demoMs {
    animation: none !important;
  }
  .rt.is-demo .rt__demoMs {
    opacity: 0 !important;
  }
}
