/* ============================================================
   WORLD CUP GAMBLER — Modern minimal design system
   ============================================================ */

:root {
  --bg:          #F7F7F5;
  --surface:     #FFFFFF;
  --surface-2:   #F2F2F0;
  --border:      #E8E8E4;
  --border-dark: #D0D0C8;

  --ink:         #0D0D0D;
  --ink-2:       #3A3A3A;
  --ink-3:       #787870;

  --green:       #00A850;
  --green-dim:   #E6F7EE;
  --red:         #E53935;
  --red-dim:     #FDECEA;
  --amber:       #F59E0B;
  --amber-dim:   #FEF3C7;

  --font: 'Inter', system-ui, -apple-system, sans-serif;

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
}

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  background: var(--ink);
  padding: 1.25rem 0;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-title .dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
}

.site-subtitle {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.02em;
  margin-left: auto;
}

/* ============================================================
   NAV
   ============================================================ */
.nav-bar {
  background: var(--ink);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 0;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  flex: 0 0 auto;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.45);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.nav-tab:hover { color: rgba(255,255,255,0.8); }
.nav-tab.active {
  color: #fff;
  border-bottom-color: var(--green);
}

/* ============================================================
   VIEWS
   ============================================================ */
.view { display: none; }
.view.active { display: block; }

main { padding: 1.75rem 0 4rem; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 1.25rem;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }

.filter-btn {
  flex: 0 0 auto;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: all 0.12s;
}
.filter-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.filter-btn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* ============================================================
   MATCH DAY LABEL
   ============================================================ */
.match-day-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.match-day-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   MATCH CARD
   ============================================================ */
.match-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.6rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.match-card:hover { box-shadow: var(--shadow); }

.match-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
}

.group-badge {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem;
}

.match-status {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.match-status.finished  { color: var(--ink-3); }
.match-status.live      { color: var(--red); }
.match-status.scheduled { color: var(--green); }

/* live pulse dot */
.match-status.live::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--red);
  border-radius: 50%;
  margin-right: 5px;
  animation: pulse 1.4s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Scoreboard ── */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

.team { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.team.away { flex-direction: row-reverse; text-align: right; }

.team-crest {
  flex: 0 0 auto;
  width: 2.2rem; height: 2.2rem;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0.02em;
}

.team-info { min-width: 0; }

.team-name {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-name-fa {
  font-size: 0.72rem;
  color: var(--ink-3);
  direction: rtl;
  unicode-bidi: plaintext;
}

.score-board {
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.45rem 1rem;
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 5.5rem;
  justify-content: center;
}
.score-board .sep { color: rgba(255,255,255,0.3); font-weight: 400; }

.match-card.live .score-board { background: var(--red); }

/* Scorers */
.scorers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.scorers ul { list-style: none; }
.scorers .away-scorers { text-align: right; }
.scorers li {
  font-size: 0.75rem;
  color: var(--ink-3);
  padding: 0.1rem 0;
}
.scorers li::before { content: '⚽ '; font-size: 0.65rem; }

/* Footer */
.match-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 0.7rem;
  color: var(--ink-3);
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   LEADERBOARD
   ============================================================ */
.score-formula {
  font-size: 0.75rem;
  color: var(--ink-3);
  margin-bottom: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.score-formula .formula-tag {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-2);
}
.score-formula .formula-op { color: var(--ink-3); }

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.leaderboard-table thead th {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.leaderboard-table td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.leaderboard-table tbody tr:last-child td { border-bottom: none; }
.leaderboard-table tbody tr:hover { background: var(--surface-2); }

/* Podium */
.leaderboard-table tbody tr.rank-1 td:first-child { border-left: 3px solid var(--amber); }
.leaderboard-table tbody tr.rank-2 td:first-child { border-left: 3px solid #9CA3AF; }
.leaderboard-table tbody tr.rank-3 td:first-child { border-left: 3px solid #B45309; }

.rank-medal { font-size: 1rem; }

.player-cell { display: flex; align-items: center; gap: 0.65rem; }

.player-avatar {
  width: 1.9rem; height: 1.9rem;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}

.player-name { font-weight: 600; font-size: 0.875rem; }
.player-team { font-size: 0.72rem; color: var(--ink-3); margin-top: 0.1rem; }

.stat-score {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--green);
}

.td-center { text-align: center; }
.td-muted  { color: var(--ink-3); }

/* ============================================================
   STANDINGS
   ============================================================ */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
}

.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.group-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.group-letter {
  width: 1.6rem; height: 1.6rem;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.group-card-header span {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.group-table { width: 100%; border-collapse: collapse; }

.group-table th {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0.45rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.group-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.group-table tbody tr:last-child td { border-bottom: none; }
.group-table tbody tr:hover { background: var(--surface-2); }

.td-en { font-weight: 600; font-size: 0.82rem; }
.td-fa { font-size: 0.68rem; color: var(--ink-3); direction: rtl; unicode-bidi: plaintext; margin-top: 1px; }
.td-pts { font-weight: 700; color: var(--ink); }
.td-pos { color: var(--ink-3); font-size: 0.75rem; }

/* ============================================================
   GAME — My Team
   ============================================================ */
.game-section { max-width: 480px; margin: 0 auto; }

.section-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--ink);
}

/* Form */
.field { margin-bottom: 0.85rem; }

.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  margin-bottom: 0.4rem;
}

.field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn-primary:hover { background: #222; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-dark);
}
.btn-secondary:hover { border-color: var(--ink); background: var(--surface-2); }

.btn-danger {
  background: var(--surface);
  color: var(--red);
  border-color: var(--border);
}
.btn-danger:hover { border-color: var(--red); background: var(--red-dim); }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-full { width: 100%; }

/* Team reveal */
.team-reveal {
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.25rem;
  text-align: center;
  margin-bottom: 0.75rem;
}

.team-reveal-crest {
  width: 3.5rem; height: 3.5rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 0.85rem;
}

.team-reveal-name {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  margin-bottom: 0.25rem;
}

.team-reveal-fa {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.45);
  direction: rtl;
  unicode-bidi: plaintext;
}

/* Profile card */
.profile-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.6rem;
}

.profile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.stat-pill {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
}
.stat-pill strong { font-weight: 700; color: var(--ink); }

.profile-id {
  font-size: 0.68rem;
  color: var(--ink-3);
  margin-top: 0.5rem;
}
.profile-id code {
  font-size: 0.65rem;
  word-break: break-all;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.reroll-note {
  font-size: 0.72rem;
  color: var(--ink-3);
  text-align: center;
  margin-top: 0.5rem;
}

.lookup-toggle {
  font-size: 0.75rem;
  color: var(--ink-3);
  text-align: center;
  margin-top: 0.5rem;
}
.lookup-toggle a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

/* ============================================================
   UTILITY
   ============================================================ */
.loading, .empty, .error {
  padding: 3rem 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-3);
}
.error { color: var(--red); }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--ink);
  color: rgba(255,255,255,0.3);
  font-size: 0.72rem;
  text-align: center;
  padding: 1rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 580px) {
  .scoreboard {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    text-align: center;
  }
  .team, .team.away {
    flex-direction: column;
    text-align: center;
    justify-content: center;
  }
  .score-board { margin: 0 auto; }
  .scorers { grid-template-columns: 1fr; }
  .scorers .away-scorers { text-align: left; }
  .groups-grid { grid-template-columns: 1fr; }
  .hide-mobile { display: none; }
  .site-subtitle { display: none; }
}