:root {
  /* Country-club / Masters palette: fairway green, logo gold, scorecard cream */
  --bg: #eef0e3;
  --bg-2: #e6e9d7;
  --surface: #fffdf6;
  --surface-alt: #f5f2e4;
  --border: #ddd6bf;
  --match-border: #cdc3a1;
  --match-shadow: 0 1px 2px rgba(51, 43, 18, 0.08), 0 5px 12px rgba(51, 43, 18, 0.09);
  --line: #a7ad8a;
  --text: #262417;
  --text-muted: #77715a;
  --accent: #0b5d3b;
  --accent-deep: #084a2e;
  --accent-soft: #e5efe0;
  --gold: #bd9b46;
  --gold-soft: #efe6c7;
  --gold-text: #6c531b;
  --bronze: #a9743f;
  --bronze-soft: #efe0d1;
  --bronze-text: #7c4a22;
  --warn-bg: #fbf3df;
  --warn-border: #e6c98d;
  --warn-text: #7d5a1c;
  --radius: 10px;
  --match-min-height: 64px;
  --gap: 44px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  background-image: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 3px solid var(--gold);
}

.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.site-header__crest {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, var(--accent) 0%, var(--accent-deep) 100%);
  border: 2px solid var(--gold);
  box-shadow: 0 2px 10px rgba(11, 93, 59, 0.28);
}

.site-header__logo {
  height: 84px;
  width: auto;
}

.site-header__text {
  text-align: center;
}

.site-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.3rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--accent);
}

.site-header__meta {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.page {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px;
}

/* ---------- Messages ---------- */
.messages {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.9rem;
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-text);
}

.message--error {
  border-color: #e7a5a5;
  background: #fdecec;
  color: #8a2b2b;
}

.message strong { display: block; margin-bottom: 2px; }
.message ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Bracket layout ---------- */
.bracket-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}

.bracket {
  display: flex;
  gap: var(--gap);
  align-items: stretch;
  min-height: 560px;
  min-width: min-content;
}

.round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1 1 0;
  min-width: 208px;
}

.round__title {
  position: sticky;
  top: 0;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  padding-bottom: 12px;
}

.round__title::after {
  content: "";
  display: block;
  width: 24px;
  height: 2px;
  margin: 5px auto 0;
  background: var(--gold);
}

/* keep the box (so the hidden champion title matches the other titles' height)
   but don't paint the gold dash */
.round--champion .round__title::after { visibility: hidden; }

/* ---------- Current round indicator ---------- */
.round--current {
  /* Flat tint, not a fade: a fade keyed to a fixed % cuts off before the
     bottom matches in a round with many of them (e.g. Round of 16). */
  background: rgba(189, 155, 70, 0.22);
  border-radius: var(--radius);
}

.round--current .round__title {
  align-self: center;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  color: var(--gold-text);
}

.round--current .round__title::before {
  content: "⛳";
  margin-right: 6px;
}

.round--current .round__title::after { display: none; }

.round__body {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1 1 auto;
}

/* A pair groups the two matches that feed one match in the next round */
.pair {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1 1 0;
  position: relative;
}

/*
 * Vertical connector joining a pair, drawn in the gap to the right.
 * With flexbox space-around and two equal items the match centres land at
 * exactly 25% and 75% of the pair height regardless of pair or card size,
 * so a fixed 25%..75% span always meets them.
 */
.round:not(:last-child) .pair--linked::after {
  content: "";
  position: absolute;
  right: calc(var(--gap) / -2);
  top: 25%;
  height: 50%;
  border-right: 2px solid var(--line);
}

/* ---------- Match card ---------- */
.match {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--match-border);
  border-radius: var(--radius);
  box-shadow: var(--match-shadow);
  min-height: var(--match-min-height);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* horizontal stub leaving a match toward the next round */
.round:not(:last-child) .match::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  width: calc(var(--gap) / 2 + 1px);
  border-top: 2px solid var(--line);
}

/* horizontal stub entering a match from the previous round */
.round:not(:first-child) .match::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  width: calc(var(--gap) / 2 + 1px);
  border-top: 2px solid var(--line);
}

.competitor {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.competitor + .competitor {
  border-top: 1px solid var(--border);
}

.competitor:first-child {
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.competitor:last-child,
.match__meta:last-child {
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.competitor__seed {
  flex: 0 0 auto;
  min-width: 20px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold-text);
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 1px 5px;
}

.competitor__name {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.competitor__result {
  flex: 0 0 auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Wordy results ("Forfeit", "Conceded") are a status, not a score */
.competitor__result--note {
  font-style: italic;
}

/* Course handicap, shown after the name in every match card */
.competitor__hcp {
  flex: 0 0 auto;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 5px;
}

.competitor__hcp::before {
  content: "H";
  margin-right: 1px;
  font-size: 0.82em;
  opacity: 0.65;
}

.competitor--loser .competitor__hcp {
  opacity: 0.6;
}

.competitor--winner {
  background: var(--accent-soft);
}
.competitor--winner .competitor__name {
  font-weight: 700;
  color: var(--accent);
}
.competitor--winner .competitor__result {
  color: var(--accent);
  font-weight: 600;
}

.competitor--loser .competitor__name { color: var(--text-muted); }

.competitor--placeholder .competitor__name {
  font-style: italic;
  color: var(--text-muted);
}

.match__meta {
  padding: 4px 12px 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
}

/* ---------- Champion ---------- */
.round--champion {
  justify-content: center;
  flex: 0 0 auto;
  min-width: 200px;
}

.champion-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 94px;
  padding: 24px 22px;
  background: linear-gradient(160deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fdfbf2;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 8px 22px rgba(11, 93, 59, 0.32);
}

.round--champion .champion-card::before {
  content: "";
  position: absolute;
  right: calc(100% + 2px);
  top: 50%;
  width: calc(var(--gap) / 2 + 4px);
  border-top: 2px solid var(--line);
}

/* label pinned to the top so the name sits at the card's true centre
   (where the connector from the Final meets it) */
.champion-card__label {
  position: absolute;
  top: 9px;
  left: 0;
  right: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
}

.champion-card__name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
}

/* ---------- 3rd-place playoff ---------- */
.champion-stack {
  position: relative;
  align-self: stretch;
}

.champion-stack .third-place {
  position: absolute;
  top: calc(100% + 16px);
  left: 0;
  right: 0;
}

.third-place {
  overflow: hidden;
  border: 1px solid var(--bronze);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--match-shadow);
  min-width: 190px;
}

.third-place__label {
  padding: 5px 8px;
  text-align: center;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--bronze-text);
  background: var(--bronze-soft);
  border-bottom: 1px solid var(--bronze);
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.site-footer__version {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.8;
}

.site-footer code,
.messages code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
}

/* ---------- Scorecard ---------- */
.match--has-scorecard {
  cursor: pointer;
}

.match--has-scorecard:hover,
.match--has-scorecard:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--match-shadow), 0 0 0 2px var(--accent-soft);
  outline: none;
}

.match__scorecard-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 50%;
  box-shadow: var(--match-shadow);
}

.scorecard-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(38, 36, 23, 0.55);
  z-index: 100;
  padding: 24px;
  align-items: center;
  justify-content: center;
}

.scorecard-overlay--open {
  display: flex;
}

.scorecard-modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--match-border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(38, 36, 23, 0.35);
  padding: 28px 20px 20px;
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
}

.scorecard-modal__close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
}

.scorecard-modal__close:hover {
  color: var(--text);
}

.scorecard-modal__course {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
  text-align: center;
}

.scorecard-table-wrap {
  overflow-x: auto;
}

.scorecard-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.scorecard-table th,
.scorecard-table td {
  border: 1px solid var(--border);
  padding: 9px 13px;
  text-align: center;
  white-space: nowrap;
}

.scorecard-table thead th {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.scorecard-table thead tr:first-child th {
  color: var(--accent);
  font-weight: 700;
}

.scorecard-table__label,
.scorecard-table__player {
  text-align: left;
  font-weight: 600;
  color: var(--accent);
}

/* Player name badges — same tokens as the Match status row below, so a
   player's name color and their "ahead" tint are guaranteed to match. */
.scorecard-table__player--a {
  background: var(--accent-soft);
  color: var(--accent);
}

.scorecard-table__player--b {
  background: var(--gold-soft);
  color: var(--gold-text);
}

.scorecard-table__score {
  position: relative;
}

.scorecard-table__score--stroke {
  font-weight: 600;
}

/* Hole-winner tint: this player's color if they won the hole, nothing
   (the table's plain background) if it was halved — a push gets no color. */
.scorecard-table__score--win-a {
  background: var(--accent-soft);
}

.scorecard-table__score--win-b {
  background: var(--gold-soft);
}

/* Small dot(s) in the lower-left corner of the score for each handicap
   stroke received on that hole — the classic scorecard convention, one dot
   per stroke (two for a hole where a big handicap gap wraps around and
   gives a 2nd stroke). A neutral dark dot stays visible whether the cell's
   background ends up plain, green, or gold. */
.stroke-dots {
  position: absolute;
  bottom: 3px;
  left: 4px;
  display: flex;
  gap: 2px;
}

.stroke-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text);
}

/* Classic scorecard birdie/bogey markers, drawn around the gross score.
   Circle = under par (double circle = eagle or better); square = over par
   (double square = double bogey or worse); plain text = par. The outline
   sits outside the border with a small offset, giving the "double" ring/box
   without a second element. */
.score-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  min-height: 1.6em;
  line-height: 1;
  box-sizing: border-box;
}

.score-marker--birdie,
.score-marker--eagle {
  border-radius: 50%;
  border: 1.5px solid var(--accent);
}

.score-marker--eagle {
  outline: 1.5px solid var(--accent);
  outline-offset: 2px;
}

.score-marker--bogey,
.score-marker--double-bogey {
  border-radius: 3px;
  border: 1.5px solid var(--bronze-text);
}

.score-marker--double-bogey {
  outline: 1.5px solid var(--bronze-text);
  outline-offset: 2px;
}

/* Running match-play status row: color-coded to whichever player is ahead */
.scorecard-table__status {
  font-weight: 700;
  font-size: 0.78rem;
}

.scorecard-table__status--a {
  background: var(--accent-soft);
  color: var(--accent);
}

.scorecard-table__status--b {
  background: var(--gold-soft);
  color: var(--gold-text);
}

.scorecard-table__status--as {
  background: var(--surface-alt);
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .page { padding: 16px; }
  .round { min-width: 180px; }
  :root { --gap: 32px; }

  .site-header__inner { flex-direction: column; gap: 12px; padding: 22px 16px; }
  .site-header__crest { width: 92px; height: 92px; }
  .site-header__logo { height: 70px; }
  .site-header h1 { font-size: 1.8rem; }
}
