:root {
  --bg: #0b0d12;
  --fg: #e8ecf4;
  --dim: #7d8699;
  --accent: #ffcc33; /* replaced by the player's colour */
  --bad: #ff4d5e;
  --good: #3ddc84;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg);
  font: 600 16px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none;
}
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }

#start { align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
#start h1 { margin: 0; font-size: 44px; letter-spacing: 0.18em; color: var(--accent); }
#start .sub { margin: 0 0 18px; color: var(--dim); letter-spacing: 0.3em; text-transform: uppercase; font-size: 13px; }
#start .hint { color: var(--dim); font-weight: 500; font-size: 14px; }
.err { color: var(--bad); font-weight: 500; max-width: 32em; }
button {
  font: inherit; color: var(--fg); background: #1a1f2b; border: 1px solid #2c3445; border-radius: 10px;
  padding: 8px 12px; min-width: 52px;
}
button.big { font-size: 22px; padding: 18px 36px; background: var(--accent); color: #111; border: none; border-radius: 14px; }
button.on { border-color: var(--accent); color: var(--accent); }

#play { padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); }
#hud { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; position: relative; z-index: 2; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--bad); }
.dot.ok { background: var(--good); }
#player { font-size: 22px; color: var(--accent); }
.pill { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: #2a1418; color: var(--bad); letter-spacing: 0.08em; }
.pill.ok { background: #10291c; color: var(--good); }
.pill.coast { background: #2b2610; color: #ffd84d; }
#ammo { font-size: 20px; letter-spacing: 0.1em; }
#hudScore { font-size: 22px; color: var(--accent); }
body.scoped #hudScore { display: none; }

#debug { position: relative; z-index: 2; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
#proc { width: min(100%, 520px); height: auto; border-radius: 8px; background: #000; image-rendering: pixelated; }
#stats { margin: 0; font: 500 12px/1.35 ui-monospace, Menlo, Consolas, monospace; color: var(--dim); white-space: pre-wrap; }

#msg {
  position: absolute; left: 0; right: 0; bottom: 18%; text-align: center; font-size: 26px; letter-spacing: 0.08em;
  pointer-events: none; text-shadow: 0 2px 12px #000; z-index: 3;
}
#flash { position: absolute; inset: 0; background: var(--accent); opacity: 0; pointer-events: none; transition: opacity 120ms ease-out; }
#flash.fire { opacity: 0.35; transition: none; }
#flash.reload { background: #fff; }
#cam { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* scope view (shown once the game's video arrives) */
#scope, #reticle, #scopeHud { display: none; }
body.scoped #scope { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; z-index: 0; }
body.scoped #reticle {
  display: block; position: absolute; left: 50%; top: 50%; width: 38vmin; height: 38vmin; transform: translate(-50%, -50%);
  border: 2px solid rgba(0, 0, 0, 0.75); border-radius: 50%; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55); pointer-events: none; z-index: 1;
}
body.scoped #reticle::before, body.scoped #reticle::after { content: ''; position: absolute; background: var(--accent); }
body.scoped #reticle::before { left: 50%; top: 8%; bottom: 8%; width: 2px; margin-left: -1px; }
body.scoped #reticle::after { top: 50%; left: 8%; right: 8%; height: 2px; margin-top: -1px; }
body.scoped #reticle i { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #ff4d5e; }
body.scoped #scopeHud {
  display: flex; justify-content: space-between; align-items: flex-end; position: absolute; left: 16px; right: 16px; bottom: 12px;
  z-index: 2; pointer-events: none; text-shadow: 0 2px 8px #000; font-size: 34px; letter-spacing: 0.06em;
}
body.scoped #score { color: var(--accent); }
body.scoped #ammo { display: none; }

/* CAM view: the phone's own camera full screen, with the same reticle */
body.camview #cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 1; z-index: 0; }
body.camview #reticle { display: block; position: absolute; left: 50%; top: 50%; width: 22vmin; height: 22vmin; transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.7); border-radius: 50%; pointer-events: none; z-index: 1; }
body.camview #reticle i { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #ff4d5e; }
body.camview #scopeHud { display: flex; justify-content: space-between; align-items: flex-end; position: absolute; left: 16px; right: 16px; bottom: 12px;
  z-index: 2; pointer-events: none; text-shadow: 0 2px 8px #000; font-size: 34px; letter-spacing: 0.06em; }
body.camview #score { color: var(--accent); }
body.camview #ammo, body.camview #hudScore { display: none; }
/* GAME view is unzoomed: a lighter reticle without the dark scope mask */
body.scoped #reticle { width: 22vmin; height: 22vmin; box-shadow: none; border-color: rgba(255, 255, 255, 0.7); }
