/* Baseline — ATP stats. Surface-coded system:
   hard = blue, clay = terracotta, grass = green, carpet = grey. */
:root {
  --ink: #17211b;
  --muted: #6c756f;
  --paper: #fcfcfa;
  --line: #e4e6e1;
  --court: #0b3d2e;        /* deep court green — primary */
  --hard: #2b62a8;
  --clay: #bf5230;
  --grass: #3e7c3a;
  --carpet: #7c7c84;
  --slam: #a8862b;
  --won: #eef6ef;
  --lost: #faf1ef;
  --radius: 8px;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--body); font-size: 15px; line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--hard); outline-offset: 2px; }

main { max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; }

h1, h2, .brand, .num, .big-num, .statline, .rank {
  font-family: var(--display);
}
h1 { font-size: clamp(30px, 5vw, 52px); font-weight: 700; line-height: 1.05;
     letter-spacing: 0.2px; margin: 0.2em 0; text-transform: uppercase; }
h2 { font-size: 22px; font-weight: 600; text-transform: uppercase;
     letter-spacing: 0.6px; margin: 0 0 10px; }
.page-title { margin-top: 28px; }
.eyebrow { font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase;
           color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.num { font-weight: 600; font-size: 18px; font-variant-numeric: tabular-nums; }
.num em { font-style: normal; color: var(--muted); font-size: 14px; }

/* ---------- header ---------- */
.site-head {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 2px solid var(--court);
  background: var(--paper); position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 26px; font-weight: 700; letter-spacing: 1px; color: var(--court); }
.brand span { color: var(--clay); }
.site-head nav { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px;
  font-weight: 500; min-width: 0; }
.site-head .search { margin-left: auto; width: 240px; }

/* ---------- search ---------- */
.search { position: relative; }
.search input {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
}
.search input:focus { border-color: var(--court); outline: none; }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  margin: 0; padding: 4px; list-style: none; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(23,33,27,.12); max-height: 320px; overflow: auto;
}
.search-results li { padding: 8px 10px; border-radius: 6px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 8px; }
.search-results li:hover, .search-results li.sel { background: var(--won); }
.search-results .t { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------- hero ---------- */
.hero { padding: 56px 0 28px; text-align: center; }
.hero h1 { max-width: 720px; margin: 8px auto; }
.hero-search { max-width: 460px; margin: 22px auto 10px; }
.hero-search input { padding: 13px 16px; font-size: 16px; }
.hero-meta { color: var(--muted); font-size: 13px; }

/* ---------- leaderboards ---------- */
.boards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
          gap: 20px; margin: 36px 0; }
.board { border: 1px solid var(--line); border-radius: var(--radius);
         padding: 18px; background: #fff; }
.board ol { margin: 0; padding: 0 0 0 22px; }
.board li { display: flex; justify-content: space-between; gap: 10px;
            padding: 4px 0; border-bottom: 1px dashed var(--line); }
.board li:last-child { border-bottom: 0; }
.board .more { display: inline-block; margin-top: 10px; font-size: 13px;
               color: var(--court); font-weight: 500; }

/* ---------- tournament cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
         gap: 14px; }
.card { border: 1px solid var(--line); border-left: 4px solid var(--carpet);
        border-radius: var(--radius); background: #fff; padding: 12px 14px;
        display: flex; flex-direction: column; gap: 2px; }
.card:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(23,33,27,.08); }
.card-level { font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
              color: var(--muted); }
.card-sub, .card-champ { font-size: 13px; color: var(--muted); }
.card.surface-hard  { border-left-color: var(--hard); }
.card.surface-clay  { border-left-color: var(--clay); }
.card.surface-grass { border-left-color: var(--grass); }

/* ---------- surface chips & bars ---------- */
.chip { display: inline-block; padding: 1px 8px; font-size: 12px; font-weight: 600;
        border-radius: 999px; color: #fff; background: var(--carpet);
        text-transform: uppercase; letter-spacing: .5px; }
.chip.surface-hard  { background: var(--hard); }
.chip.surface-clay  { background: var(--clay); }
.chip.surface-grass { background: var(--grass); }
.chip.surface-none  { background: var(--line); color: var(--muted); }
.chip.slam { background: var(--slam); }

.surfaces, .h2h-surfaces { margin: 22px 0; display: grid; gap: 10px; }
.surface-row { display: grid; grid-template-columns: 84px 1fr 150px;
               align-items: center; gap: 14px; }
.h2h-surfaces .surface-row { grid-template-columns: 44px 1fr 84px 44px; }
.bar { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.fill { display: block; height: 100%; border-radius: 999px; background: var(--carpet); }
.fill.surface-hard  { background: var(--hard); }
.fill.surface-clay  { background: var(--clay); }
.fill.surface-grass { background: var(--grass); }
.bar.split { background: repeating-linear-gradient(90deg, var(--line) 0 6px, #d3d6d0 6px 12px); }

/* ---------- player page ---------- */
.player-head { display: flex; flex-wrap: wrap; justify-content: space-between;
               align-items: flex-end; gap: 20px; padding: 34px 0 10px;
               border-bottom: 2px solid var(--court); }
.statline { display: flex; gap: 26px; }
.statline > div { text-align: center; }
.statline .num { font-size: 34px; font-weight: 700; display: block; line-height: 1; }
.statline label { font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
                  color: var(--muted); }

.titles-list { margin: 20px 0; border: 1px solid var(--line);
               border-radius: var(--radius); background: #fff; padding: 12px 16px; }
.titles-list summary { cursor: pointer; font-weight: 600; }
.titles-list ul { columns: 2; margin: 10px 0 0; padding-left: 20px; }
.titles-list li { margin: 3px 0; break-inside: avoid; }

.results { margin-top: 30px; }
.results-head { display: flex; justify-content: space-between; align-items: center; }
select { font: inherit; padding: 7px 10px; border: 1px solid var(--line);
         border-radius: var(--radius); background: #fff; }

.tourney-block { border: 1px solid var(--line); border-left: 4px solid var(--carpet);
                 border-radius: var(--radius); background: #fff;
                 margin: 14px 0; overflow: hidden; }
.tourney-block.surface-hard  { border-left-color: var(--hard); }
.tourney-block.surface-clay  { border-left-color: var(--clay); }
.tourney-block.surface-grass { border-left-color: var(--grass); }
.tourney-block header { display: flex; align-items: center; gap: 10px;
                        padding: 10px 14px; border-bottom: 1px solid var(--line); }
.tourney-block table { width: 100%; border-collapse: collapse; }
.tourney-block td { padding: 7px 14px; border-top: 1px solid var(--line); }
.tourney-block tr:first-child td { border-top: 0; }
tr.won  { background: var(--won); }
tr.lost { background: var(--lost); }
td.rnd { width: 52px; color: var(--muted); font-size: 13px; }
td.res { width: 30px; font-weight: 700; }
tr.won  td.res { color: var(--grass); }
tr.lost td.res { color: var(--clay); }
td.score, .score { font-variant-numeric: tabular-nums; white-space: nowrap;
                   text-align: right; color: var(--muted); }

/* ---------- tournament page ---------- */
.round { margin-top: 26px; }
.round-table { width: 100%; border-collapse: collapse; background: #fff;
               border: 1px solid var(--line); border-radius: var(--radius);
               overflow: hidden; }
.round-table td { padding: 8px 12px; border-top: 1px solid var(--line); }
.round-table tr:first-child td { border-top: 0; }
.round-table .def { color: var(--muted); width: 24px; }
.h2h-link { font-size: 12px; color: var(--hard); font-weight: 600; }

/* ---------- head to head: the net ---------- */
.h2h-pickers { display: flex; align-items: center; gap: 14px; margin: 18px 0 28px;
               flex-wrap: wrap; }
.h2h-pickers .search { flex: 1; min-width: 220px; }
.vs { font-family: var(--display); font-weight: 700; font-size: 20px;
      color: var(--muted); }

.net-court { display: grid; grid-template-columns: 1fr 20px 1fr;
             align-items: center; background: var(--court); color: #fff;
             border-radius: var(--radius); padding: 30px 10px; margin: 10px 0 22px; }
.net-court .eyebrow { color: #b9cdc4; }
.net-court h2 { font-size: 20px; }
.net-court a { color: #fff; }
.side { text-align: center; }
.big-num { font-size: 76px; font-weight: 700; line-height: 1; display: block;
           font-variant-numeric: tabular-nums; }
.net { height: 100%; min-height: 120px;
       background-image: repeating-linear-gradient(0deg, rgba(255,255,255,.55) 0 2px, transparent 2px 9px),
                         repeating-linear-gradient(90deg, rgba(255,255,255,.55) 0 2px, transparent 2px 9px);
       border-top: 3px solid #fff; }
.h2h-surfaces .side-a-num { text-align: right; }

/* ---------- leaders ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0 20px; }
.tabs a { padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
          font-size: 13px; font-weight: 500; background: #fff; }
.tabs a.active { background: var(--court); border-color: var(--court); color: #fff; }
.tabs a:hover { text-decoration: none; border-color: var(--court); }
.leader-table { width: 100%; border-collapse: collapse; background: #fff;
                border: 1px solid var(--line); }
.leader-table th { text-align: left; font-size: 12px; letter-spacing: 1px;
                   text-transform: uppercase; color: var(--muted);
                   padding: 10px 12px; border-bottom: 2px solid var(--court); }
.leader-table th.num-h { text-align: right; }
.leader-table td { padding: 8px 12px; border-top: 1px solid var(--line); }
.leader-table td.num { text-align: right; font-size: 15px; }
.leader-table .rank { color: var(--muted); width: 40px; font-size: 17px; }
.leader-table tbody tr:nth-child(-n+3) .rank { color: var(--slam); font-weight: 700; }

/* ---------- player flags ---------- */
.flag-badge { display: inline-block; vertical-align: middle; margin-left: 10px;
  padding: 2px 10px; font-family: var(--body); font-size: 12px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase; color: #fff; background: #b3261e;
  border-radius: 999px; }
.flag-note { margin: 16px 0 0; padding: 12px 16px; font-size: 14px;
  border: 1px solid #e8c9c6; border-left: 4px solid #b3261e; border-radius: var(--radius);
  background: #fdf4f3; color: var(--ink); }
.flag-note a { margin-left: 6px; text-decoration: underline; color: #b3261e; }

/* ---------- footer ---------- */
.site-foot { max-width: 1080px; margin: 0 auto; padding: 18px 20px 40px;
             color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.site-foot a { text-decoration: underline; }

@media (max-width: 720px) {
  .tourney-block td { padding: 6px 8px; }
  td.rnd { width: 34px; }
  td.score, .score { white-space: normal; font-size: 12px; line-height: 1.35;
    min-width: 72px; }
  .site-head { gap: 10px 16px; }
  .site-head nav { width: 100%; order: 2; gap: 4px 14px; font-size: 13px; }
  .site-head .search { width: 100%; margin-left: 0; order: 3; }
  .statline { gap: 16px; flex-wrap: wrap; }
  .statline .num { font-size: 26px; }
  .titles-list ul { columns: 1; }
  .surface-row { grid-template-columns: 70px 1fr 110px; gap: 8px; }
  .big-num { font-size: 52px; }
}
@media (prefers-reduced-motion: no-preference) {
  .fill { transition: width .5s ease; }
}

/* ---------- filter bar (streaks & deep dives) ---------- */
.filter-bar { display: flex; gap: 18px; flex-wrap: wrap; margin: 14px 0 22px;
  padding: 14px 16px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); }
.filter-bar label { display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted); font-weight: 600; }
.filter-bar select { min-width: 160px; }
.filter-bar .check-label span { display: flex; align-items: center; gap: 6px;
  min-height: 34px; font-weight: 400; text-transform: none; letter-spacing: 0;
  font-size: 14px; color: var(--ink); }
.chip.gold { background: #b8860b; }
.streak-link { text-decoration: underline; color: var(--hard); }
.compare-table td.best { background: var(--won); font-weight: 700; color: var(--grass); }
.compare-table th a { white-space: nowrap; }

/* ---------- compare: share bars + era chart ---------- */
.share-bars { display: grid; gap: 10px; margin: 14px 0 26px; }
.share-row { display: grid; grid-template-columns: 150px 1fr 170px; gap: 12px;
  align-items: center; }
.share-name { font-weight: 600; font-size: 14px; }
.share-bar { display: flex; height: 18px; border-radius: 999px; overflow: hidden;
  background: var(--line); }
.share-row.calendar { opacity: .65; border-top: 1px dashed var(--line); padding-top: 10px; }
.share-nums { font-size: 13px; color: var(--muted); }
.era-chart { width: 100%; height: auto; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); }
.era-chart .tick { font-family: var(--body); font-size: 10px; fill: var(--muted); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  vertical-align: middle; }
@media (max-width: 720px) { .share-row { grid-template-columns: 90px 1fr; }
  .share-nums { display: none; } }

/* ---------- GOAT builder ---------- */
.filter-bar.builder { align-items: flex-end; }
.filter-bar.builder input[type=number] { width: 110px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--radius); font: inherit; }
.builder-actions { display: flex; gap: 8px; align-items: flex-end; }
.btn { font: inherit; font-weight: 600; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--court); background: var(--court); color: #fff; cursor: pointer; }
.btn.ghost { background: #fff; color: var(--court); text-decoration: none; }
.btn:hover { opacity: .9; text-decoration: none; }
td.move { width: 44px; font-size: 12px; font-weight: 700; }
td.move .up { color: var(--grass); }
td.move .down { color: var(--clay); }

/* ---------- slam grid ---------- */
.slam-grid-wrap { overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; padding: 10px; }
.slam-grid { border-collapse: separate; border-spacing: 3px; }
.slam-grid th { font-size: 10px; color: var(--muted); font-weight: 600;
  font-family: var(--body); text-align: center; }
.slam-grid th.slam-name { text-align: right; padding-right: 8px; font-size: 12px;
  white-space: nowrap; }
.slam-grid td.cell { width: 26px; height: 24px; min-width: 26px; text-align: center;
  font-size: 10px; font-weight: 700; border-radius: 4px; color: #fff;
  font-family: var(--body); }
.res-w   { background: var(--slam); }
.res-f   { background: #0b3d2e; }
.res-sf  { background: #3e7c3a; }
.res-qf  { background: #7aa877; }
.res-r16, .res-r32, .res-r64, .res-r128, .res-rr { background: #cdd7cc; color: #55605a !important; }
.res-none { background: #f2f3f0; }

/* ---------- radar ---------- */
.radar-wrap { display: flex; flex-direction: column; align-items: center; }
.radar { width: min(420px, 100%); height: auto; }

/* ---------- h2h centered surface split ---------- */
.surface-row-centered { display: grid; grid-template-columns: 40px 1fr 92px 1fr 40px;
  align-items: center; gap: 10px; }
.surface-row-centered .chip { text-align: center; }
.surface-row-centered .num:first-child { text-align: right; }
.bar.half.left { display: flex; justify-content: flex-end; }

/* ---------- methodology notes ---------- */
.method { margin: 34px 0 8px; padding: 12px 16px; border: 1px dashed var(--line);
  border-radius: var(--radius); background: #fff; }
.method summary { cursor: pointer; font-weight: 600; font-size: 13px;
  letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.method p { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 10px 0 2px; }
.method strong { color: var(--ink); }

/* ---------- h2h split line (number–bar–chip–bar–number) ---------- */
.split-line { display: grid; grid-template-columns: 36px 1fr 92px 1fr 36px;
  align-items: center; gap: 10px; }
.split-line .num:first-child { text-align: right; }
.split-line .chip { text-align: center; }
.split-line .zone { height: 14px; }
.split-line .zone.left { display: flex; justify-content: flex-end; }
.split-line .stick { display: block; height: 100%; min-width: 5px; }
.split-line .zone.left .stick { border-radius: 7px 0 0 7px; }
.split-line .zone:not(.left) .stick { border-radius: 0 7px 7px 0; }
.stick.surface-hard  { background: var(--hard); }
.stick.surface-clay  { background: var(--clay); }
.stick.surface-grass { background: var(--grass); }
.stick.surface-carpet { background: var(--carpet); }

/* ---------- rivals table ---------- */
.rivals-table .num.lead { color: var(--grass); font-weight: 700; }
.rivals-table .num.trail { color: var(--clay); }
