:root {
    --ink: #12211a;
    --paper: #f4efe4;
    --card: #fffdf8;
    --line: #d9d0c0;
    --green: #1f6b46;
    --red: #9b2c2c;
    --muted: #6b6258;
    --horse: #7a4e16;
    --amber: #a8791f;
}

* { box-sizing: border-box; }

/* Elements toggled via the "hidden" attribute (player-card, the finder/elig/
   trend/recent sections, etc.) must actually disappear even when a class
   like .player-card also sets its own `display`, which otherwise silently
   wins over the browser's default [hidden] rule and leaves stale content
   showing (e.g. the player card lingering below the finder after "Back to
   list"). */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "Source Sans 3", system-ui, sans-serif;
}

a { color: var(--green); }

.top {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: flex-end;
    padding: 1.4rem 1.4rem 0.8rem;
    border-bottom: 3px solid var(--ink);
}

h1 {
    font-family: Oswald, sans-serif;
    font-size: clamp(1.7rem, 3.6vw, 2.6rem);
    margin: 0;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.kicker {
    margin: 0;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--green);
}

.lede {
    max-width: 40rem;
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.tools { flex-shrink: 0; }

.search-wrap { position: relative; width: 20rem; max-width: 100%; }

.search-wrap input {
    width: 100%;
    border: 1px solid var(--ink);
    background: #fff;
    padding: 0.6rem 0.8rem;
    font: inherit;
    font-size: 1rem;
}

.search-wrap input:focus { outline: 2px solid var(--green); outline-offset: 1px; }

.suggestions {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--ink);
    max-height: 18rem;
    overflow-y: auto;
    z-index: 20;
}

.suggestions button {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.8rem;
    border: none;
    border-bottom: 1px solid var(--line);
    background: none;
    font: inherit;
    cursor: pointer;
    color: var(--ink);
}

.suggestions button:last-child { border-bottom: none; }
.suggestions button:hover, .suggestions button.active { background: #fff6d8; }
.suggestions .s-name { font-weight: 600; }
.suggestions .s-meta { color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 0.78rem; }

main { padding: 1.2rem 1.4rem 3rem; max-width: 62rem; margin: 0 auto; }

.status {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.85rem;
    color: var(--muted);
    min-height: 1.4rem;
}

.status.err { color: var(--red); }

.player-card {
    display: flex;
    gap: 1.1rem;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--line);
    padding: 1rem 1.2rem;
    margin: 0.6rem 0 1.2rem;
}

.player-card img {
    width: 4.6rem;
    height: 4.6rem;
    object-fit: cover;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 50%;
    flex-shrink: 0;
}

.player-card h2 {
    font-family: Oswald, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin: 0 0 0.2rem;
    font-size: 1.5rem;
}

.player-meta {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.82rem;
    color: var(--muted);
}

.card-stat-bar {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
}

.card-stat-window-tabs button {
    padding: 0.15rem 0.45rem;
    font-size: 0.66rem;
}

.card-stat-line {
    display: flex;
    gap: 0.9rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.card-stat-line.empty {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.78rem;
    color: var(--muted);
}

.card-stat { text-align: center; }

.card-stat-val {
    display: block;
    font-family: "IBM Plex Mono", monospace;
    font-weight: 600;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.card-stat-label {
    display: block;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    padding: 1rem 1.2rem 1.2rem;
    margin: 0 0 1.2rem;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 0.7rem;
}

.section-head h3 {
    margin: 0;
    font-size: 0.86rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--green);
}

.platform-tabs, .window-tabs {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.platform-tabs button, .window-tabs button {
    font: inherit;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    cursor: pointer;
}

.platform-tabs button.on, .window-tabs button.on {
    border-color: var(--ink);
    background: var(--ink);
    color: var(--paper);
}

.elig-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
    gap: 0.7rem;
}

.elig-card {
    border: 1px solid var(--line);
    padding: 0.7rem 0.8rem;
    background: #fff;
}

.elig-card .pos {
    font-family: Oswald, sans-serif;
    font-size: 1.15rem;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.elig-card .pill {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.66rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 0.12rem 0.4rem;
    border-radius: 999px;
    border: 1px solid transparent;
}

.pill.elig { background: #e5f2ea; color: var(--green); border-color: #bfe0cc; }
.pill.close { background: #fbeecb; color: var(--amber); border-color: #f0dca0; }
.pill.far { background: #f5e6e4; color: var(--red); border-color: #e6c6c2; }

.elig-card .bar-track {
    height: 0.45rem;
    background: var(--paper);
    border: 1px solid var(--line);
    margin: 0.5rem 0 0.4rem;
    overflow: hidden;
}

.elig-card .bar-fill { height: 100%; background: var(--green); }
.elig-card .bar-fill.close { background: var(--amber); }

.elig-card .stat-line {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.76rem;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
}

.elig-card .prior {
    margin-top: 0.4rem;
    font-size: 0.74rem;
    color: var(--muted);
}

.elig-card .prior b { color: var(--ink); }

.elig-card .stat-line.next-season {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px dashed var(--line);
}

.footnote {
    margin: 0.8rem 0 0;
    font-size: 0.78rem;
    color: var(--muted);
}

#trend-body .trend-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

#trend-body .trend-row:last-child { border-bottom: none; }

.trend-pos {
    font-family: Oswald, sans-serif;
    text-transform: uppercase;
    font-size: 1.05rem;
    width: 3.2rem;
    flex-shrink: 0;
}

.trend-detail { flex: 1; min-width: 14rem; }

.trend-detail .headline { font-weight: 600; }
.trend-detail .sub { color: var(--muted); font-size: 0.85rem; font-family: "IBM Plex Mono", monospace; }

.sparkline { flex-shrink: 0; }

.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: 0.7rem;
    margin-bottom: 0.9rem;
}

.stat-tile {
    border: 1px solid var(--line);
    background: #fff;
    padding: 0.6rem 0.7rem;
}

.stat-tile .num {
    font-family: "IBM Plex Mono", monospace;
    font-size: 1.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stat-tile .label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.small-sample {
    color: var(--amber);
    font-size: 0.78rem;
    margin-top: -0.4rem;
    margin-bottom: 0.8rem;
}

table.game-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

table.game-table th, table.game-table td {
    text-align: left;
    padding: 0.3rem 0.4rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

table.game-table th {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
}

table.game-table td.num, table.game-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

table.game-table th.sortable { cursor: pointer; user-select: none; }
table.game-table th.sortable:hover { color: var(--ink); }
table.game-table th.sortable[aria-sort="ascending"]::after { content: " ↑"; }
table.game-table th.sortable[aria-sort="descending"]::after { content: " ↓"; }

.section-head + .section-head { margin-top: -0.5rem; }
.section-head .footnote { margin: 0; }

.finder-side {
    min-width: 0;
}

.filter-block {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.pos-filter {
    border: 1px solid var(--line);
    padding: 0.5rem 0.7rem 0.6rem;
    margin: 0;
    flex: 1 1 16rem;
}

.pos-filter legend {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 0.3rem;
}

.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.9rem;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.8rem;
    cursor: pointer;
}

.slider-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
    gap: 0.7rem 1.2rem;
    margin-bottom: 0.9rem;
}

.slider-field { display: flex; flex-direction: column; gap: 0.15rem; }

.slider-label {
    display: flex;
    justify-content: space-between;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    color: var(--muted);
}

.slider-field input[type="range"] {
    width: 100%;
    accent-color: var(--green);
}

.player-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.7rem;
}

.player-tile {
    border: 1px solid var(--line);
    background: #fff;
    padding: 0.7rem 0.6rem;
    text-align: center;
    cursor: pointer;
}

.player-tile:hover { border-color: var(--ink); background: #fff6d8; }

.player-tile img {
    width: 4rem;
    height: 4rem;
    object-fit: cover;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 50%;
}

.player-tile .p-name {
    font-weight: 700;
    font-size: 0.82rem;
    margin-top: 0.5rem;
    line-height: 1.2;
}

.player-tile .p-team {
    color: var(--muted);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.66rem;
    margin-top: 0.15rem;
}

.player-tile .pos-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    justify-content: center;
    margin-top: 0.5rem;
}

.player-tile .pos-pills .pill { font-size: 0.6rem; }

.site-foot {
    max-width: 62rem;
    margin: 0 auto;
    padding: 1.2rem 1.4rem 3rem;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.site-foot p { margin: 0.3rem 0; }

@media (max-width: 700px) {
    .top { display: block; }
    .search-wrap { width: 100%; margin-top: 0.8rem; }
    .player-card { flex-wrap: wrap; }
    .card-stat-bar { align-items: flex-start; margin-left: 0; }
    .card-stat-window-tabs, .card-stat-line { justify-content: flex-start; }
}
