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

:root {
  --bg-primary: #0f1923;
  --bg-secondary: #1a2736;
  --bg-card: #1e2d3d;
  --bg-input: #0d1520;
  --text-primary: #e8edf2;
  --text-secondary: #8899aa;
  --text-muted: #5a6b7d;
  --accent: #4ade80;
  --accent-dim: rgba(74, 222, 128, 0.15);
  --accent-glow: rgba(74, 222, 128, 0.3);
  --danger: #f87171;
  --warning: #fbbf24;
  --border: #2a3d52;
  --border-light: #344a61;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: 0.2s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.hidden { display: none !important; }

/* ===== Header ===== */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-primary); font-weight: 700; font-size: 1.1rem;
}
.logo:hover { text-decoration: none; }
.logo-icon { flex-shrink: 0; }
.main-nav { display: flex; gap: 24px; }
.main-nav a {
  color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;
  padding: 4px 0; border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.main-nav a:hover { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }

/* ===== Hero ===== */
.hero-section {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  padding: 60px 20px; text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero-content { max-width: 640px; margin: 0 auto; }
.hero-content h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800; line-height: 1.2; margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  color: var(--text-secondary); font-size: 1.1rem;
  margin-bottom: 28px;
}
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: all var(--transition);
  font-family: var(--font);
}
.btn-primary {
  background: var(--accent); color: #0f1923;
  border-color: var(--accent);
}
.btn-primary:hover { background: #22c55e; border-color: #22c55e; text-decoration: none; }
.btn-secondary {
  background: transparent; color: var(--accent);
  border-color: var(--accent);
}
.btn-secondary:hover { background: var(--accent-dim); text-decoration: none; }
.btn-small { padding: 6px 14px; font-size: 0.82rem; }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); text-decoration: none; }

/* ===== Explorer Section ===== */
.explorer-section {
  max-width: 1200px; margin: 0 auto; padding: 40px 20px;
}
.explorer-layout {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 24px; align-items: start;
}

/* ===== Panels ===== */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-size: 1.1rem; font-weight: 700; }
.panel-actions {
  display: flex; gap: 8px; padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ===== Group Selector ===== */
.group-selector select {
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 12px; font-size: 0.85rem; font-family: var(--font);
  cursor: pointer;
}
.group-selector select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ===== Custom Setup ===== */
.custom-setup { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.setup-label { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 8px; }
.team-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.team-inputs input {
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 0.85rem; font-family: var(--font);
}
.team-inputs input:focus { outline: 2px solid var(--accent); outline-offset: 0; }

/* ===== Live Badge ===== */
.live-badge {
  background: var(--accent-dim); color: var(--accent);
  font-size: 0.7rem; font-weight: 700; padding: 3px 8px;
  border-radius: 20px; letter-spacing: 0.5px;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ===== Matches List ===== */
.matches-list { padding: 8px 0; }
.match-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid rgba(42, 61, 82, 0.5);
}
.match-row:last-child { border-bottom: none; }
.match-row:hover { background: rgba(74, 222, 128, 0.05); }
.match-teams { display: flex; align-items: center; gap: 12px; flex: 1; }
.match-team {
  flex: 1; text-align: center;
  font-weight: 600; font-size: 0.9rem;
}
.match-team.home { text-align: right; }
.match-team.away { text-align: left; }
.match-score {
  display: flex; align-items: center; gap: 6px;
  min-width: 80px; justify-content: center;
}
.score-val {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem;
}
.score-val.has-value { border-color: var(--accent); color: var(--accent); }
.score-sep { color: var(--text-muted); font-weight: 600; }
.match-status {
  font-size: 0.7rem; color: var(--text-muted);
  text-align: right; min-width: 40px;
}
.match-status.played { color: var(--accent); }

/* ===== Standings Table ===== */
.standings-table-wrapper { overflow-x: auto; padding: 0; }
.standings-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.85rem;
}
.standings-table th {
  background: var(--bg-secondary); color: var(--text-secondary);
  font-weight: 600; font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 10px 8px; text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.standings-table th.team-col { text-align: left; padding-left: 16px; }
.standings-table td {
  padding: 12px 8px; text-align: center;
  border-bottom: 1px solid rgba(42, 61, 82, 0.4);
  transition: background var(--transition);
}
.standings-table td.team-col { text-align: left; padding-left: 16px; font-weight: 600; }
.standings-table tr:last-child td { border-bottom: none; }
.standings-table tr.advances td { background: rgba(74, 222, 128, 0.08); }
.standings-table tr.eliminated td { opacity: 0.6; }
.standings-table tr:hover td { background: rgba(74, 222, 128, 0.05); }
.pos-col { width: 32px; }
.num-col { width: 36px; }
.standings-table .gd-positive { color: var(--accent); }
.standings-table .gd-negative { color: var(--danger); }

/* ===== Advancement Zones ===== */
.advancement-zones {
  display: flex; gap: 20px; padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-secondary);
}
.zone { display: flex; align-items: center; gap: 6px; }
.zone-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.zone-advances .zone-dot { background: var(--accent); }
.zone-eliminated .zone-dot { background: var(--text-muted); }

/* ===== Bracket Preview ===== */
.bracket-preview { padding: 16px 20px; border-top: 1px solid var(--border); }
.bracket-preview h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 12px; }
.bracket-rows { display: flex; flex-direction: column; gap: 8px; }
.bracket-match {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-secondary); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 0.82rem;
}
.bracket-round {
  background: var(--accent-dim); color: var(--accent);
  font-size: 0.7rem; font-weight: 700; padding: 2px 6px;
  border-radius: 4px; white-space: nowrap;
}
.bracket-team { font-weight: 600; }
.bracket-vs { color: var(--text-muted); font-size: 0.75rem; }

/* ===== Tiebreaker Info ===== */
.tiebreaker-info { padding: 16px 20px; border-top: 1px solid var(--border); }
.tiebreaker-info h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 8px; }
.tiebreaker-info ol { padding-left: 20px; color: var(--text-secondary); font-size: 0.82rem; }
.tiebreaker-info li { margin-bottom: 4px; }

/* ===== How Section ===== */
.how-section {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 60px 20px;
}
.how-content { max-width: 1200px; margin: 0 auto; }
.how-content h2 {
  font-size: 1.6rem; font-weight: 800; text-align: center;
  margin-bottom: 36px;
}
.how-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.how-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.how-step {
  width: 32px; height: 32px; background: var(--accent-dim);
  color: var(--accent); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.9rem; margin-bottom: 12px;
}
.how-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.how-card p { color: var(--text-secondary); font-size: 0.88rem; line-height: 1.5; }

/* ===== Guide Section ===== */
.guide-section { padding: 60px 20px; max-width: 800px; margin: 0 auto; }
.guide-content h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 20px; }
.guide-content p { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.7; margin-bottom: 16px; }
.scenario-examples { margin-top: 32px; }
.scenario-examples h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.scenario-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.scenario-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.scenario-card h4 { font-size: 0.95rem; font-weight: 700; margin-bottom: 8px; color: var(--accent); }
.scenario-card p { color: var(--text-secondary); font-size: 0.85rem; line-height: 1.5; }

/* ===== FAQ Section ===== */
.faq-section {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 60px 20px;
}
.faq-content { max-width: 800px; margin: 0 auto; }
.faq-content h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 24px; }
.faq-list { display: flex; flex-direction: column; gap: 4px; }
.faq-list details {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.faq-list summary {
  padding: 14px 20px; cursor: pointer; font-weight: 600;
  font-size: 0.92rem; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
}
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after {
  content: '+'; font-size: 1.2rem; color: var(--text-muted);
  transition: transform var(--transition);
}
.faq-list details[open] summary::after { content: '−'; color: var(--accent); }
.faq-list details p {
  padding: 0 20px 16px; color: var(--text-secondary);
  font-size: 0.88rem; line-height: 1.6;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 40px 20px;
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-brand { margin-bottom: 16px; }
.footer-logo { font-weight: 700; font-size: 1rem; display: block; margin-bottom: 4px; }
.footer-tagline { color: var(--text-muted); font-size: 0.85rem; }
.footer-links { display: flex; gap: 20px; margin-bottom: 16px; flex-wrap: wrap; }
.footer-links a { color: var(--text-secondary); font-size: 0.85rem; }
.footer-links a:hover { color: var(--accent); }
.footer-note { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 8px; }
.footer-copy { color: var(--text-muted); font-size: 0.8rem; }
.footer-copy a { color: var(--text-secondary); }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg-card); border: 1px solid var(--accent);
  color: var(--text-primary); padding: 12px 20px;
  border-radius: var(--radius-sm); font-size: 0.88rem;
  box-shadow: var(--shadow); z-index: 1000;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.hidden { opacity: 0; transform: translateY(10px); pointer-events: none; }

/* ===== Score Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  width: 100%; max-width: 400px;
}
.modal h3 { font-size: 1rem; font-weight: 700; margin-bottom: 20px; text-align: center; }
.modal-teams { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.modal-team { flex: 1; text-align: center; }
.modal-team label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; }
.modal-team input {
  width: 100%; background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; font-size: 1.4rem; font-weight: 700;
  text-align: center; font-family: var(--font);
}
.modal-team input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.modal-vs { color: var(--text-muted); font-weight: 600; font-size: 0.85rem; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .explorer-layout { grid-template-columns: 1fr; }
  .standings-panel { order: -1; }
}
@media (max-width: 600px) {
  .header-inner { padding: 0 16px; }
  .main-nav { gap: 14px; }
  .main-nav a { font-size: 0.82rem; }
  .hero-section { padding: 40px 16px; }
  .hero-actions { flex-direction: column; align-items: center; }
  .btn { width: 100%; max-width: 280px; justify-content: center; }
  .team-inputs { grid-template-columns: 1fr; }
  .match-teams { gap: 8px; }
  .match-team { font-size: 0.82rem; }
  .advancement-zones { flex-direction: column; gap: 8px; }
  .how-grid { grid-template-columns: 1fr; }
  .scenario-cards { grid-template-columns: 1fr; }
  .standings-table { font-size: 0.78rem; }
  .standings-table th, .standings-table td { padding: 8px 4px; }
}

/* ===== Print Styles ===== */
@media print {
  .site-header, .hero-section, .how-section, .guide-section, .faq-section, .site-footer,
  .panel-actions, .matches-panel { display: none !important; }
  .explorer-section { padding: 0; }
  .standings-panel { border: 1px solid #ccc; }
  body { background: white; color: black; }
  .standings-table th, .standings-table td { color: black; }
}



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
