:root{
    --blue:#1976d2;
    --blue-dark:#0d47a1;
    --border:#ddd;
    --border-dark:#aaa;
    --background:#f6f6f6;
    --surface:#fff;
    --surface-alternate:#fafafa;
    --surface-hover:#f2f7fd;
    --text:#1d1d1d;
    --text-muted:#555;
    --grid:#d5dbe3;
    --search-button:#0d47a1;
}

:root[data-theme="dark"] {
    --blue:#4d9be8;
    --blue-dark:#102f53;
    --border:#46515e;
    --border-dark:#718096;
    --background:#111820;
    --surface:#1b2530;
    --surface-alternate:#222e3a;
    --surface-hover:#263a4e;
    --text:#edf2f7;
    --text-muted:#b8c2cc;
    --grid:#43505e;
    --search-button:#165d9f;
}

body{
    margin:0;
    font-family:Arial,sans-serif;
    background:var(--background);
    color:var(--text);
    transition:background-color 0.2s, color 0.2s;
}

header{
    background:var(--blue-dark);
    color:white;
    padding:20px;
    position:relative;
}

header h1{
    margin:0;
}

.site-title {
    display:inline-flex;
    align-items:center;
    gap:0.65rem;
    color:inherit;
    text-decoration:none;
}

.site-logo {
    width:3.25rem;
    height:3.25rem;
    padding:0.15rem;
    box-sizing:border-box;
    object-fit:contain;
    border-radius:0.65rem;
    background:rgba(255,255,255,0.96);
}

nav{
    margin-top:15px;
}

nav a{
    color:white;
    text-decoration:none;
    margin-right:20px;
    font-weight:bold;
}

main{
    max-width:1400px;
    margin:auto;
    padding:30px;
}

table{
    width:100%;
    border-collapse:collapse;
}

th{
    background:var(--blue);
    color:white;
}

th,td{
    padding:8px;
    border:1px solid var(--border);
}

tr:nth-child(even){
    background:var(--surface-alternate);
}

#season,
.dt-search input {
    font-size: 1rem;
    border: 1px solid var(--border-dark);
    border-radius: 6px;
    background-color: var(--surface);
    color:var(--text);
}

.dt-search input {
    padding: 4px 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#season {
    padding: 4px 4px;
}

#season:focus,
.dt-search input:focus,
.entity-search input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 4px rgba(25,118,210,0.3);
}

table.dataTable tbody td {
    line-height: 1.25;
    height: 3rem;
    padding:6px;
    vertical-align: middle;
    white-space: nowrap;
}

table.dataTable thead th {
    padding:6px 20px 6px 5px;
    box-sizing:border-box;
}

.dt-scroll-head table.dataTable thead th {
    height:3.5rem !important;
    min-height:3.5rem !important;
    vertical-align:middle !important;
}

table.dataTable thead .dt-column-order {
    right:4px !important;
}

.dt-scroll-head .dt-column-title {
    white-space:normal;
}

/* DataTables keeps a second header in the scroll body only to measure columns. */
.dt-scroll-body table.dataTable thead tr,
.dt-scroll-body table.dataTable thead th {
    height:0 !important;
    min-height:0 !important;
    padding-top:0 !important;
    padding-bottom:0 !important;
    border-top:0 !important;
    border-bottom:0 !important;
}

.wrap-column {
    white-space: normal !important;
    overflow-wrap: break-word;
}

.nowrap-column {
    white-space:nowrap !important;
}

.page-length-control {
    display:flex;
    align-items:center;
    gap:0.35rem;
    margin-right:0.75rem;
    color:var(--text);
    white-space:nowrap;
}

.page-length-dropdown {
    position:relative;
    display:inline-block;
    vertical-align:middle;
}

.page-length-toggle {
    position:relative;
    min-width:4.8em;
    padding:3px 1.5rem 3px 6px;
    border:1px solid var(--border-dark);
    border-radius:6px;
    background:var(--surface);
    color:var(--text);
    font:inherit;
    font-size:0.875rem;
    font-variant-numeric:tabular-nums;
    text-align:right;
    cursor:pointer;
}

.page-length-toggle::after {
    content:"▾";
    position:absolute;
    top:50%;
    right:0.45rem;
    transform:translateY(-50%);
}

.page-length-menu {
    position:absolute;
    z-index:100;
    top:calc(100% + 0.2rem);
    right:0;
    min-width:100%;
    padding:0.2rem;
    border:1px solid var(--border-dark);
    border-radius:6px;
    background:var(--surface);
    box-shadow:0 4px 12px rgba(0,0,0,0.18);
}

.page-length-menu[hidden] {
    display:none;
}

.page-length-option {
    display:block;
    width:100%;
    padding:0.35rem 0.5rem;
    border:0;
    border-radius:4px;
    background:transparent;
    color:var(--text);
    font:inherit;
    font-variant-numeric:tabular-nums;
    text-align:right;
    cursor:pointer;
}

.page-length-option:hover,
.page-length-option:focus-visible,
.page-length-option[aria-selected="true"] {
    background:var(--surface-hover);
    outline:none;
}

.sex-selection {
    display:flex;
    flex-wrap:wrap;
    gap:0.5rem;
    margin:0 0 1.25rem;
}

.ranking-filter .sex-selection {
    margin:0;
}

.ranking-filter {
    display:flex;
    align-items:baseline;
    gap:0.75rem;
    margin:0 0 0.75rem;
}

.ranking-filter:last-of-type {
    margin-bottom:1.25rem;
}

.ranking-filter-label {
    min-width:5rem;
    font-weight:bold;
}

.movers-str-filter {
    white-space:nowrap;
    font-size:1rem;
    font-weight:normal;
}

.sex-button {
    margin-right:0;
    padding:0.45rem 0.9rem;
    border:1px solid var(--blue);
    border-radius:6px;
    color:var(--blue);
    background:var(--surface);
    text-decoration:none;
    font-weight:bold;
}

.sex-button:hover,
.sex-button:focus-visible,
.sex-button.is-active {
    color:white;
    background:var(--blue);
}

.hero {
    margin-bottom: 2rem;
}

.grid.two-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.card {
    min-width:0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.card h3 {
    margin-top: 0;
}

.compact-table {
    margin-bottom: 1rem;
    table-layout: fixed;
    min-width:36rem;
}

.compact-table-scroll {
    width:100%;
    max-width:100%;
    overflow-x:auto;
}

.compact-table th,
.compact-table td {
    border-bottom: 1px solid var(--border);
    padding: 6px 8px;
    height: 1rem;
    line-height: 1.25;
    vertical-align: middle;
    overflow-wrap: normal;
    word-break: normal;
}

.compact-cell-content {
    display:-webkit-box;
    overflow:hidden;
    line-height:1.15;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
    line-clamp:2;
}

.compact-table th {
    text-align: center;
    height:3rem;
    white-space:pre-line;
}

.compact-table th:first-child,
.compact-table td:first-child {
    width: 6%;
    white-space:nowrap;
}

.compact-table th:first-child {
    text-align:center;
}

.compact-table td:first-child {
    text-align:right;
}

.compact-table th:nth-child(2),
.compact-table td:nth-child(2) {
    width: 36%;
}

.compact-table th:nth-child(3),
.compact-table td:nth-child(3) {
    width: 46%;
}

.compact-table th:last-child,
.compact-table td:last-child {
    width: 12%;
    text-align: center;
}

.compact-table th:last-child {
    white-space:pre-line;
}

.compact-table td:last-child {
    white-space:nowrap;
}

.button {
    display: inline-block;
    padding: 6px 12px;
    background: var(--blue);
    color: white;
    border-radius: 6px;
    text-decoration: none;
}

.button:hover {
    background: var(--blue-dark);
}

.player-profile-link {
    color:var(--blue);
    font-weight:600;
    text-decoration:none;
}

.player-profile-link:visited {
    color:var(--blue);
}

.player-profile-link:hover,
.player-profile-link:focus-visible {
    text-decoration:underline;
}

.home-chart {
    width:100%;
    height:420px;
}

.home-chart svg {
    display:block;
    width:100%;
    height:100%;
}

@media (max-width: 800px) {
    .grid.two-columns {
        grid-template-columns: 1fr;
    }
}

.data-error {
    padding: 1rem;
    color: #8b1a1a;
    text-align: left;
}

.entity-search {
    display: flex;
    max-width: 40rem;
    margin: 1.5rem 0;
}

.entity-search input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    font-size: 1rem;
    border: 1px solid var(--border-dark);
    border-right: 0;
    border-radius: 6px 0 0 6px;
}

.entity-search button {
    padding: 8px 14px;
    border: 1px solid var(--search-button);
    border-radius: 0 6px 6px 0;
    background: var(--search-button);
    color: white;
    cursor: pointer;
}

.entity-search button:hover,
.entity-search button:focus-visible {
    filter:brightness(1.2);
}

.entity-search button svg {
    display:block;
    width:24px;
    height:24px;
    fill:none;
    stroke:currentColor;
    stroke-width:2.75;
    stroke-linecap:round;
}

.status-message {
    min-height: 1.5em;
}

.search-results-list {
    display: grid;
    gap: 0.5rem;
    max-width: 48rem;
}

.show-more-results {
    margin-top:1rem;
    border:0;
    cursor:pointer;
    font-size:1rem;
}

.info-tooltip {
    position:relative;
    z-index:1001;
    display:inline-flex;
    vertical-align:super;
    transform:translateY(-0.15em);
}

.info-button {
    width:1.2rem;
    height:1.2rem;
    padding:0;
    border:2px solid var(--blue);
    border-radius:50%;
    background:var(--surface);
    color:var(--blue);
    font-weight:bold;
    font-size:0.75rem;
    line-height:1;
    cursor:help;
}

.info-tooltip-text {
    position:absolute;
    z-index:1000;
    top:calc(100% + 0.5rem);
    left:50%;
    width:min(22rem, 75vw);
    padding:0.75rem;
    border:1px solid var(--border);
    border-radius:6px;
    background-color:var(--surface);
    color:var(--text);
    box-shadow:0 4px 14px rgba(0,0,0,0.22);
    font-size:0.9rem;
    font-weight:normal;
    line-height:1.4;
    opacity:0;
    visibility:hidden;
    transform:translateX(-50%);
}

.info-tooltip:hover .info-tooltip-text,
.info-tooltip:focus-within .info-tooltip-text {
    opacity:1;
    visibility:visible;
}

.search-result {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: inherit;
    text-decoration: none;
}

.search-result:hover {
    border-color: var(--blue);
    background: var(--surface-hover);
}

.search-result span {
    color: var(--text-muted);
    text-align: right;
}

.back-link {
    display:inline-flex;
    align-items:center;
    gap:0.5rem;
    margin-bottom: 1rem;
    color:var(--blue);
    text-decoration:none;
    font-weight:bold;
}

.back-link::before {
    content:"↩";
    display:inline-block;
    font-size:1.5rem;
    font-weight:bold;
    line-height:1;
    transition:transform 0.15s;
}

.back-link:visited {
    color:var(--blue);
}

.back-link:hover::before,
.back-link:focus-visible::before {
    transform:translateX(-0.2rem);
}

.table-scroll {
    overflow-x: auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.not-found {
    text-align: center;
    padding-top: 5rem;
}

.theme-toggle {
    position:absolute;
    top:18px;
    right:20px;
    width:42px;
    height:42px;
    border:1px solid rgba(255,255,255,0.55);
    border-radius:50%;
    background:rgba(255,255,255,0.12);
    color:white;
    cursor:pointer;
    font-size:1.15rem;
}

.theme-toggle:hover {
    background:rgba(255,255,255,0.24);
}

.player-chart-section,
.player-statistics-section {
    margin-top:2rem;
}

.player-str-chart {
    padding:1rem;
    border:1px solid var(--border);
    border-radius:10px;
    background:var(--surface);
    overflow-x:auto;
}

.player-str-chart svg {
    display:block;
    width:100%;
    min-width:650px;
    height:auto;
}

.chart-grid-line {
    stroke:var(--grid);
    stroke-width:1;
}

.chart-axis-label {
    fill:var(--text-muted);
    font-size:14px;
}

.chart-line {
    fill:none;
    stroke:var(--blue);
    stroke-width:4;
    stroke-linecap:round;
    stroke-linejoin:round;
}

.chart-point {
    fill:var(--surface);
    stroke:var(--blue);
    stroke-width:4;
}

.chart-point:focus {
    outline:none;
    stroke-width:7;
}

.chart-hover-column,
.chart-histogram-hover {
    fill:transparent;
    pointer-events:all;
}

.chart-hover-column:hover,
.chart-hover-column:focus,
.chart-histogram-hover:hover,
.chart-histogram-hover:focus {
    fill:rgba(100,181,246,0.08);
    outline:none;
}

.chart-point:hover,
.chart-point.is-active {
    fill:var(--blue);
    stroke-width:6;
}

.chart-histogram-bar {
    fill:var(--blue);
}

.chart-histogram-bar.is-active {
    fill:#64b5f6;
}

.chart-value-tooltip {
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transition:opacity 0.1s;
}

.chart-value-tooltip.is-visible {
    opacity:1;
    visibility:visible;
}

.chart-value-tooltip rect {
    fill:var(--blue-dark);
    stroke:var(--surface);
    stroke-width:1;
}

.chart-value-tooltip text {
    fill:white;
    font-size:15px;
    font-weight:bold;
}

.chart-note {
    color:var(--text-muted);
    font-size:0.9rem;
}

.chart-stats {
    margin:0 0 0.5rem;
    color:var(--text-muted);
    font-size:0.9rem;
}

.chart-stats-placeholder {
    visibility:hidden;
}

#player-history {
    table-layout:fixed;
    min-width:760px;
}

#player-history th,
#player-history td {
    width:14.5%;
    text-align:right;
    font-variant-numeric:tabular-nums;
    white-space:nowrap;
}

#player-history th:first-child,
#player-history td:first-child {
    width:13%;
    text-align:center;
}

#player-history th {
    height:3.5rem;
    text-align:center;
    white-space:normal;
    overflow-wrap:break-word;
}

.dt-container,
.dt-container label,
.dt-container .dt-info,
.dt-container .dt-paging-button {
    color:var(--text) !important;
}

@media (max-width: 600px) {
    main {
        padding:16px;
    }

    .search-result {
        flex-direction: column;
        gap: 0.25rem;
    }

    .search-result span {
        text-align: left;
    }
}
