:root {
  --bg: #0b0d12;
  --panel: rgba(17, 20, 28, 0.72);
  --text: #f2f4f8;
  --muted: #8b93a7;
  --good: #22c55e;
  --bad: #ef4444;
  --idle: #64748b;
  --accent: #7c9cff;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
}
.brand { white-space: nowrap; font-weight: 700; letter-spacing: 0.2px; display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
select {
  appearance: none; background: #161a24; color: var(--text); border: 1px solid #262c3a;
  border-radius: 999px; padding: 8px 32px 8px 14px; font: inherit; font-size: 14px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}

main { flex: 1; display: flex; justify-content: center; padding: 0 16px max(16px, env(safe-area-inset-bottom)); min-height: 0; }
.stage {
  position: relative; width: 100%; max-width: 1100px; border-radius: 24px; overflow: hidden;
  background: #11141c; border: 1px solid #1d2230; aspect-ratio: 16 / 9; container-type: inline-size; max-height: 100%; margin: auto;
}
@media (max-aspect-ratio: 1/1) { .stage { aspect-ratio: auto; height: 100%; min-height: 420px; } }
video, canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

.start {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 8px;
  background: radial-gradient(ellipse at center, rgba(124, 156, 255, 0.12), transparent 60%), #0e1118; z-index: 3;
}
.start h1 { margin: 0; font-size: clamp(32px, 6vw, 56px); letter-spacing: -1px; }
.start p { margin: 0; max-width: 440px; color: var(--muted); line-height: 1.5; }
.start.hidden { display: none; }
button {
  margin-top: 16px; font: inherit; font-weight: 600; font-size: 16px; color: #0b0d12; background: var(--text);
  border: 0; border-radius: 999px; padding: 14px 28px; cursor: pointer; transition: transform .15s;
}
button:hover { transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: wait; }
.muted { font-size: 13px; }

.hud { position: absolute; top: 16px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: flex-start; z-index: 2; pointer-events: none; }
.status {
  display: flex; align-items: center; gap: 10px; padding: clamp(8px, 1.6cqw, 14px) clamp(12px, 2.6cqw, 22px); border-radius: 18px;
  font-weight: 800; font-size: clamp(15px, 4.2cqw, 34px); letter-spacing: -0.5px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: background .2s, box-shadow .2s;
}
.status::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: currentColor; }
.status.good { background: var(--panel); color: var(--good); font-size: clamp(13px, 2.6cqw, 20px); }
.status.bad { background: rgba(239, 68, 68, 0.92); color: #fff; box-shadow: 0 8px 32px rgba(239, 68, 68, .45); }
.status.idle { background: var(--panel); color: var(--muted); }
.reps {
  display: flex; flex-direction: column; align-items: center; padding: 10px 18px; border-radius: 18px;
  background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.reps { padding: 12px 24px; border: 1px solid rgba(255,255,255,.08); }
.reps span { font-size: clamp(30px, 11cqw, 104px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.reps small { color: var(--muted); text-transform: uppercase; letter-spacing: 2px; font-size: 11px; margin-top: 4px; }
.reps.bump span { animation: bump .4s ease; }
@keyframes bump { 40% { transform: scale(1.3); color: var(--good); } }

.flash {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 2; pointer-events: none; opacity: 0;
  font-size: clamp(96px, 30cqw, 320px); font-weight: 900; color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 40px rgba(34, 197, 94, .8), 0 6px 24px rgba(0,0,0,.5);
}
.flash.bump { animation: flash .9s ease-out; }
@keyframes flash { 0% { opacity: 0; transform: scale(.6); } 20% { opacity: .95; transform: scale(1); } 100% { opacity: 0; transform: scale(1.15); } }

.cue {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2;
  padding: 12px 24px; border-radius: 999px; background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-weight: 700; font-size: clamp(14px, 3.6cqw, 26px); white-space: nowrap;
}
.metrics { position: absolute; left: 16px; bottom: 24px; z-index: 2; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .metrics { bottom: 76px; } }

.controls { display: flex; align-items: center; gap: 8px; }
button.icon {
  margin: 0; padding: 0; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: #161a24; color: var(--text); border: 1px solid #262c3a;
}
button.icon svg { width: 18px; height: 18px; }
button.icon[aria-pressed="true"] { color: var(--muted); }
select.voice { max-width: 180px; text-overflow: ellipsis; }
@media (max-width: 600px) { select.voice { max-width: 104px; } .brand { font-size: 15px; } }

.demo {
  position: absolute; right: 16px; bottom: 16px; z-index: 4; margin: 0; width: clamp(96px, 16cqw, 170px);
  padding: 8px 8px 6px; border-radius: 16px; background: var(--panel);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,.06);
}
.demo svg { display: block; width: 100%; aspect-ratio: 1; }
.demo figcaption { text-align: center; font-size: clamp(9px, 1.5cqw, 11px); white-space: nowrap; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.demo .limb { fill: none; stroke: var(--good); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.demo .head { fill: var(--good); }
.demo .floor { stroke: #3a4152; stroke-width: 2; stroke-linecap: round; }
@media (max-width: 600px) { .flash {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 2; pointer-events: none; opacity: 0;
  font-size: clamp(96px, 30cqw, 320px); font-weight: 900; color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 40px rgba(34, 197, 94, .8), 0 6px 24px rgba(0,0,0,.5);
}
.flash.bump { animation: flash .9s ease-out; }
@keyframes flash { 0% { opacity: 0; transform: scale(.6); } 20% { opacity: .95; transform: scale(1); } 100% { opacity: 0; transform: scale(1.15); } }

.cue { bottom: 16px; left: 16px; transform: none; } .metrics { display: none; } }
