:root {
  color-scheme: light;
  --paper: #f7f7f7;
  --surface: #fff;
  --subtle: #f0f0f0;
  --hover: #e9e9e9;
  --ink: #1b1b1b;
  --muted: #555;
  --line: #dedede;
  --control-border: #858585;
  --score-positive: #17643c;
  --score-negative: #a12f30;
  --radius: 12px;
  font-family: Inter, Avenir Next, Avenir, Arial, sans-serif;
  font-size: 100%;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121212;
  --surface: #1b1b1b;
  --subtle: #242424;
  --hover: #303030;
  --ink: #f4f4f4;
  --muted: #bcbcbc;
  --line: #3c3c3c;
  --control-border: #858585;
  --score-positive: #81dba8;
  --score-negative: #ff9b9b;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--paper); color: var(--ink); line-height: 1.55; }
main { flex: 1; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .19em; }
a:hover { color: var(--ink); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h2, h3 { letter-spacing: -.025em; line-height: 1.2; }
h2 { font-size: 1.2rem; margin-bottom: 0; }
h3 { font-size: 1rem; margin-bottom: .75rem; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
[hidden] { display: none !important; }
.skip { position: fixed; z-index: 5; top: .5rem; left: .5rem; transform: translateY(-160%); background: var(--surface); padding: .6rem 1rem; }
.skip:focus { transform: translateY(0); }
.shell { width: min(1160px, calc(100% - 3rem)); margin-inline: auto; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner, .footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.header-inner { min-height: 68px; }
.brand { color: var(--ink); text-decoration: none; font-size: 1.05rem; font-weight: 400; }
.header-actions { display: flex; align-items: center; gap: .75rem; }
.club-link { font-size: .89rem; font-weight: 700; }
.theme-toggle { flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.theme-toggle:is(:hover, :focus-visible) { color: var(--ink); }
.theme-toggle-icon { width: 17px; height: 17px; border: 1.5px solid currentColor; border-radius: 50%; background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.theme-toggle[aria-pressed="true"] .theme-toggle-icon { transform: rotate(180deg); }
.site-nav { background: var(--surface); }
.nav-inner { display: flex; flex-wrap: wrap; align-items: center; column-gap: clamp(1rem, 4vw, 2.6rem); min-height: 51px; }
.nav-auth { margin-inline-start: auto; }
.nav-auth button { background: none; border: 0; }
.nav-inner a, .nav-auth button { display: flex; align-items: center; min-height: 51px; color: var(--muted); border-bottom: 3px solid transparent; padding: 3px 0 0; font-size: .93rem; font-weight: 680; text-decoration: none; white-space: nowrap; }
.nav-inner a:hover, .nav-inner a[aria-current="page"], .nav-auth button:hover { border-bottom-color: var(--ink); color: var(--ink); }
.staff-nav { display: flex; flex-wrap: wrap; column-gap: inherit; }
.site-footer { margin-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); }
.footer-inner { min-height: 77px; flex-wrap: wrap; row-gap: .5rem; padding-block: 1rem; font-size: .875rem; }
.footer-inner p { margin: 0; }
.footer-inner .footer-credit { margin-inline-start: auto; text-align: end; }

.hero { background: var(--subtle); border-bottom: 1px solid var(--line); }
.home-hero { position: relative; isolation: isolate; background-color: var(--surface); }
.home-hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: #fff url("./home-banner.jpg") right 22% / min(100%, 68rem) auto no-repeat;
}
:root[data-theme="dark"] .home-hero { --muted: #d7d7d7; }
:root[data-theme="dark"] .home-hero::before { opacity: .26; }
.hero-inner { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.3rem 2rem; padding-block: 3rem 3.25rem; }
.compact-hero .hero-inner { padding-block: 2.2rem 2.4rem; }
.hero h1 { max-width: 16ch; margin: 0; font-weight: 650; font-size: clamp(2.55rem, 5.6vw, 4.65rem); letter-spacing: -.04em; line-height: 1.08; }
.compact-hero h1 { font-size: clamp(2.45rem, 5.8vw, 3.65rem); }
.overline { margin: 0 0 .75rem; color: var(--muted); font-weight: 750; letter-spacing: .105em; text-transform: uppercase; font-size: .83rem; }
.hero-description { margin: .9rem 0 0; color: var(--muted); max-width: 55ch; }

.page { padding-block: 2rem 2.5rem; }
.standings-page { padding-top: 1.45rem; }
.narrow { max-width: 790px; }
.summary-strip { display: grid; grid-template-columns: 1.2fr repeat(3, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 2.1rem; }
.summary-strip > div { display: grid; gap: .15rem; padding: .85rem clamp(.8rem, 2.4vw, 1.45rem) .95rem; border-inline-start: 1px solid var(--line); }
.summary-strip > div:first-child { border-inline-start: 0; }
.summary-strip span, .leader-meta { font-size: .875rem; color: var(--muted); }
.summary-strip strong { font-size: clamp(1.15rem, 2.4vw, 1.5rem); }
.summary-strip strong, .score, .number, .metrics dd { font-variant-numeric: tabular-nums; }

.leaders { margin-bottom: 2.15rem; }
.leaders h2 { margin-bottom: .85rem; font-size: 1.4rem; }
.podium { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: .85rem; }
.leader { display: grid; gap: .23rem; padding: 1rem 1.15rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; overflow: hidden; }
.leader[href]:hover { border-color: var(--ink); }
.leader-1 { background: var(--subtle); border-color: var(--control-border); }
.leader-heading { display: flex; gap: .6rem; align-items: center; font-size: 1.05rem; font-weight: 750; }
.medallion, .rank { min-width: 2rem; min-height: 2rem; display: inline-grid; place-items: center; border-radius: 6px; background: var(--subtle); color: var(--muted); font-size: .83rem; font-weight: 760; }
.leader-1 .medallion, .rank-1 { color: var(--surface); background: var(--ink); }
.leader .score { width: fit-content; font-size: 2rem; font-weight: 800; letter-spacing: -.055em; line-height: 1.15; }

.standings-grid, .history-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .45rem; padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
.panel-heading > span { color: var(--muted); font-size: .86rem; }
.panel-heading h1 { margin: 0; font-size: 1.42rem; letter-spacing: -.03em; }
.game-heading p { color: var(--muted); margin: .18rem 0 0; font-size: .88rem; }
.game-heading h2 a { text-decoration: none; }
.game-heading h2 a:hover { text-decoration: underline; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: .65rem .85rem; border-bottom: 1px solid var(--line); }
.data-table tr > :first-child { padding-left: 1rem; }
.data-table tr > :last-child { padding-right: 1rem; }
.data-table thead th { background: var(--subtle); color: var(--muted); font-weight: 720; font-size: .82rem; white-space: nowrap; }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--hover); }
.data-table tbody th { font-size: .94rem; font-weight: 700; }
.data-table tbody th a { text-decoration: none; }
.data-table tbody th a:hover { text-decoration: underline; }
.data-table .number { text-align: right; }
.data-table .score { font-weight: 760; }
.score.positive { color: var(--score-positive); }
.score.negative { color: var(--score-negative); }
.player-link { display: flex; align-items: center; gap: .55rem; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: var(--muted); background: var(--subtle); width: 2rem; height: 2rem; flex: none; font-size: .72rem; font-weight: 780; }
.rules-note, .field-hint { margin: 1.05rem 0 0; color: var(--muted); font-size: .9rem; }
.empty { margin: 0; padding: 1rem; color: var(--muted); }
.game-table td, .game-table th { padding-block: .48rem; }
.game-results { overflow-x: auto; }
.game-results tbody th { overflow-wrap: anywhere; }

.filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; }
.filter-bar { margin-bottom: 1.25rem; }
.field { display: grid; align-content: start; gap: .3rem; min-width: 0; font-weight: 650; }
.field span, .field > label, .score-rules summary { font-size: .875rem; }
.field select, .field input { width: 100%; min-width: 0; min-height: 44px; padding: .51rem .72rem; border: 1px solid var(--control-border); border-radius: 7px; background: var(--surface); color: var(--ink); }
.field input::placeholder { color: var(--muted); }
.field select { min-width: min(100%, 11.2rem); appearance: none; padding-right: 2rem; background-image: linear-gradient(45deg, transparent 47%, currentColor 51%, currentColor 66%, transparent 69%), linear-gradient(135deg, transparent 47%, currentColor 51%, currentColor 66%, transparent 69%); background-size: 6px 6px; background-position: calc(100% - 15px) 53%, calc(100% - 10px) 53%; background-repeat: no-repeat; }
.season-fields { display: flex; align-items: flex-end; gap: .75rem; min-inline-size: 0; max-inline-size: 100%; }
.season-fields .year-field { flex: 0 1 auto; inline-size: 7.25rem; }
.season-fields [data-season-field] { flex: 1 1 auto; inline-size: max-content; min-inline-size: min(10rem, 55vw); }
.season-fields select { min-inline-size: 0; }
.checkbox { display: flex; align-items: center; gap: .45rem; min-height: 44px; font-size: .875rem; font-weight: 650; }
.checkbox input { accent-color: var(--ink); width: 1rem; height: 1rem; }
.roster-intro { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.roster-intro p { margin: 0; }
.roster-bulk { display: flex; flex-wrap: wrap; gap: .5rem; }
.roster-table .roster-active { padding-block: 0; }
.roster-active .checkbox { width: 44px; justify-content: center; cursor: pointer; }
.roster-table tbody th { overflow-wrap: anywhere; }
.roster-table tbody .player-edit-link { display: inline-flex; align-items: center; min-height: 28px; padding-inline: .4rem; color: var(--muted); font-size: .875rem; font-weight: 400; text-decoration: underline; }
.roster-save { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; width: fit-content; padding: .53rem .95rem; border: 1px solid transparent; border-radius: 7px; color: var(--surface); background: var(--ink); text-decoration: none; font-weight: 740; }
.button:hover { background: var(--muted); color: var(--surface); }
.button.secondary { color: var(--ink); background: var(--surface); border-color: var(--control-border); }
.button.secondary:hover { background: var(--hover); border-color: var(--ink); }
.result-count { color: var(--muted); font-size: .9rem; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .85rem; margin-top: 1.4rem; }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-bottom: 1rem; }
.notice { margin: 1rem 0; border: 1px solid var(--line); border-radius: 7px; padding: .65rem .85rem; background: var(--subtle); }

.period-presets { margin: 0; }
.period-presets [aria-current="page"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.stats-body, .form-body { padding: 1rem; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin: 0 0 1.1rem; }
.metrics div { border: 1px solid var(--line); padding: .55rem .65rem; border-radius: 7px; }
.metrics dt { color: var(--muted); font-size: .875rem; }
.metrics dd { margin: .15rem 0 0; font-weight: 780; font-size: 1.25rem; }
.placement-list > div { display: grid; grid-template-columns: 2rem minmax(0, 1fr) 3.8rem; align-items: center; gap: .6rem; margin: .38rem 0; font-size: .9rem; }
.placement-list meter { width: 100%; height: .7rem; appearance: none; border: 0; border-radius: 5px; background: var(--subtle); }
.placement-list meter::-webkit-meter-bar { background: var(--subtle); border: 1px solid var(--line); }
.placement-list meter::-webkit-meter-optimum-value { background: var(--muted); }
.placement-list meter::-moz-meter-bar { background: var(--muted); }
.placement-list .number { text-align: right; }
.recent-panel { margin-top: 1.2rem; }
.recent-chart { --rank-gutter: 2.5rem; display: grid; padding: .7rem 1rem 1rem; }
.recent-guides, .recent-points, .recent-dates { list-style: none; padding: 0; margin: 0; }
.recent-guides, .recent-plot { grid-area: 1 / 1; min-inline-size: 0; }
.recent-guides, .recent-dates { color: var(--muted); font-size: .83rem; }
.recent-guides { display: grid; grid-template-rows: repeat(4, 1fr); }
.recent-guides li { display: grid; grid-template-columns: var(--rank-gutter) 1fr; align-items: center; }
.recent-guides li::after { content: ""; border-top: 1px solid var(--line); }
.recent-plot { position: relative; block-size: clamp(9rem, 20vw, 13rem); margin-inline-start: var(--rank-gutter); }
.recent-line, .recent-points { position: absolute; inset: 0; }
.recent-line { width: 100%; height: 100%; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.recent-points a { position: absolute; left: var(--game-x); top: var(--game-y); transform: translate(-50%, -50%); display: grid; place-items: center; inline-size: min(44px, 100% / var(--game-count)); block-size: 44px; border-radius: 50%; }
.recent-points a::before { content: ""; inline-size: .7rem; block-size: .7rem; border: 2px solid var(--ink); border-radius: 50%; background: var(--surface); }
.recent-points a:is(:hover, :focus-visible)::before { background: var(--ink); }
.recent-point-detail { display: none; position: absolute; z-index: 1; top: var(--game-y); left: clamp(0px, var(--game-x) - 5rem, 100% - 10rem); transform: translateY(calc(-100% - .8rem)); width: 10rem; padding: .25rem .4rem; border: 1px solid var(--control-border); border-radius: 6px; background: var(--surface); text-align: center; font-size: .8rem; pointer-events: none; }
.recent-points [data-place="1"] .recent-point-detail { transform: translateY(.85rem); }
.recent-points a:is(:hover, :focus-visible) + .recent-point-detail { display: block; }
.recent-dates { display: grid; grid-template-columns: repeat(var(--game-count), minmax(0, 1fr)); margin-inline-start: var(--rank-gutter); text-align: center; white-space: nowrap; }
.roster ul { list-style: none; margin: 0; padding: .85rem 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: .55rem .85rem; }
.roster li a { display: block; }
.auth-page { max-width: 470px; }
.auth-page .form-body, .score-form { display: grid; gap: 1.05rem; }
.detail-fields { display: grid; grid-template-columns: 1.2fr 1fr .65fr; gap: .8rem; }
.season-create { margin-bottom: 1.2rem; }
.season-create summary { padding: .75rem 1rem; cursor: pointer; font-weight: 700; }
.season-create[open] summary { border-bottom: 1px solid var(--line); }
.season-create .form-body { max-width: 45rem; }
.season-date-range time { white-space: nowrap; }
.data-table tbody .season-edit-link { display: block; width: fit-content; padding-block: .25rem; color: var(--muted); font-size: .875rem; font-weight: 400; text-decoration: underline; }
.seat-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.seat-fields fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 8px; margin: 0; padding: .5rem .75rem .75rem; display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.seat-fields fieldset > :nth-child(2) { grid-column: 1 / -1; }
.seat-fields legend { padding: 0 .3rem; font-weight: 740; }
.seat-fields .field-hint { grid-column: 1 / -1; margin: 0; }
.seat-fields .field select { min-width: 0; }
.seat-preview { grid-column: 1 / -1; padding: .55rem 0 .1rem; border-top: 1px solid var(--line); }
.seat-preview-summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem .75rem; font-size: .875rem; }
.seat-preview-summary strong { margin-inline-start: .2rem; font-size: 1rem; }
.seat-score-components { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; margin: .5rem 0 0; }
.seat-score-components dt { color: var(--muted); font-size: .875rem; }
.seat-score-components dd { margin: 0; font-variant-numeric: tabular-nums; }
.score-actions { justify-content: center; margin-bottom: 1.5rem; }
.score-submit { width: min(100%, 20rem); }
.score-submit:disabled { background: var(--subtle); color: var(--muted); border-color: var(--control-border); cursor: not-allowed; }
.score-rules .form-body { padding-block: .25rem; }
.score-rules details + details { border-top: 1px solid var(--line); }
.score-rules summary { min-height: 44px; padding: .65rem 0; font-weight: 650; cursor: pointer; }
.score-rules details .field-hint { margin: 0 0 .75rem; }
.errorlist { margin: .2rem 0; padding: .55rem 1rem .55rem 1.7rem; background: var(--subtle); color: var(--ink); border: 1px solid var(--control-border); border-radius: 6px; }
#score-total { font-variant-numeric: tabular-nums; }
#score-total[data-complete] { color: var(--score-positive); font-weight: 750; }

@media (max-width: 860px) {
  .standings-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 650px) {
  .shell { width: calc(100% - 1.5rem); }
  .header-inner { min-height: 58px; }
  .header-inner, .header-actions { gap: .5rem; }
  .nav-inner, .nav-inner a, .nav-auth button { min-height: 45px; }
  .hero-inner { padding-block: 2.1rem; }
  .home-hero .hero-main { max-width: 57%; }
  .home-hero h1 { font-size: clamp(1.85rem, 8vw, 2.55rem); }
  .home-hero::before { background-size: cover; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-strip > div:nth-child(3) { border-inline-start: 0; }
  .summary-strip > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .podium { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .42rem; }
  .leader { padding: .65rem .5rem; }
  .leader-heading { flex-direction: column; align-items: flex-start; gap: .3rem; font-size: .88rem; }
  .leader .score { font-size: 1.55rem; }
  .leader-meta { font-size: .79rem; }
  .history-grid { grid-template-columns: minmax(0, 1fr); }
  .recent-chart { --rank-gutter: 1.9rem; padding-inline: .65rem; }
  .recent-dates li:not(:first-child, :last-child) { visibility: hidden; }
  .recent-dates li:first-child { justify-self: start; }
  .recent-dates li:last-child { justify-self: end; }
  .recent-dates li:only-child { justify-self: center; }
  .data-table th, .data-table td { padding-inline: .4rem; }
  .data-table tr > :first-child { padding-left: .65rem; }
  .data-table tr > :last-child { padding-right: .65rem; }
  .avatar { display: none; }
  .panel-heading { padding-inline: .75rem; }
  .detail-fields, .seat-fields { grid-template-columns: 1fr; }
}
