:root {
  --bg: #0e1116;
  --card: #171b22;
  --text: #e8eaed;
  --muted: #9aa4b2;
  --accent: #4f8cff;
  --alarm: #ff2d2d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.hidden { display: none !important; }

/* ---- red flash overlay ---- */
#flash {
  position: fixed;
  inset: 0;
  background: var(--alarm);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
}
#flash.flash-on { animation: flash 0.6s ease-out; }
@keyframes flash {
  0% { opacity: 0.75; }
  100% { opacity: 0; }
}

/* ---- join / debrief card ---- */
.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid #262b34;
  border-radius: 16px;
  padding: 32px;
  text-align: center;
}
h1 { margin: 0 0 8px; font-size: 34px; letter-spacing: -0.5px; }
.tagline { color: var(--muted); margin: 0 0 24px; }
label { display: block; text-align: left; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #2c333e;
  background: #0f1319;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 16px;
}
button {
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
button.ghost {
  width: auto;
  background: transparent;
  border: 1px solid #333b46;
  color: var(--muted);
  padding: 8px 16px;
  font-weight: 500;
}
.error { color: #ff6b6b; min-height: 20px; margin: 12px 0 0; font-size: 14px; }
.fineprint { color: #6b7482; font-size: 12px; margin: 18px 0 0; }

/* ---- live screen ---- */
#live { justify-content: space-between; padding: 0; }
.live-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
}
.clock { font-variant-numeric: tabular-nums; font-size: 20px; color: var(--muted); }
.live-center { text-align: center; }
.listening { font-size: 28px; color: var(--muted); letter-spacing: 0.5px; }
.level {
  width: 220px;
  height: 6px;
  background: #222833;
  border-radius: 3px;
  margin: 18px auto 0;
  overflow: hidden;
}
#levelBar { height: 100%; width: 0; background: var(--accent); transition: width 0.08s linear; }

.dbg {
  margin: 22px auto 0;
  width: 280px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--muted);
}
.dbg-row { display: flex; justify-content: space-between; padding: 2px 0; }
.dbg-k { color: #6b7482; }
.dbg-v { color: var(--text); font-variant-numeric: tabular-nums; }
.dbg-bar {
  position: relative;
  height: 8px;
  background: #222833;
  border-radius: 4px;
  margin-top: 8px;
  overflow: hidden;
}
#dbgFill { height: 100%; width: 0; background: var(--accent); transition: width 0.06s linear, background 0.06s linear; }
.dbg-thr {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 12px;
  background: #fff;
  opacity: 0.8;
}

#wordBanner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 60;
  font-size: clamp(40px, 9vw, 96px);
  font-weight: 800;
  letter-spacing: -1px;
  color: #fff;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  text-align: center;
}
#wordBanner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.tally {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  color: var(--muted);
}
.tally-total { font-size: 40px; font-weight: 800; color: var(--text); text-align: center; }
.tally-label { text-align: center; text-transform: uppercase; font-size: 11px; letter-spacing: 1px; margin-bottom: 12px; }
.tally-row { display: flex; justify-content: space-between; padding: 4px 0; border-top: 1px solid #20262f; }

/* ---- debrief ---- */
.debrief-card { max-width: 480px; text-align: center; }
.debrief-reason { color: var(--muted); margin-top: 0; }
.big-number { font-size: 64px; font-weight: 800; }
.big-label { color: var(--muted); margin-bottom: 20px; }
.debrief-summary { text-align: left; max-width: 260px; margin: 0 auto 20px; }
.timeline { text-align: left; list-style: none; padding: 0; max-height: 260px; overflow-y: auto; }
.timeline li { padding: 6px 0; border-top: 1px solid #20262f; font-size: 14px; }
.timeline .ts { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }
.timeline em { color: var(--muted); font-style: normal; font-size: 12px; }
h3 { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; margin: 24px 0 4px; }
