/* ATP Tour — pixel sticker theme: cream paper, hard ink outlines, clay-court header. */

@font-face { font-family: 'Jersey 10'; font-weight: 400; font-display: swap; src: url('fonts/Jersey10-400.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 400; font-display: swap; src: url('fonts/BarlowSemiCondensed-400.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 600; font-display: swap; src: url('fonts/BarlowSemiCondensed-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 700; font-display: swap; src: url('fonts/BarlowSemiCondensed-700.woff2') format('woff2'); }

:root {
  --paper: #f2e9d0;
  --card: #fffbee;
  --card-2: #efe4c4;
  --k: #1a1a2e;
  --muted: #655d4d;
  --soft: rgba(26, 26, 46, .14);
  --yellow: #ffd23f;
  --ball: #d6e33a;
  --clay: #c45a2e;
  --clay-2: #b44f27;
  --red: #c0321f;
  --green: #217a39;
  --pix: 'Jersey 10', ui-monospace, Menlo, monospace;
  --body: 'Barlow Semi Condensed', 'Arial Narrow', system-ui, sans-serif;
  --shadow: 4px 4px 0 var(--k);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background-color: var(--paper);
  background-image: radial-gradient(rgba(26, 26, 46, .1) 1.2px, transparent 1.4px); background-size: 16px 16px;
  color: var(--k); font: 400 17px/1.4 var(--body);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: inherit; text-decoration: none; }
b, strong { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.num { font-variant-numeric: tabular-nums; }
.pix { filter: drop-shadow(1px 0 0 var(--k)) drop-shadow(-1px 0 0 var(--k)) drop-shadow(0 1px 0 var(--k)) drop-shadow(0 -1px 0 var(--k)); vertical-align: -3px; }
.pos { color: var(--green); font-weight: 700; } .neg { color: var(--red); font-weight: 700; }

h1 {
  display: inline-block; margin: .3rem 0 .9rem; padding: .15rem .7rem;
  font: 400 2.38rem/1.15 var(--pix); text-transform: uppercase; letter-spacing: .03em;
  background: var(--ball); border: 2px solid var(--k); box-shadow: 3px 3px 0 var(--k); transform: rotate(-1deg);
}
h2 { margin: 1.8rem 0 .7rem; font: 400 1.44rem/1.2 var(--pix); text-transform: uppercase; letter-spacing: .05em; border-bottom: 3px solid var(--k); padding-bottom: .25rem; }
.tagline { margin: -.3rem 0 1rem; color: var(--muted); font-weight: 600; }

/* ---- header: clay court */
.top {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: .6rem 1rem; flex-wrap: wrap;
  padding: .6rem 1rem .7rem; background: repeating-linear-gradient(90deg, var(--clay) 0 32px, var(--clay-2) 32px 64px); border-bottom: 4px solid var(--k);
}
.brand { display: inline-flex; align-items: center; gap: .55rem; font: 400 1.62rem/1 var(--pix); text-transform: uppercase; color: #fff; text-shadow: 2px 2px 0 var(--k); }
nav { display: flex; flex-wrap: wrap; gap: .45rem; }
nav a { padding: .3rem .65rem; font: 400 1.3rem/1.2 var(--pix); text-transform: uppercase; background: var(--card); border: 2px solid var(--k); box-shadow: 2px 2px 0 var(--k); }
nav a.on { background: var(--ball); transform: translate(2px, 2px); box-shadow: none; }
@media (max-width: 720px) {
  .top { flex-direction: column; align-items: stretch; }
  nav { width: 100%; display: grid; grid-template-columns: repeat(6, 1fr); }
  nav a { grid-column: span 2; text-align: center; padding: .3rem .1rem; font-size: 1.15rem; }
  nav a:nth-child(4) { grid-column: 2 / span 2; } nav a:nth-child(5) { grid-column: span 2; }
}
main { max-width: 860px; margin: 0 auto; padding: 1.3rem 1rem 2.5rem; }
footer { text-align: center; padding: .5rem 1rem 2.5rem; font: 400 1.06rem var(--pix); color: var(--muted); }

/* ---- surfaces */
.panel, .stat, .tcard, .scard, .summary > div { background: var(--card); border: 2px solid var(--k); border-radius: 4px; box-shadow: var(--shadow); }
.panel { padding: .8rem 1rem; margin: 0 0 1.1rem; }
.panel > h3 { margin: -.8rem -1rem .7rem; padding: .45rem 1rem; display: flex; align-items: center; gap: .5rem; font: 400 1.25rem/1.2 var(--pix); text-transform: uppercase; letter-spacing: .04em; color: var(--paper); background: var(--k); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 560px) { .cols { grid-template-columns: 1fr; } }
.chip { display: inline-flex; align-items: center; gap: .25rem; padding: 0 .45rem; font-size: .85rem; font-weight: 700; background: #fff; border: 2px solid var(--k); white-space: nowrap; }
.chip.clay { background: #f0b394; } .chip.hard { background: #9cc3ee; }
.chip.V { background: #9fdcab; } .chip.S { background: #f2a79c; } .chip.P { background: #e6dcb8; }
.chip.gold { background: var(--yellow); }
.form { display: inline-flex; gap: .2rem; }
.form .chip { min-width: 1.7rem; justify-content: center; padding: 0 .25rem; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: .9rem; margin: 0 0 1.1rem; }
.stat { padding: .55rem .8rem .65rem; box-shadow: 3px 3px 0 var(--k); }
.stat b { display: block; font: 400 1.75rem/1.1 var(--pix); }
.stat span { color: var(--muted); font-size: .88rem; font-weight: 600; line-height: 1.2; display: block; }
.note { margin: .8rem 0; padding: .55rem .8rem; font-weight: 600; background: #fff1a8; border: 2px solid var(--k); box-shadow: 3px 3px 0 var(--k); transform: rotate(-.4deg); }
.empty { padding: 1.2rem; text-align: center; color: var(--muted); font-weight: 600; }

/* ---- tables (always full, scroll sideways on narrow screens) */
.tw { overflow-x: auto; margin: 0 -1rem; padding: 0 1rem; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th { font: 400 1.05rem var(--pix); text-transform: uppercase; letter-spacing: .04em; text-align: right; padding: .25rem .5rem; border-bottom: 3px solid var(--k); white-space: nowrap; }
td { padding: .42rem .5rem; text-align: right; border-top: 1px solid var(--soft); white-space: nowrap; font-weight: 600; }
th:nth-child(2), td:nth-child(2), th.l, td.l { text-align: left; }
td:first-child, th:first-child { text-align: center; width: 2.4rem; padding-left: .2rem; padding-right: .2rem; }
tbody tr:nth-child(even) td { background: rgba(26, 26, 46, .035); }
tr.lead td { background: #fff1a8 !important; }
td a { text-decoration: underline; text-decoration-color: var(--soft); text-underline-offset: 3px; }
td a:hover, td a:focus-visible { text-decoration-color: var(--k); }
.rk { font: 400 1.3rem var(--pix); }

/* ---- tournament / match cards */
.list { display: grid; gap: 1rem; }
.tcard { padding: 0; }
.tcard > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; min-height: 44px; }
.tcard > summary::-webkit-details-marker { display: none; }
.tcard > summary::after { content: '+'; margin-left: auto; font: 400 1.6rem var(--pix); }
.tcard[open] > summary::after { content: '−'; }
.tcard[open] > summary { border-bottom: 2px solid var(--k); background: var(--card-2); }
.tcard .body { padding: .7rem .9rem .9rem; }
.tn { font: 400 1.6rem/1 var(--pix); text-transform: uppercase; }
.mrow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .6rem; padding: .55rem .3rem; border-top: 1px solid var(--soft); min-height: 44px; font-weight: 600; }
.mrow:hover, .mrow:focus-visible { background: rgba(255, 210, 63, .25); outline: none; }
.mrow .p2 { text-align: right; }
.mrow .w { font-weight: 700; }
.sc { padding: 0 .6rem; font: 400 1.5rem/1.3 var(--pix); letter-spacing: .08em; color: var(--ball); background: #14141f; border: 2px solid var(--k); box-shadow: inset 0 0 0 2px #3a3a52; }
.bigscore { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .8rem; margin: .5rem 0 1rem; }
.bigscore .t { font: 400 1.9rem/1.1 var(--pix); text-transform: uppercase; }
.bigscore .t:last-child { text-align: right; }
.bigscore .sc { font-size: 3rem; padding: .1rem 1rem; }
@media (max-width: 480px) { .bigscore { grid-template-columns: 1fr; text-align: center; } .bigscore .t:last-child { text-align: center; } .bigscore .sc { justify-self: center; } }

/* ---- sticker cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.scard { position: relative; isolation: isolate; display: block; padding: .5rem .6rem .7rem; text-align: center; transition: transform .08s; }
.scard:hover, .scard:focus-visible { transform: translate(-1px, -1px); outline: none; box-shadow: 5px 5px 0 var(--k); }
.scard.gold { background: linear-gradient(160deg, #fff3b0, #f2c230); } .scard.silver { background: linear-gradient(160deg, #f6f8fa, #bcc6d0); } .scard.bronze { background: linear-gradient(160deg, #f6d9bd, #d29a62); }
.scard .face { position: relative; height: 92px; margin: .2rem 0 .3rem; display: grid; place-items: center; overflow: hidden; border-radius: 3px; background: rgba(255, 255, 255, .45); border: 2px solid var(--k); }
.scard .face .ini { font: 400 3.6rem/1 var(--pix); }
.scard .face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.scard.has-photo .ini { display: none; }
.scard .elo { display: block; text-align: left; font: 400 1.4rem/1 var(--pix); }
.scard .nm { font: 400 1.35rem/1.1 var(--pix); text-transform: uppercase; }
.scard .nick { font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.scard .mini { display: flex; justify-content: center; gap: .6rem; margin-top: .3rem; font: 400 1.1rem var(--pix); }
.hero { display: grid; grid-template-columns: auto 1fr; gap: 1.1rem; align-items: center; margin-bottom: 1.1rem; }
.hero .scard { width: 170px; box-shadow: var(--shadow); }
@media (max-width: 480px) { .hero { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.nickline { font: 400 1.35rem var(--pix); letter-spacing: .05em; color: var(--clay); text-transform: uppercase; margin: 0; }

/* ---- controls */
.controls { display: flex; flex-wrap: wrap; gap: .6rem; margin: 0 0 1rem; }
select, input[type=search], button, .btn {
  min-height: 44px; padding: .3rem .7rem; font: 600 1rem var(--body); color: var(--k); background: #fff; border: 2px solid var(--k); border-radius: 0; box-shadow: 2px 2px 0 var(--k);
}
button, .btn { cursor: pointer; background: var(--ball); font-family: var(--pix); font-weight: 400; font-size: 1.25rem; text-transform: uppercase; display: inline-flex; align-items: center; gap: .4rem; }
button:active { transform: translate(2px, 2px); box-shadow: none; }
button.ghost { background: #fff; }
input[type=search] { flex: 1 1 180px; }
.pills { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .8rem; }
.pills label { cursor: pointer; }
.pills input { position: absolute; opacity: 0; pointer-events: none; }
.pills span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 .6rem; font-weight: 700; background: #fff; border: 2px solid var(--k); }
.pills input:checked + span { background: var(--ball); box-shadow: 2px 2px 0 var(--k); }
.pills input:focus-visible + span { outline: 3px solid var(--clay); outline-offset: 2px; }

/* ---- charts */
.chart { overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; min-width: 460px; }
.chart text { font: 600 11px var(--body); fill: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin: .4rem 0; font-weight: 700; font-size: .9rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--k); margin-right: .3rem; vertical-align: -1px; }
.tip { position: fixed; z-index: 90; pointer-events: none; padding: .3rem .55rem; font-weight: 700; font-size: .85rem; background: var(--k); color: var(--paper); border: 2px solid var(--k); box-shadow: 3px 3px 0 rgba(0, 0, 0, .25); max-width: 220px; }
details.sec > summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }

/* ---- badges, bars, misc */
.badges { display: flex; flex-wrap: wrap; gap: .5rem; }
.badge { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .6rem; font-weight: 700; background: #fff; border: 2px solid var(--k); box-shadow: 2px 2px 0 var(--k); }
.bar { height: 14px; background: #fff; border: 2px solid var(--k); min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--clay); }
.bar.cem i { background: #2a78d6; }
.row2 { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .8rem 0; }

/* ---- export modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; background: rgba(26, 26, 46, .75); }
.modal > div { max-width: 460px; width: 100%; max-height: 92vh; overflow: auto; padding: .8rem; background: var(--card); border: 3px solid var(--k); box-shadow: var(--shadow); }
.modal img { width: 100%; height: auto; display: block; border: 2px solid var(--k); }
.modal .actions { justify-content: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
:focus-visible { outline: 3px solid var(--clay); outline-offset: 2px; }
