:root {
  --fondo: #08090b;
  --carta: #111317;
  --carta-alta: #15181d;
  --linea: rgba(255, 255, 255, 0.08);
  --testo: #eef0f3;
  --tenue: #8a909a;
  --spento: #4b5059;
  --accento: #6ff2c4;
  --filo: rgba(255, 255, 255, 0.13);
  --punti: rgba(255, 255, 255, 0.07);
  --punti-luce: rgba(111, 242, 196, 0.42);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  display: grid;
  place-items: center;
  --mx: 50%;
  --my: 50%;
}

/* the dotted canvas, and a second, brighter one revealed only around the pointer */
.grid {
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, var(--punti) 1px, transparent 1.4px);
  background-size: 22px 22px;
  pointer-events: none;
}
.grid--lit {
  background-image: radial-gradient(circle at 1px 1px, var(--punti-luce) 1px, transparent 1.5px);
  -webkit-mask-image: radial-gradient(180px circle at var(--mx) var(--my), #000 0%, transparent 70%);
  mask-image: radial-gradient(180px circle at var(--mx) var(--my), #000 0%, transparent 70%);
  opacity: 0.55;
}

.frame { position: relative; }
.board {
  position: absolute; left: 0; top: 0;
  transform-origin: 0 0;
}

/* toolbar */
.bar {
  position: absolute; left: 0; right: 0; top: 0;
  height: 46px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 0 6px;
  border-bottom: 1px solid var(--linea);
}
.bar__name { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 14px; }
.bar__name b { font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.bar__mark { width: 18px; height: 18px; fill: none; stroke: var(--accento); stroke-width: 1.4; stroke-linejoin: round; flex: none; }
.bar__status {
  display: inline-block; overflow: hidden; height: 18px;
  font-size: 12px; color: var(--tenue); white-space: nowrap;
}
.bar__status span { display: inline-block; line-height: 18px; }

.run {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 16px 0 12px;
  border: 1px solid rgba(111, 242, 196, 0.35);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(111, 242, 196, 0.16), rgba(111, 242, 196, 0.06));
  color: var(--testo);
  font: 600 13px/1 "Mona Sans Variable", system-ui, sans-serif;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 6px 18px -8px rgba(111, 242, 196, 0.5);
}
.run__ico { position: relative; width: 14px; height: 14px; flex: none; }
.run__ico svg { position: absolute; inset: 0; width: 14px; height: 14px; }
.run__play { fill: var(--accento); }
.run__spin { fill: none; stroke: var(--accento); stroke-width: 1.8; stroke-linecap: round; stroke-dasharray: 0.62 1; opacity: 0; }
.run__lab { display: inline-block; overflow: hidden; height: 16px; }
.run__lab span { display: inline-block; line-height: 16px; }
@media (hover: hover) {
  .run:hover { border-color: rgba(111, 242, 196, 0.6); }
}

/* the wires */
.wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.wire { fill: none; stroke: var(--filo); stroke-width: 1.5; }
.wire--trail { fill: none; stroke: var(--accento); stroke-width: 1.6; stroke-linecap: round; opacity: 0.75; }
.wire--glow { fill: none; stroke: var(--accento); stroke-width: 6; stroke-linecap: round; opacity: 0.18; filter: blur(3px); }
.wire--off { stroke-dasharray: 3 5; }
.port { fill: var(--fondo); stroke: rgba(255, 255, 255, 0.28); stroke-width: 1.3; }
.spark { fill: #fff; }
.spark-halo { fill: var(--accento); opacity: 0.35; filter: blur(4px); }
.tag { font: 500 10.5px/1 "JetBrains Mono Variable", ui-monospace, monospace; fill: var(--spento); letter-spacing: 0.02em; }
.tag-bg { fill: var(--fondo); }

/* nodes */
.node { position: absolute; width: 168px; height: 62px; }
.node__card {
  position: absolute; inset: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px 0 10px;
  border-radius: 13px;
  background: linear-gradient(180deg, var(--carta-alta), var(--carta));
  border: 1px solid var(--linea);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 24px -14px rgba(0, 0, 0, 0.9);
  cursor: default;
}
.node__glow {
  position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 140% at 0% 50%, rgba(111, 242, 196, 0.16), transparent 60%);
  opacity: 0;
}
.node__ring {
  position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  border: 1px solid rgba(111, 242, 196, 0.55);
  box-shadow: 0 0 18px -6px rgba(111, 242, 196, 0.55);
  opacity: 0;
}
.node__icon {
  position: relative;
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.node__icon svg { width: 18px; height: 18px; fill: none; stroke: #c9ced6; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.node__txt { position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.node__txt b { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.node__txt small { font-size: 11px; color: var(--tenue); white-space: nowrap; }
.node__badge {
  position: absolute; right: -7px; top: -7px;
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--fondo);
  opacity: 0;
}
.tick { width: 18px; height: 18px; fill: none; stroke: var(--accento); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tick circle, .tick path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.ms {
  position: absolute; left: 12px; top: 69px;
  font: 500 10.5px/1 "JetBrains Mono Variable", ui-monospace, monospace;
  color: var(--accento); white-space: nowrap; opacity: 0;
}
.ms--skip { color: var(--spento); }
.node--off .node__card { opacity: 0.62; }

/* the drawn pointer */
.ghost {
  position: absolute; left: 0; top: 0;
  width: 24px; height: 24px;
  fill: #111; stroke: #fff; stroke-width: 1.4; stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
  pointer-events: none; opacity: 0; z-index: 5;
}

@media (prefers-reduced-motion: reduce) {
  .ghost { display: none; }
}
