:root {
    --bg: #100d16;
    --panel: rgba(23, 20, 32, 0.95);
    --panel-soft: rgba(39, 30, 46, 0.92);
    --text: #f1e6d1;
    --muted: #bcae90;
    --line: rgba(220, 159, 78, 0.22);
    --accent: #d78542;
    --accent-soft: rgba(215, 133, 66, 0.14);
    --accent-strong: #f0b36d;
    --teal: #78c7c3;
    --gold: #e0b36a;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 18% 8%, rgba(120, 199, 195, 0.12), transparent 0 18%),
        radial-gradient(circle at 82% 2%, rgba(215, 133, 66, 0.18), transparent 0 24%),
        linear-gradient(180deg, #0f0c16 0%, #171320 42%, #23171b 100%);
}

body.modal-open {
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.28;
    background-image:
        radial-gradient(rgba(255, 255, 255, 0.4) 1px, transparent 1px),
        radial-gradient(rgba(120, 199, 195, 0.24) 1px, transparent 1px);
    background-size: 120px 120px, 200px 200px;
    background-position: 0 0, 48px 72px;
}

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

.page-shell {
    position: relative;
    z-index: 1;
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px;
}

.hero {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(20, 18, 29, 0.96), rgba(60, 36, 28, 0.94)),
        radial-gradient(circle at right top, rgba(240, 179, 109, 0.18), transparent 0 36%);
    color: #fff4e2;
    padding: 28px;
    border-radius: 20px;
    border: 1px solid rgba(240, 179, 109, 0.22);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(120, 199, 195, 0.08), transparent);
}

.eyebrow {
    margin: 0 0 10px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--gold);
    opacity: 0.95;
}

.hero h1,
.info-box h2,
.section-heading h2,
.league-card h3 {
    font-family: Georgia, "Times New Roman", serif;
}

.hero h1 {
    margin: 0 0 10px;
    font-size: clamp(2rem, 3vw, 2.8rem);
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.28);
}

.lead {
    margin: 0;
    max-width: 880px;
    color: rgba(255, 244, 226, 0.9);
    line-height: 1.65;
}

.hero-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.hero-pills span {
    background: rgba(12, 12, 20, 0.34);
    border: 1px solid rgba(240, 179, 109, 0.18);
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.95rem;
}

.season-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.season-btn {
    border: 1px solid rgba(240, 179, 109, 0.22);
    background: rgba(8, 10, 18, 0.45);
    color: #f7ddba;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.season-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(240, 179, 109, 0.42);
}

.season-btn.active {
    color: #fff9ef;
    background: linear-gradient(135deg, #d78542 0%, #8f4b2c 100%);
    border-color: rgba(255, 226, 185, 0.4);
}

main {
    display: grid;
    gap: 24px;
}

.info-box,
.table-card,
.round-card,
.league-card {
    background: linear-gradient(180deg, rgba(25, 21, 35, 0.97), rgba(18, 16, 28, 0.96));
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
}

.info-box {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
    padding: 20px 22px;
}

.info-box h2,
.section-heading h2,
.league-card h3 {
    margin: 0 0 10px;
}

.rule-list {
    margin: 0;
    padding-left: 18px;
    line-height: 1.7;
}

.muted {
    color: var(--muted);
}

.section-heading p {
    margin: 0;
    color: var(--muted);
}

.section-heading {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
}

.section-tabs {
    display: inline-flex;
    gap: 8px;
    margin-bottom: 14px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(13, 12, 20, 0.72);
}

.tab-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 10px 14px;
    border-radius: 999px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.tab-btn:hover {
    color: #fff0d9;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--accent), #8f4b2c);
    color: #fff7ec;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 6px 14px rgba(0, 0, 0, 0.2);
}
.tab-panel[hidden] {
    display: none;
}

.tab-panel {
    display: grid;
    gap: 12px;
}

.stat-card {
    background:
        linear-gradient(180deg, rgba(48, 32, 32, 0.72), rgba(24, 20, 34, 0.96)),
        var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow);
}

.stat-card .label {
    display: block;
    font-size: 0.84rem;
    color: var(--muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card strong {
    display: block;
    font-size: 1.15rem;
    margin-bottom: 6px;
}

.stat-card small {
    color: var(--muted);
}

.table-card {
    overflow: hidden;
}

.table-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.control-field {
    display: grid;
    gap: 6px;
    font-size: 0.92rem;
    color: var(--muted);
}

.control-field span {
    font-weight: 700;
}

.control-field input,
.control-field select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(16, 14, 24, 0.95);
    color: var(--text);
    font: inherit;
}

.control-field input::placeholder {
    color: #988a72;
}

.control-field input:focus,
.control-field select:focus {
    outline: 2px solid rgba(120, 199, 195, 0.18);
    border-color: var(--accent-strong);
}

.players-summary {
    margin: 0 0 12px;
    font-size: 0.95rem;
}

.player-link {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--teal);
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.player-link:hover {
    text-decoration: underline;
}

.player-profile {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(16, 14, 24, 0.84);
    padding: 12px;
    margin-bottom: 4px;
}

.player-profile-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
}

.player-profile-head h3 {
    margin: 0 0 6px;
    font-family: Georgia, "Times New Roman", serif;
}

.player-profile-head .eyebrow {
    margin-bottom: 6px;
}

.player-profile-close {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(215, 133, 66, 0.12);
    color: #ffe0b5;
    padding: 8px 12px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.player-modal-dialog {
    width: min(1200px, calc(100vw - 24px));
}

.player-detail-grid {
    display: grid;
    gap: 14px;
    padding: 12px 16px 16px;
}

.player-detail-section {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    background: rgba(16, 14, 24, 0.84);
}

.player-detail-section h4 {
    margin: 0 0 10px;
    color: var(--gold);
}

.total-row td {
    font-weight: 700;
    background: rgba(215, 133, 66, 0.12);
}

.sgf-link {
    display: inline-block;
    border: 1px solid rgba(120, 199, 195, 0.18);
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(120, 199, 195, 0.1);
    color: var(--teal);
    font-weight: 700;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}

.sgf-link:hover {
    text-decoration: underline;
    background: rgba(120, 199, 195, 0.16);
}

.sgf-link-secondary {
    border-color: rgba(215, 133, 66, 0.22);
    background: rgba(215, 133, 66, 0.1);
    color: #ffe0b5;
}

.sgf-external-link {
    display: inline-block;
    margin-left: 6px;
    color: var(--gold);
    font-weight: 700;
    text-decoration: none;
}

.sgf-external-link:hover {
    text-decoration: underline;
}

.sgf-missing {
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    background: linear-gradient(180deg, #8d5030 0%, #643725 100%);
    color: #fff5e4;
    font-weight: 700;
    white-space: nowrap;
}

tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.025);
}

tbody tr:hover {
    background: rgba(120, 199, 195, 0.08);
}

.league-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
}

.league-card {
    overflow: hidden;
}

.league-card header {
    padding: 16px 18px 10px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(68, 43, 35, 0.82) 0%, rgba(27, 20, 31, 0.94) 100%);
}

.league-card p {
    margin: 0;
    color: var(--muted);
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(120, 199, 195, 0.12);
    color: var(--teal);
    font-weight: 700;
}

.leader-row {
    background: rgba(113, 144, 88, 0.16) !important;
}

.bottom-row {
    background: rgba(129, 56, 38, 0.16) !important;
}

.rounds-list {
    display: grid;
    gap: 12px;
}

.round-card {
    overflow: hidden;
}

.round-card summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    font-weight: 700;
    background: linear-gradient(180deg, rgba(68, 43, 35, 0.78) 0%, rgba(25, 20, 31, 0.96) 100%);
}

.round-card summary::-webkit-details-marker {
    display: none;
}

.round-content {
    padding: 0 18px 18px;
}

.round-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 14px;
    padding-top: 12px;
}

.round-group {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    background: rgba(30, 24, 38, 0.82);
}

.round-group h4 {
    margin: 0 0 10px;
    color: var(--gold);
}

.match-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
}

.match-list li {
    border-bottom: 1px dashed var(--line);
    padding-bottom: 8px;
}

.match-list li:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.match-score {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(215, 133, 66, 0.16);
    border: 1px solid rgba(215, 133, 66, 0.18);
    color: var(--gold);
    font-weight: 700;
}

.sgf-modal[hidden] {
    display: none;
}

.sgf-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 12px;
}

.sgf-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 8, 14, 0.78);
    backdrop-filter: blur(5px);
}

.sgf-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(1120px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow: auto;
    border: 1px solid rgba(215, 133, 66, 0.24);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(20, 18, 28, 0.98), rgba(15, 12, 22, 0.98));
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.sgf-modal-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 18px 10px;
    border-bottom: 1px solid var(--line);
}

.sgf-modal-header h3 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
}

.sgf-modal-actions {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.sgf-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 1.4rem;
    cursor: pointer;
}

.sgf-player-host {
    padding: 12px 16px 16px;
    min-height: 560px;
}

.sgf-viewer-fallback {
    margin: 0;
    padding: 16px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
}

.wgo-player {
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(215, 133, 66, 0.18);
    background: #16121f;
}

.wgo-player .wgo-box-title,
.wgo-player .wgo-player-control {
    background: linear-gradient(180deg, #8d5030 0%, #643725 100%);
    color: #fff5e4;
}

.wgo-player .wgo-commentbox,
.wgo-player .wgo-infobox,
.wgo-player .wgo-box-wrapper {
    background: rgba(18, 16, 25, 0.96);
    color: #f1e6d1;
}

@media (max-width: 840px) {
    .page-shell {
        padding: 16px;
    }

    .info-box {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead {
        display: none;
    }

    tr {
        padding: 10px 0;
        border-bottom: 1px solid var(--line);
    }

    td {
        border: 0;
        padding: 8px 12px 8px 46%;
        position: relative;
        min-height: 36px;
    }

    td::before {
        content: attr(data-label);
        position: absolute;
        left: 12px;
        top: 8px;
        width: calc(46% - 18px);
        color: var(--muted);
        font-weight: 700;
    }

    .round-card summary {
        flex-direction: column;
        align-items: flex-start;
    }
}