:root {
  --bg: #05080b;
  --ink: #d9efec;
  --ink-soft: #6f8b8c;
  --accent: #35e8c4;
  --accent-2: #4f8dff;
  --line: rgba(53, 232, 196, 0.18);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Mono", "Courier New", monospace;
}

#labCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Boot sequence — a five-second "accessing the lab" overlay that plays
   once per page load, ahead of everything else. */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.boot-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-inner {
  width: min(420px, 86vw);
}

.boot-line {
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-align: center;
  margin: 0 0 1.4rem;
  animation: status-blink 1.6s ease-in-out infinite;
}

.boot-log {
  height: 108px;
  overflow: hidden;
  font-size: 0.7rem;
  line-height: 1.9;
  color: var(--ink-soft);
  margin-bottom: 1rem;
}

.boot-log div {
  opacity: 0;
  animation: boot-log-in 0.4s ease forwards;
}

@keyframes boot-log-in {
  to { opacity: 1; }
}

.boot-bar {
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.boot-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.boot-pct {
  margin: 0.6rem 0 0;
  font-size: 0.7rem;
  color: var(--ink-soft);
  text-align: right;
  letter-spacing: 0.1em;
}

/* Custom reticle cursor — a precise dot plus a lagging outer ring that
   grows over links, replacing the system cursor on pointer devices. */
@media (hover: hover) and (pointer: fine) {
  body, a, button {
    cursor: none;
  }
}

.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 90;
  transform: translate(-50%, -50%);
}

.cursor-dot {
  width: 5px;
  height: 5px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.cursor-ring {
  width: 32px;
  height: 32px;
  border: 1px solid var(--accent);
  opacity: 0.5;
  transition: width 0.2s ease, height 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}

.cursor-ring.is-active {
  width: 52px;
  height: 52px;
  opacity: 0.9;
  border-color: #9fffe0;
}

@media (hover: none) {
  .cursor-dot, .cursor-ring { display: none; }
}

/* Tap/click ripple — a brief expanding ring wherever the screen is tapped. */
.tap-ripple {
  position: fixed;
  top: 0;
  left: 0;
  border-radius: 50%;
  border: 1px solid var(--accent);
  pointer-events: none;
  z-index: 70;
  transform: translate(-50%, -50%);
  animation: tap-ripple-expand 0.7s ease-out forwards;
}

@keyframes tap-ripple-expand {
  from { width: 0; height: 0; opacity: 0.9; }
  to { width: 140px; height: 140px; opacity: 0; }
}

/* "Initialize" verification pop — three-second ring fill that resolves
   into a denial, right before the whole site flips to alert mode. */
.access-modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 3, 5, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.access-modal.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.access-modal-inner {
  width: min(320px, 84vw);
  padding: 2.2rem 1.8rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(8, 12, 16, 0.92);
  text-align: center;
  box-shadow: 0 0 40px rgba(53, 232, 196, 0.18);
  transform: scale(0.92);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.access-modal.open .access-modal-inner {
  transform: scale(1);
}

.access-modal.is-denied .access-modal-inner {
  box-shadow: 0 0 44px rgba(255, 59, 59, 0.28);
}

.access-modal-label {
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin: 0 0 1.4rem;
}

.access-modal.is-denied .access-modal-label {
  color: #ff3b3b;
  animation: access-denied-glitch 0.4s steps(2, end) 2;
}

@keyframes access-denied-glitch {
  0% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-1px); }
  100% { transform: translateX(0); }
}

.access-ring {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 1.2rem;
}

.access-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.access-ring-track {
  fill: none;
  stroke: var(--line);
  stroke-width: 4;
}

.access-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--accent));
}

.access-modal.is-denied .access-ring-fill {
  stroke: #ff3b3b;
  filter: drop-shadow(0 0 8px #ff3b3b);
}

.access-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--ink);
}

.access-modal-sub {
  font-size: 0.72rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  margin: 0;
}

/* "Intruder located" popup — a fake technical readout, deliberately
   dense with jargon a casual visitor won't recognize. Every value is
   generated client-side and thrown away; nothing here is real. */
.locate-modal-inner {
  width: min(380px, 90vw);
}

.locate-label {
  color: #ff3b3b;
  animation: access-denied-glitch 0.4s steps(2, end) 2;
}

.locate-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 1.4rem;
  row-gap: 0.65rem;
  margin-top: 1.3rem;
  text-align: left;
}

.locate-key {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  white-space: nowrap;
  align-self: center;
}

.locate-val {
  font-size: 0.72rem;
  color: #ffb199;
  text-align: right;
  word-break: break-all;
  align-self: center;
}

.locate-key,
.locate-val {
  opacity: 0;
  animation: boot-log-in 0.35s ease forwards;
}

.locate-val.is-critical {
  color: #ff3b3b;
  font-weight: 700;
}

/* A faint CRT/monitor texture — reinforces the "lab console" feeling
   without fighting the three.js scene underneath. */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.025) 0px,
    rgba(255, 255, 255, 0.025) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.5;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 38%, rgba(0, 0, 0, 0.8) 100%);
}

/* Viewfinder-style HUD chrome — corner brackets and small telemetry
   readouts, purely decorative, reinforcing the "you're looking at a
   live system" feeling rather than a static coming-soon page. */
.hud {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.hud-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  opacity: 0.6;
}

.hud-corner--tl { top: 1.75rem; left: 1.75rem; border-right: none; border-bottom: none; }
.hud-corner--tr { top: 1.75rem; right: 1.75rem; border-left: none; border-bottom: none; }
.hud-corner--bl { bottom: 1.75rem; left: 1.75rem; border-right: none; border-top: none; }
.hud-corner--br { bottom: 1.75rem; right: 1.75rem; border-left: none; border-top: none; }

.hud-tag {
  position: absolute;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  opacity: 0.65;
  white-space: nowrap;
}

.hud-tag--top { top: 2.6rem; right: 3.4rem; }
.hud-tag--bottom { bottom: 2.6rem; left: 3.4rem; }

@media (max-width: 640px) {
  .hud-corner { width: 18px; height: 18px; }
  .hud-corner--tl, .hud-corner--tr { top: 1.1rem; }
  .hud-corner--bl, .hud-corner--br { bottom: 1.1rem; }
  .hud-corner--tl, .hud-corner--bl { left: 1.1rem; }
  .hud-corner--tr, .hud-corner--br { right: 1.1rem; }
  .hud-tag { font-size: 0.58rem; }
  .hud-tag--top { top: 1.9rem; right: 2.2rem; }
  .hud-tag--bottom { bottom: 1.9rem; left: 2.2rem; }
}

.lab-shell {
  position: relative;
  z-index: 3;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  gap: 1.5rem;
}

/* Guarantees the text stays legible over the wireframe core regardless
   of viewport aspect ratio — the 3D scene is tuned to look right on its
   own terms, this is just a safety net so text never has to compete
   with a dense tangle of lines directly behind it. */
.lab-shell::before {
  content: "";
  position: absolute;
  inset: -4rem;
  z-index: -1;
  background: radial-gradient(ellipse 60% 55% at 50% 50%, rgba(5, 8, 11, 0.82) 0%, rgba(5, 8, 11, 0.5) 55%, transparent 80%);
  pointer-events: none;
}

.lab-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-transform: uppercase;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent), 0 0 16px rgba(53, 232, 196, 0.5);
  animation: status-blink 2.2s ease-in-out infinite;
}

@keyframes status-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.lab-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.35em;
  color: var(--ink-soft);
  text-transform: uppercase;
  margin: 0;
}

.lab-title {
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
  max-width: 16ch;
  text-shadow: 0 0 30px rgba(53, 232, 196, 0.25);
}

.cursor-blink {
  display: inline-block;
  color: var(--accent);
  animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.lab-sub {
  max-width: 46ch;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.75;
  margin: 0;
}

/* The one actual call-to-action on the page — deliberately louder than
   everything else here: filled-in accent color by default (not muted),
   a slow persistent glow, and a light sweep that passes across it every
   few seconds, the way a "press me" button reads in a HUD. */
.lab-back {
  position: relative;
  overflow: hidden;
  background: transparent;
  font-family: inherit;
  color: var(--accent);
  text-decoration: none;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  border: 1px solid var(--accent);
  padding: 0.75rem 1.7rem;
  border-radius: 999px;
  transition: color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
  animation: access-btn-glow 2.6s ease-in-out infinite;
}

.lab-back::before {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  animation: access-btn-shine 3.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes access-btn-shine {
  0% { left: -60%; }
  35% { left: 140%; }
  100% { left: 140%; }
}

@keyframes access-btn-glow {
  0%, 100% { box-shadow: 0 0 14px rgba(53, 232, 196, 0.3); }
  50% { box-shadow: 0 0 30px rgba(53, 232, 196, 0.6); }
}

.lab-back:hover {
  color: #04110d;
  background: var(--accent);
  box-shadow: 0 0 32px rgba(53, 232, 196, 0.65);
  transform: translateY(-1px);
}

html.alert-mode .lab-back:hover {
  color: #1a0505;
  box-shadow: 0 0 32px rgba(255, 59, 59, 0.65);
}

/* Replaces the "Initialize" button once access is denied — a hard
   deadline instead of an invitation. */
.lockdown-timer {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.lockdown-timer.visible {
  display: flex;
}

.lockdown-label {
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.lockdown-clock {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ff3b3b;
  text-shadow: 0 0 18px rgba(255, 59, 59, 0.6);
  font-variant-numeric: tabular-nums;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

@media (max-width: 640px) {
  .lab-title {
    font-size: clamp(1.5rem, 7vw, 2.2rem);
  }
  .lab-sub {
    font-size: 0.85rem;
  }
  .lab-shell {
    gap: 1.1rem;
  }
}

/* Alert mode — triggered once "Access Now" resolves into a denial.
   Overriding the shared custom properties re-colors everything built on
   top of them (status dot, HUD corners, cursor, ripples, the lab-back
   button) in one move; the handful of spots below with a color baked
   directly into an rgba() — because they layer more than one shadow —
   get their own explicit override. */
html.alert-mode {
  --accent: #ff3b3b;
  --accent-2: #ff6a5a;
  --line: rgba(255, 59, 59, 0.28);
  --ink-soft: #cf8f8f;
}

html.alert-mode .status-dot {
  box-shadow: 0 0 8px var(--accent), 0 0 16px rgba(255, 59, 59, 0.5);
  animation-duration: 0.6s;
}

html.alert-mode .lab-title {
  text-shadow: 0 0 34px rgba(255, 59, 59, 0.35);
}

html.alert-mode .scanlines {
  opacity: 0.7;
}

/* A slow red alarm wash breathing around the screen edges. */
html.alert-mode body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(255, 30, 30, 0.2) 100%);
  animation: alert-pulse 1.6s ease-in-out infinite;
}

@keyframes alert-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
