:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --ok: #22c55e;
  --bad: #ef4444;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top, #1e1b4b, var(--bg) 60%);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  min-height: 100vh;
}

.card {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .4);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h1 { margin: 0; font-size: clamp(1.4rem, 5vw, 2rem); text-align: center; }
.subtitle { margin: 6px 0 0; color: var(--muted); text-align: center; font-size: .95rem; }

.status { margin: 0; text-align: center; font-size: .85rem; color: var(--muted); }
.status.ready { color: var(--ok); }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0b1220;
  border: 2px dashed #334155;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage video, .stage img { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage video.mirror { transform: scaleX(-1); }
.placeholder { color: var(--muted); }

.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid transparent;
}
.result.mouse { background: rgba(34, 197, 94, .12); border-color: var(--ok); }
.result.not-mouse { background: rgba(239, 68, 68, .12); border-color: var(--bad); }
.result.loading { background: rgba(99, 102, 241, .12); border-color: var(--accent); }
.result-label { font-size: clamp(1.4rem, 6vw, 2rem); font-weight: 700; }
.result-confidence { color: var(--muted); font-size: .9rem; }
.result[hidden], .error[hidden], [hidden] { display: none !important; }

.error {
  background: rgba(239, 68, 68, .12);
  border: 1px solid var(--bad);
  color: #fecaca;
  border-radius: 12px;
  padding: 12px;
  font-size: .9rem;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  flex: 1 1 160px;
  padding: 14px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: #334155;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: background .15s, transform .05s;
  user-select: none;
}
.btn:hover:not(:disabled) { background: #475569; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.primary { background: var(--accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

@media (min-width: 640px) {
  body { align-items: center; padding: 32px; }
  .card { padding: 32px; }
}
