/* ── Variables ── */
:root {
  --green-darkest: #0d1f12;
  --green-dark: #1a3a22;
  --green-mid: #2d6a4f;
  --green-light: #52b788;
  --green-court: #3d7a36;
  --green-court-light: #4a9140;
  --accent: #ffd166;
  --accent2: #ef476f;
  --white: #f0f4f1;
  --gray: #8a9e8d;
  --card-bg: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  --nav-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--green-darkest);
  color: var(--white);
  font-family: 'Inter', sans-serif;
  overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--green-dark); }
::-webkit-scrollbar-thumb { background: var(--green-mid); border-radius: 3px; }

/* ═══════════════════════ NAVBAR ═══════════════════════ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 2rem;
  z-index: 1000;
  background: rgba(13, 31, 18, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  transition: background 0.3s;
}

.navbar.scrolled {
  background: rgba(13, 31, 18, 0.98);
  box-shadow: 0 2px 20px rgba(0,0,0,0.4);
}

.nav-brand {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.8rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  flex: 1;
}

.nav-links a {
  color: var(--gray);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}

.nav-links a:hover { color: var(--white); }

.nav-actions {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
}

.btn-nav {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--white);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s;
}

.btn-nav:hover { background: rgba(255,255,255,0.12); }
.btn-nav.accent { background: var(--green-mid); border-color: var(--green-light); }
.btn-nav.accent:hover { background: var(--green-light); }

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
}

/* ═══════════════════════ SECTIONS ═══════════════════════ */
.section {
  min-height: 100vh;
  padding: calc(var(--nav-height) + 3rem) 2rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: 0.06em;
  color: var(--green-light);
}

/* ═══════════════════════ HERO ═══════════════════════ */
.hero-section {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  max-width: 100%;
  overflow: hidden;
}

/* CSS padel court background */
.court-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.court-surface {
  width: min(90vw, 700px);
  height: min(60vh, 500px);
  background: var(--green-court);
  border: 3px solid rgba(255,255,255,0.7);
  border-radius: 4px;
  position: relative;
  opacity: 0.18;
}

.court-line {
  position: absolute;
  background: rgba(255,255,255,0.85);
}

.line-center-h {
  height: 2px;
  left: 0; right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.line-center-v {
  width: 2px;
  top: 0; bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.line-service-left {
  width: 2px;
  top: 0; bottom: 50%;
  left: 25%;
}

.line-service-right {
  width: 2px;
  top: 0; bottom: 50%;
  right: 25%;
}

.court-net {
  position: absolute;
  height: 4px;
  left: 0; right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.6);
  box-shadow: 0 0 8px rgba(255,255,255,0.3);
}

/* Radial gradient overlay to fade edges */
.court-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, var(--green-darkest) 80%);
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem;
}

.hero-sub {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--green-light);
  margin-bottom: 0.5rem;
}

.hero-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(4rem, 14vw, 9rem);
  line-height: 0.9;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #ffffff 0%, var(--green-light) 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
  text-shadow: none;
}

.hero-tagline {
  font-size: 1rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  color: var(--gray);
  margin-bottom: 2.5rem;
}

.hero-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  animation: bounce 2s infinite;
}

.scroll-arrow {
  width: 20px;
  height: 20px;
  border-right: 2px solid var(--gray);
  border-bottom: 2px solid var(--gray);
  transform: rotate(45deg);
}

@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(8px); }
}

/* ═══════════════════════ STATS ═══════════════════════ */
.stats-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}

.stats-inner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  width: 100%;
  max-width: 900px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  transition: transform 0.3s, border-color 0.3s;
  backdrop-filter: blur(4px);
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--green-light);
}

.stat-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.stat-number {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(3rem, 8vw, 5rem);
  line-height: 1;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.stat-label {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray);
  margin-top: 0.5rem;
}

/* ═══════════════════════ MATCHES ═══════════════════════ */
.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.match-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
  cursor: pointer;
}

.match-card:hover {
  transform: translateY(-3px);
  border-color: var(--green-light);
}

/* Court: SVG fills the area, overlays sit on top */
.match-court {
  position: relative;
  height: 170px;
  overflow: hidden;
}

.court-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Each team occupies one half of the court */
.court-half {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.55rem 0.6rem;
  z-index: 1;
}

.court-left  { left: 0; }
.court-right { right: 0; }

/* Scores at the top of each half */
.court-scores {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.court-left  .court-scores { justify-content: flex-start; }
.court-right .court-scores { justify-content: flex-end; }

.set-box {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 5px;
  min-width: 30px;
  text-align: center;
  padding: 0.05rem 0.35rem;
}

.set-box.set-win {
  background: rgba(255, 209, 102, 0.25);
  border-color: rgba(255, 209, 102, 0.55);
}

.set-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.5rem;
  line-height: 1;
  color: rgba(255,255,255,0.9);
}

.set-box.set-win .set-num { color: var(--accent); }

/* Players at the bottom of each half */
.court-players {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.court-left  .court-players { align-items: flex-start; }
.court-right .court-players { align-items: flex-end; }

.court-avatars { display: flex; gap: 0.25rem; }

.court-names {
  font-size: 0.66rem;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.court-right .court-names { text-align: right; }

.player-avatar-sm {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.55);
  background: var(--green-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
  overflow: hidden;
  flex-shrink: 0;
}

.player-avatar-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Footer: date + edit */
.match-footer {
  padding: 0.55rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--card-border);
}

.match-date {
  font-size: 0.72rem;
  color: var(--gray);
}

.match-edit-btn {
  background: none;
  border: none;
  color: var(--gray);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: color 0.2s;
}

.match-edit-btn:hover { color: var(--white); }

/* ═══════════════════════ PLAYERS ═══════════════════════ */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.sort-label {
  font-size: 0.8rem;
  color: var(--gray);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.sort-btn {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--gray);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.2s;
}

.sort-btn:hover { color: var(--white); border-color: var(--green-light); }
.sort-btn.active { background: var(--green-mid); border-color: var(--green-light); color: var(--white); }

.players-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.player-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0.9rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}

.player-card:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--green-light);
}

.player-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--green-light);
  object-fit: cover;
  background: var(--green-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  overflow: hidden;
  flex-shrink: 0;
}

.player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-info { flex: 1; min-width: 0; }

.player-name {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-stats-row {
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.player-stat {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
}

.player-stat-val {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.25rem;
  color: var(--accent);
  line-height: 1;
}

.player-stat-lbl {
  font-size: 0.66rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.win-pct-bar {
  flex: 1;
  min-width: 60px;
  max-width: 160px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
  align-self: center;
}

.win-pct-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-mid), var(--green-light));
  border-radius: 2px;
  transition: width 1s ease;
}

/* ═══════════════════════ PENDING ═══════════════════════ */
.pending-count {
  font-size: 0.85rem;
  color: var(--gray);
  font-weight: 600;
}

.pending-section { min-height: 60vh; }

.pending-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.pending-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  transition: border-color 0.2s;
}

.pending-card:hover { border-color: var(--green-light); }

.pending-team {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.pending-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.pending-vs {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  color: var(--green-light);
  text-align: center;
  flex-shrink: 0;
}

.pending-controls {
  text-align: center;
  padding: 1rem 0;
}

/* ═══════════════════════ BUTTONS ═══════════════════════ */
.btn-primary {
  background: var(--green-mid);
  border: 1px solid var(--green-light);
  color: var(--white);
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover { background: var(--green-light); color: var(--green-darkest); }
.btn-primary:active { transform: scale(0.97); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--white);
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: border-color 0.2s, background 0.2s;
}

.btn-outline:hover { border-color: var(--green-light); background: var(--card-bg); }

.btn-danger {
  background: rgba(239, 71, 111, 0.15);
  border: 1px solid rgba(239, 71, 111, 0.4);
  color: #ef476f;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-danger:hover { background: rgba(239, 71, 111, 0.3); }

.btn-small {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--white);
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 0.2s;
}

.btn-small:hover { background: rgba(255,255,255,0.1); }

/* ═══════════════════════ MODALS ═══════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #1a2e20;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-wide { max-width: 680px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-header h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.5rem;
  letter-spacing: 0.06em;
  color: var(--green-light);
}

.modal-close {
  background: none;
  border: none;
  color: var(--gray);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: color 0.2s;
}

.modal-close:hover { color: var(--white); }

.modal form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 1rem;
  margin-bottom: 0.3rem;
}

.modal form input,
.modal form select {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--white);
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s;
  appearance: auto;
}

.modal form input:focus,
.modal form select:focus {
  outline: none;
  border-color: var(--green-light);
}

.modal form select option { background: #1a2e20; }

.modal-footer {
  display: flex;
  gap: 0.7rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* Teams layout inside modal */
.teams-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.team-col {
  flex: 1;
}

.team-col h4 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  color: var(--green-light);
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.vs-divider {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  color: var(--accent);
  text-align: center;
  flex-shrink: 0;
}

/* Sets */
.sets-section { margin-top: 1rem; }

.sets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.sets-header h4 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  color: var(--green-light);
  letter-spacing: 0.05em;
}

.sets-list { display: flex; flex-direction: column; gap: 0.4rem; }

.set-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.set-score {
  width: 60px !important;
  text-align: center;
}

.btn-remove-set {
  background: none;
  border: none;
  color: var(--accent2);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.2rem;
}

/* ═══════════════════════ PADEL BALLS ═══════════════════════ */
#balls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}

.ball {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f5f96a, #bfcf00);
  box-shadow: 0 3px 10px rgba(0,0,0,0.35), inset -3px -3px 6px rgba(0,0,0,0.15);
  opacity: 0;
  animation: ballFly var(--duration, 3s) var(--delay, 0s) linear forwards;
}

/* White seam on ball */
.ball::before {
  content: '';
  position: absolute;
  top: 22%;
  left: 14%;
  right: 14%;
  height: 3px;
  background: rgba(255,255,255,0.55);
  border-radius: 2px;
  transform: rotate(-20deg);
}

@keyframes ballFly {
  0% {
    transform: translate(var(--x0), var(--y0)) scale(0.6);
    opacity: 0;
  }
  8% { opacity: 0.85; }
  85% { opacity: 0.7; }
  100% {
    transform: translate(var(--x1), var(--y1)) scale(0.4);
    opacity: 0;
  }
}

/* ═══════════════════════ TOAST ═══════════════════════ */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #2d6a4f;
  color: white;
  padding: 0.7rem 1.5rem;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 3000;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--accent2); }

/* ═══════════════════════ MISC ═══════════════════════ */
.loading-msg {
  color: var(--gray);
  font-style: italic;
  font-size: 0.9rem;
}

.winner-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(255, 209, 102, 0.15);
  border: 1px solid rgba(255, 209, 102, 0.3);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}

/* ═══════════════════════ RESPONSIVE ═══════════════════════ */
@media (max-width: 700px) {
  .navbar { padding: 0 1rem; gap: 1rem; }
  .nav-links { display: none; }
  .nav-actions { display: none; }
  .hamburger { display: block; }

  .nav-links.mobile-open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--nav-height);
    left: 0; right: 0;
    background: rgba(13, 31, 18, 0.98);
    padding: 1rem 1.5rem 2rem;
    gap: 1rem;
    border-bottom: 1px solid var(--card-border);
    z-index: 999;
  }

  .nav-links.mobile-open a { font-size: 1.1rem; }

  .stats-inner {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
  }

  .stat-card { padding: 1.5rem 0.8rem; }

  .section { padding: calc(var(--nav-height) + 2rem) 1rem 2rem; }

  .teams-row { flex-direction: column; }
  .vs-divider { transform: rotate(90deg); }

  .matches-grid, .players-grid, .pending-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 400px) {
  .stats-inner { grid-template-columns: 1fr; }
  .stat-card { padding: 1.2rem; }
}
