/* RallyPoint Live — viewer styles */
:root {
  --bg: #f9fafb;
  --bg-elev: #ffffff;
  --text: #1c1c1e;
  --text-muted: #6b7280;
  --accent: #ef4444;
  --ok: #10b981;
  --warn: #f59e0b;
  --border: #e5e7eb;
  --input-bg: #f3f4f6;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

* {
  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: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

.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(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.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='final'] .dot {
  background: var(--ok);
}
.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: var(--input-bg);
  color: var(--text-muted);
}

.pill-accent {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent);
}

.teams {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
}
/* Thin divider between the two colored halves. */
.teams .team-a {
  border-right: 1px solid rgba(255, 255, 255, 0.35);
}

.team {
  text-align: center;
  padding: 18px 14px 16px;
  /* Background color set inline by JS to the team color. */
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

.team-name {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  max-width: 100%;
  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: 6px 0 4px;
}

.serve-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.2s;
  text-shadow: none;
}
.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: 84px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s ease-out;
}
.score.bump {
  transform: scale(1.15);
}

.sets-won {
  margin-top: 6px;
  opacity: 0.85;
  font-size: 13px;
  font-weight: 600;
}
.sets-won strong {
  font-weight: 800;
}

.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;
  opacity: 0.8;
}
.timeouts .dots {
  display: inline-flex;
  gap: 8px;
}
.timeouts .to-circle {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  background: transparent;
  overflow: hidden;
}
.timeouts .to-circle.used {
  opacity: 0.45;
}
.timeouts .to-circle.used::after {
  content: '';
  position: absolute;
  left: -4px;
  right: -4px;
  top: 50%;
  height: 2.5px;
  background: rgba(255, 60, 60, 0.95);
  transform: translateY(-50%) rotate(-45deg);
  border-radius: 2px;
}

/* Set indicator pill, centered over the divider between team panels. */
.set-indicator-pill {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: #ffffff;
  color: #0b1220;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  text-shadow: none;
  z-index: 2;
}

/* ─── 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: var(--input-bg);
  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);
}

/* ─── 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: var(--bg-elev);
  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: 68px;
  }
  .team {
    padding: 14px 8px;
  }
  .team-name {
    font-size: 14px;
  }
  .set-indicator-pill {
    font-size: 10px;
    padding: 3px 9px;
  }
  .watermark {
    display: none;
  }
}

/* --- Landing (no session code in URL) --------------------- */
/* Self-contained dark/teal theme matching the marketing site. */
.landing {
  --landing-bg: #061816;
  --landing-bg-elev: #0e2624;
  --landing-teal: #1e797a;
  --landing-teal-bright: #2bcec0;
  --landing-text: #f5f7f3;
  --landing-text-muted: #8aa0a0;
  --landing-text-dim: #5c7474;
  --landing-border: rgba(255, 255, 255, 0.08);
  --landing-border-strong: rgba(255, 255, 255, 0.14);

  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  background: var(--landing-bg);
  color: var(--landing-text);
  font-family:
    'Manrope',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    sans-serif;
  display: grid;
  place-items: center;
  overflow-y: auto;
  z-index: 5;
}

.landing::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 80% 0%, rgba(43, 206, 192, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 0% 30%, rgba(30, 121, 122, 0.1), transparent 60%);
  pointer-events: none;
}

.landing-inner {
  position: relative;
  width: 100%;
  max-width: 560px;
  padding: 56px 28px;
  text-align: center;
}

.landing-eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid var(--landing-border-strong);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--landing-teal-bright);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 24px;
  background: rgba(43, 206, 192, 0.05);
}

.landing-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: clamp(34px, 6vw, 52px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0 0 14px;
  color: var(--landing-text);
}

.landing-sub {
  color: var(--landing-text-muted);
  font-size: 16px;
  margin: 0 0 32px;
  line-height: 1.5;
}

.code-form {
  margin: 0 auto 28px;
  text-align: left;
  max-width: 440px;
}

.code-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--landing-text-dim);
  margin-bottom: 10px;
}

.code-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.code-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 14px 16px;
  font-size: 18px;
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--landing-text);
  background: var(--landing-bg-elev);
  border: 1px solid var(--landing-border-strong);
  border-radius: 12px;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.code-input::placeholder {
  color: var(--landing-text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.code-input:focus {
  border-color: var(--landing-teal-bright);
  box-shadow: 0 0 0 3px rgba(43, 206, 192, 0.18);
}
.code-input.invalid {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18);
}

.code-btn {
  padding: 14px 22px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-family: 'Manrope', sans-serif;
  color: #061816;
  background: var(--landing-teal-bright);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.05s;
  white-space: nowrap;
}
.code-btn:hover {
  background: #4be0d3;
}
.code-btn:active {
  transform: scale(0.98);
}
.code-btn:focus-visible {
  outline: 2px solid var(--landing-text);
  outline-offset: 2px;
}

.code-error {
  margin: 10px 2px 0;
  font-size: 13px;
  color: #f87171;
  min-height: 18px;
}

.landing-help {
  color: var(--landing-text-muted);
  font-size: 14px;
  margin: 0;
}
.landing-help a {
  color: var(--landing-teal-bright);
  text-decoration: none;
  border-bottom: 1px solid rgba(43, 206, 192, 0.3);
  transition:
    border-color 0.2s,
    color 0.2s;
}
.landing-help a:hover {
  color: var(--landing-text);
  border-bottom-color: var(--landing-text);
}

@media (max-width: 480px) {
  .landing-inner {
    padding: 40px 20px;
  }
  .code-row {
    flex-direction: column;
  }
  .code-btn {
    width: 100%;
  }
}
