:root{
  --bg:#0b0e12; --fg:#e8fffb;
  --turq:#40e0d0; --orange:#ff8a00; --amber:#ffb347; --blue:#2f6fff; --sky:#5ec8ff; --azure:#4ec9ff;

  /* grid */
  --cell:60px;          /* spacing between horizontal lines */
  --tileY: calc(var(--cell) * 6);   /* vertical loop distance */
  --tileXC: calc(var(--cell) * 2);  /* cyan X loop */
  --tileXO: calc(var(--cell) * 2);  /* orange X loop */
  --speed-y: 4.5;       /* seconds per tile on Y (lower = faster) */
  --speed-x: 14;        /* seconds per tile on X */

  --horizon: 50%;
  --fade-top: 10vh;
  --fade-bottom: 12vh;
}

*{ box-sizing:border-box }
html,body{ height:100%; margin:0 }
body{ background:var(--bg); color:var(--fg); font-family:system-ui,-apple-system,Segoe UI,Roboto,Inter,Arial,sans-serif; overflow:hidden }

#tron{ position:fixed; inset:0; z-index:0; overflow:hidden;
  background:
    radial-gradient(1200px 60vh at 50% 85%, rgba(64,224,208,.12), transparent 60%),
    linear-gradient(#050608, #0b0e12 40%, #0b0e12 70%, #06080b 100%);
}
.sky{ position:absolute; inset:0; pointer-events:none; opacity:.18;
  background-image:
    radial-gradient(2px 2px at 20% 10%, #cfe 60%, transparent 61%),
    radial-gradient(1.5px 1.5px at 60% 25%, #fff 60%, transparent 61%),
    radial-gradient(1.6px 1.6px at 80% 40%, #eff 60%, transparent 61%),
    radial-gradient(1.2px 1.2px at 40% 60%, #dff 60%, transparent 61%),
    radial-gradient(1.8px 1.8px at 70% 70%, #fff 60%, transparent 61%);
  background-repeat:no-repeat;
}
.horizon{ position:absolute; left:0; right:0; bottom:50%; height:52%; pointer-events:none;
  background: radial-gradient(80% 40% at 50% 100%, rgba(64,224,208,.35), transparent 60%);
}
.horizon::after{
  content:""; position:absolute; left:-10vw; right:-10vw; bottom:-1px; height:2px;
  background: linear-gradient(90deg, transparent, var(--turq), transparent);
  filter: drop-shadow(0 0 8px rgba(64,224,208,.8)); opacity:.9;
}

/* GRID plane anchored to horizon */
.grid{
  position:absolute; left:50%; top: calc(var(--horizon) + 1px); width:220vw; height:220vh;
  transform-origin:50% 0%;
  transform: translateX(-50%) perspective(900px) rotateX(68deg);
  backface-visibility:hidden; transform-style:preserve-3d; z-index:0; contain:paint;

  /* distance fade: lines fade in from horizon, out near camera */
  mask-image: linear-gradient(to bottom,
    rgba(0,0,0,0) 0,
    rgba(0,0,0,1) var(--fade-top),
    rgba(0,0,0,1) calc(100% - var(--fade-bottom)),
    rgba(0,0,0,0) 100%);
  -webkit-mask-image: linear-gradient(to bottom,
    rgba(0,0,0,0) 0,
    rgba(0,0,0,1) var(--fade-top),
    rgba(0,0,0,1) calc(100% - var(--fade-bottom)),
    rgba(0,0,0,0) 100%);
}
.grid-h,.grid-v{ position:absolute; inset:0; pointer-events:none }

/* Horizontal layers: crisp 2px lines every cell; motion via GSAP transform */
.layer.h{
  position:absolute; inset:0; transform: translate3d(0,0,0.01px);
  background:
    repeating-linear-gradient(to top,
      rgba(64,224,208,1) 0 2px,
      rgba(64,224,208,0) 2px var(--cell));
  filter:
    drop-shadow(0 0 8px rgba(64,224,208,.20))
    drop-shadow(0 0 14px rgba(64,224,208,.12));
  opacity:.95;
}
.layer.h.a{ /* phase 0   */ }
.layer.h.b{ /* phase 1/3 */ }
.layer.h.c{ /* phase 2/3 */ }

/* Vertical layers: cyan & orange */
.layer.v{
  position:absolute; inset:0; transform: translate3d(0,0,0.02px);
}
.layer.v.cyan{
  background:
    repeating-linear-gradient(to right,
      rgba(64,224,208,.85) 0 2px,
      rgba(64,224,208,0) 2px var(--cell));
  filter: drop-shadow(0 0 6px rgba(64,224,208,.22));
}
.layer.v.orange{
  opacity: 0;
  background:
    repeating-linear-gradient(to right,
      rgba(255,138,0,.9) 0 2px,
      rgba(255,138,0,0) 2px var(--cell));
  filter: drop-shadow(0 0 6px rgba(255,138,0,.22));
  will-change: transform, opacity; /* <— add this */
}

/* FRONT layer (title) */
.center-wrap{ position:relative; z-index:2; min-height:100dvh; display:flex; align-items:flex-start; justify-content:center; padding-top:clamp(18vh,24vh,30vh); text-align:center }
#titleSvg{ width:min(92vw,1100px); height:auto; display:block }

/* Toggle */
.theme-toggle{ position:fixed; top:14px; right:14px; z-index:3; display:inline-flex; align-items:center; justify-content:center; width:44px; height:44px; border:1px solid currentColor; border-radius:999px; background:transparent; color:var(--fg); cursor:pointer; padding:0; transition:opacity .2s, transform .1s }
.theme-toggle:hover{ opacity:.9 } .theme-toggle:active{ transform:scale(.98) }
.theme-toggle .material-symbols-outlined{ font-variation-settings:'FILL' 0,'wght' 400,'GRAD' 0,'opsz' 24; font-size:22px }

/* Status dot */
#statusDot{ position:fixed; left:12px; bottom:12px; z-index:3; width:10px; height:10px; border-radius:999px; background:#ff6b6b; box-shadow:0 0 10px rgba(255,107,107,.8) }
#statusDot.ok{ background:#40e0d0; box-shadow:0 0 10px rgba(64,224,208,.8) }
#statusDot.warn{ background:#ffd166; box-shadow:0 0 10px rgba(255,209,102,.8) }
