:root {
  --bg: #0a0e1a;
  --bg-deep: #05070f;
  --teal: #1fd4c4;
  --teal-glow: #2ffbe6;
  --magenta: #ff2d8f;
  --magenta-glow: #ff5fae;
  --acid: #b6ff3c;
  --ink: #e9f5f4;
  --muted: #6f8a96;
  --danger: #ff4d4d;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: "Space Mono", monospace;
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* ============ TITLE SCREEN ============ */
#title-screen {
  background:
    radial-gradient(circle at 30% 20%, rgba(31,212,196,0.18), transparent 45%),
    radial-gradient(circle at 75% 80%, rgba(255,45,143,0.20), transparent 45%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-deep) 100%);
  flex-direction: column;
  text-align: center;
  padding: 2rem;
}

.vignette {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 200px 60px rgba(0,0,0,0.85);
}
.scanlines {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0,0,0,0.25) 2px 4px);
  mix-blend-mode: multiply;
}

.title-content { position: relative; z-index: 2; max-width: 480px; animation: rise 0.9s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(30px);} to { opacity:1; transform: none;} }

.logo { display: flex; flex-direction: column; line-height: 0.82; margin-bottom: 1.5rem; }
.logo-hidden {
  font-family: "Bungee", sans-serif; font-size: clamp(2.6rem, 13vw, 4.6rem);
  letter-spacing: 0.04em; color: var(--ink);
  text-shadow: 0 0 18px rgba(255,255,255,0.15);
}
.logo-spectre {
  font-family: "Bungee", sans-serif; font-size: clamp(3rem, 16vw, 5.6rem);
  color: var(--teal);
  text-shadow: 0 0 24px var(--teal-glow), 0 0 60px rgba(31,212,196,0.5);
  animation: flicker 4s infinite;
}
@keyframes flicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: 0.4; } 94% { opacity: 1; } 96% { opacity: 0.7; } 97% { opacity: 1; }
}

.tagline { color: var(--muted); font-size: 0.95rem; line-height: 1.6; margin-bottom: 2rem; }

.hud-line { font-size: 0.7rem; letter-spacing: 0.3em; color: var(--teal); opacity: 0.7; margin-bottom: 0.5rem; }
.capability {
  font-size: 0.8rem; padding: 0.7rem 1rem; border: 1px solid rgba(31,212,196,0.3);
  border-radius: 4px; margin-bottom: 1.8rem; background: rgba(31,212,196,0.05);
}
.capability.checking { color: var(--muted); }
.capability.full { color: var(--acid); border-color: rgba(182,255,60,0.4); background: rgba(182,255,60,0.06); }
.capability.fallback { color: var(--teal); }
.capability.none { color: var(--danger); border-color: rgba(255,77,77,0.4); background: rgba(255,77,77,0.06); }

.btn-primary {
  position: relative; display: inline-block; font-family: "Bungee", sans-serif;
  font-size: 1.05rem; letter-spacing: 0.06em; color: var(--bg-deep);
  background: var(--teal); border: none; border-radius: 6px;
  padding: 1rem 2.2rem; cursor: pointer; overflow: hidden;
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 0 30px rgba(31,212,196,0.45);
}
.btn-primary:active { transform: scale(0.96); }
.btn-primary:disabled { opacity: 0.35; box-shadow: none; cursor: not-allowed; }
.btn-glow {
  position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,0.6), transparent);
  transform: translateX(-120%); animation: sweep 2.8s infinite;
}
@keyframes sweep { 0%,60% { transform: translateX(-120%);} 100% { transform: translateX(120%);} }

.btn-ghost {
  display: block; margin: 1.1rem auto 0; background: none; border: none;
  color: var(--muted); font-family: "Space Mono", monospace; font-size: 0.8rem;
  text-decoration: underline; text-underline-offset: 4px; cursor: pointer;
}

/* ============ MODAL ============ */
.modal {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center; padding: 1.5rem;
  background: rgba(3,5,11,0.85); backdrop-filter: blur(6px);
}
.modal.open { display: flex; }
.modal-card {
  background: linear-gradient(160deg, #11182b, #0a0e1a);
  border: 1px solid rgba(31,212,196,0.3); border-radius: 12px;
  padding: 1.8rem; max-width: 440px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal-card h2 { font-family: "Bungee", sans-serif; color: var(--teal); font-size: 1.4rem; margin-bottom: 1.2rem; }
.howto-list { list-style: none; counter-reset: step; margin-bottom: 1.5rem; }
.howto-list li {
  counter-increment: step; position: relative; padding-left: 2.6rem;
  margin-bottom: 1rem; font-size: 0.88rem; line-height: 1.5; color: var(--ink);
}
.howto-list li::before {
  content: counter(step); position: absolute; left: 0; top: -2px;
  width: 1.9rem; height: 1.9rem; display: flex; align-items: center; justify-content: center;
  background: var(--teal); color: var(--bg-deep); font-family: "Bungee", sans-serif;
  border-radius: 50%; font-size: 0.85rem;
}
.howto-list strong { color: var(--teal-glow); }
.howto-list em { color: var(--magenta-glow); font-style: normal; }

/* ============ HUNT SCREEN ============ */
#hunt-screen { background: #000; }
#camera-feed {
  position: fixed; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0; display: none;
}
#camera-feed.active { display: block; }
#gl-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; }

.scan-prompt {
  position: fixed; inset: 0; z-index: 5; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 1.4rem; pointer-events: none; transition: opacity 0.6s;
}
.scan-prompt.hidden { opacity: 0; }
.radar {
  width: 110px; height: 110px; border-radius: 50%;
  border: 2px solid rgba(31,212,196,0.4); position: relative; overflow: hidden;
  box-shadow: 0 0 40px rgba(31,212,196,0.3);
}
.radar-sweep {
  position: absolute; inset: 0;
  background: conic-gradient(from 0deg, rgba(31,212,196,0.6), transparent 40%);
  animation: spin 1.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg);} }
.scan-prompt p { font-size: 0.8rem; letter-spacing: 0.25em; color: var(--teal); }

/* HUD */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud.hidden { display: none; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; gap: 1rem; padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem;
  align-items: flex-start;
}
.hud-stat {
  background: rgba(5,7,15,0.6); border: 1px solid rgba(31,212,196,0.25);
  border-radius: 6px; padding: 0.45rem 0.8rem; backdrop-filter: blur(4px);
}
.hud-label { display: block; font-size: 0.55rem; letter-spacing: 0.2em; color: var(--muted); }
.hud-value { font-family: "Bungee", sans-serif; font-size: 1.3rem; color: var(--teal); }
.hud-exit {
  margin-left: auto; pointer-events: auto; width: 2.4rem; height: 2.4rem;
  background: rgba(5,7,15,0.6); border: 1px solid rgba(255,77,77,0.4);
  color: var(--danger); border-radius: 6px; font-size: 1rem; cursor: pointer;
}

/* Reticle */
.reticle {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 120px; height: 120px; pointer-events: none;
}
.reticle-ring {
  position: absolute; inset: 18px; border: 2px solid rgba(233,245,244,0.35);
  border-radius: 50%; transition: border-color 0.2s, box-shadow 0.2s;
}
.reticle.locked .reticle-ring { border-color: var(--magenta); box-shadow: 0 0 24px var(--magenta-glow); }
.reticle-dot {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 6px; height: 6px; background: var(--ink); border-radius: 50%;
}
.reticle.locked .reticle-dot { background: var(--magenta-glow); }
.capture-ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.capture-track { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 4; }
.capture-fill {
  fill: none; stroke: var(--acid); stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 339.3; stroke-dashoffset: 339.3;
  filter: drop-shadow(0 0 6px var(--acid));
  transition: stroke-dashoffset 0.08s linear;
}
.lock-label {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 8px; font-size: 0.65rem; letter-spacing: 0.15em; color: var(--magenta-glow);
  white-space: nowrap; opacity: 0; transition: opacity 0.2s;
}
.reticle.locked .lock-label { opacity: 1; }

/* Direction hint */
.dir-hint {
  position: absolute; top: 38%; left: 50%; transform: translateX(-50%);
  background: rgba(255,45,143,0.15); border: 1px solid var(--magenta);
  color: var(--magenta-glow); padding: 0.4rem 0.9rem; border-radius: 20px;
  font-size: 0.7rem; letter-spacing: 0.1em; backdrop-filter: blur(4px);
}
.dir-hint.hidden { display: none; }
.dir-arrow { display: inline-block; animation: nudge 0.9s infinite; }
.dir-hint.right .dir-arrow { transform: scaleX(-1); }
@keyframes nudge { 0%,100% { transform: translateX(0);} 50% { transform: translateX(-4px);} }

/* Trap button */
.hud-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: center;
  padding: 1rem 1rem max(1.6rem, env(safe-area-inset-bottom));
}
.trap-btn {
  pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  width: 100px; height: 100px; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, var(--magenta), #8a0d4d);
  border: 3px solid var(--magenta-glow); color: #fff; cursor: pointer;
  box-shadow: 0 0 30px rgba(255,45,143,0.5); transition: transform 0.1s, box-shadow 0.15s;
  font-family: "Space Mono", monospace;
}
.trap-btn:active, .trap-btn.holding { transform: scale(0.92); box-shadow: 0 0 50px var(--magenta-glow); }
.trap-icon {
  width: 26px; height: 26px;
  background: radial-gradient(circle, #fff 30%, transparent 70%);
  border: 2px solid #fff; border-radius: 50% 50% 50% 0; transform: rotate(45deg);
}
.trap-text { font-size: 0.5rem; letter-spacing: 0.12em; }

/* Capture flash + toast */
.capture-flash {
  position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(182,255,60,0.5), transparent 60%);
}
.capture-flash.fire { animation: flash 0.5s ease-out; }
@keyframes flash { 0% { opacity: 0; transform: scale(0.6);} 40% { opacity: 1;} 100% { opacity: 0; transform: scale(1.4);} }

.toast {
  position: fixed; top: 22%; left: 50%; transform: translate(-50%, -10px);
  z-index: 25; font-family: "Bungee", sans-serif; font-size: 1.4rem;
  color: var(--acid); text-shadow: 0 0 20px var(--acid); opacity: 0;
  pointer-events: none; white-space: nowrap; letter-spacing: 0.04em;
}
.toast.show { animation: toastPop 1.4s ease-out; }
@keyframes toastPop {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.7);}
  20% { opacity: 1; transform: translate(-50%, -10px) scale(1.1);}
  70% { opacity: 1; transform: translate(-50%, -10px) scale(1);}
  100% { opacity: 0; transform: translate(-50%, -30px) scale(1);}
}
