:root {
  --bg: #0d0f12;
  --panel: #161a20;
  --panel-2: #1e232b;
  --line: #2a313b;
  --text: #f2f4f7;
  --muted: #8b95a3;
  --signal: #c6f432;      /* field-readable lime */
  --signal-ink: #10140a;
  --danger: #ff4d4f;
  --warn: #ffb020;
  --ok: #3ddc84;
  --team: #3b82f6;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.boot { height: 100vh; display: grid; place-items: center; font-weight: 900; letter-spacing: .3em; color: var(--muted); }

/* ---------- Login ---------- */
.login { min-height: 100vh; padding: calc(40px + var(--safe-top)) 24px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 22px; max-width: 460px; margin: 0 auto; }
.wordmark { font-weight: 900; font-size: 44px; letter-spacing: .08em; line-height: 1; }
.wordmark span { color: var(--signal); }
.login h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.code-input { width: 100%; font-family: var(--mono); font-size: 40px; letter-spacing: .35em; text-align: center; padding: 18px 8px; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); outline: none; }
.code-input:focus { border-color: var(--signal); }
.consent { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; font-size: 14px; line-height: 1.45; color: #c9d0d9; }
.consent label { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; color: var(--text); font-weight: 600; }
.consent input { width: 22px; height: 22px; accent-color: var(--signal); flex: none; margin: 0; }
.hint { background: #1d1a0e; border: 1px solid #4a4012; color: #ffe08a; border-radius: var(--radius); padding: 12px 14px; font-size: 14px; line-height: 1.45; }
.error { color: var(--danger); font-weight: 600; min-height: 1.2em; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: var(--radius); padding: 16px 18px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; background: var(--panel-2); cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--signal); color: var(--signal-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; padding: calc(10px + var(--safe-top)) 16px 10px; display: flex; align-items: center; gap: 10px; background: rgba(13,15,18,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 900; letter-spacing: .1em; font-size: 15px; }
.topbar .brand span { color: var(--signal); }
.team-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: var(--panel-2); }
.team-chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--team); display: inline-block; }
.conn { margin-left: auto; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 3px rgba(255,77,79,.2); }
.conn.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(61,220,132,.18); }
main { flex: 1; padding: 16px 16px calc(96px + var(--safe-bottom)); max-width: 640px; width: 100%; margin: 0 auto; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(13,15,18,.96); border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom); }
.tabs button { background: none; border: 0; padding: 12px 4px 10px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tabs button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--signal); }

/* ---------- Cards ---------- */
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.title { font-size: 30px; font-weight: 900; line-height: 1.05; margin: 0 0 14px; letter-spacing: -.01em; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat { font-family: var(--mono); font-size: 34px; font-weight: 800; }
.big-status { text-align: center; padding: 26px 16px; border-radius: var(--radius); font-weight: 900; font-size: 28px; letter-spacing: .04em; margin-bottom: 14px; }
.big-status small { display: block; font-size: 14px; font-weight: 600; letter-spacing: 0; margin-top: 8px; opacity: .85; }
.big-status.wanted { background: var(--danger); color: #fff; }
.big-status.hunting { background: var(--signal); color: var(--signal-ink); }
.big-status.caught { background: var(--panel-2); color: var(--muted); border: 1px dashed var(--line); }
.big-status.wait { background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 20px; }

.capture-code { font-family: var(--mono); font-size: 64px; font-weight: 800; letter-spacing: .25em; text-align: center; padding: 18px 0 18px .25em; background: #fff; color: #000; border-radius: var(--radius); margin: 10px 0; }
.timers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.timer { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.timer b { display: block; font-family: var(--mono); font-size: 26px; margin-top: 2px; }
.timer.alert b { color: var(--warn); }

.tracking-banner { display: flex; gap: 10px; align-items: center; background: #14240a; border: 1px solid #3c5c12; color: #d9f99d; border-radius: var(--radius); padding: 12px 14px; font-size: 14px; line-height: 1.35; margin-bottom: 14px; }
.tracking-banner.bad { background: #2a0f10; border-color: #6b1d20; color: #ffc9ca; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--signal); flex: none; animation: pulse 1.6s infinite; }
.tracking-banner.bad .pulse { background: var(--danger); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(198,244,50,.6); } 100% { box-shadow: 0 0 0 12px rgba(198,244,50,0); } }

.code-entry { display: flex; gap: 10px; }
.code-entry input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 34px; letter-spacing: .3em; text-align: center; padding: 12px 6px; background: var(--bg); border: 2px solid var(--line); border-radius: var(--radius); outline: none; }
.code-entry input:focus { border-color: var(--signal); }

.map { position: relative; z-index: 0; isolation: isolate; height: 320px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #222; }
.leaflet-container { font-family: var(--sans); }
.ping-label { display: inline-block; transform: translate(-50%, -130%); background: var(--danger); color: #fff; font-weight: 800; font-size: 12px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; border: 2px solid #fff; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; margin-right: 8px; }
.dot.on { background: var(--ok); }
.pill { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.pill.ok { background: rgba(61,220,132,.16); color: var(--ok); }
.pill.warn { background: rgba(255,176,32,.16); color: var(--warn); }
.pill.bad { background: rgba(255,77,79,.16); color: var(--danger); }

.score-row { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.score-row:last-child { border-bottom: 0; }
.score-row .place { font-family: var(--mono); font-weight: 800; font-size: 20px; color: var(--muted); }
.score-row .name { font-weight: 800; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.score-row .name i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.score-row .pts { font-family: var(--mono); font-weight: 800; font-size: 24px; }
.score-row.mine .name { color: var(--signal); }

.challenge { border-left: 4px solid var(--signal); }
.challenge.closed { border-left-color: var(--line); opacity: .75; }
.challenge .task { font-size: 20px; font-weight: 800; line-height: 1.25; margin: 4px 0 12px; }
.sub-list { margin: 10px 0 0; font-size: 14px; }
.sub-list li { padding: 8px 0; }

.setting { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--panel-2); border-radius: 999px; border: 1px solid var(--line); transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--signal); border-color: var(--signal); }
.switch input:checked + span::after { transform: translateX(22px); background: var(--signal-ink); }

.message { background: #0f1d2e; border: 1px solid #1f3a5c; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; font-size: 15px; }
.message small { display: block; color: var(--muted); margin-top: 4px; font-size: 12px; }

/* ---------- Overlay / Camera ---------- */
#overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.86); display: flex; align-items: center; justify-content: center; padding: 24px; }
.ov-card { width: 100%; max-width: 420px; text-align: center; padding: 30px 22px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }
.ov-card .ov-title { font-size: 32px; font-weight: 900; line-height: 1.05; margin: 8px 0 12px; }
.ov-card.good { background: var(--signal); color: var(--signal-ink); border: 0; }
.ov-card.bad { background: var(--danger); color: #fff; border: 0; }
.ov-card p { font-size: 16px; line-height: 1.4; margin: 0 0 22px; }
.ov-card .btn { width: 100%; }
.ov-card.good .btn { background: var(--signal-ink); color: var(--signal); }
.ov-card.bad .btn { background: #fff; color: var(--danger); }

.camera { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.camera .cam-top { padding: calc(12px + var(--safe-top)) 16px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #fff; }
.camera .cam-top .task { font-weight: 700; font-size: 14px; opacity: .9; }
.camera .stage { flex: 1; position: relative; overflow: hidden; }
.camera video, .camera img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.camera .cam-bottom { padding: 18px 16px calc(22px + var(--safe-bottom)); display: flex; align-items: center; justify-content: center; gap: 12px; }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: transparent; padding: 0; display: grid; place-items: center; }
.shutter::after { content: ""; width: 60px; height: 60px; border-radius: 50%; background: #fff; transition: transform .1s; }
.shutter:active::after { transform: scale(.88); }
.camera .cam-bottom .btn { flex: 1; }
.cam-close { background: rgba(255,255,255,.15); border: 0; color: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 700; }

#toasts { position: fixed; left: 12px; right: 12px; top: calc(64px + var(--safe-top)); z-index: 70; display: flex; flex-direction: column; gap: 8px; pointer-events: none; align-items: center; }
.toast { max-width: 480px; width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--signal); padding: 12px 14px; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: tin .2s ease-out; }
.toast.bad { border-left-color: var(--danger); }
@keyframes tin { from { transform: translateY(-8px); opacity: 0; } }

.maint { background: var(--warn); color: #000; text-align: center; font-weight: 800; padding: 8px; font-size: 14px; }
