*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1a1a2e;
    background: #f5f6f8;
    line-height: 1.5;
    font-size: 14px;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
    background: #1a1a2e;
    color: #fff;
    padding: 1rem 2rem;
    display: flex;
    align-items: baseline;
    gap: 1rem;
}
.site-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.site-header h1 a { color: #fff; text-decoration: none; }
.tagline { font-size: 0.8rem; color: #8888aa; }

main { max-width: 1600px; margin: 0 auto; padding: 1rem 1.5rem; }

.mode-selector {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
}
.mode-btn {
    cursor: pointer;
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    background: #fff;
    border-right: 1px solid #d1d5db;
    transition: background 0.15s;
}
.mode-btn:last-child { border-right: none; }
.mode-btn:hover { background: #f0f4ff; }
.mode-btn input[type="radio"] { display: none; }
.mode-btn:has(input:checked) { background: #2563eb; color: #fff; }

.source-seg {
    display: inline-flex;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
    padding: 0;
    margin: 0;
    min-width: 0;
}
.source-opt { cursor: pointer; display: inline-flex; }
.source-opt > span {
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 500;
    background: #fff;
    color: #334155;
    white-space: nowrap;
}
.source-opt + .source-opt > span { border-left: 1px solid #d1d5db; }
/* Hidden but focusable — NOT display:none (which drops it from tab order). */
.source-opt input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    overflow: hidden;
}
/* Equal weight: whichever source is checked gets the SAME blue treatment. */
.source-opt:has(input:checked) > span { background: #2563eb; color: #fff; }
.source-opt input:focus-visible + span { outline: 2px solid #1d4ed8; outline-offset: -2px; }
/* On the selected (blue) pill, a white inset ring keeps the focus state visible. */
.source-opt:has(input:checked) input:focus-visible + span { outline-color: #fff; }

.source-caption:not(:empty) {
    font-size: 0.78rem;
    color: #64748b;
    margin: 0 0 0.6rem;
    padding: 0 0.25rem;
}
.source-caption a { color: #1e40af; text-decoration: none; font-weight: 600; }
.source-caption a:hover { text-decoration: underline; }

.methodology { max-width: 760px; margin: 0 auto; line-height: 1.55; }
.methodology h2 { margin-bottom: 0.2rem; }
.methodology-version { color: #64748b; font-size: 0.8rem; margin-top: 0; }
.methodology section { margin-top: 1.4rem; }
.methodology h3 { color: #1e40af; font-size: 1.05rem; margin-bottom: 0.4rem; }
.provenance-table { border-collapse: collapse; width: 100%; margin-top: 0.5rem; font-size: 0.9rem; }
.provenance-table th, .provenance-table td { text-align: left; padding: 0.4rem 0.7rem; border-bottom: 1px solid #e5e7eb; }
.provenance-table th { color: #475569; font-weight: 600; }
.provenance-table td:first-child { color: #334155; font-weight: 500; }

.setup-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
}

.config-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.6rem 1.25rem;
    margin-bottom: 0.5rem;
}
.config-summary {
    font-size: 0.85rem;
    color: #374151;
    font-weight: 500;
}
.customize-toggle {
    padding: 0.35rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 500;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    color: #374151;
    transition: all 0.15s;
}
.customize-toggle:hover {
    border-color: #2563eb;
    color: #2563eb;
}
.setup-panel.collapsed {
    display: none;
}

.presets {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}
.preset-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-block;
}
.preset-btn:hover { background: #f0f4ff; border-color: #2563eb; color: #2563eb; text-decoration: none; }
.preset-btn.active { background: #eff6ff; border-color: #2563eb; color: #2563eb; font-weight: 600; }

.cat-grid, .points-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
.cat-column h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}
.cat-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0;
    cursor: pointer;
    font-size: 0.85rem;
}
.cat-option input[type="checkbox"] { accent-color: #2563eb; }
.cat-label { flex: 1; }
.weight-input {
    width: 50px;
    padding: 0.15rem 0.3rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.75rem;
    text-align: center;
    margin-left: auto;
    color: #374151;
}
.weight-input:focus {
    outline: none;
    border-color: #2563eb;
}

.points-table { width: 100%; font-size: 0.85rem; border-collapse: collapse; }
.points-table th, .points-table td { padding: 0.3rem 0.5rem; text-align: left; }
.points-table th { font-size: 0.75rem; color: #6b7280; text-transform: uppercase; border-bottom: 1px solid #e5e7eb; }
.points-table input[type="number"] {
    width: 70px; padding: 0.25rem 0.4rem;
    border: 1px solid #d1d5db; border-radius: 4px;
    font-size: 0.85rem; text-align: right;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    background: #f9fafb;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
}
.pool-toggle {
    display: flex;
    gap: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
}
.pool-btn {
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    background: #fff;
    border-right: 1px solid #d1d5db;
    transition: background 0.15s;
}
.pool-btn:last-child { border-right: none; }
.pool-btn input[type="radio"] { display: none; }
.pool-btn:has(input:checked) { background: #1a1a2e; color: #fff; }
.pool-btn:hover:not(:has(input:checked)) { background: #f0f0f5; }

.position-select {
    padding: 0.35rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.8rem;
    background: #fff;
}
.search-input {
    padding: 0.35rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.8rem;
    width: 200px;
    background: #fff;
}
.search-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px #2563eb22; }

.results-meta { font-size: 0.8rem; color: #6b7280; margin-bottom: 0.5rem; }

.rankings-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.8rem;
}
.rankings-table thead {
    background: #f9fafb;
    position: sticky;
    top: 0;
    z-index: 1;
}
.rankings-table th {
    padding: 0.45rem 0.4rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}
.rankings-table td {
    padding: 0.35rem 0.4rem;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
}

.col-rank { width: 40px; text-align: center; color: #9ca3af; }
.col-compare { width: 30px; text-align: center; }
.col-name { min-width: 150px; }
.col-pos { color: #6b7280; font-size: 0.75rem; }
.col-team { color: #6b7280; font-size: 0.75rem; }
.col-dollars { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 40px; }
.col-value { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.col-cat { text-align: right; font-variant-numeric: tabular-nums; font-size: 0.75rem; }

.tier-break {
    border-top: 2px solid #2563eb !important;
}
.tier-badge {
    display: inline-block;
    margin-left: 0.3rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    background: #2563eb;
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    vertical-align: middle;
}

.pos-rank {
    display: inline-block;
    margin-left: 0.35rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 3px;
    padding: 0.05rem 0.3rem;
    vertical-align: middle;
}

.no-ros-badge {
    display: inline-block;
    margin-left: 0.3rem;
    font-size: 0.6rem;
    font-weight: 600;
    color: #d97706;
    background: #fef3c7;
    border-radius: 3px;
    padding: 0.05rem 0.3rem;
    vertical-align: middle;
}

.split-toggle {
    display: flex;
    align-items: center;
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid #e5e7eb;
}

.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: #2563eb; }
.sortable[data-sort="asc"]::after { content: " \25B2"; font-size: 0.65rem; }
.sortable[data-sort="desc"]::after { content: " \25BC"; font-size: 0.65rem; }

.val-pos { color: #16a34a; }
.val-neg { color: #dc2626; }
.na { color: #d1d5db; }

.player-row { cursor: pointer; transition: background 0.1s; }
.player-row:hover { background: #f0f4ff; }

.compare-cb {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    border: 1px solid #d1d5db; border-radius: 4px;
    font-size: 0.75rem; color: #9ca3af;
    cursor: pointer; transition: all 0.15s; user-select: none;
}
.compare-cb:hover { border-color: #2563eb; color: #2563eb; }
.compare-cb.selected { background: #2563eb; color: #fff; border-color: #2563eb; }

.detail-row td { padding: 0; background: #fafbff; }

.player-detail { padding: 1rem 1.5rem; border-left: 3px solid #2563eb; }
.detail-header { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.detail-header h3 { font-size: 1rem; }
.detail-meta { font-size: 0.8rem; color: #6b7280; }
.detail-value { font-size: 0.9rem; font-weight: 700; margin-left: auto; }

.detail-body { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.detail-section h4 { font-size: 0.75rem; text-transform: uppercase; color: #6b7280; margin-bottom: 0.5rem; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.detail-table th, .detail-table td { padding: 0.25rem 0.5rem; text-align: right; border-bottom: 1px solid #f0f0f0; }
.detail-table th { text-align: left; font-weight: 600; color: #6b7280; font-size: 0.7rem; text-transform: uppercase; }
.detail-table td:first-child { text-align: left; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 0.5rem; }
.stat-item { display: flex; flex-direction: column; padding: 0.3rem 0.5rem; background: #f0f4ff; border-radius: 4px; }
.stat-label { font-size: 0.65rem; color: #6b7280; text-transform: uppercase; font-weight: 600; }
.stat-value { font-size: 0.85rem; font-weight: 600; }

.compare-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #1a1a2e; color: #fff;
    padding: 0.75rem 2rem;
    display: flex; align-items: center; gap: 1rem;
    z-index: 100; box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
}
.compare-bar button {
    padding: 0.4rem 1rem; border: none; border-radius: 6px;
    font-size: 0.85rem; cursor: pointer; font-weight: 500;
}
.compare-bar button:first-of-type { background: #2563eb; color: #fff; }
.compare-bar button:first-of-type:disabled { background: #4a4a6a; cursor: not-allowed; }
.btn-clear { background: transparent; color: #aaa; border: 1px solid #555 !important; }

.compare-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 200;
    display: flex; align-items: center; justify-content: center;
}
.compare-modal {
    background: #fff; border-radius: 12px; padding: 1.5rem;
    max-width: 700px; width: 90%; max-height: 80vh; overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.compare-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.compare-header h2 { font-size: 1.1rem; }
.close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #6b7280; padding: 0.25rem; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.compare-table th, .compare-table td { padding: 0.4rem 0.75rem; border-bottom: 1px solid #f0f0f0; text-align: right; }
.compare-table th { font-weight: 600; }
.compare-table td:first-child, .compare-table th:first-child { text-align: left; }
.compare-player { text-align: center !important; }
.compare-total { background: #f9fafb; }
.compare-total td { font-size: 0.95rem; }

.no-results { text-align: center; padding: 3rem; color: #6b7280; }
.error { color: #dc2626; }

.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.75rem;
    color: #9ca3af;
    border-top: 1px solid #f0f0f0;
    margin-top: 2rem;
}
.footer-how {
    max-width: 600px;
    margin: 0 auto 0.5rem;
    line-height: 1.6;
    color: #6b7280;
}

@media (max-width: 640px) {
    main { padding: 0.75rem; }
    .site-header { padding: 0.75rem 1rem; flex-direction: column; gap: 0.25rem; }
    .mode-selector { width: 100%; }
    .mode-btn { flex: 1; text-align: center; padding: 0.5rem 0.5rem; font-size: 0.8rem; }
    .cat-grid, .points-grid { grid-template-columns: 1fr; gap: 1rem; }
    .filter-bar { flex-direction: column; align-items: stretch; gap: 0.5rem; }
    .pool-toggle { width: 100%; }
    .pool-btn { flex: 1; text-align: center; }
    .search-input { width: 100%; }
    .rankings-table thead { display: none; }
    .rankings-table, .rankings-table tbody, .rankings-table tr, .rankings-table td { display: block; width: 100%; }
    .rankings-table tr.player-row {
        background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
        margin-bottom: 0.5rem; padding: 0.75rem; position: relative;
    }
    .rankings-table td { border: none; padding: 0.15rem 0; }
    .col-rank { position: absolute; top: 0.75rem; right: 0.75rem; width: auto; font-size: 0.75rem; }
    .col-compare { display: none; }
    .col-name { font-size: 1rem; }
    .col-value { text-align: left; font-size: 1rem; margin-top: 0.25rem; }
    .col-cat { display: none; }
    .col-pos, .col-team { display: inline; }
    .col-pos::after { content: " | "; }
    .detail-body { grid-template-columns: 1fr; }
    .compare-modal { width: 95%; padding: 1rem; }
    .config-bar { flex-direction: column; gap: 0.4rem; align-items: stretch; }
    .customize-toggle { width: 100%; text-align: center; }
    .export-btn { width: 100%; text-align: center; margin-left: 0; }
}

.export-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    color: #374151;
    transition: all 0.15s;
    margin-left: auto;
    text-decoration: none;
}
.export-btn:hover {
    border-color: #2563eb;
    color: #2563eb;
    text-decoration: none;
}

.mode-btn-dynasty:has(input:checked) { background: #7c3aed; color: #fff; }
.mode-btn-prospects:has(input:checked) { background: #059669; color: #fff; }

.config-bar-locked {
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 8px;
    padding: 0.6rem 1.25rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.5;
}

.prospect-badge {
    display: inline-block;
    margin-left: 0.3rem;
    font-size: 0.6rem;
    font-weight: 600;
    color: #7c3aed;
    background: #f5f3ff;
    border-radius: 3px;
    padding: 0.05rem 0.3rem;
    vertical-align: middle;
}

.prospect-rank-badge {
    display: inline-block;
    margin-left: 0.3rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: #059669;
    background: #ecfdf5;
    border-radius: 3px;
    padding: 0.05rem 0.3rem;
    vertical-align: middle;
}

.notice {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #92400e;
}

/* Risk badges */
.risk-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    vertical-align: middle;
}
.risk-low { background: #059669; }
.risk-moderate { background: #d97706; }
.risk-high { background: #ea580c; }
.risk-extreme { background: #dc2626; }

.col-risk { text-align: center; white-space: nowrap; }
.col-range { text-align: center; white-space: nowrap; font-size: 0.85rem; color: #6b7280; }

.risk-block {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.risk-range {
    font-size: 0.85rem;
    color: #6b7280;
}
.risk-drivers {
    width: 100%;
    font-size: 0.78rem;
    color: #9ca3af;
    margin-top: 0.15rem;
}
