:root {
  --base-0: #05070a;
  --base-1: #0a1115;
  --base-2: #111a20;
  --grid: rgba(62, 255, 151, 0.08);
  --ambient: #7dff93;
  --ui: #5be9ff;
  --social: #ff5df7;
  --alert: #ffb54d;
  --text: #bdeed9;
  --muted: #7ca59a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 10%, rgba(93, 255, 170, 0.09), transparent 45%),
    radial-gradient(circle at 90% 80%, rgba(89, 217, 255, 0.09), transparent 45%),
    linear-gradient(160deg, var(--base-0), var(--base-1) 56%, var(--base-2));
  color: var(--text);
  font-family: "Orbitron", "Bank Gothic", "Eurostile", "Trebuchet MS", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.013) 0,
      rgba(255, 255, 255, 0.013) 1px,
      transparent 1px,
      transparent 3px
    );
  mix-blend-mode: screen;
  opacity: 0.35;
}

#matrix-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: default;
}

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: 1rem 1.2rem;
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr;
  gap: 0.9rem;
  pointer-events: none;
}

.title-block,
.status-block,
.legend-block,
.diagnostic-panel {
  border: 1px solid rgba(91, 233, 255, 0.3);
  background: linear-gradient(130deg, rgba(10, 17, 21, 0.88), rgba(17, 26, 32, 0.55));
  backdrop-filter: blur(2px);
  box-shadow:
    0 0 0 1px rgba(5, 7, 10, 0.9) inset,
    0 0 24px rgba(91, 233, 255, 0.12);
  border-radius: 0.35rem;
}

.title-block {
  padding: 0.8rem 1rem;
}

.kicker {
  margin: 0;
  font-size: 0.56rem;
  letter-spacing: 0.18rem;
  color: var(--ambient);
}

.title-block h1 {
  margin: 0.25rem 0;
  font-size: clamp(1.05rem, 2.2vw, 1.8rem);
  line-height: 1;
  letter-spacing: 0.22rem;
  color: #e0ffed;
  text-shadow: 0 0 10px rgba(124, 255, 173, 0.35);
}

.subtitle {
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.12rem;
  color: var(--muted);
}

.status-block {
  padding: 0.65rem 0.8rem;
  display: grid;
  gap: 0.24rem;
}

.status-block p {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.66rem;
  letter-spacing: 0.08rem;
}

.status-block span {
  color: var(--muted);
}

.status-block strong {
  color: #dbfff0;
}

.legend-block {
  padding: 0.72rem 0.8rem;
  display: grid;
  gap: 0.28rem;
}

.legend-block p {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.58rem;
  letter-spacing: 0.08rem;
  color: var(--muted);
}

.swatch {
  width: 0.56rem;
  height: 0.56rem;
  border-radius: 999px;
}

.swatch-green {
  background: var(--ambient);
  box-shadow: 0 0 10px rgba(125, 255, 147, 0.45);
}

.swatch-cyan {
  background: var(--ui);
  box-shadow: 0 0 10px rgba(91, 233, 255, 0.45);
}

.swatch-magenta {
  background: var(--social);
  box-shadow: 0 0 10px rgba(255, 93, 247, 0.45);
}

.swatch-amber {
  background: var(--alert);
  box-shadow: 0 0 10px rgba(255, 181, 77, 0.45);
}

.diagnostic-panel {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 25;
  width: min(26rem, calc(100vw - 2.4rem));
  padding: 0.8rem 0.95rem;
}

.panel-title {
  margin: 0 0 0.65rem;
  font-size: 0.64rem;
  letter-spacing: 0.14rem;
  color: var(--ui);
}

#top-handles {
  display: grid;
  gap: 0.32rem;
}

#top-handles p {
  margin: 0;
  font-size: 0.59rem;
  letter-spacing: 0.06rem;
  color: #abcfbf;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

#top-handles strong {
  color: #ebfff5;
  text-shadow: 0 0 8px rgba(91, 233, 255, 0.32);
}

.node-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.node-modal.hidden {
  display: none;
}

.node-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 11, 0.6);
}

.node-modal-card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(34rem, calc(100vw - 1.6rem));
  max-height: calc(100vh - 1.8rem);
  transform: translate(-50%, -50%);
  overflow: auto;
  border: 1px solid rgba(91, 233, 255, 0.34);
  background:
    radial-gradient(circle at top right, rgba(91, 233, 255, 0.14), transparent 42%),
    linear-gradient(150deg, rgba(7, 11, 16, 0.94), rgba(12, 19, 24, 0.93));
  box-shadow:
    0 0 0 1px rgba(5, 7, 10, 0.86) inset,
    0 0 30px rgba(91, 233, 255, 0.18);
  border-radius: 0.45rem;
  padding: 0.92rem;
}

.node-modal-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.8rem;
  align-items: center;
}

.node-modal-kicker {
  margin: 0;
  grid-column: 1 / 2;
  color: var(--ambient);
  font-size: 0.56rem;
  letter-spacing: 0.14rem;
}

.node-modal-header h2 {
  margin: 0;
  grid-column: 1 / 2;
  font-size: 1rem;
  letter-spacing: 0.08rem;
  color: #ebfff4;
}

.node-modal-close {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
  border: 1px solid rgba(91, 233, 255, 0.44);
  background: rgba(8, 13, 18, 0.95);
  color: #e3fff3;
  border-radius: 0.27rem;
  font-family: inherit;
  font-size: 0.65rem;
  letter-spacing: 0.1rem;
  height: 2rem;
  min-width: 2rem;
  cursor: pointer;
}

.node-modal-grid {
  margin-top: 0.82rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.38rem;
}

.node-field {
  border: 1px solid rgba(91, 233, 255, 0.19);
  border-radius: 0.28rem;
  padding: 0.42rem 0.45rem;
  background: rgba(4, 8, 12, 0.56);
}

.node-field strong {
  display: block;
  color: var(--muted);
  font-size: 0.53rem;
  letter-spacing: 0.09rem;
  margin-bottom: 0.2rem;
}

.node-field span {
  color: #e8fff4;
  font-family: "Consolas", "Menlo", monospace;
  font-size: 0.65rem;
}

.node-modal-raw {
  margin: 0.76rem 0 0;
  border: 1px solid rgba(91, 233, 255, 0.17);
  background: rgba(2, 5, 8, 0.8);
  color: #b7e6d2;
  border-radius: 0.28rem;
  padding: 0.5rem;
  font-size: 0.57rem;
  line-height: 1.45;
  overflow: auto;
  max-height: 12rem;
}

@media (max-width: 980px) {
  .hud {
    grid-template-columns: 1fr;
    gap: 0.55rem;
    padding: 0.8rem;
  }

  .legend-block {
    display: none;
  }

  .diagnostic-panel {
    left: 0.8rem;
    right: 0.8rem;
    bottom: 0.8rem;
    width: auto;
  }

  .title-block h1 {
    letter-spacing: 0.12rem;
  }

  .node-modal-grid {
    grid-template-columns: 1fr;
  }
}
