:root {
  color-scheme: light;
  --wine-900: #3d0f1c;
  --wine-800: #521628;
  --wine-700: #6e1b2e;
  --wine-600: #7d2136;
  --wine-500: #8f2440;
  --cream: #f7f1e6;
  --panel: #fffdf9;
  --ink: #2a1116;
  --muted: #8a6b72;
  --border: #e6dcc9;
  --gold: #c9a15a;
  --gold-dark: #a37f3f;
  --error: #b3261e;
  --tag-setup: #9a8f86;
  --tag-in_progress: var(--wine-700);
  --tag-complete: #6b5b60;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- App identity bar ---------- */
.site-header {
  background: var(--wine-900);
  padding: 12px 0;
  padding-top: max(12px, env(safe-area-inset-top));
}
.site-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.site-header .brand img { display: block; border-radius: 6px; }

.site-footer {
  margin-top: 40px;
  padding: 20px 0 max(20px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.85rem;
}

main { padding: 20px 0 40px; }

h1 { margin-top: 0; letter-spacing: -0.01em; }
h1, h2, h3 { color: var(--wine-900); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

a { color: var(--wine-700); }

/* ---------- Per-league tab navigation (app shell) ---------- */
/* Sits directly under the site header, on every screen size - icons+label,
   not fixed/pinned, so it scrolls away with the page like the rest of the
   app chrome instead of floating over content. */
.app-nav {
  display: flex;
  background: var(--wine-900);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  /* Break out of the centered .container it's nested in so it spans the
     full viewport edge-to-edge, like the header bar above it. */
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}
.app-nav a {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 2px 8px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.62rem;
  font-weight: 600;
}
.app-nav-label {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.app-nav a.active { color: #fff; }
.app-nav-icon { width: 22px; height: 22px; }
.app-nav-icon svg { width: 100%; height: 100%; }
.app-nav a.active .app-nav-icon { color: var(--gold); }

@media (min-width: 768px) {
  .app-nav a {
    flex-direction: row;
    font-size: 0.85rem;
    padding: 12px 16px;
    gap: 8px;
    justify-content: center;
  }
  .app-nav-icon { width: 18px; height: 18px; }
}

/* Old flat subnav still used on admin pages that don't have per-league tabs */
.week-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 12px 0 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.week-tabs a {
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--wine-700);
}
.week-tabs a.active {
  background: var(--wine-700);
  color: #fff;
}

.league-list { list-style: none; padding: 0; }
.league-list li {
  padding: 14px;
  margin-bottom: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.league-list a { font-weight: 700; text-decoration: none; font-size: 1.05rem; color: var(--wine-900); }

.tag {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 9px;
  border-radius: 999px;
  color: #fff;
  margin-left: 8px;
}
.tag-setup { background: var(--tag-setup); }
.tag-in_progress { background: var(--tag-in_progress); }
.tag-complete { background: var(--tag-complete); }
.tag-tie { background: var(--gold-dark); color: #2a1e0d; }

.table-scroll {
  overflow-x: auto;
  margin-bottom: 24px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.table-scroll table { margin-bottom: 0; border: none; border-radius: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  background: var(--panel);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
  background: var(--wine-800);
}
tbody tr:last-child td { border-bottom: none; }
.standings-table td:nth-child(n+3), .standings-table th:nth-child(n+3) { text-align: center; }
.split-row td { border-bottom: 2px solid var(--gold); }

@media (max-width: 400px) {
  .standings-table th, .standings-table td { padding: 8px 5px; }
  .standings-table { font-size: 0.92rem; }
}

/* ---------- Match cards (fixtures/results) ---------- */
.round-block { margin-bottom: 26px; }
.round-block h3 { margin-bottom: 8px; font-size: 1rem; }

.match-list { display: flex; flex-direction: column; gap: 8px; }
.match-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.match-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}
.match-team { font-weight: 600; font-size: 0.95rem; }
.match-team-home { text-align: right; }
.match-team-away { text-align: left; }
.score-badge {
  display: inline-block;
  min-width: 54px;
  text-align: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--wine-700);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}
.score-badge-pending {
  background: var(--border);
  color: var(--muted);
}
.match-meta {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.score-form {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}
.score-form input[type="number"] {
  width: 42px;
  padding: 5px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.score-sep { color: var(--muted); }
.score-form select { padding: 4px; border-radius: 6px; border: 1px solid var(--border); max-width: 140px; }
.score-form button {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 16px 0;
}
.team-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.team-card h3, .team-card h4 { margin: 0 0 8px; }
.roster { list-style: none; padding: 0; margin: 0 0 10px; }
.roster li {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 24px;
}
.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
}
.admin-form input, .admin-form select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}
.admin-form button, form button[type="submit"] {
  background: var(--wine-700);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
}
.admin-form button:hover, form button[type="submit"]:hover { background: var(--wine-600); }

.inline-form {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.inline-form input { padding: 6px; border: 1px solid var(--border); border-radius: 6px; }

/* Text-style buttons (log out, remove, delete). Selectors are as specific as the
   generic pill-button rule above so they actually win. */
button.link-button, form button[type="submit"].link-button {
  background: none;
  border-radius: 0;
  color: var(--wine-700);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 400;
}
form button[type="submit"].link-button:hover { background: none; color: var(--wine-500); }
button.link-button.danger, form button[type="submit"].link-button.danger { color: var(--error); }

.admin-table { font-size: 0.95rem; }
.admin-actions a { margin-right: 10px; font-size: 0.85rem; }

.callout {
  background: #fbf3e3;
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 24px;
}

.error { color: var(--error); }

/* ---------- Info pages ---------- */
.info-list { list-style: none; padding: 0; }
.info-list li { margin-bottom: 10px; }
.info-list a {
  display: block;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  color: var(--wine-900);
}
.page-title { margin-top: 4px; }
.prose { max-width: 680px; line-height: 1.6; }
.prose h2 { margin: 1.4em 0 0.4em; font-size: 1.25rem; }
.prose h3 { margin: 1.3em 0 0.3em; font-size: 1.05rem; color: var(--wine-700); }
.prose p { margin: 0 0 0.9em; }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.3em; }
.prose li { margin-bottom: 0.35em; }
.admin-form-wide { max-width: 760px; }
.admin-form textarea {
  width: 100%;
  min-height: 360px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}
.admin-form .check-row { flex-direction: row; align-items: center; gap: 8px; }
.admin-form .check-row input { width: auto; }
.help { font-size: 0.82rem; color: var(--muted); margin: 0; }

.bracket {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.bracket-round h4 { margin-bottom: 8px; color: var(--wine-900); }
.bracket-match {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  min-width: 180px;
}
.bracket-score { font-weight: 700; margin: 4px 0; color: var(--wine-700); }

@media (max-width: 600px) {
  .fixtures-table th:nth-child(1), .fixtures-table td:nth-child(1) { display: none; }
}
