:root {
  --bg: #000;
  --fg: #c9d3e3;
  --dim: #5d6779;
  --accent: #ffb020;
  --card: rgba(10, 12, 16, 0.82);
  --line: rgba(160, 180, 210, 0.14);
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); font-family: "Space Grotesk", system-ui, sans-serif; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
canvas.dragging { cursor: grabbing; }

.hud { position: fixed; pointer-events: none; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--dim); }
.tl { top: 24px; left: 28px; }
.tl h1 { margin: 0; font-family: "Space Grotesk"; font-weight: 300; font-size: 34px; letter-spacing: 0.55em; color: #e8eef8; }
.tl p { margin: 6px 0 0; }
#cities { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 14px; pointer-events: auto; }
#cities a { color: var(--dim); text-decoration: none; text-transform: uppercase; letter-spacing: 0.12em; padding: 2px 0; border-bottom: 1px solid transparent; transition: color 0.15s; }
#cities a:hover { color: var(--fg); }
#cities a.on { color: #e8eef8; border-bottom-color: #ff4a2a; }
.bl { bottom: 22px; left: 28px; }
#count { color: #ff4a2a; }
.br { bottom: 22px; right: 28px; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; color: var(--dim); pointer-events: none; transition: opacity 0.6s; }
#loading.done { opacity: 0; }

/* pins */
#pins { position: fixed; inset: 0; pointer-events: none; }
.pin { position: absolute; width: 0; height: 0; pointer-events: auto; cursor: pointer; }
.pin .tip { position: absolute; left: 14px; top: -9px; white-space: nowrap; font-family: var(--mono); font-size: 11px; color: var(--fg); background: var(--card); border: 1px solid var(--line); padding: 2px 7px; border-radius: 3px; opacity: 0; transition: opacity 0.15s; pointer-events: none; }
.pin:hover .tip { opacity: 1; }

/* riot pins: molotov + danger zone */
.pin.riot .halo { position: absolute; left: 0; top: 0; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none;
  background: radial-gradient(circle, rgba(255, 60, 30, 0.32) 0%, rgba(255, 40, 20, 0.12) 55%, rgba(255, 30, 10, 0) 72%);
  box-shadow: inset 0 0 0 1px rgba(255, 70, 40, 0.35); animation: danger 2.2s ease-in-out infinite; }
.pin.riot .dot { position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: #ff4a2a; box-shadow: 0 0 10px 3px rgba(255, 74, 42, 0.8); }
.pin.riot .molotov { position: absolute; left: -19px; top: -62px; width: 38px; height: 57px; overflow: visible;
  transform-origin: 50% 100%; animation: wobble 3s ease-in-out infinite; filter: drop-shadow(0 0 6px rgba(255, 90, 20, 0.55)); }
.pin.riot:hover .molotov { filter: drop-shadow(0 0 10px rgba(255, 140, 40, 0.9)); }
.molotov .bottle { fill: rgba(150, 200, 230, 0.16); stroke: rgba(200, 230, 255, 0.7); stroke-width: 1.1; }
.molotov .liquid { fill: #ff8a1f; opacity: 0.85; }
.molotov .rag { fill: #e8d7b8; }
.molotov .flame { transform-origin: 16px 19px; animation: flicker 0.18s ease-in-out infinite alternate; }
.molotov .f1 { fill: #ff5a14; }
.molotov .f2 { fill: #ffb92e; }
.molotov .f3 { fill: #fff3b0; }
.molotov .f2 { transform-origin: 16px 19px; animation: flicker2 0.27s ease-in-out infinite alternate; }
.molotov .ember { fill: #ffb347; animation: ember 1.6s ease-out infinite; }
.molotov .ember.e2 { animation-delay: 0.55s; }
.molotov .ember.e3 { animation-delay: 1.1s; }
.pin.riot .tip { left: 22px; top: -48px; border-color: rgba(255, 70, 40, 0.4); }
@keyframes flicker { from { transform: scale(1, 1) skewX(-3deg); } to { transform: scale(0.92, 1.12) skewX(4deg); } }
@keyframes flicker2 { from { transform: scale(1.05, 0.9) skewX(5deg); } to { transform: scale(0.9, 1.1) skewX(-4deg); } }
@keyframes wobble { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes ember { from { transform: translate(0, 0); opacity: 1; } to { transform: translate(var(--dx, 3px), -16px); opacity: 0; } }
@keyframes danger { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
#player[hidden], [hidden] { display: none !important; }
.label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--accent); }
.err { font-family: var(--mono); font-size: 11px; color: #ff6a4a; }
.err:empty { display: none; }
.loc { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.zone { position: relative; display: grid; place-items: center; height: 170px; border: 1px dashed rgba(160, 180, 210, 0.3); border-radius: 8px; cursor: pointer; overflow: hidden; font-size: 13px; color: var(--dim); transition: border-color 0.15s, background 0.15s; }
.zone:hover, .zone.over { border-color: var(--accent); background: rgba(255, 176, 32, 0.05); }
.zone video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--dim); }
.field input, .field select { background: transparent; border: none; border-bottom: 1px solid var(--line); color: var(--fg); font: inherit; font-size: 14px; padding: 6px 0; outline: none; border-radius: 0; }
.field select { background: #0a0c10; }
.field input:focus, .field select:focus { border-color: var(--accent); }
.row { display: flex; justify-content: flex-end; gap: 8px; }
button { font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #000; cursor: pointer; }
button:disabled { opacity: 0.3; cursor: default; }
button.ghost { background: transparent; color: var(--dim); border-color: var(--line); }
button.ghost:hover { color: var(--fg); }

#player { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.6); padding: 16px; animation: fade 0.2s; }
#player .card { width: min(720px, 100%); overflow: hidden; }
#player video { display: block; width: 100%; max-height: 70vh; background: #000; }
#player .meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; }
#pcaption { font-size: 15px; margin-bottom: 4px; }

@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

@media (max-width: 600px) {
  .tl { top: 16px; left: 16px; }
  .tl h1 { font-size: 24px; }
  .bl { left: 16px; bottom: 16px; }
  .br { right: 16px; bottom: 16px; }
}

/* admin page */
body.page { height: auto; min-height: 100%; overflow: auto; }
.admin { max-width: 560px; margin: 0 auto; padding: 32px 16px 64px; display: flex; flex-direction: column; gap: 16px; }
.admin-head { display: flex; justify-content: space-between; align-items: baseline; }
.admin-head h1 { margin: 0; font-weight: 300; font-size: 28px; letter-spacing: 0.5em; color: #e8eef8; }
.admin-head a { text-decoration: none; }
#app { display: flex; flex-direction: column; gap: 16px; }
.stack { padding: 18px; display: flex; flex-direction: column; gap: 14px; animation: rise 0.25s ease-out; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row.spread { justify-content: space-between; align-items: center; }
.ok { font-family: var(--mono); font-size: 11px; color: #7fd18b; }
.ok:empty { display: none; }
.reports { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.reports li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.reports li:first-child { border-top: none; }
.r-title { font-size: 14px; margin-bottom: 2px; }
@media (max-width: 600px) { .two { grid-template-columns: 1fr; } }
