:root {
  --green-900: #14331f;
  --green-800: #1b4d2e;
  --green-700: #225c38;
  --green-600: #2e7d46;
  --kelly: #2fa84f;
  --kelly-soft: #e3f3e7;
  --cream: #f7f4ec;
  --card: #ffffff;
  --sand: #ddceac;
  --sand-soft: #efe7d3;
  --ink: #1f2a24;
  --muted: #6b7a70;
  --red: #b23a48;
  --red-soft: #f6e6e8;
  --gold: #c9a227;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 1px 2px rgba(20, 51, 31, 0.06), 0 6px 18px rgba(20, 51, 31, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* ensure the hidden attribute always wins over display rules */

body {
  margin: 0;
  font-family: var(--serif);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.5;
}

.num { font-family: var(--sans); font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */
.topbar {
  background: linear-gradient(160deg, var(--green-800), var(--green-900));
  color: #f3f0e6;
  border-bottom: 3px solid var(--gold);
}
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 20px 22px 16px; }
.brand { margin: 0; font-size: 1.9rem; font-weight: 700; letter-spacing: 0.2px; }
.brand .flag { margin-right: 6px; }
.tagline { margin: 2px 0 0; color: #c6d8cb; font-size: 0.98rem; font-style: italic; }

/* ---------- Year tabs ---------- */
.yeartabs {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 22px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.yeartab {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid var(--sand);
  background: var(--card);
  color: var(--green-700);
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.yeartab:hover { border-color: var(--kelly); }
.yeartab.active {
  background: var(--green-700);
  color: #fff;
  border-color: var(--green-700);
  box-shadow: var(--shadow);
}

/* ---------- Layout ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 18px 22px 60px; }
.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green-800);
  margin: 26px 0 12px;
}
.section-title .hint { font-size: 0.8rem; font-weight: 400; color: var(--muted); font-style: italic; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 18px; }
.card {
  background: var(--card);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--sand);
}
.card-index { border-top-color: var(--kelly); }
.card-anti { border-top-color: var(--red); }
.card-stats { border-top-color: var(--gold); }
.card-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.card-value { font-size: 3rem; font-weight: 700; line-height: 1.05; margin: 6px 0 2px; }
.card-index .card-value { color: var(--green-700); }
.card-anti .card-value { color: var(--red); }
.card-stats .card-value { color: var(--gold); }
.card-sub { font-size: 0.9rem; color: var(--muted); font-family: var(--sans); }

/* ---------- Sub-index chips ---------- */
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  background: var(--card);
  border: 1px solid var(--sand);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 130px;
  box-shadow: var(--shadow);
}
.chip .chip-name { font-weight: 600; color: var(--green-800); font-size: 0.92rem; }
.chip .chip-vals { font-family: var(--sans); margin-top: 4px; display: flex; gap: 12px; font-weight: 600; }
.chip .v-index { color: var(--green-700); }
.chip .v-anti { color: var(--red); }
.chip .chip-meta { font-size: 0.76rem; color: var(--muted); font-family: var(--sans); margin-top: 2px; }

/* ---------- Chart ---------- */
.chartwrap svg { width: 100%; height: auto; display: block; background: var(--card); border: 1px solid var(--sand); border-radius: var(--radius); box-shadow: var(--shadow); }
.legend { display: flex; gap: 18px; margin-top: 10px; font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 16px; height: 4px; border-radius: 2px; display: inline-block; }
.sw-index { background: var(--kelly); }
.sw-anti { background: var(--red); }

/* ---------- Rounds table ---------- */
.rounds-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; }
.table-scroll { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--sand); box-shadow: var(--shadow); }
.scorecard { width: 100%; border-collapse: collapse; background: var(--card); font-size: 0.92rem; }
.scorecard thead th {
  background: var(--green-700);
  color: #eef6f0;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 11px 12px;
  text-align: left;
  white-space: nowrap;
}
.scorecard th.r, .scorecard td.r { text-align: right; }
.scorecard th.c, .scorecard td.c { text-align: center; }
.scorecard tbody td { padding: 10px 12px; border-top: 1px solid var(--sand-soft); white-space: nowrap; }
.scorecard tbody tr:nth-child(even) { background: #fbf9f3; }
.scorecard tbody tr:hover { background: var(--kelly-soft); }
.scorecard .num { font-family: var(--sans); font-variant-numeric: tabular-nums; }
.scorecard .datelink {
  font: inherit; font-weight: 600; background: none; border: none; padding: 0; cursor: pointer;
  color: var(--green-700); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px;
}
.scorecard .datelink:hover { color: var(--kelly); }
.scorecard .col-index { color: var(--green-700); font-weight: 600; }
.scorecard .col-anti { color: var(--red); font-weight: 600; }
.usedots { display: inline-flex; gap: 5px; align-items: center; justify-content: center; }
/* nudge right so the dot sits centered in the gap between the Diff and Index numbers */
.dot { width: 6.3px; height: 6.3px; border-radius: 50%; display: inline-block; position: relative; left: 7px; }
.dot-index { background: var(--green-700); }
.dot-anti { background: var(--red); }
.scorecard .muted { color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; font-size: 0.95rem; padding: 4px 6px; border-radius: 6px; color: var(--muted);
}
.icon-btn:hover { background: var(--sand-soft); color: var(--ink); }
.tag {
  font-family: var(--sans); font-size: 0.74rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--sand-soft); color: var(--green-800);
}
.tag-Home { background: var(--kelly-soft); color: var(--green-700); }
.tag-Away { background: #eaf0f6; color: #3a5a7a; }
.tag-Competition { background: #f6efe0; color: #8a6d18; }
.tag-Nine { background: #f1ecf6; color: #5b4a7a; }
.empty { text-align: center; color: var(--muted); padding: 26px; font-style: italic; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--sans); font-weight: 600; font-size: 0.9rem;
  border: 1px solid var(--sand); background: var(--card); color: var(--green-800);
  padding: 8px 15px; border-radius: 10px; cursor: pointer; transition: all 0.12s ease;
}
.btn:hover { border-color: var(--kelly); }
.btn-primary { background: var(--kelly); border-color: var(--kelly); color: #fff; }
.btn-primary:hover { background: var(--green-600); border-color: var(--green-600); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #9c2f3c; border-color: #9c2f3c; }
#round-delete { margin-right: auto; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 51, 31, 0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 520px; padding: 22px 24px; border-top: 4px solid var(--kelly);
}
.modal h3 { margin: 0 0 14px; color: var(--green-800); font-size: 1.3rem; }
.modal label { display: block; font-weight: 600; color: var(--green-800); font-size: 0.9rem; margin-bottom: 12px; }
.modal input, .modal select {
  font-family: var(--sans); font-size: 0.95rem; width: 100%; margin-top: 4px;
  padding: 9px 11px; border: 1px solid var(--sand); border-radius: 9px; background: #fff; color: var(--ink);
}
.modal input:focus, .modal select:focus { outline: 2px solid var(--kelly); border-color: var(--kelly); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.opt { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.req { color: var(--red); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.form-error { color: var(--red); background: var(--red-soft); padding: 8px 12px; border-radius: 8px; font-family: var(--sans); font-size: 0.85rem; }

.course-add { display: flex; gap: 8px; margin-bottom: 6px; }
.course-add input { margin-top: 0; }
.hint { font-size: 0.82rem; color: var(--muted); font-style: italic; }
.course-list { max-height: 320px; overflow-y: auto; margin: 10px 0; border: 1px solid var(--sand-soft); border-radius: 10px; }
.course-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--sand-soft); font-size: 0.92rem; }
.course-row:last-child { border-bottom: none; }
.course-row .cname { flex: 1; }
.course-row .star, .course-row .home { cursor: pointer; font-size: 1rem; opacity: 0.35; background: none; border: none; display: inline-flex; align-items: center; padding: 0; }
.course-row .star.on { opacity: 1; color: var(--gold); }
.course-row .home.on { opacity: 1; color: var(--kelly); }

/* ---------- Footer ---------- */
.foot { max-width: 1080px; margin: 0 auto; padding: 8px 22px 30px; color: var(--muted); font-family: var(--sans); font-size: 0.8rem; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .cards { grid-template-columns: 1fr; }
  .card-value { font-size: 2.4rem; }
  .grid3 { grid-template-columns: 1fr; }
}
