:root {
  --bg: #0b1020;
  --panel: #151c33;
  --line: #27304d;
  --text: #e8ecf8;
  --muted: #8d97b5;
  --ok: #22c55e;
  --dup: #f59e0b;
  --bad: #ef4444;
  --accent: #3b82f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  max-width: 640px;
  margin-inline: auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 0 12px;
}

h1 { font-size: 18px; margin: 0; letter-spacing: 0.02em; }

.count {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.modes {
  display: flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.modes button {
  flex: 1;
  padding: 11px 6px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.modes button.active {
  background: var(--accent);
  color: #fff;
}

.stage {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

video { width: 100%; height: 100%; object-fit: cover; display: block; }

.reticle {
  position: absolute;
  inset: 22% 10%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 10px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.banner {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  background: rgba(10, 14, 28, 0.82);
  backdrop-filter: blur(4px);
}

.banner.hit { background: var(--ok); color: #04210f; }
.banner.dup { background: var(--dup); color: #2a1a00; }
.banner.miss { background: var(--bad); color: #2a0606; }

.stage.hit { outline: 4px solid var(--ok); }
.stage.dup { outline: 4px solid var(--dup); }
.stage.miss { outline: 4px solid var(--bad); }

.controls, .footer {
  display: flex;
  gap: 10px;
  margin: 12px 0;
}

.btn {
  flex: 1;
  padding: 14px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.send { background: var(--ok); border-color: var(--ok); color: #04210f; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { flex: 0 1 auto; padding-inline: 18px; }

.manual { display: flex; gap: 10px; margin-bottom: 12px; }

.manual input {
  flex: 1;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.list { list-style: none; margin: 0; padding: 0; }

.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  margin-bottom: 8px;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.list li.fresh { animation: pop 0.5s ease; }
@keyframes pop { from { background: #16351f; } to { background: var(--panel); } }

.list li .idx { color: var(--muted); font-size: 14px; min-width: 22px; }
.list li .time { margin-left: auto; color: var(--muted); font-size: 13px; letter-spacing: 0; }

.list li button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}

.status { color: var(--muted); font-size: 14px; min-height: 20px; text-align: center; }
.status.error { color: var(--bad); }
.status.good { color: var(--ok); }
