: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 {
  background: linear-gradient(180deg, rgba(189, 155, 70, 0.14) 0%, rgba(189, 155, 70, 0) 60%);
  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: 8px;
  padding: 8px 12px;
  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;
}

.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;
}

@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; }
}
