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

.stage {
  position: relative;
}

.ng {
  width: min(100%, 400px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.ng__title {
  font-weight: 800;
  font-size: clamp(10px, 2.8vw, 12px);
  line-height: 1.2;
  color: #17141a;
  letter-spacing: 0.01em;
}

.ng__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #17141a;
  color: #fff7e6;
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: clamp(9px, 2.4vw, 10px);
  line-height: 1;
}

.ng__num {
  display: inline-block;
  height: 12px;
  overflow: hidden;
}

.ng__digits {
  display: block;
  transform: translateY(0);
}

.ng__digits i {
  display: block;
  height: 12px;
  font-style: normal;
  font-weight: 800;
  font-size: 10px;
  line-height: 12px;
  white-space: nowrap;
}

.ng__canvas {
  position: relative;
  width: 100%;
  height: clamp(132px, 42vw, 196px);
  background-color: #ffffff;
  background-image: linear-gradient(to right, rgba(23, 20, 26, 0.1) 1px, transparent 1px), linear-gradient(to bottom, rgba(23, 20, 26, 0.1) 1px, transparent 1px);
  background-size: 24px 24px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
  touch-action: none;
  cursor: crosshair;
}

.ng__layer {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.ng__marquee {
  fill: rgba(47, 109, 246, 0.16);
  stroke: #2f6df6;
  stroke-width: 2;
  stroke-dasharray: 6 4;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: 0 0;
}

.ng__marquee.is-on {
  opacity: 1;
}

.ng__node {
  position: absolute;
  width: 24%;
  height: 22%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff7e6;
  border: 1px solid rgba(23, 20, 26, 0.18);
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
}

.ng__node--a {
  left: 20%;
  top: 16%;
}

.ng__node--b {
  left: 56%;
  top: 20%;
}

.ng__node--c {
  left: 24%;
  top: 60%;
}

.ng__node--d {
  left: 70%;
  top: 62%;
}

.ng__name {
  font-weight: 700;
  font-size: clamp(8px, 2.4vw, 11px);
  line-height: 1.1;
  color: #17141a;
}

.ng__port {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(23, 20, 26, 0.45);
  transform: translateY(-50%);
}

.ng__port--in {
  left: -5px;
}

.ng__port--out {
  right: -5px;
}

.ng__ring {
  position: absolute;
  inset: -4px;
  border: 2px solid #2f6df6;
  border-radius: 16px;
  opacity: 0;
  pointer-events: none;
}

.ng__node.is-picked .ng__ring {
  opacity: 1;
}

.ng__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ng.is-demo .ng__marquee {
  animation-name: ngGrow, ngFade;
  animation-duration: 2s, 2s;
  animation-timing-function: linear, ease-out;
  animation-iteration-count: infinite, infinite;
  animation-fill-mode: backwards, backwards;
}

@keyframes ngGrow {
  0%, 8% {
    transform: scale(0.02, 0.02);
  }
  64%, 100% {
    transform: scale(1, 1);
  }
}
@keyframes ngFade {
  0%, 7% {
    opacity: 0;
  }
  9%, 82% {
    opacity: 1;
  }
  90%, 100% {
    opacity: 0;
  }
}
.ng.is-demo .ng__digits {
  animation-name: ngCount;
  animation-duration: 2s;
  animation-timing-function: steps(1, end);
  animation-iteration-count: infinite;
  animation-fill-mode: backwards;
}

@keyframes ngCount {
  0% {
    transform: translateY(0);
  }
  14.5% {
    transform: translateY(-12px);
  }
  42.5% {
    transform: translateY(-24px);
  }
  53.5% {
    transform: translateY(-36px);
  }
  100% {
    transform: translateY(-36px);
  }
}
.ng.is-demo .ng__ring {
  animation-duration: 2s;
  animation-timing-function: steps(1, end);
  animation-iteration-count: infinite;
  animation-fill-mode: backwards;
}

.ng.is-demo .ng__node--a .ng__ring {
  animation-name: ngRingA;
}

.ng.is-demo .ng__node--c .ng__ring {
  animation-name: ngRingC;
}

.ng.is-demo .ng__node--b .ng__ring {
  animation-name: ngRingB;
}

@keyframes ngRingA {
  0% {
    opacity: 0;
  }
  14.5% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}
@keyframes ngRingC {
  0% {
    opacity: 0;
  }
  42.5% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}
@keyframes ngRingB {
  0% {
    opacity: 0;
  }
  53.5% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}
@media (max-width: 340px), (max-height: 220px) {
  .ng {
    gap: 4px;
  }
  .ng__badge {
    padding: 0 8px;
  }
  .ng__title {
    font-size: 9px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ng.is-demo .ng__marquee,
  .ng.is-demo .ng__digits,
  .ng.is-demo .ng__ring {
    animation: none !important;
  }
  .ng.is-demo .ng__marquee {
    opacity: 1 !important;
    transform: scale(1, 1) !important;
  }
  .ng.is-demo .ng__ring {
    opacity: 1 !important;
  }
  .ng.is-demo .ng__node--d .ng__ring {
    opacity: 0 !important;
  }
  .ng.is-demo .ng__digits {
    transform: translateY(-36px) !important;
  }
}
