/* METAWYM AR Lab — rifle range */
:root {
  --c1: #7cf7ff; --c2: #8b7bff; --c3: #ff7ad9;
  --amber: #ffb547; --red: #ff3b30; --text: #eef1f8; --muted: #9aa3b8; --line: rgba(255,255,255,.14);
  --font: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #000; color: var(--text); font: 16px/1.55 var(--font); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

/* ───────── Intro ───────── */
.intro {
  min-height: 100svh; display: grid; place-items: center; padding: 64px 16px 32px; position: relative;
  background:
    radial-gradient(45% 35% at 20% 15%, rgba(124,247,255,.12), transparent 70%),
    radial-gradient(45% 40% at 85% 85%, rgba(139,123,255,.16), transparent 70%), #05060a;
}
.back { position: absolute; top: 18px; left: 18px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--text); }
.intro__card {
  width: min(520px, 100%); padding: 32px; border-radius: 26px; border: 1px solid var(--line);
  background: rgba(255,255,255,.04); backdrop-filter: blur(14px);
}
.preview {
  width: 132px; height: 132px; margin: 0 auto 22px; border-radius: 50%; position: relative; overflow: hidden;
  background: radial-gradient(circle at 40% 35%, #3a4a5c, #121820 70%);
  box-shadow: 0 0 0 6px #0a0a0a, 0 0 0 7px rgba(255,255,255,.12), inset 0 0 26px 10px rgba(0,0,0,.85), 0 20px 60px -20px rgba(139,123,255,.6);
}
.preview svg { position: absolute; inset: 0; width: 100%; height: 100%; animation: sway 6s ease-in-out infinite; }
@keyframes sway { 0%,100% { transform: translate(0,0); } 30% { transform: translate(3px,-2px); } 65% { transform: translate(-2px,2px); } }
.kicker { margin: 0 0 8px; text-align: center; font: 600 12px/1 var(--mono); letter-spacing: .16em; color: var(--c1); }
h1 { margin: 0; text-align: center; font-size: clamp(30px, 7vw, 40px); letter-spacing: -.04em; line-height: 1.1; }
.lead { margin: 14px 0 20px; text-align: center; color: var(--muted); }
.features { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.features li { position: relative; padding-left: 28px; font-size: 15px; }
.features li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--c1); box-shadow: 0 0 10px var(--c1); }
.note { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); }
.note--safety { color: var(--amber); }
.start {
  width: 100%; height: 56px; margin-top: 14px; border-radius: 999px; font-weight: 750; font-size: 17px; color: #05060a;
  background: linear-gradient(100deg, var(--c1), var(--c2) 55%, var(--c3)); box-shadow: 0 14px 40px -12px rgba(139,123,255,.8);
}
.start:active { transform: scale(.98); }
.start[disabled] { opacity: .6; }
.hint { margin: 10px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.error { margin: 12px 0 0; text-align: center; font-size: 14px; color: #ff9aa9; min-height: 1em; }

/* ───────── Stage ───────── */
.stage { position: fixed; inset: 0; overflow: hidden; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; }
.world { position: absolute; inset: 0; will-change: transform; }
.world video { width: 100%; height: 100%; object-fit: cover; display: block; }
.fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; will-change: transform; }

/* Scope: circular field of view, eyepiece shadow, reticle. --r is set from JS. */
.scope { position: absolute; inset: 0; pointer-events: none; will-change: transform; --r: 45vmin; }
.scope__mask {
  position: absolute; inset: -40px;
  background: radial-gradient(circle at 50% 50%, transparent calc(var(--r) - 1px), rgba(0,0,0,.75) var(--r), #000 calc(var(--r) + 18px));
}
.scope__lens {
  position: absolute; left: 50%; top: 50%; width: calc(var(--r) * 2); height: calc(var(--r) * 2); transform: translate(-50%, -50%); border-radius: 50%;
  box-shadow: inset 0 0 calc(var(--r) * .22) calc(var(--r) * .06) rgba(0,0,0,.85), 0 0 0 2px rgba(0,0,0,.9);
  background:
    radial-gradient(120% 80% at 30% 18%, rgba(255,255,255,.10), transparent 40%),
    radial-gradient(circle, rgba(120,170,255,.05), rgba(0,10,30,.18));
}
.scope__reticle { position: absolute; left: 50%; top: 50%; width: calc(var(--r) * 2); height: calc(var(--r) * 2); transform: translate(-50%, -50%); filter: drop-shadow(0 0 2px rgba(255,59,48,.0)); }
.stage.is-armed .scope__reticle { filter: drop-shadow(0 0 1.5px rgba(255,59,48,.9)); }

.flash { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 62%, rgba(255,236,190,.55), rgba(255,170,60,.18) 35%, transparent 65%); }
.flash.on { animation: muzzle 90ms ease-out; }
@keyframes muzzle { 0% { opacity: 1; } 100% { opacity: 0; } }

/* HUD */
.hud { position: absolute; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 0; }
.hud--top { top: 0; }
.hud--bottom { bottom: 0; align-items: flex-end; padding: 0 16px max(18px, env(safe-area-inset-bottom)); }
.chip { height: 38px; padding: 0 16px; border-radius: 999px; font-size: 14px; font-weight: 650; background: rgba(20,22,30,.82); border: 1px solid var(--line); }
.chip:active { transform: scale(.96); }
.hud__right { display: flex; gap: 8px; }

.readout { display: flex; gap: 16px; align-items: baseline; font-family: var(--mono); text-shadow: 0 1px 4px #000; }
.ammo b { font-size: 26px; font-weight: 600; }
.ammo small, .hits small { font-size: 12px; color: var(--muted); }
.hits b { font-size: 18px; margin-left: 6px; color: var(--amber); }
.ammo.is-low b { color: var(--red); }
.status { position: absolute; left: 0; right: 0; top: calc(max(14px, env(safe-area-inset-top)) + 48px); margin: 0; text-align: center;
  font: 600 12px/1.4 var(--mono); letter-spacing: .1em; color: var(--c1); text-shadow: 0 1px 4px #000; pointer-events: none; padding: 0 16px; }
.status.is-warn { color: var(--amber); }

.left { display: grid; gap: 10px; justify-items: start; }
.modes { display: flex; padding: 4px; border-radius: 999px; background: rgba(20,22,30,.82); border: 1px solid var(--line); }
.modes button { height: 34px; padding: 0 12px; border-radius: 999px; font: 600 12px/1 var(--mono); letter-spacing: .06em; color: var(--muted); }
.modes button[aria-checked="true"] { background: #fff; color: #05060a; }
.chip--reload { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; }
.chip--reload.is-due { border-color: var(--amber); color: var(--amber); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .45; } }

.fire {
  width: 92px; height: 92px; border-radius: 50%; flex: none; position: relative;
  font: 700 13px/1 var(--mono); letter-spacing: .12em; color: #fff;
  background: radial-gradient(circle at 35% 30%, #ff6a5c, #c4160c 70%);
  box-shadow: 0 0 0 5px rgba(255,255,255,.12), 0 0 0 6px rgba(0,0,0,.6), 0 12px 30px -6px rgba(255,59,48,.65);
  transition: transform .06s, filter .2s;
}
.fire:active, .fire.is-down { transform: scale(.93); }
.stage.is-locked .fire { filter: grayscale(1) brightness(.6); }

.lock {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, calc(var(--lock-y, 26vmin))); text-align: center; pointer-events: none;
  padding: 10px 16px; border-radius: 14px; background: rgba(110,0,0,.78); border: 1px solid rgba(255,90,80,.8);
  animation: blink 1s infinite;
}
.stage.is-casualty::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 3px rgba(255,59,48,.9), inset 0 0 120px 30px rgba(255,30,20,.45);
  animation: casualty 3s ease-out forwards;
}
@keyframes casualty { 0%, 10% { opacity: 1; } 20% { opacity: .5; } 30% { opacity: 1; } 100% { opacity: 0; } }
.lock b { display: block; font: 700 14px/1.2 var(--mono); letter-spacing: .14em; color: #fff; }
.lock span { font-size: 12px; color: #ffd1cc; }

.haptic { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

@media (orientation: landscape) and (max-height: 500px) {
  .ammo b { font-size: 20px; }
  .fire { width: 76px; height: 76px; }
}
@media (prefers-reduced-motion: reduce) { .preview svg { animation: none; } }
