/* VBallScore — shared styles. Mobile-first, big touch targets, no frameworks. */

:root {
  --bg: #0a1f3a;
  --fg: #fff;
  --gold: #f5a623;
  --blue: #3567c7;
  --orange: #e58a2b;
  --error: #ff5252;
  --chrome: rgba(0, 0, 0, 0.35);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  border: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

/* ===== SPLASH ===== */
body.splash {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1rem;
}
body.splash main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 30rem;
}
.wordmark {
  font-size: clamp(2.5rem, 12vw, 5rem);
  margin: 0;
  letter-spacing: -0.02em;
  font-weight: 900;
}
.tagline {
  font-size: clamp(1rem, 3vw, 1.25rem);
  opacity: 0.75;
  margin: 0 0 1rem;
}
.cta {
  font-size: 1.25rem;
  font-weight: 700;
  padding: 1rem 2.5rem;
  border-radius: 999px;
  background: var(--gold);
  color: #1a1a1a;
  min-width: 14rem;
  transition: transform 0.1s ease, opacity 0.2s ease;
}
.cta:active { transform: scale(0.97); }
.cta:disabled { opacity: 0.5; cursor: wait; }
.error {
  color: var(--error);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

/* ===== MATCH HEADER ===== */
body.match {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  overflow: hidden;
}
.match-header {
  background: var(--chrome);
  padding: 0.5rem 1rem;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
}
.match-header .back {
  color: var(--fg);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
}
.match-header .match-id {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
  opacity: 0.7;
  text-align: center;
}
.match-header .presence {
  font-size: 0.85rem;
  opacity: 0.85;
}
.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  color: var(--fg);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.3); }

/* ===== SCOREBOARD (two color blocks) ===== */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  overflow: hidden;
}
.team {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-width: 0;
  padding: 1rem;
  text-align: center;
}
.team-a { background: var(--orange); }
.team-b { background: var(--blue); }

.team-name {
  margin: 0;
  font-size: clamp(1rem, 4vw, 1.75rem);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}
.score {
  font-size: clamp(8rem, 35vw, 18rem);
  font-weight: 900;
  line-height: 0.9;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}
.sets {
  font-size: 1rem;
  opacity: 0.8;
}
.plus, .minus {
  position: absolute;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.plus { top: 0.75rem; right: 0.75rem; }
.minus { bottom: 0.75rem; right: 0.75rem; }
.plus:active, .minus:active { background: rgba(255, 255, 255, 0.45); transform: scale(0.95); }

.swap {
  background: var(--chrome);
  color: #fff;
  width: 3rem;
  font-size: 1.5rem;
  display: grid;
  place-items: center;
}
.swap:active { background: rgba(0, 0, 0, 0.55); }

/* Watcher mode: hide score-change controls */
body.match[data-role="watcher"] .plus,
body.match[data-role="watcher"] .minus,
body.match[data-role="watcher"] .swap,
body.match[data-role="watcher"] .match-footer .actions,
body.match[data-role="watcher"] .team-name { cursor: default; }
body.match[data-role="watcher"] .plus,
body.match[data-role="watcher"] .minus,
body.match[data-role="watcher"] .swap,
body.match[data-role="watcher"] .match-footer .actions { display: none; }

/* ===== FOOTER ===== */
.match-footer {
  background: var(--chrome);
  padding: 0.5rem 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.game-history {
  font-size: 0.85rem;
  opacity: 0.85;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  flex: 1 1 auto;
  min-width: 0;
}
.match-footer .actions {
  display: flex;
  gap: 0.5rem;
}
.action {
  background: rgba(255, 255, 255, 0.15);
  color: var(--fg);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}
.action:active { background: rgba(255, 255, 255, 0.3); }
.action.danger { background: rgba(255, 82, 82, 0.25); }
.action.danger:active { background: rgba(255, 82, 82, 0.5); }

/* ===== CONNECTION STATUS ===== */
.connection-status {
  position: fixed;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: var(--fg);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 100;
}

/* ===== RESPONSIVE: narrow phones in portrait ===== */
@media (max-width: 480px) and (orientation: portrait) {
  .scoreboard {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto 1fr;
  }
  .swap {
    width: 100%;
    height: 2.5rem;
  }
}
