@import url('https://fonts.googleapis.com/css2?family=Teko:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --pitch-dark: #0B2545;
  --pitch-mid: #14345E;
  --cream: #F4F6FA;
  --gold: #D4A94F;
  --ink: #16233D;
  --muted: #6C7690;
  --danger: #B8433A;
  --card-radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  font-family: 'Inter', sans-serif;
  background: linear-gradient(180deg, var(--pitch-dark) 0%, var(--pitch-mid) 340px, var(--cream) 340px);
  color: var(--ink);
  min-height: 100vh;
}

h1, h2, h3, .brand, .score-input {
  font-family: 'Teko', sans-serif;
  letter-spacing: 0.02em;
}

/* --- NAV --- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  max-width: 960px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--cream);
  font-size: 26px;
  font-weight: 700;
  text-decoration: none;
}
.brand-logo { width: 40px; height: 40px; border-radius: 50%; display: block; }
.brand span { color: var(--gold); }
.nav-links { display: flex; gap: 6px; align-items: center; }
.nav-links a {
  color: rgba(246,244,236,0.85);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}
.nav-links a:hover, .nav-links a.active { background: rgba(255,255,255,0.12); color: var(--cream); }
.nav-links button {
  background: none; border: 1px solid rgba(246,244,236,0.4);
  color: var(--cream); padding: 8px 14px; border-radius: 6px;
  font-size: 14px; cursor: pointer; font-family: inherit;
}
.nav-links button:hover { background: rgba(255,255,255,0.12); }
.user-name {
  color: var(--gold);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 10px 8px 4px;
  white-space: nowrap;
}

/* --- CONTAINER --- */
.container { max-width: 960px; margin: 0 auto; padding: 0 20px 60px; }

.page-title {
  color: var(--cream);
  font-size: 44px;
  font-weight: 700;
  margin: 4px 0 22px;
}
.page-subtitle { color: rgba(246,244,236,0.75); margin-top: -14px; margin-bottom: 22px; font-size: 15px; }

/* --- WEEK SELECTOR --- */
.week-selector {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 20px;
}
.week-pill {
  flex: none;
  background: rgba(255,255,255,0.08);
  color: var(--cream);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.week-pill.active { background: var(--gold); color: var(--pitch-dark); border-color: var(--gold); font-weight: 700; }

/* --- CARDS --- */
.card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: 0 2px 10px rgba(11,61,46,0.08);
  padding: 20px 22px;
  margin-bottom: 14px;
}

.lock-banner {
  background: rgba(11,61,46,0.06);
  border-left: 3px solid var(--gold);
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 18px;
}
.lock-banner.locked { border-left-color: var(--danger); }

/* --- MATCH CARD --- */
.match-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.match-teams {
  display: flex; align-items: center; gap: 14px;
  flex: 1; min-width: 220px;
}
.team-name { font-size: 16px; font-weight: 600; flex: 1; overflow-wrap: normal; }
.team-name.home { text-align: right; }
.match-meta { font-size: 12px; color: var(--muted); width: 100%; margin-top: 6px; }

.scoreboard {
  display: flex; align-items: center; gap: 8px;
}
.score-input {
  width: 46px; height: 46px;
  background: var(--pitch-dark);
  color: var(--gold);
  font-size: 26px;
  text-align: center;
  border: 2px solid var(--pitch-dark);
  border-radius: 6px;
  font-weight: 600;
}
.score-input:disabled { background: #e6e8ee; color: var(--muted); border-color: #e6e8ee; }
.score-sep { color: var(--muted); font-weight: 700; font-size: 18px; }

.points-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  margin-left: 8px;
}
.points-badge.p3 { background: #E1F0E6; color: #1F7A3F; }
.points-badge.p1 { background: #FBF0D9; color: #92700D; }
.points-badge.p0 { background: #F5E6E4; color: var(--danger); }

.save-row { text-align: right; margin-top: 18px; }

button.primary {
  background: var(--gold);
  color: var(--pitch-dark);
  border: none;
  padding: 12px 26px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
button.primary:hover { filter: brightness(0.95); }
button.primary:disabled { background: #ddd; color: #999; cursor: not-allowed; }

button.secondary {
  background: transparent;
  border: 1px solid var(--pitch-dark);
  color: var(--pitch-dark);
  padding: 10px 20px;
  border-radius: 7px;
  font-weight: 600;
  cursor: pointer;
}

/* --- LEADERBOARD --- */
.leaderboard-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid #eee;
}
.leaderboard-row:last-child { border-bottom: none; }
.rank {
  font-family: 'Teko', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--muted);
  width: 34px;
}
.rank.top1 { color: var(--gold); }
.rank.top2 { color: #9AA6BC; }
.rank.top3 { color: #B08968; }
.leaderboard-name { flex: 1; font-weight: 600; font-size: 16px; }
.leaderboard-score { font-family: 'Teko', sans-serif; font-size: 26px; font-weight: 700; color: var(--pitch-mid); }

/* --- AUTH FORM --- */
.auth-wrap {
  max-width: 380px; margin: 90px auto; background: #fff;
  padding: 36px 30px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.auth-wrap h1 { color: var(--pitch-dark); font-size: 34px; margin-bottom: 4px; }
.auth-wrap p.sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--ink); }
.field input {
  width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 7px; font-size: 16px;
}
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.auth-switch a { color: var(--pitch-mid); font-weight: 600; cursor: pointer; }

/* --- TOAST --- */
.toast {
  position: fixed; bottom: -80px; left: 50%; transform: translateX(-50%);
  background: var(--pitch-dark); color: var(--cream); padding: 12px 24px;
  border-radius: 8px; font-size: 14px; transition: bottom 0.3s; z-index: 100;
}
.toast.show { bottom: 24px; }
.toast.error { background: var(--danger); }

/* --- ADMIN --- */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.admin-grid input, .admin-grid select {
  padding: 11px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 16px;
}
.small-note { font-size: 12px; color: var(--muted); margin-top: 4px; }

@media (max-width: 640px) {
  .admin-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 32px; }
}

/* --- MOBILE (phones) --- */
@media (max-width: 480px) {
  .container { padding: 0 14px 50px; }

  /* Navbar: stack brand and links, let links wrap on their own row */
  .navbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 16px 16px 14px;
  }
  .brand { font-size: 22px; justify-content: center; margin-bottom: 2px; }
  .brand-logo { width: 32px; height: 32px; }
  .nav-links {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .nav-links a, .nav-links button {
    padding: 9px 12px;
    font-size: 13px;
    flex: none;
    white-space: nowrap;
  }
  .user-name { flex: none; white-space: nowrap; padding: 9px 6px; }

  .page-title { font-size: 26px; margin-top: 2px; }
  .page-subtitle { font-size: 13px; }

  /* Week selector: smoother touch scroll, slightly tighter pills */
  .week-selector {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    margin: 0 -14px 18px;
    padding: 0 14px 6px;
  }
  .week-pill { scroll-snap-align: start; padding: 9px 16px; font-size: 13px; }

  .card { padding: 16px 14px; }

  /* Match card: stack home team / score / away team vertically, centered */
  .match-teams {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
  .team-name, .team-name.home {
    text-align: center;
    width: 100%;
  }
  .match-meta { text-align: center; }
  .points-badge { display: inline-block; margin: 6px 0 0; margin-left: 0; }

  .score-input { width: 52px; height: 52px; font-size: 28px; }

  .save-row button.primary { width: 100%; }

  /* Leaderboard: tighter spacing so long names don't crowd the score */
  .leaderboard-row { padding: 12px 14px; gap: 10px; }
  .leaderboard-name { font-size: 14px; }
  .leaderboard-score { font-size: 22px; }
  .rank { font-size: 22px; width: 26px; }

  /* Auth form: fit narrow screens without side overflow */
  .auth-wrap {
    margin: 32px 14px;
    padding: 28px 20px;
    max-width: none;
  }
  .auth-wrap h1 { font-size: 28px; }

  /* Admin: match result rows already stack via admin-grid; buttons full width */
  .save-row { display: flex; flex-direction: column; gap: 8px; }
  .save-row button { width: 100%; }
}
