:root {
  --fg: #33ff33;
  --fg-dim: #1f9c1f;
  --bg: #000;
  --offline: #ff3b3b;
  --lat-good: #33ff33;
  --lat-mid: #e6e63b;
  --lat-high: #ff9b3b;
  --glow: rgba(51, 255, 51, 0.45);

  /* --- Murad CRT tunables --- */
  --crt-radius: 22px;          /* curved-glass corner */
  --scanline-opacity: 0.28;    /* darkness of horizontal scanlines */
  --scanline-size: 3px;        /* scanline period */
  --grille-opacity: 0.10;      /* RGB aperture-grille strength */
  --flicker-opacity: 0.04;     /* base brightness flicker */
  --beam-period: 7s;           /* how often the scan beam sweeps */
}

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

html,
body {
  height: 100%;
}

body {
  background: #050505;
  color: var(--fg);
  font-family: 'Cascadia Mono', 'Cascadia Code', Consolas, Menlo, Monaco,
    'DejaVu Sans Mono', 'Ubuntu Mono', 'Liberation Mono', monospace;
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
}

/* ---- Monitor / curved glass ---- */
#crt {
  position: relative;
  height: 100vh;
  padding: 16px 18px;
  background: radial-gradient(ellipse at center, #061006 0%, #000 100%);
  border-radius: var(--crt-radius);
  overflow: hidden;
  /* curved-glass bulge + deep inner shadow + outer monitor body */
  box-shadow:
    inset 0 0 120px 24px rgba(0, 0, 0, 0.9),
    inset 0 0 28px rgba(0, 0, 0, 0.95),
    0 0 0 2px #0a0a0a,
    0 0 60px rgba(0, 0, 0, 0.8);
}

#screen {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  align-items: stretch;
  gap: 22px;
  /* phosphor bloom + a gentle, continuous brightness "breathe" */
  text-shadow: 0 0 4px var(--glow);
  animation: breathe 5s ease-in-out infinite, textShadow 2s steps(60) infinite;
}

.panel-left {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.panel-left #output {
  flex: 1 1 auto;
}

.panel-right {
  flex: 0 0 auto;
  width: clamp(240px, 34vw, 360px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

#globe {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 0 6px var(--glow));
  transform-origin: center;
  animation: globeGlitch 7s linear infinite;
}

/* occasional signal-interference glitch: tiny shift + RGB split */
@keyframes globeGlitch {
  0%,
  44%,
  48%,
  92%,
  100% {
    transform: translate3d(0, 0, 0) skewX(0deg);
    filter: drop-shadow(0 0 6px var(--glow));
  }
  45% {
    transform: translate3d(-2px, 1px, 0) skewX(-1.2deg);
    filter: drop-shadow(2px 0 0 rgba(255, 40, 90, 0.55))
      drop-shadow(-2px 0 0 rgba(0, 150, 255, 0.55))
      drop-shadow(0 0 6px var(--glow));
  }
  46% {
    transform: translate3d(2px, -1px, 0) skewX(0.8deg);
  }
  47% {
    transform: translate3d(-1px, 0, 0) skewX(0deg);
    filter: drop-shadow(0 0 6px var(--glow));
  }
  93% {
    transform: translate3d(2px, 0, 0) skewX(1deg);
    filter: drop-shadow(-2px 0 0 rgba(255, 40, 90, 0.55))
      drop-shadow(2px 0 0 rgba(0, 150, 255, 0.55))
      drop-shadow(0 0 6px var(--glow));
  }
  94% {
    transform: translate3d(-2px, 0, 0);
  }
  95% {
    transform: translate3d(1px, 0, 0);
    filter: drop-shadow(0 0 6px var(--glow));
  }
}

.globe-caption {
  width: 100%;
  text-align: center;
  color: var(--fg-dim);
  font-size: 11px;
  letter-spacing: 2px;
  line-height: 1.6;
}

.globe-caption .ok {
  color: var(--fg);
  animation: blink 1.2s steps(1) infinite;
}

.globe-caption .dim {
  opacity: 0.7;
}

/* ---- globe / map elements ---- */
.globe-disc {
  fill: url(#discGrad);
}

.globe-rim {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.4;
  opacity: 0.85;
}

.graticule {
  fill: none;
  stroke: var(--fg);
  stroke-width: 0.7;
  opacity: 0.3;
}

.orbit {
  fill: none;
  stroke: var(--fg-dim);
  stroke-width: 1;
  stroke-dasharray: 2 8;
  opacity: 0.5;
  transform-box: view-box;
  transform-origin: 170px 180px;
  animation: spin 26s linear infinite;
}

.sweep {
  transform-box: view-box;
  transform-origin: 170px 180px;
  animation: spin 6s linear infinite;
}

.sweep-wedge {
  fill: var(--fg);
  opacity: 0.1;
}

.sweep-line {
  stroke: var(--fg);
  stroke-width: 1.2;
  opacity: 0.7;
}

.net-link {
  stroke: var(--fg);
  stroke-width: 1;
  stroke-dasharray: 2 6;
  opacity: 0.6;
  animation: dashFlow 0.9s linear infinite;
}

.net-link.faint {
  opacity: 0.28;
  animation-duration: 1.6s;
}

.net-node {
  fill: var(--fg);
  opacity: 0.8;
}

.net-node.faint {
  opacity: 0.4;
}

.link-arc {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.2;
  stroke-dasharray: 4 7;
  opacity: 0.7;
  animation: dashFlow 0.8s linear infinite;
}

.packet {
  fill: #d9ffd9;
  filter: drop-shadow(0 0 5px var(--fg));
}

.packet.dim {
  fill: var(--fg);
  opacity: 0.6;
}

.marker-dot {
  fill: #eafff0;
  filter: drop-shadow(0 0 5px var(--fg));
}

.marker-ring {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.2;
  transform-box: fill-box;
  transform-origin: center;
  animation: ringPulse 2.4s ease-out infinite;
}

.marker-ring.b {
  animation-delay: 1.2s;
}

.marker-label {
  fill: var(--fg);
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes dashFlow {
  to {
    stroke-dashoffset: -16;
  }
}

@keyframes ringPulse {
  0% {
    transform: scale(0.4);
    opacity: 0.9;
  }
  100% {
    transform: scale(2.8);
    opacity: 0;
  }
}

/* stack columns on narrow screens */
@media (max-width: 760px) {
  #screen {
    flex-direction: column;
  }
  .panel-right {
    width: 100%;
    max-width: 320px;
    align-self: center;
  }
}

/* subtle brightness breathing of the whole picture */
@keyframes breathe {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.06);
  }
}

/* chromatic aberration: red/blue fringes drifting on the text */
@keyframes textShadow {
  0% {
    text-shadow: 0.5px 0 1px rgba(255, 0, 70, 0.25),
      -0.5px 0 1px rgba(0, 70, 255, 0.25), 0 0 4px var(--glow);
  }
  50% {
    text-shadow: 0.8px 0 1px rgba(255, 0, 70, 0.3),
      -0.8px 0 1px rgba(0, 70, 255, 0.3), 0 0 5px var(--glow);
  }
  100% {
    text-shadow: 0.3px 0 1px rgba(255, 0, 70, 0.2),
      -0.3px 0 1px rgba(0, 70, 255, 0.2), 0 0 4px var(--glow);
  }
}

.line {
  white-space: pre;
}

#header {
  color: var(--fg-dim);
  margin-bottom: 8px;
}

#output {
  white-space: pre;
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
}

.row {
  white-space: pre;
}

.dot.online {
  color: var(--fg);
}

.dot.offline {
  color: var(--offline);
  text-shadow: 0 0 4px rgba(255, 59, 59, 0.5);
}

.dots {
  color: var(--fg-dim);
}

.status.online {
  color: var(--fg);
}

.status.offline {
  color: var(--offline);
  text-shadow: 0 0 4px rgba(255, 59, 59, 0.5);
}

.lat {
  color: var(--fg-dim);
}

.lat.lat-good {
  color: var(--lat-good);
}

.lat.lat-mid {
  color: var(--lat-mid);
}

.lat.lat-high {
  color: var(--lat-high);
}

/* boot reveal: rows slide in one at a time */
.row.boot {
  animation: bootIn 0.25s ease-out both;
}

@keyframes bootIn {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

#footer {
  margin-top: 8px;
  color: var(--fg-dim);
}

#brand {
  margin-top: 14px;
  color: var(--fg-dim);
  opacity: 0.75;
}

#brand .sep {
  display: block;
  border-top: 1px dashed var(--fg-dim);
  margin-bottom: 6px;
  opacity: 0.5;
}

#brand .brand-name {
  letter-spacing: 3px;
  font-size: 12px;
}

/* blinking block cursor */
.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.05em;
  margin-left: 2px;
  background: var(--fg);
  box-shadow: 0 0 6px var(--glow);
  vertical-align: text-bottom;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ========================================================= */
/* ===============   MURAD CRT OVERLAY STACK   ============= */
/* ========================================================= */
.crt-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--crt-radius);
}

/* (1) horizontal scanlines + vertical RGB aperture grille */
.crt-scanlines {
  z-index: 2;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0) calc(var(--scanline-size) - 1px),
      rgba(0, 0, 0, var(--scanline-opacity)) var(--scanline-size)
    ),
    repeating-linear-gradient(
      to right,
      rgba(255, 0, 0, var(--grille-opacity)) 0,
      rgba(0, 255, 0, var(--grille-opacity)) 1px,
      rgba(0, 0, 255, var(--grille-opacity)) 2px,
      rgba(0, 0, 0, 0) 3px
    );
  background-size: 100% var(--scanline-size), 3px 100%;
  mix-blend-mode: multiply;
}

/* (2) bright beam sweeping down the tube */
.crt-beam {
  z-index: 3;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0%,
    rgba(180, 255, 180, 0.06) 45%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(180, 255, 180, 0.06) 55%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 100% 22%;
  background-repeat: no-repeat;
  animation: beam var(--beam-period) linear infinite;
}

@keyframes beam {
  0% {
    background-position: 0 -25%;
  }
  100% {
    background-position: 0 125%;
  }
}

/* (3) fast brightness flicker (afterglow-style) */
.crt-flicker {
  z-index: 4;
  background: rgba(51, 255, 51, 1);
  opacity: var(--flicker-opacity);
  mix-blend-mode: screen;
  animation: flicker 0.15s steps(1) infinite;
}

@keyframes flicker {
  0% { opacity: 0.021; }
  10% { opacity: 0.045; }
  20% { opacity: 0.015; }
  30% { opacity: 0.052; }
  40% { opacity: 0.018; }
  50% { opacity: 0.06; }
  60% { opacity: 0.022; }
  70% { opacity: 0.048; }
  80% { opacity: 0.012; }
  90% { opacity: 0.05; }
  100% { opacity: 0.025; }
}

/* (4) vignette + curved-glass sheen */
.crt-vignette {
  z-index: 5;
  background:
    radial-gradient(
      ellipse at center,
      rgba(0, 0, 0, 0) 55%,
      rgba(0, 0, 0, 0.55) 100%
    ),
    /* top-left glass reflection */
    linear-gradient(
      125deg,
      rgba(255, 255, 255, 0.06) 0%,
      rgba(255, 255, 255, 0) 35%
    );
  box-shadow: inset 0 0 90px 30px rgba(0, 0, 0, 0.55);
}

/* (5) power-on flash: thin line expands to full screen, then fades */
.crt-poweron {
  z-index: 10;
  background: #cfffcf;
  transform-origin: center;
  animation: powerOn 1s ease-out forwards;
}

@keyframes powerOn {
  0% {
    opacity: 1;
    transform: scaleY(0.004) scaleX(0.6);
  }
  25% {
    opacity: 1;
    transform: scaleY(0.004) scaleX(1);
  }
  45% {
    opacity: 0.9;
    transform: scaleY(1) scaleX(1);
  }
  70% {
    opacity: 0.25;
  }
  100% {
    opacity: 0;
    transform: scaleY(1) scaleX(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor,
  .row.boot,
  #screen,
  .crt-beam,
  .crt-flicker,
  .crt-poweron,
  #globe,
  .orbit,
  .sweep,
  .net-link,
  .link-arc,
  .marker-ring,
  .globe-caption .ok {
    animation: none;
  }
  .crt-poweron {
    display: none;
  }
}
