:root {
  --green: #006633;
  --green-dark: #004225;
  --cream: #f5f1e8;
  --card: #fffdf8;
  --ink: #1d1d1b;
  --gold: #b8873a;
  --border: #e3ddcc;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1.125rem;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: "Libre Baskerville", Georgia, serif;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 0.5rem;
}

h1 {
  font-size: 1.9rem;
  text-align: center;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
h2 { font-size: 1.35rem; margin-top: 2rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 0.75rem; }

a { color: var(--green); }
a:hover { color: var(--gold); }

/* Header + nav */
.site-header {
  background: var(--card);
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.site-header .logo {
  display: inline-block;
  line-height: 0;
}

.site-header .logo img {
  height: 130px;
  width: auto;
  display: block;
}

.site-nav {
  display: flex;
  overflow-x: auto;
  background: var(--green);
  -webkit-overflow-scrolling: touch;
}

.site-nav a {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}

.site-nav a.active,
.site-nav a:hover {
  color: white;
  border-bottom-color: var(--gold);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

/* Hero */
.hero { margin-bottom: 1.5rem; }
.hero-sub { color: #555; text-align: center; }
.hero-sub-line1 { font-size: 1.15rem; }
.hero-sub-line2 { font-size: 0.95rem; }

/* Cards shared by venues / results / golfers */
.venue-card,
.results-card,
.golfer-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.venue-card { padding-bottom: 1.25rem; }

.venue-photo {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background: var(--border);
}

.venue-body { padding: 1rem 1.25rem 0; }

.venue-meta { color: #555; font-size: 1rem; }

address { font-style: normal; color: #444; }

.venue-links a {
  display: inline-block;
  margin-right: 1rem;
  font-size: 1rem;
  font-weight: 600;
}

/* RSVP */
.rsvp {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.rsvp h4 { margin-bottom: 0.5rem; font-size: 1rem; }

.rsvp-form label {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.6rem;
}

.rsvp-form select,
.rsvp-form input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1.1rem;
  background: white;
}

.rsvp-choice {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
}

.rsvp-choice label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0;
}

.rsvp-form button {
  background: var(--green);
  color: white;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: 4px;
  font-size: 1.05rem;
  cursor: pointer;
}

.rsvp-form button:hover { background: var(--green-dark); }

.rsvp-status {
  font-size: 0.95rem;
  color: var(--gold);
  min-height: 1.2em;
  margin: 0.5rem 0 0;
}

.rsvp-list {
  margin-top: 1rem;
  font-size: 1rem;
}

.rsvp-count { font-weight: 600; margin-bottom: 0.4rem; }

.rsvp-guests-heading { font-weight: 600; margin: 0.75rem 0 0.4rem; }

.rsvp-guest-remove {
  border: none;
  background: none;
  padding: 0;
  color: #999;
  font-size: 0.75em;
  text-decoration: underline;
  cursor: pointer;
}

.rsvp-guest-remove:hover { color: #777; }
.rsvp-guest-remove:disabled { color: #ccc; cursor: default; text-decoration: none; }

.rsvp-form .rsvp-guest-field { display: none; }

.rsvp-responses {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.rsvp-responses li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
}

.rsvp-responses li.muted { color: #888; background: none; border-style: dashed; }

.rsvp-icon { font-weight: 700; }
.rsvp-responses li.playing .rsvp-icon { color: #2a7a3b; }
.rsvp-responses li.not-playing .rsvp-icon { color: #b23b3b; }

.rsvp-error { color: #a33; }

/* Golfers */
.golfer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.golfer-card {
  text-align: center;
  padding: 1rem 0.75rem;
}

.golfer-card img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 50%;
  margin-bottom: 0.6rem;
  background: var(--border);
}

.golfer-card h3 { font-size: 1rem; margin-bottom: 0.2rem; }
.golfer-nickname { font-size: 0.95rem; color: var(--gold); font-style: italic; margin: -0.1rem 0 0.3rem; }
.golfer-handicap { font-size: 1rem; color: #555; margin-bottom: 0.3rem; }

.handicap-history {
  font-size: 0.9rem;
  text-align: left;
  margin-top: 0.4rem;
}

.handicap-history summary {
  cursor: pointer;
  color: var(--green);
  font-weight: 600;
}

.handicap-history ul {
  margin: 0.4rem 0 0;
  padding-left: 1rem;
  color: #555;
}

/* Latest results (home page) */
.latest-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.latest-result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem 0.75rem;
  text-align: center;
}

.lr-photo {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 50%;
  background: var(--border);
}

.lr-photo-wrap {
  position: relative;
  display: inline-block;
}

.lr-badge {
  position: absolute;
  bottom: -8px;
  right: -10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
}

.lr-star {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1;
  padding-bottom: 3px;
}

.lr-star-gold { background: #d4af37; color: #4a3800; }
.lr-star-silver { background: #c0c0c0; color: #333; }

.lr-place {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--gold);
  margin: 0.6rem 0 0.1rem;
}

.latest-result-card.place-1 .lr-place { color: var(--green); }
.latest-result-card.place-2 .lr-place { color: #4d9970; }
.latest-result-card.place-last .lr-place { color: #7fae93; }

.lr-name { font-weight: 700; margin: 0 0 0.1rem; }
.lr-score { color: #666; font-size: 0.95rem; margin: 0; }

.latest-results-meta {
  color: #777;
  font-size: 0.95rem;
  text-align: center;
  margin-top: 0.25rem;
}

/* Results / Captain's Cup tables */
.results-card { padding: 1rem 1.25rem 1.25rem; }
.results-date { color: #777; font-size: 0.95rem; margin-top: -0.3rem; }

.stat-card h2 { margin-top: 0; }
.stat-headline { font-size: 1.3rem; font-weight: 700; color: var(--green); margin-bottom: 0.2rem; }
.stat-detail { color: #666; font-size: 1rem; margin-bottom: 0; }

.results-year-heading {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 2px solid var(--border);
}

/* h1 already has its own divider - don't stack a second line under it when
   a year heading comes straight after */
h1 + .results-year-heading {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 1.03rem;
}

th, td {
  text-align: left;
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid var(--border);
}

th { color: #666; font-weight: 600; font-size: 0.93rem; }

tr.winner td:first-child { color: var(--green); font-weight: 700; }
tr.winner { background: rgba(0, 102, 51, 0.08); }

tr.second td:first-child { color: #4d9970; font-weight: 600; }
tr.second { background: rgba(0, 102, 51, 0.04); }

/* Captain's Cup leaderboard: Name and Total are separate, non-scrolling
   tables either side of a scrollable middle table for the rounds - rather
   than sticky columns inside one scrolling table, which mobile browsers
   render unreliably (scrolled-past columns can paint through the "fixed"
   ones). Separate tables can never overlap, so there's nothing to paint
   through. */
.cc-frozen-layout {
  display: flex;
  align-items: flex-start;
  width: 80vw;
  margin: 0.5rem calc(50% - 40vw) 1rem;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--card);
}

.cc-name-table,
.cc-total-table {
  flex: 0 0 auto;
  width: auto;
}

.cc-name-table { border-right: 1px solid var(--border); }
.cc-total-table { border-left: 1px solid var(--border); }

.cc-scroll-middle {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cc-frozen-layout table {
  margin: 0;
}

/* Name is now two lines (first name / surname) - give every row across all
   3 tables the same fixed height so they line up, since each table sizes
   its own rows independently. "height" on a table cell is a minimum, not a
   cap, so this has to be generous enough that the two-line Name cell never
   needs to grow past it - otherwise that row grows taller in the name table
   only, and every row below it in that table drifts out of alignment with
   the other two. */
.cc-frozen-layout td {
  height: 3.4rem;
  box-sizing: border-box;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
  line-height: 1.2;
}

.sortable-table th {
  position: relative;
  user-select: none;
  padding-right: 1.1rem;
  white-space: nowrap;
}

.sortable-table td {
  white-space: nowrap;
}

.sortable-table thead th {
  background: var(--green);
  color: #fff;
}

.sortable-table th.sort-asc::after,
.sortable-table th.sort-desc::after {
  position: absolute;
  right: 0.3rem;
  color: var(--gold);
  font-size: 0.75rem;
}

.sortable-table th.sort-asc::after { content: "\25B2"; }
.sortable-table th.sort-desc::after { content: "\25BC"; }

.season-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.season-links a {
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  font-size: 1rem;
  color: var(--green);
}

.season-links a.active {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.btn {
  display: inline-block;
  background: var(--green);
  color: white;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: 4px;
  font-size: 1.05rem;
  font-weight: 600;
  text-decoration: none;
}

.btn:hover { background: var(--green-dark); color: white; }

.cc-winners-scroll {
  max-width: 420px;
  margin: 0 auto;
}

.cc-winner-entry {
  text-align: center;
  padding: 0.75rem 0;
}

.cc-winner-year {
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 0.15rem;
}

.cc-winner-name { margin: 0; color: #444; }

.cc-winners-link { text-align: center; margin: 1rem 0; }

/* Captain's Weekends */
.cw-details {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.35rem 0.75rem;
  margin: 0.5rem 0 0;
}

.cw-details dt { color: #777; font-size: 0.95rem; }
.cw-details dd { margin: 0; min-height: 1.5em; }
.cw-course { display: block; min-height: 1.5em; }

.cc-explainer { text-align: center; color: #555; font-size: 1.05rem; margin: 0 0 0.5rem; }

.editors-note {
  font-size: 0.95rem;
  color: #777;
  margin-top: 1.5rem;
  text-align: center;
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.9rem;
  color: #888;
}

/* Slightly wider layout on larger screens */
@media (min-width: 640px) {
  .venue-photo { height: 240px; }
  h1 { font-size: 2.2rem; }
  .site-header .logo img { height: 130px; }
}
