/* ============================================================================
   CAPS — Design tokens
   ESPN-broadcast-card energy: condensed display numerals, warm chalk
   background (not stark white), a single gold accent reserved for the
   cap/streak moment, Soviet-red reserved only for streak-name reveals.
   ============================================================================ */

:root {
  /* Color */
  --felt: #1B4D3E;
  --felt-dark: #123329;
  --cap-gold: #D4A030;
  --cap-gold-bright: #F0C25E;
  --chalk: #F7F5F0;
  --chalk-dim: #EAE6DC;
  --ink: #1A1A1A;
  --ink-soft: #4A4A45;
  --miss-red: #C1432B;
  --soviet-red: #8B2332;
  --line: #D9D4C7;
  --white: #FFFFFF;

  /* Team colors (assigned per game, these are the two defaults) */
  --team-1: #1B4D3E;
  --team-2: #8B2332;

  /* Type */
  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Radii */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-card: 0 2px 8px rgba(26, 26, 26, 0.08), 0 1px 2px rgba(26, 26, 26, 0.06);
  --shadow-lift: 0 8px 24px rgba(26, 26, 26, 0.16);

  /* Tap target minimum (mobile-first, thumb-friendly) */
  --tap-min: 56px;

  /* Safe area for PWA standalone mode */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--chalk);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0;
}

.score-digit {
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

table {
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--felt);
  text-decoration: none;
}

button {
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--cap-gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------------------------------------------------------------
   Shared components
   --------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap-min);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 16px;
  background: var(--felt);
  color: var(--chalk);
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn--gold { background: var(--cap-gold); color: var(--ink); }
.btn--miss { background: var(--miss-red); color: var(--chalk); }
.btn--ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: var(--sp-2) var(--sp-4); font-size: 14px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.card {
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: var(--sp-5);
}

.input,
select.input {
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  border: 1.5px solid var(--line);
  background: var(--white);
  font-size: 16px;
  font-family: var(--font-body);
  color: var(--ink);
}
.input:focus { outline: none; border-color: var(--felt); }

.label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-bottom: var(--sp-2);
  display: block;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  background: var(--chalk-dim);
  color: var(--ink-soft);
}
.pill--gold { background: var(--cap-gold); color: var(--ink); }
.pill--soviet { background: var(--soviet-red); color: var(--chalk); }

.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--chalk-dim);
  border: 2px solid var(--white);
  box-shadow: var(--shadow-card);
}

.toast {
  position: fixed;
  bottom: calc(var(--sp-5) + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--chalk);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--chalk-dim);
  border-top-color: var(--felt);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.modal-backdrop.show { opacity: 1; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}

.modal-sheet {
  background: var(--chalk);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--sp-5);
  padding-bottom: calc(var(--sp-6) + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
.modal-backdrop.show .modal-sheet { transform: translateY(0); }
@media (min-width: 640px) {
  .modal-sheet { border-radius: var(--r-lg); max-height: 80vh; transform: translateY(16px) scale(0.98); }
  .modal-backdrop.show .modal-sheet { transform: translateY(0) scale(1); }
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  z-index: 50;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-2) 0 var(--sp-3);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.bottom-nav a.active { color: var(--felt); }
.bottom-nav svg { width: 22px; height: 22px; }

.empty-state {
  text-align: center;
  padding: var(--sp-7) var(--sp-5);
  color: var(--ink-soft);
}

.cap-flash {
  animation: cap-flash 0.5s ease;
}
@keyframes cap-flash {
  0% { background-color: var(--cap-gold-bright); }
  100% { background-color: transparent; }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
