/* 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; }

/* ───────── Title screen ───────── */
/* A night arena: deep navy sky, a grid floor running toward the horizon, a slowly turning scope
   emblem behind the wordmark, and the two modes as chamfered HUD panels. */
.title {
  --display: "Michroma", "Eurostile", "Bank Gothic", var(--font);
  --ink: #04060c; --panel: rgba(9,13,24,.86); --edge: rgba(124,247,255,.22); --edge2: rgba(255,122,217,.26);
  position: relative; isolation: isolate; overflow: hidden; min-height: 100svh;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto auto auto; justify-items: center; gap: 26px;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--ink);
}
.title__sky {
  position: absolute; inset: 0; z-index: -3;
  background:
    radial-gradient(70% 22% at 50% 58%, rgba(124,247,255,.16), transparent 70%),
    radial-gradient(55% 40% at 50% 34%, rgba(90,124,255,.14), transparent 70%),
    radial-gradient(35% 28% at 86% 8%, rgba(255,122,217,.10), transparent 70%),
    linear-gradient(#070b18, var(--ink) 62%);
}
.title__floor {
  position: absolute; left: -60%; right: -60%; top: 58%; height: 70%; z-index: -2;
  background-image: linear-gradient(rgba(124,247,255,.24) 1px, transparent 1px), linear-gradient(90deg, rgba(124,247,255,.16) 1px, transparent 1px);
  background-size: 64px 64px;
  transform: perspective(380px) rotateX(64deg); transform-origin: 50% 0;
  -webkit-mask-image: linear-gradient(transparent, #000 25%, #000 60%, transparent);
  mask-image: linear-gradient(transparent, #000 25%, #000 60%, transparent);
  animation: floor 2.8s linear infinite;
}
@keyframes floor { to { background-position: 0 64px, 0 0; } }
.title__scan {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.022) 0 1px, transparent 1px 3px);
}
.title__scan::after {
  content: ""; position: absolute; left: 0; right: 0; height: 120px; top: -120px;
  background: linear-gradient(transparent, rgba(124,247,255,.06), transparent);
  animation: sweep 7s linear infinite;
}
@keyframes sweep { to { transform: translateY(calc(100svh + 120px)); } }

.title__top { width: 100%; display: flex; justify-content: space-between; align-items: center; font: 600 11px/1 var(--mono); letter-spacing: .16em; color: var(--muted); }
.title__back { color: var(--muted); text-decoration: none; text-transform: uppercase; }
.title__back:hover, .title__back:focus-visible { color: var(--text); }

.title__hero { position: relative; align-self: center; display: grid; justify-items: center; text-align: center; padding-block: 24px; animation: rise .9s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.emblem { position: absolute; left: 50%; top: 50%; z-index: -1; width: min(88vw, 440px); aspect-ratio: 1; transform: translate(-50%, -52%); pointer-events: none; }
.emblem svg { width: 100%; height: 100%; overflow: visible; }
.emblem__ring { fill: none; transform-box: fill-box; transform-origin: center; }
.emblem__ring--outer { stroke: rgba(124,247,255,.22); stroke-width: .8; stroke-dasharray: 160 18 8 18; animation: spin 48s linear infinite; }
.emblem__ring--ticks { stroke: rgba(124,247,255,.35); stroke-width: 5; stroke-dasharray: .7 9.56; animation: spin 90s linear infinite reverse; }
.emblem__ring--inner { stroke: rgba(255,122,217,.28); stroke-width: .8; stroke-dasharray: 2 6; animation: spin 30s linear infinite; }
.emblem__corners { fill: none; stroke: rgba(124,247,255,.4); stroke-width: 1.2; }
.emblem__reticle { opacity: .55; }
@keyframes spin { to { transform: rotate(360deg); } }

.title__brand { margin: 0; padding-left: .7em; font: 400 12px/1 var(--display); letter-spacing: .7em; color: #b8c3dc; }
.title__name {
  margin: 10px 0 0; padding-left: .1em; font: 400 clamp(96px, 30vw, 176px)/.92 var(--display); letter-spacing: .1em;
  background: linear-gradient(180deg, #fff 18%, #a8efff 58%, #5b7dff); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 28px rgba(124,247,255,.35));
}
.title__sub { margin: 16px 0 0; padding-left: .42em; font: 600 12px/1 var(--mono); letter-spacing: .42em; color: var(--c1); }
.title__tag { margin: 12px 0 0; font-size: 15px; color: var(--muted); text-wrap: balance; }

.picks { width: min(780px, 100%); display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; animation: rise .9s .15s cubic-bezier(.2,.7,.2,1) both; }
.pick {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-content: start; padding: 20px 20px 22px;
  background: linear-gradient(180deg, rgba(124,247,255,.06), transparent 40%), var(--panel);
  border: 1px solid var(--edge);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
.pick[hidden] { display: none; }
.pick--demo { grid-column: 1 / -1; background: linear-gradient(180deg, rgba(139,123,255,.08), transparent 40%), var(--panel); }
.pick--demo .pick__idx { color: var(--c2); }
.pick--demo .pick__go { background: var(--c2); }
.pick--duel { border-color: var(--edge2); background: linear-gradient(180deg, rgba(255,122,217,.06), transparent 40%), var(--panel); }
.pick__idx { margin: 0; font: 600 11px/1 var(--mono); letter-spacing: .22em; color: var(--c1); }
.pick--duel .pick__idx { color: var(--c3); }
.pick__name { margin: 0; font: 400 22px/1.2 var(--display); letter-spacing: .08em; text-transform: uppercase; }
.pick__desc { margin: 0 0 4px; font-size: 14px; color: var(--muted); }
.pick__go {
  height: 48px; padding: 0 22px; font: 700 13px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink);
  background: var(--c1); clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  transition: filter .15s, transform .06s;
}
.pick--duel .pick__go { background: var(--c3); }
.pick__go:hover, .pick__go:focus-visible { filter: brightness(1.15); }
.pick__go:focus-visible, .join__go:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.pick__go:active { transform: scale(.98); }
.pick button[disabled] { opacity: .5; cursor: progress; }
.pick__row { display: flex; flex-wrap: wrap; gap: 10px; }
.join { flex: 1 1 170px; display: flex; height: 48px; border: 1px solid var(--edge2); }
.join:focus-within { border-color: var(--c3); }
.join__code {
  flex: 1; min-width: 0; width: 0; padding: 0 10px; border: 0; background: transparent; color: var(--text); /* width 0: no 20-character default */
  font: 700 15px/1 var(--mono); letter-spacing: .32em; text-transform: uppercase; text-align: center;
}
.join__code:focus { outline: none; }
.join__code::placeholder { color: rgba(154,163,184,.55); }
.join__go { padding: 0 16px; border-left: 1px solid var(--edge2); font: 700 12px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--c3); }

/* Radio voice: two chamfered segmented switches */
.radio-opt { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 14px; animation: rise .9s .25s cubic-bezier(.2,.7,.2,1) both; }
.radio-opt__label { font: 600 11px/1 var(--mono); letter-spacing: .22em; color: var(--muted); }
.seg {
  display: flex; padding: 3px; gap: 2px; background: var(--panel); border: 1px solid var(--edge);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.seg button { height: 34px; padding: 0 14px; font: 700 12px/1 var(--mono); letter-spacing: .12em; color: var(--muted); transition: color .15s, background .15s; }
.seg button[aria-pressed="true"] { color: var(--ink); background: var(--c1); }
.seg button:focus-visible { outline: 1px solid #fff; outline-offset: -2px; }
.seg button[disabled] { opacity: .5; }
@media (prefers-reduced-motion: reduce) { .radio-opt { animation: none; } }

.error { margin: 0; text-align: center; font-size: 14px; color: #ff9aa9; min-height: 1em; }
.title__foot { width: min(780px, 100%); display: grid; gap: 10px; justify-items: center; text-align: center; }
.needs { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.needs li { padding: 7px 10px; border: 1px solid var(--line); font: 600 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.title__note { margin: 0; max-width: 62ch; font-size: 12.5px; color: var(--muted); }
.title__debug { font: 600 11px/1 var(--mono); color: var(--muted); text-decoration: underline; }
@media (max-height: 640px) { .title__name { font-size: clamp(72px, 20vh, 120px); } .title__hero { padding-block: 8px; } }
@media (prefers-reduced-motion: reduce) {
  .title__floor, .title__scan::after, .emblem__ring, .title__hero, .picks { animation: none; }
}

/* ───────── 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; min-width: 0; }

/* Fire-mode selector: a chamfered HUD switch. Each mode shows its burst as bullet glyphs; a lit bar slides under the choice. */
.firemode {
  --i: 0; --w: 58px; position: relative; display: grid; gap: 6px; padding: 7px 6px 9px;
  background: linear-gradient(180deg, rgba(124,247,255,.07), transparent 60%), rgba(6,10,20,.8);
  border: 1px solid rgba(124,247,255,.28);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}
.firemode__label { padding-left: 4px; font: 600 8.5px/1 var(--mono); letter-spacing: .26em; color: rgba(124,247,255,.6); }
.firemode__opts { display: grid; grid-template-columns: repeat(3, var(--w)); }
.firemode button { display: grid; justify-items: center; gap: 6px; padding: 4px 0 3px; font: 700 10.5px/1 var(--mono); letter-spacing: .1em; color: var(--muted); transition: color .15s, text-shadow .15s; }
.firemode button[aria-checked="true"] { color: var(--c1); text-shadow: 0 0 8px rgba(124,247,255,.65); }
.firemode button:focus-visible { outline: 1px solid var(--c1); outline-offset: -1px; }
.rounds { display: flex; align-items: flex-end; gap: 2px; height: 13px; }
.rounds b { width: 4px; height: 13px; background: currentColor; clip-path: polygon(50% 0, 100% 30%, 100% 100%, 0 100%, 0 30%); } /* a round, tip up */
.rounds--belt { gap: 1px; }
.rounds--belt b { width: 3px; height: 11px; }
.firemode button[aria-checked="true"] .rounds b { filter: drop-shadow(0 0 3px rgba(124,247,255,.9)); }
.firemode__bar {
  position: absolute; left: 6px; bottom: 4px; width: var(--w); height: 2px; background: var(--c1); box-shadow: 0 0 8px var(--c1);
  transform: translateX(calc(var(--i) * var(--w))); transition: transform .22s cubic-bezier(.2,.7,.2,1);
}
@media (prefers-reduced-motion: reduce) { .firemode__bar { transition: none; } }
.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; }

/* ───────── Duel ───────── */
.duel { position: absolute; left: 0; right: 0; top: calc(max(14px, env(safe-area-inset-top)) + 72px); padding: 0 16px;
  display: grid; justify-items: center; gap: 10px; pointer-events: none; }
.duel__bar { width: min(420px, 100%); display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: end; font-family: var(--mono); }
.hp { display: grid; gap: 4px; }
.hp small { font-size: 11px; letter-spacing: .1em; color: var(--muted); text-shadow: 0 1px 4px #000; }
.hp--op { justify-items: end; }
.hp i { display: flex; width: 100%; height: 8px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.14); }
.hp b { width: 100%; height: 100%; background: var(--c1); transition: width .25s; }
.hp--op i { justify-content: flex-end; }
.hp--op b { background: var(--c3); }
.duel__score { font-size: 18px; text-shadow: 0 1px 4px #000; }
.duel__net { margin-top: -4px; font: 600 10px/1 var(--mono); letter-spacing: .1em; color: var(--muted); text-shadow: 0 1px 4px #000; }
.duel__net.is-p2p { color: var(--c1); }
.duel__msg { margin: 0; max-width: 420px; text-align: center; font: 700 13px/1.4 var(--mono); letter-spacing: .08em; color: #fff; text-shadow: 0 1px 4px #000; }
.duel__msg.is-warn { color: var(--amber); }

.posture {
  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(60,40,0,.8); border: 1px solid var(--amber); max-width: calc(100% - 32px);
}
.posture b { display: block; font: 700 14px/1.2 var(--mono); letter-spacing: .14em; color: var(--amber); }
.posture span { font-size: 12px; color: #ffe3b8; }

.register {
  position: absolute; left: 50%; bottom: calc(max(18px, env(safe-area-inset-bottom)) + 112px); transform: translateX(-50%);
  height: 48px; padding: 0 26px; border-radius: 999px; font: 700 14px/1 var(--mono); letter-spacing: .14em; color: #05060a;
  background: linear-gradient(100deg, var(--c1), var(--c2)); box-shadow: 0 10px 30px -10px rgba(124,247,255,.7);
}
.register:active { transform: translateX(-50%) scale(.96); }

/* ?diag readout */
.diag {
  position: absolute; left: max(8px, env(safe-area-inset-left)); top: calc(max(14px, env(safe-area-inset-top)) + 150px); z-index: 5; margin: 0;
  max-width: calc(100% - 16px); padding: 6px 8px; background: rgba(0,0,0,.62); border: 1px solid rgba(124,247,255,.3);
  font: 600 10px/1.45 var(--mono); color: var(--c1); white-space: pre-wrap; pointer-events: none;
}

.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; }
}

/* No image dragging or long-press save menus on visuals */
img, svg, canvas, video { -webkit-user-drag: none; -webkit-touch-callout: none; }
