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

:root {
  --primary: #1a5632;
  --primary-light: #2d8a4e;
  --accent: #f5a623;
  --accent-light: #ffd275;
  --bg: #0f1923;
  --bg-card: #1a2735;
  --bg-card-hover: #1f3042;
  --text: #e8edf2;
  --text-muted: #8899aa;
  --border: #2a3a4a;
  --win: #2d8a4e;
  --draw: #f5a623;
  --loss: #c0392b;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, #0d2818 0%, #1a5632 50%, #0d2818 100%);
  border-bottom: 3px solid var(--accent);
  padding: 28px 20px;
  text-align: center;
}
.header h1 { font-size: 2rem; font-weight: 800; letter-spacing: 1px; }
.header-subtitle { color: var(--accent-light); font-size: 0.95rem; margin-top: 4px; }
.tournament-dates { color: var(--text-muted); font-size: 0.82rem; margin-top: 6px; }

/* ── Navigation Tabs ──────────────────────────────────────── */
.nav-tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
}
.tab {
  padding: 10px 22px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tab.active { color: var(--accent); border-color: var(--accent); background: rgba(245,166,35,0.1); }

/* ── Main Content ─────────────────────────────────────────── */
.main-content { max-width: 1400px; margin: 0 auto; padding: 20px; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.section-header h2 { font-size: 1.4rem; color: var(--text); }
.section-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary-light); color: #fff; }
.btn-primary:hover { background: #35a05c; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #3a4d60; }
.btn-small { padding: 5px 12px; font-size: 0.78rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Group Selector ───────────────────────────────────────── */
.group-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.group-btn {
  width: 42px; height: 42px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
display: flex; align-items: center; justify-content: center;
}
.group-btn:hover { border-color: var(--accent); color: var(--accent); }
.group-btn.active { background: var(--primary); border-color: var(--primary-light); color: #fff; }

/* ── Match Cards ──────────────────────────────────────────── */
.matches-container { display: grid; gap: 12px; }
.match-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.match-card:hover { background: var(--bg-card-hover); border-color: var(--accent); }
.match-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.match-status {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-pending { background: rgba(136,153,170,0.2); color: var(--text-muted); }
.status-completed { background: rgba(45,138,78,0.2); color: var(--win); }
.status-live { background: rgba(245,166,35,0.2); color: var(--accent); animation: pulse 2s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.match-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  text-align: center;
}
.match-team {
  font-size: 1rem;
  font-weight: 700;
}
.match-team .flag { font-size: 1.4rem; margin-right: 6px; }
.team-name-cn { display: block; font-size: 0.92rem; }
.team-name-en { display: block; font-size: 0.7rem; font-weight: 400; color: var(--text-muted); }
.match-team-score { font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.match-vs { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.match-prediction-row {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.pred-score { color: var(--accent-light); font-weight: 600; }
.result-score { color: var(--win); font-weight: 600; }
.confidence-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-top: 8px;
  overflow: hidden;
}
.confidence-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary-light), var(--accent));
}

/* ── Knockout Bracket ─────────────────────────────────────── */
.knockout-container { overflow-x: auto; padding-bottom: 20px; }
.bracket-stage { margin-bottom: 24px; }
.bracket-stage h3 {
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}
.bracket-matches { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; }

/* ── Standings Table ──────────────────────────────────────── */
.standings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); gap: 20px; }
.standings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.standings-card h4 {
  padding: 12px 16px;
  background: var(--primary);
  font-size: 0.95rem;
  color: #fff;
}
.standings-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.standings-table th {
  text-align: left;
  padding: 8px 12px;
  background: rgba(0,0,0,0.2);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.standings-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.standings-table tr:hover td { background: rgba(255,255,255,0.03); }
.standings-table .pos-1 { color: var(--primary-light); font-weight: 700; }
.standings-table .pos-2 { color: var(--accent); font-weight: 700; }

/* ── Tournament Prediction Panel ──────────────────────────── */
.tournament-prediction-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 768px) { .tournament-prediction-panel { grid-template-columns: 1fr; } }

.tp-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.tp-card h3 { font-size: 1.1rem; margin-bottom: 18px; color: var(--accent); }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.podium-item { text-align: center; cursor: pointer; transition: transform 0.2s; }
.podium-item:hover { transform: translateY(-4px); }
.podium-icon { font-size: 3rem; display: block; }
.podium-1 .podium-icon { font-size: 4.5rem; }
.podium-2 .podium-icon { font-size: 3.5rem; }
.podium-3 .podium-icon { font-size: 2.8rem; }
.podium-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.podium-team { font-size: 1rem; font-weight: 700; margin-top: 2px; }

.tp-form { display: flex; flex-direction: column; gap: 12px; }
.tp-form select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}
.tp-form select:focus { border-color: var(--accent); outline: none; }

.tp-history { max-height: 300px; overflow-y: auto; }
.tp-history-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.tp-history-date { color: var(--text-muted); font-size: 0.75rem; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  justify-content: center;
  align-items: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }

.prediction-form { display: flex; flex-direction: column; gap: 14px; }
.prediction-form label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.score-inputs { display: flex; align-items: center; gap: 16px; }
.score-inputs input {
  width: 70px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.2rem;
  text-align: center;
  font-weight: 700;
}
.score-inputs input:focus { border-color: var(--accent); outline: none; }
.score-vs { color: var(--text-muted); font-weight: 600; }

.pred-result { margin-top: 10px; padding: 12px; background: rgba(0,0,0,0.2); border-radius: 6px; }
.pred-result-row { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 0.85rem; }
.result-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.85rem;
}
.result-home { background: rgba(45,138,78,0.2); color: var(--win); }
.result-away { background: rgba(192,57,43,0.2); color: var(--loss); }
.result-draw { background: rgba(245,166,35,0.2); color: var(--draw); }

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ── Loading spinner ──────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth Area ────────────────────────────────────────────── */
.auth-area { margin-left: auto; display: flex; align-items: center; gap: 8px; white-space: nowrap; }

/* ── Team Analysis ────────────────────────────────────────── */
.team-analysis-container { max-width: 900px; margin: 0 auto; }
.team-analysis-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.team-analysis-card h3 {
  padding: 16px 20px;
  background: var(--primary);
  font-size: 1.2rem;
  color: #fff;
}
.team-analysis-card h3 small { font-size: 0.8rem; color: rgba(255,255,255,0.7); }
.ta-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.ta-section:last-child { border-bottom: none; }
.ta-section h4 { color: var(--accent); margin-bottom: 10px; font-size: 0.95rem; }
.ta-section p { font-size: 0.88rem; color: var(--text); margin-bottom: 4px; }

.star-players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .star-players { grid-template-columns: 1fr; } }
.star-card {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.82rem;
}
.star-card strong { color: var(--accent-light); }

.swot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .swot-grid { grid-template-columns: 1fr; } }
.swot-box {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 0.82rem;
}
.swot-box strong { display: block; margin-bottom: 4px; font-size: 0.88rem; }
.swot-strength { border-left: 3px solid var(--win); }
.swot-weakness { border-left: 3px solid var(--loss); }
.swot-opportunity { border-left: 3px solid var(--accent); }
.swot-threat { border-left: 3px solid #e67e22; }

/* ── Auth Modal Inputs ────────────────────────────────────── */
.auth-input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.auth-input:focus { border-color: var(--accent); outline: none; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .header h1 { font-size: 1.4rem; }
  .match-card { padding: 12px; }
  .match-team { font-size: 0.85rem; }
  .match-team-score { font-size: 1.2rem; }
  .standings-grid { grid-template-columns: 1fr; }
  .bracket-matches { grid-template-columns: 1fr; }
  .auth-area { margin-left: 0; }
}
