.bg-grid {
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, rgba(0, 255, 156, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 255, 156, 0.08) 1px, transparent 1px);
  background-size: 48px 48px;
  perspective: 600px;
  perspective-origin: 50% 35%;
  mask-image: radial-gradient(ellipse at 50% 55%, rgba(0, 0, 0, 1) 35%, rgba(0, 0, 0, 0.15) 80%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 55%, rgba(0, 0, 0, 1) 35%, rgba(0, 0, 0, 0.15) 80%);
}

.bg-grid::before,
.bg-grid::after {
  content: '';
  position: absolute;
  left: -10%;
  right: -10%;
  height: 70%;
  background-image:
    linear-gradient(to right, rgba(0, 255, 156, 0.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 255, 156, 0.18) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
  will-change: transform;
}

.bg-grid::before {
  bottom: 0;
  transform-origin: top center;
  transform: rotateX(60deg) translateZ(0);
  animation: grid-scroll-down 14s linear infinite;
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 1) 35%, rgba(0, 0, 0, 1) 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 1) 35%, rgba(0, 0, 0, 1) 100%);
}

.bg-grid::after {
  top: 0;
  transform-origin: bottom center;
  transform: rotateX(-60deg) translateZ(0);
  animation: grid-scroll-up 18s linear infinite;
  mask-image: linear-gradient(to top, transparent 0%, rgba(0, 0, 0, 0.7) 60%, rgba(0, 0, 0, 0.85) 100%);
  -webkit-mask-image: linear-gradient(to top, transparent 0%, rgba(0, 0, 0, 0.7) 60%, rgba(0, 0, 0, 0.85) 100%);
  opacity: 0.45;
}

@keyframes grid-scroll-down {
  from { background-position: 0 0; }
  to { background-position: 0 56px; }
}

@keyframes grid-scroll-up {
  from { background-position: 0 0; }
  to { background-position: 0 -56px; }
}

.bg-scanlines {
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 255, 156, 0.04) 0,
    rgba(0, 255, 156, 0.04) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: screen;
  opacity: 0.6;
}

.bg-vignette {
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(0, 8, 20, 0.65) 80%, rgba(0, 0, 0, 0.95) 100%),
    radial-gradient(ellipse at center, transparent 65%, rgba(0, 255, 156, 0.04) 80%, transparent 100%);
}

.bg-glitch {
  background: rgba(0, 255, 156, 0.06);
  opacity: 0;
  mix-blend-mode: screen;
  animation: glitch-flicker 12s steps(1, end) infinite;
}

@keyframes glitch-flicker {
  0%, 96%, 100% { opacity: 0; transform: translate(0, 0); }
  96.4% { opacity: 0.8; transform: translate(-2px, 1px); background: rgba(255, 42, 77, 0.12); }
  96.8% { opacity: 0.6; transform: translate(3px, -1px); background: rgba(0, 255, 156, 0.1); }
  97.2% { opacity: 0; transform: translate(0, 0); }
}

.reticle-ring-outer {
  transform-origin: 100px 100px;
  animation: reticle-spin 12s linear infinite;
  opacity: 0.7;
}

.reticle-ring-mid {
  transform-origin: 100px 100px;
  animation: reticle-spin-reverse 18s linear infinite;
  opacity: 0.85;
}

.reticle-ring-inner {
  transform-origin: 100px 100px;
  stroke-dasharray: 260;
  animation: reticle-pulse 2.2s ease-in-out infinite;
}

.reticle-corners {
  opacity: 0.9;
  animation: corner-pulse 2.6s ease-in-out infinite;
  transform-origin: 100px 100px;
}

.reticle-crosshair {
  opacity: 0.55;
  animation: crosshair-fade 3.4s ease-in-out infinite;
}

@keyframes reticle-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes reticle-spin-reverse {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

@keyframes reticle-pulse {
  0%, 100% {
    stroke-dashoffset: 0;
    opacity: 1;
  }
  50% {
    stroke-dashoffset: 260;
    opacity: 0.4;
  }
}

@keyframes corner-pulse {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50% { transform: scale(1.04); opacity: 0.6; }
}

@keyframes crosshair-fade {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-grid::before,
  .bg-grid::after,
  .bg-glitch,
  .reticle-ring-outer,
  .reticle-ring-mid,
  .reticle-ring-inner,
  .reticle-corners,
  .reticle-crosshair,
  .status-dot,
  .terminal .cursor {
    animation: none;
  }
}
