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

.ng {
  width: min(100%, 400px);
}

.ng__canvas {
  position: relative;
  width: 100%;
  height: clamp(140px, 48vw, 224px);
  overflow: hidden;
  border-radius: 16px;
  box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
  background-color: #fff7e6;
  background-image: linear-gradient(to right, rgba(23, 20, 26, 0.16) 1px, transparent 1px), linear-gradient(to bottom, rgba(23, 20, 26, 0.16) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
  touch-action: none;
  cursor: grab;
}

.ng__world {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  transform: translate(0, 0) scale(1);
}

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

.ng__wire {
  fill: none;
  stroke: #2f6df6;
  stroke-width: 2;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

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

.ng__node--a {
  left: 22%;
  top: 26%;
}

.ng__node--b {
  left: 46%;
  top: 50%;
}

.ng__node--c {
  left: 70%;
  top: 20%;
}

.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 #2f6df6;
  transform: translateY(-50%);
}

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

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

.ng__chip {
  position: absolute;
  left: 8px;
  top: 8px;
  background: #17141a;
  color: #fff7e6;
  border-radius: 999px;
  padding: 4px 8px;
  font-weight: 700;
  font-size: 9px;
  line-height: 1.2;
}

.ng__tools {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ng__zoom {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 16px;
  background: #17141a;
  border-radius: 4px;
}

.ng__zoomNow, .ng__zoomAlt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 9px;
  line-height: 1;
  color: #fff7e6;
}

.ng__zoomAlt {
  opacity: 0;
}

.ng__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: #17141a;
  color: #fff7e6;
  cursor: pointer;
  transition: transform 140ms ease-out;
}

.ng__btn:active {
  transform: scale(0.92);
}

.ng__ico {
  width: 14px;
  height: 14px;
}

.ng.is-demo .ng__canvas {
  animation-name: ngGridPan;
  animation-duration: 2s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-fill-mode: backwards;
}

.ng.is-demo .ng__world {
  animation-name: ngWorldPan;
  animation-duration: 2s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-fill-mode: backwards;
}

@keyframes ngGridPan {
  0% {
    background-position: 0 0;
  }
  40%, 80% {
    background-position: -36px -20px;
  }
  88%, 100% {
    background-position: 0 0;
  }
}
@keyframes ngWorldPan {
  0% {
    transform: translate(0, 0) scale(1);
  }
  40% {
    transform: translate(-36px, -20px) scale(1);
  }
  50%, 80% {
    transform: translate(-36px, -20px) scale(1.2);
  }
  88%, 100% {
    transform: translate(0, 0) scale(1);
  }
}
.ng.is-demo .ng__zoomNow, .ng.is-demo .ng__zoomAlt {
  animation-duration: 2s;
  animation-timing-function: steps(1, end);
  animation-iteration-count: infinite;
  animation-fill-mode: backwards;
}

.ng.is-demo .ng__zoomNow {
  animation-name: ngLabelBase;
}

.ng.is-demo .ng__zoomAlt {
  animation-name: ngLabelZoom;
}

@keyframes ngLabelBase {
  0% {
    opacity: 1;
  }
  45.5% {
    opacity: 0;
  }
  83.5% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}
@keyframes ngLabelZoom {
  0% {
    opacity: 0;
  }
  45.5% {
    opacity: 1;
  }
  83.5% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
@media (max-width: 340px), (max-height: 220px) {
  .ng__chip {
    font-size: 8px;
    padding: 0 4px;
  }
  .ng__btn {
    width: 18px;
    height: 18px;
  }
  .ng__ico {
    width: 12px;
    height: 12px;
  }
  .ng__zoom {
    width: 30px;
    height: 14px;
  }
  .ng__zoomNow, .ng__zoomAlt {
    font-size: 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ng.is-demo .ng__canvas,
  .ng.is-demo .ng__world,
  .ng.is-demo .ng__zoomNow,
  .ng.is-demo .ng__zoomAlt {
    animation: none !important;
  }
  .ng.is-demo .ng__world {
    transform: translate(0, 0) scale(1) !important;
  }
  .ng.is-demo .ng__canvas {
    background-position: 0 0 !important;
  }
  .ng.is-demo .ng__zoomNow {
    opacity: 1 !important;
  }
  .ng.is-demo .ng__zoomAlt {
    opacity: 0 !important;
  }
  .ng__btn {
    transition: none !important;
  }
}
