:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #ebe7dd;
  --ink: #202520;
  --muted: #697068;
  --line: #d9d4c7;
  --green: #196f56;
  --green-2: #d9eee6;
  --gold: #a96f1e;
  --red: #b0473a;
  --blue: #246c8f;
  --shadow: 0 12px 28px rgba(38, 40, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 24px 32px 18px;
  background: #223127;
  color: #f6f5f1;
  border-bottom: 4px solid #c98b35;
}

.eyebrow {
  margin: 0 0 4px;
  color: #c8d8cb;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 780;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

h3 {
  font-size: 17px;
  line-height: 1.25;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 680px;
}

.meta-chip,
.count-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 4px 8px;
  color: inherit;
  background: rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

main {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 42px;
}

.controls {
  display: grid;
  grid-template-columns: auto minmax(150px, 190px) minmax(120px, 150px) minmax(170px, 220px) 140px 140px minmax(180px, 1fr);
  gap: 10px;
  align-items: end;
  padding: 14px 0 18px;
}

.tabs {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.tab-button {
  min-width: 92px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 740;
}

.tab-button.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(24, 31, 25, 0.08);
}

.control {
  display: grid;
  gap: 5px;
}

.control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.control input,
.control select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 2px 0 18px;
}

.summary-item {
  min-height: 84px;
  padding: 14px;
  border-top: 3px solid var(--green);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-item:nth-child(2) {
  border-color: var(--gold);
}

.summary-item:nth-child(3) {
  border-color: var(--blue);
}

.summary-item:nth-child(4) {
  border-color: var(--red);
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
  text-transform: uppercase;
}

.summary-value {
  margin-top: 7px;
  font-size: 22px;
  font-weight: 780;
  line-height: 1.1;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin: 0 0 12px;
}

.section-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.count-pill {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 740;
}

.card-grid {
  display: grid;
  gap: 12px;
}

.current-course-row {
  margin-bottom: 18px;
}

.historical-head {
  margin-top: 6px;
}

.golfer-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.course-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: visible;
}

.current-course-card {
  border-color: rgba(25, 111, 86, 0.45);
  box-shadow: 0 18px 38px rgba(25, 111, 86, 0.16);
}

.current-course-card .card-head {
  grid-template-columns: minmax(0, 1fr);
  background: linear-gradient(90deg, #f6fff9 0%, #ffffff 68%);
  border-bottom-color: rgba(25, 111, 86, 0.25);
}

.course-flag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  margin-bottom: 8px;
  padding: 5px 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #196f56, #2e9e78);
  color: #ffffff;
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
  box-shadow: 0 6px 14px rgba(25, 111, 86, 0.22);
}

.course-flag::before {
  content: "";
  width: 8px;
  height: 18px;
  margin-right: 8px;
  border-radius: 2px;
  background: #f2b84b;
}

.card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.name-stack {
  min-width: 0;
}

.name-stack h3 {
  overflow-wrap: anywhere;
}

.subline {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.info-link {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  margin-top: 7px;
  align-items: center;
  border: 1px solid rgba(25, 111, 86, 0.24);
  border-radius: 5px;
  padding: 3px 7px;
  color: var(--green);
  background: #f6fff9;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
  text-decoration: none;
}

.info-link:hover,
.info-link:focus {
  border-color: rgba(25, 111, 86, 0.42);
  background: var(--green-2);
  outline: none;
}

.primary-number {
  position: relative;
  min-width: 74px;
  text-align: right;
}

.primary-number strong {
  display: block;
  font-size: 22px;
  line-height: 1.05;
}

.primary-number span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
  text-transform: uppercase;
}

.similarity-score {
  position: relative;
  cursor: help;
  outline: none;
}

.similarity-score:hover,
.similarity-score:focus {
  color: var(--green);
}

.similarity-tooltip {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 10px);
  right: 0;
  width: min(320px, 74vw);
  padding: 10px 12px;
  border: 1px solid rgba(25, 111, 86, 0.28);
  border-radius: 7px;
  background: #203127;
  color: #ffffff;
  text-align: left;
  font-size: 12px;
  font-weight: 640;
  line-height: 1.4;
  text-transform: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease;
  box-shadow: 0 14px 34px rgba(32, 49, 39, 0.2);
}

.similarity-score:hover .similarity-tooltip,
.similarity-score:focus .similarity-tooltip,
.similarity-score.is-active .similarity-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.course-current-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
  min-width: 0;
  padding: 9px 10px;
  background: #fbfaf6;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.scorecard {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
}

.score-row {
  display: grid;
  grid-template-columns: 76px minmax(82px, 1fr) 58px;
  gap: 10px;
  align-items: center;
  min-height: 25px;
}

.score-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e7e1d4;
}

.bar-fill {
  display: block;
  height: 100%;
  min-width: 2px;
  background: linear-gradient(90deg, var(--green), #3d9b7a);
}

.score-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 720;
}

.card-history {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.card-history-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.card-tabs {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-width: 132px;
  height: 32px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.card-tab {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 760;
}

.card-tab.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(24, 31, 25, 0.08);
}

.card-chart-control {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.card-chart-control select {
  width: 150px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 8px;
  font-size: 12px;
}

.history-graph {
  min-width: 0;
}

.chart-block {
  display: grid;
  width: 100%;
}

.sparkline {
  width: 100%;
  height: 150px;
}

.chart-axis-line,
.chart-gridline {
  stroke: #d9d4c7;
  stroke-width: 1;
}

.chart-gridline {
  opacity: 0.62;
}

.chart-tick,
.chart-empty {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 680;
}

.history-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.history-table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 12px;
}

.history-table th,
.history-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.history-table th {
  color: var(--muted);
  background: #fbfaf6;
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

.history-table td {
  color: var(--ink);
}

.history-table th:last-child,
.history-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.history-table tbody tr:last-child td {
  border-bottom: 0;
}

.history-table td {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-empty {
  padding: 12px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 14px;
}

.tag {
  border-color: var(--line);
  background: var(--green-2);
  color: #174335;
  font-size: 11px;
  font-weight: 740;
}

.tag.muted {
  background: #f3efe6;
  color: var(--muted);
}

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
}

.load-state {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: 520px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.load-state.is-hidden {
  display: none;
}

.load-state.is-error {
  color: #6f271f;
  border-color: #d7a39c;
}

@media (max-width: 1320px) {
  .controls {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .golfer-grid,
  .course-grid,
  .summary-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 16px;
  }

  .event-meta {
    justify-content: flex-start;
  }

  main {
    width: min(100% - 20px, 1500px);
    padding-top: 12px;
  }

  .controls,
  .summary-band,
  .golfer-grid,
  .course-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-history-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .card-chart-control {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-chart-control select {
    width: 100%;
  }
}
