:root {
  --navy: #17264D;
  --red: #ED1E24;
  --white: #FFFFFF;
  --bb-primary: #050708;
  --bb-accent: #ef4a23;
  --iu-primary: #0e3039;
  --iu-accent: #e1bfda;
  --gray-bg: #f4f5f7;
  --gray-border: #dde1e6;
  --text: #1c1c1e;
  --muted: #888;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--gray-bg);
  color: var(--text);
  padding-bottom: 60px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--navy);
  color: var(--white);
  padding: 10px 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.logo-small { height: 44px; width: 44px; object-fit: contain; border-radius: 50%; background: white; padding: 2px; }
.topbar-text { flex: 1; }
.event-name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.event-sub { font-size: 12px; opacity: 0.85; }
.captain-toggle {
  background: var(--red);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tabs {
  display: flex;
  overflow-x: auto;
  background: white;
  border-bottom: 1px solid var(--gray-border);
  position: sticky;
  top: 64px;
  z-index: 19;
}
.tab-btn {
  flex: 1;
  min-width: 90px;
  padding: 12px 8px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn.active { color: var(--navy); border-bottom-color: var(--red); }

main#app { padding: 16px; max-width: 720px; margin: 0 auto; }

/* Leaderboard */
.leaderboard-header {
  text-align: center;
  margin-bottom: 16px;
}
.leaderboard-header h2 { margin: 0 0 4px; font-size: 18px; color: var(--navy); }
.leaderboard-header p { margin: 0; font-size: 13px; color: #666; }

.scoreboard {
  background: white;
  border-radius: 14px;
  padding: 20px 16px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 18px;
}
.scoreboard-teams { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sb-team { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 42%; }
.sb-team img { width: 100px; height: 100px; object-fit: contain; }
.sb-team .sb-name { font-size: 11px; font-weight: 700; text-align: center; }
.sb-team.bb .sb-name { color: var(--bb-primary); }
.sb-team.iu .sb-name { color: var(--iu-primary); }
.sb-team .sb-points { font-size: 34px; font-weight: 800; line-height: 1; }
.sb-team.bb .sb-points { color: var(--bb-accent); }
.sb-team.iu .sb-points { color: var(--iu-primary); }
.sb-mid { font-size: 14px; color: var(--gray-border); font-weight: 700; }
.race-track { position: relative; height: 16px; border-radius: 8px; background: var(--gray-border); margin-bottom: 6px; overflow: hidden; }
.race-bb { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bb-accent); }
.race-iu { position: absolute; right: 0; top: 0; bottom: 0; background: var(--iu-primary); }
.race-center-line { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: 0.35; }
.race-caption { text-align: center; font-size: 11px; color: #888; font-weight: 600; }
.race-caption b { color: var(--text); }

.round-summary {
  background: white;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.round-summary .rs-left { font-size: 13px; font-weight: 600; }
.round-summary .rs-sub { font-size: 11px; color: #888; font-weight: 400; }
.round-summary .rs-score { font-size: 13px; font-weight: 700; color: var(--navy); }

/* Matchups */
.round-block {
  background: white;
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.round-block-header {
  background: var(--navy);
  color: white;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.round-block-header .rbh-title { font-weight: 700; font-size: 14px; }
.round-block-header .rbh-sub { font-size: 11px; opacity: 0.8; }

/* Team column header — sits below the navy round bar, above the match
   list. Answers "which side is which team" the way Ryder Cup shows
   USA/EUROPE over its columns. Deliberately its own full-width row
   (not crammed into the navy bar, which overflowed on mobile) split
   50/50 to match the two-column match layout underneath it. */
.team-col-header { display: flex; background: var(--gray-bg); border-bottom: 1px solid var(--gray-border); }
.team-col-header > div { flex: 1; text-align: center; padding: 6px 4px; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; }
.tch-bb { color: var(--bb-accent); }
.tch-iu { color: var(--iu-primary); }

.match-card { padding: 14px; border-bottom: 1px solid var(--gray-border); }
.match-card:last-child { border-bottom: none; }
.match-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.match-format { font-size: 12px; font-weight: 700; color: var(--navy); }
.match-points { font-size: 11px; color: #888; }

.tbd-label { font-size: 12px; color: #999; font-style: italic; }

/* Player reveal cards — the pre-result "reveal" state on Matchups.
   size variants: .lg for 2-per-side and singles formats (side-stack /
   single card), .md for the 4-per-side Scramble grid (reveal-grid).
   Each team's content sits in its own centered half-column (.card-side)
   so 4-Man's 2x2 grid, 2v2's stack, and singles' single card all land
   on the SAME center point — no more anchoring to the outer edges. */
.card-row { display: flex; align-items: center; gap: 10px; }
.card-side { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; }
.vs-divider { align-self: center; font-size: 11px; font-weight: 800; color: #aaa; padding: 0 4px; }
.side-stack { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.reveal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; justify-items: center; }

.player-card { position: relative; border-radius: 8px; overflow: hidden; border: 2px solid transparent; background: var(--gray-bg); }
.player-card.lg { width: 92px; height: 92px; }
.player-card.md { width: 64px; height: 64px; }
.player-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.player-card.pc-team-bb { border-color: var(--bb-accent); }
.player-card.pc-team-iu { border-color: var(--iu-accent); }
.pc-scrim { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.55); padding: 2px 4px; }
.pc-name { color: white; font-size: 10px; font-weight: 700; display: block; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Net strokes line — shown under reveal cards (handicap-based concessions).
   Ported from design-preview.html v7 and extended for singles matches. */
.net-strokes { font-size: 11px; color: var(--muted); text-align: center; margin-top: 6px; }
.net-strokes b { color: var(--text); font-weight: 700; }
.net-strokes-final { font-size: 10.5px; color: var(--muted); text-align: center; margin-top: 4px; }
.net-strokes-final b { color: var(--text); font-weight: 700; }

/* Desktop / TV breakpoint — Cody plugs in at the hotel via TV, so the
   4-Man Scramble grid and 2v2 side-stack/singles cards both get
   materially bigger here. 4-Man stays a 2x2 grid per team at every
   width (never flattens to a row) per Cody's explicit call; 2v2
   flattens from a vertical stack to a single row of 4 on desktop only.
   .lg is bumped to the SAME 130px as .md on desktop (Cody's explicit
   call, 2026-08-02) so every card across every format matches width —
   that's what closes the leftover whitespace between sides. */
@media (min-width: 768px) {
  .player-card.md { width: 130px; height: 130px; }
  .player-card.lg { width: 130px; height: 130px; }
  .reveal-grid { gap: 10px; }
  .side-stack { flex-direction: row; gap: 10px; }
}

/* Ryder Cup style match result — shown once a match is revealed and is
   either in progress or final. Colors show which team is ahead/won (or
   halved) plus points at stake. Match-play formats get a centered margin
   badge ("2&1," "1 UP," "All Square"); the stroke-play 4-Man Scramble
   shows the raw team score inside each side instead. Added 2026-08-02
   to close the gap vs. design-preview.html v7 — this was previously
   scoped but never built. */
.rc-columns { display: flex; align-items: stretch; border-radius: 8px; overflow: hidden; margin-top: 8px; }
.rc-side { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.rc-side:first-child { align-items: flex-start; text-align: left; }
.rc-side:last-child { align-items: flex-end; text-align: right; }
.rc-names { font-weight: 700; }
.rc-names .name-line { display: block; line-height: 1.3; }
/* Singles rows (1 name per side): centered vertically within a height
   matched to the 2-line paired rows, instead of pinned near the top. */
.rc-names.rc-names-1line { display: flex; flex-direction: column; justify-content: center; min-height: 2.6em; }

/* Match-play margin badge, centered between the two rc-side blocks */
.rc-margin { flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; background: #f2f2f2; color: var(--text); }
.rc-margin.rc-margin-pending { color: #ccc; font-weight: 600; }

/* Stroke-play (4-Man Scramble): score number lives INSIDE its team's
   rc-side box (inherits that side's win/lose background + text color,
   e.g. white on a win) rather than in a separate neutral middle column.
   .rc-side-stroke flips rc-side to a horizontal row so the name block
   and the score land on opposite edges of the box — name toward the
   outside, score toward the inside edge, right next to (not inside)
   the neutral space the match-play margin badge occupies below it.
   DOM order controls which edge the score lands on: bb-side puts name
   first (name=outer/left, score=inner/right); iu-side puts score first
   (score=inner/left, name=outer/right). Cody's explicit call, 2026-08-02. */
.rc-side.rc-side-stroke { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
.rc-score-num { flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; padding: 0 6px; }

/* bold — Leaderboard tab, per-match rows inside "Round by round" */
.rc-bold .rc-side { padding: 14px; }
.rc-bold .rc-names { font-size: 13.5px; }
.rc-bold .rc-score-num { font-size: 15px; }
.rc-bold .rc-margin { width: 64px; font-size: 15px; }
.rc-bold .rc-margin.rc-margin-as { font-size: 11px; }
.rc-bold .rc-win-bb { background: var(--bb-accent); color: #fff; }
.rc-bold .rc-win-iu { background: var(--iu-primary); color: var(--iu-accent); }
.rc-bold .rc-lose-bb { background: #FCFBF9; color: var(--bb-primary); }
.rc-bold .rc-lose-iu { background: #FCFBF9; color: var(--iu-primary); }
.rc-bold .rc-halved { background: #f7f7f7; color: #666; }

/* soft — Matches tab, after a match flips from reveal photos to a result row */
.rc-soft .rc-side { padding: 8px 10px; }
.rc-soft .rc-names { font-size: 11.5px; }
.rc-soft .rc-score-num { font-size: 11px; }
.rc-soft .rc-margin { width: 48px; font-size: 11px; background: #eee; }
.rc-soft .rc-win-bb { background: rgba(239,74,35,0.14); color: #c23e12; }
.rc-soft .rc-win-iu { background: #DCEEF4; color: var(--iu-primary); }
.rc-soft .rc-lose-bb { background: #FCFBF9; color: var(--bb-primary); }
.rc-soft .rc-lose-iu { background: #FCFBF9; color: var(--iu-primary); }
.rc-soft .rc-halved { background: #f5f5f5; color: #888; }

.rc-pending-note { text-align: center; font-size: 11px; color: #999; font-style: italic; margin-top: 6px; }

/* Round recap — per-match rows inside the Leaderboard tab's "Round by round" section */
.round-recap { background: white; border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.rr-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.rr-header h4 { margin: 0; font-size: 13px; color: var(--navy); }
.rr-header span { font-size: 11px; color: #888; }
.rr-match { margin-bottom: 10px; }
.rr-match:last-child { margin-bottom: 0; }
.rr-format-line { font-size: 11px; font-weight: 600; color: #888; margin-bottom: 2px; }
.rr-pending-line { font-size: 12px; color: #999; font-style: italic; padding: 6px 0; }

/* Captain controls */
.captain-controls { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--gray-border); }
.captain-controls label { font-size: 11px; font-weight: 600; color: #666; display: block; margin-bottom: 3px; margin-top: 8px; }
.captain-controls select, .captain-controls .btn-row { width: 100%; }
select.player-select { width: 100%; padding: 6px; border-radius: 6px; border: 1px solid var(--gray-border); font-size: 13px; margin-bottom: 4px; }
.margin-input, .score-input { padding: 6px; border-radius: 6px; border: 1px solid var(--gray-border); font-size: 13px; }
.margin-input { width: 100%; }
.score-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.score-row .score-input { width: 70px; text-align: center; }
.score-row label { display: inline; font-size: 11px; margin: 0; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.btn-small {
  flex: 1;
  min-width: 70px;
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid var(--gray-border);
  background: white;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.btn-small.active-bb { background: var(--bb-accent); color: white; border-color: var(--bb-accent); }
.btn-small.active-iu { background: var(--iu-primary); color: white; border-color: var(--iu-primary); }
.btn-small.active-halved { background: #999; color: white; }
.btn-reveal { background: var(--red); color: white; border: none; padding: 8px; border-radius: 6px; font-weight: 700; font-size: 12px; width: 100%; margin-top: 8px; cursor: pointer; }
.btn-reveal:disabled { background: #ccc; cursor: default; }

/* Schedule */
.schedule-card {
  background: white;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.schedule-card h3 { margin: 0 0 4px; font-size: 15px; color: var(--navy); }
.schedule-card .sc-meta { font-size: 12px; color: #777; margin-bottom: 6px; }
.schedule-card .sc-formats { font-size: 12px; color: #444; }
.schedule-card .sc-slope { font-size: 11px; color: #999; margin: 4px 0 0; font-style: italic; }

.day-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.day-divider:first-child { margin-top: 0; }
.day-divider::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--gray-border);
}

.lunch-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #888;
  font-style: italic;
  padding: 6px 4px;
  margin-bottom: 4px;
}
.lunch-note::before { content: "🍽"; font-style: normal; }

/* Optional round (Round 6) — intentionally muted/less prominent */
.schedule-card.optional-card {
  background: #fafafa;
  border: 1px dashed var(--gray-border);
  box-shadow: none;
  opacity: 0.85;
}
.schedule-card.optional-card h3 { color: #888; font-size: 13px; }
.schedule-card.optional-card .sc-meta { color: #999; }
.schedule-card.optional-card .sc-formats { color: #999; }
.schedule-card.optional-card .sc-note { font-size: 11px; color: #aaa; margin-top: 6px; }

/* Rosters */
.roster-columns { display: flex; gap: 12px; }
.roster-col { flex: 1; }
.roster-col-header {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  padding: 8px;
  border-radius: 8px 8px 0 0;
  color: white;
}
.roster-col-header.bb { background: var(--bb-primary); }
.roster-col-header.iu { background: var(--iu-primary); }
.roster-player {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  padding: 8px;
  border-bottom: 1px solid var(--gray-border);
  font-size: 13px;
}
.roster-player:last-child { border-radius: 0 0 8px 8px; }
.roster-player img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.roster-player .rp-name { flex: 1; font-weight: 600; }
.roster-player .rp-hcp { font-size: 11px; color: #888; }
.roster-player .rp-hcp-label { font-size: 10px; color: #aaa; text-transform: uppercase; margin-left: 3px; letter-spacing: 0.3px; }
.captain-star { color: var(--red); margin-left: 3px; }

/* Trip Info */
.trip-card { background: white; border-radius: 10px; padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.trip-card h3 { margin: 0 0 6px; font-size: 14px; color: var(--navy); }
.trip-card p { margin: 0; font-size: 13px; color: #444; line-height: 1.5; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-box { background: white; border-radius: 12px; padding: 20px; width: 85%; max-width: 320px; }
.modal-box h3 { margin: 0 0 6px; color: var(--navy); }
.modal-box p { font-size: 13px; color: #666; margin: 0 0 10px; }
.modal-box input { width: 100%; padding: 10px; border-radius: 6px; border: 1px solid var(--gray-border); font-size: 14px; margin-bottom: 10px; }
.modal-actions { display: flex; gap: 8px; }
.btn-primary { flex: 1; background: var(--red); color: white; border: none; padding: 10px; border-radius: 6px; font-weight: 700; cursor: pointer; }
.btn-secondary { flex: 1; background: var(--gray-bg); border: 1px solid var(--gray-border); padding: 10px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.error { color: var(--red); font-size: 12px; }
.error.hidden { display: none; }

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--gray-border);
  padding: 8px 14px;
  font-size: 11px;
  color: #999;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.reset-btn { background: none; border: 1px solid var(--gray-border); border-radius: 6px; padding: 4px 8px; font-size: 10px; color: #999; cursor: pointer; margin-right: 6px; }
.reset-btn.hidden { display: none; }
#demoBtn { border-color: var(--iu-accent); color: var(--iu-primary); }

@media (min-width: 600px) {
  .tab-btn { font-size: 14px; }
}
