:root {
  --bg: #06090a;
  --teal: #82d6cc;
  --teal-dim: #4e988f;
  --amber: #ffb466;
  --amber-dim: #cf7d33;
  --panel: rgba(8, 17, 17, 0.62);
}

* {
  box-sizing: border-box;
}

html,
body,
#app,
#ar-container {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

#ar-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#ar-container video,
#ar-container canvas {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

#ar-container video {
  object-fit: cover !important;
  transform: none !important;
}

body {
  font-family: "OCR A Extended", "Consolas", "SFMono-Regular", monospace;
  color: var(--teal);
}

#ar-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.camera-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  pointer-events: auto;
}

.camera-gate.hidden {
  display: none;
}

.camera-gate-panel {
  width: min(90vw, 320px);
  background: rgba(8, 12, 13, 0.9);
  border: 1px solid rgba(130, 214, 204, 0.45);
  border-radius: 6px;
  padding: 12px;
  text-align: center;
}

.camera-gate-title {
  color: var(--amber);
  font-size: 13px;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

#start-ar-btn {
  cursor: pointer;
  font-family: inherit;
  color: var(--teal);
  background: rgba(12, 20, 20, 0.92);
  border: 1px solid rgba(130, 214, 204, 0.55);
  border-radius: 4px;
  padding: 8px 14px;
}

.hud {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 8;
}

body.camera-active,
body.camera-active #app,
body.camera-active #ar-container {
  background: transparent;
}

body.camera-active .crt-overlay,
body.camera-active .noise-overlay {
  opacity: 0.02;
}

.crt-overlay {
  position: absolute;
  inset: 0;
  opacity: 0.2;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.06) 0px,
      rgba(255, 255, 255, 0.02) 1px,
      rgba(0, 0, 0, 0.08) 2px,
      rgba(0, 0, 0, 0.08) 3px
    );
}

.noise-overlay {
  position: absolute;
  inset: 0;
  opacity: 0.1;
  mix-blend-mode: screen;
  background-image: radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.14) 0, transparent 2px);
  background-size: 3px 3px;
  animation: noiseShift 0.22s steps(2, end) infinite;
}

.hud-top {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: min(92vw, 760px);
}

.status-line {
  color: var(--amber);
  font-size: clamp(13px, 2.2vw, 18px);
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(255, 170, 88, 0.5);
}

.target-label {
  margin-top: 6px;
  color: var(--teal);
  font-size: clamp(11px, 1.7vw, 14px);
  letter-spacing: 0.14em;
  opacity: 0.82;
}

.center-brackets {
  position: absolute;
  width: min(62vw, 260px);
  aspect-ratio: 1;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.center-brackets .br {
  position: absolute;
  width: 24%;
  height: 24%;
  border: 2px solid var(--teal);
  filter: drop-shadow(0 0 8px rgba(130, 214, 204, 0.5));
}

.center-brackets .tl { left: 0; top: 0; border-right: 0; border-bottom: 0; }
.center-brackets .tr { right: 0; top: 0; border-left: 0; border-bottom: 0; }
.center-brackets .bl { left: 0; bottom: 0; border-right: 0; border-top: 0; }
.center-brackets .brc { right: 0; bottom: 0; border-left: 0; border-top: 0; }

.hud-panels {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(94vw, 780px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  opacity: 1;
  transition: opacity 280ms ease;
}

.hud-panels.hidden {
  opacity: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(130, 214, 204, 0.3);
  border-radius: 6px;
  padding: 8px 10px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.35), 0 0 14px rgba(130, 214, 204, 0.08);
}

.panel h3 {
  margin: 0 0 6px;
  color: var(--amber);
  font-size: 11px;
  letter-spacing: 0.12em;
  font-weight: 400;
}

.metric {
  font-size: 13px;
  line-height: 1.45;
}

.nixie-display {
  font-family: "Tilt Neon", "Nixie One", "Consolas", monospace;
  color: #ffbf79;
  font-size: clamp(18px, 2.4vw, 26px);
  letter-spacing: 0.05em;
  text-shadow: 0 0 8px rgba(255, 180, 105, 0.75), 0 0 18px rgba(255, 130, 62, 0.35);
}

#scope-canvas {
  width: 100%;
  height: 68px;
  border: 1px solid rgba(130, 214, 204, 0.18);
  background: rgba(0, 0, 0, 0.45);
}

.glitch-flash {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0 40%, rgba(118, 255, 235, 0.45) 46%, transparent 52%);
  opacity: 0;
}

.glitch-flash.active {
  animation: glitchFlash 0.16s steps(1, end) 1;
}

.debug-panel {
  pointer-events: auto;
  position: fixed;
  right: 10px;
  top: max(10px, env(safe-area-inset-top));
  z-index: 12;
  width: 200px;
  background: rgba(8, 12, 13, 0.88);
  border: 1px solid rgba(130, 214, 204, 0.4);
  border-radius: 6px;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.debug-panel.hidden {
  display: none;
}

.debug-panel button {
  pointer-events: auto;
  cursor: pointer;
  font-family: inherit;
  color: var(--amber);
  background: rgba(16, 18, 19, 0.95);
  border: 1px solid rgba(255, 180, 102, 0.5);
  border-radius: 4px;
  padding: 6px 8px;
  text-align: left;
}

#fps-readout {
  color: var(--teal);
  font-size: 12px;
}

.error-banner {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 640px);
  border: 1px solid rgba(255, 126, 114, 0.45);
  background: rgba(38, 10, 10, 0.92);
  color: #ffc7c2;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.4;
}

.error-banner.hidden {
  display: none;
}

@keyframes noiseShift {
  from { transform: translate(0, 0); }
  to { transform: translate(1px, -1px); }
}

@keyframes glitchFlash {
  0% { opacity: 0; }
  35% { opacity: 0.85; }
  100% { opacity: 0; }
}

@media (max-width: 760px) {
  .hud-panels {
    grid-template-columns: 1fr;
    width: min(94vw, 420px);
  }
}
