/* RallyPoint Live — viewer styles */
:root {
  --bg: #0b1220;
  --bg-elev: #131b2e;
  --text: #f5f7fb;
  --text-muted: #9aa5b8;
  --accent: #ff3b55;
  --ok: #34d399;
  --warn: #fbbf24;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── Top bar ───────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.8);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.brand-name { font-weight: 700; letter-spacing: 0.02em; }
.brand-tag {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-elev);
  border: 1px solid var(--border);
}

.status-chip .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
}

.status-chip[data-state="live"] .dot { background: var(--ok); animation: pulse 1.6s infinite; }
.status-chip[data-state="reconnecting"] .dot { background: var(--warn); animation: pulse 1s infinite; }
.status-chip[data-state="ended"] .dot { background: var(--text-muted); }
.status-chip[data-state="error"] .dot { background: var(--accent); }
.status-chip[data-state="loading"] .dot { background: var(--warn); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ─── Main ──────────────────────────────────────────────── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 96px;
}

.state-card {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin: 40px auto;
}

.state-card h2 { margin: 0 0 8px; font-size: 22px; }
.state-card p { color: var(--text-muted); margin: 0 0 20px; }

.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.cta {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}

/* ─── Scoreboard ────────────────────────────────────────── */
.scoreboard {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px 16px;
  box-shadow: var(--shadow);
}

.match-meta {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.pill-accent { background: rgba(255, 59, 85, 0.15); color: var(--accent); }

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

.team { text-align: center; padding: 8px; }

.team-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 28px;
}

.color-swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.team-name {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fixed-height row keeps the score from jumping when serve switches sides. */
.serve-row {
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.serve-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.14);
  color: var(--warn);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.2s;
}
.serve-indicator.active { opacity: 1; }
.serve-indicator .serve-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.8);
  animation: pulse 1.4s infinite;
}

.score {
  font-size: 80px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s ease-out, color 0.15s;
}
.score.bump { transform: scale(1.15); color: var(--accent); }

.sets-won {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 13px;
}
.sets-won strong { color: var(--text); font-weight: 700; }

.timeouts {
  margin-top: 10px;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
}
.timeouts .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-muted);
}
.timeouts .dots {
  display: inline-flex;
  gap: 8px;
}
.timeouts .to-circle {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  background: transparent;
  overflow: hidden;
}
.timeouts .to-circle.used {
  border-color: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.35);
}
.timeouts .to-circle.used::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  top: 50%;
  height: 2.5px;
  background: rgba(255, 60, 60, 0.9);
  transform: translateY(-50%) rotate(-45deg);
  border-radius: 2px;
}

.divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.vs { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; }
.set-label { font-size: 14px; font-weight: 600; color: var(--text); }

/* ─── Set-by-set breakdown ──────────────────────────────── */
.set-breakdown {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.set-pill {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 2px;
  min-width: 52px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.set-pill .label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.set-pill .a, .set-pill .b { font-weight: 700; font-size: 15px; }
.set-pill.current { outline: 2px solid var(--accent); }
.set-pill .a.winner, .set-pill .b.winner { color: var(--ok); }

.winner-banner {
  margin-top: 18px;
  padding: 14px;
  text-align: center;
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.15), rgba(52, 211, 153, 0.05));
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 12px;
  font-weight: 800;
  font-size: 16px;
  color: var(--ok);
}

/* ─── Scorer presence banner ────────────────────────────── */
.scorer-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(245, 158, 11, 0.06));
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--warn);
}
.scorer-banner .banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  animation: pulse 1s infinite;
}
.scorer-banner.hidden { display: none; }

/* ─── Footer ────────────────────────────────────────────── */
.footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(11, 18, 32, 0.92);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.viewer-count::before { content: "👀 "; }
.session-code { font-family: "SF Mono", Menlo, Consolas, monospace; font-weight: 700; color: var(--text); }
.watermark { text-align: right; }

/* ─── Small screens ─────────────────────────────────────── */
@media (max-width: 480px) {
  .score { font-size: 64px; }
  .team-name { font-size: 13px; max-width: 120px; }
  .watermark { display: none; }
}
