:root {
    color-scheme: dark;
    --bg: #09090d;
    --panel: rgba(20, 18, 24, 0.94);
    --panel-deep: rgba(13, 12, 17, 0.98);
    --line: rgba(216, 163, 83, 0.25);
    --line-bright: rgba(229, 180, 99, 0.55);
    --gold: #e2b262;
    --gold-pale: #f1d9a4;
    --blood: #8f2637;
    --blood-bright: #b83c50;
    --text: #eee8df;
    --muted: #a99f96;
    --shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 18% 8%, rgba(120, 37, 54, 0.24), transparent 34rem),
        radial-gradient(circle at 86% 16%, rgba(120, 77, 34, 0.16), transparent 30rem),
        linear-gradient(145deg, #08080c 0%, #111016 48%, #08080b 100%);
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    content: "";
    pointer-events: none;
    opacity: 0.35;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.01) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(to bottom, black, transparent 80%);
}

.page-shell {
    width: min(1440px, calc(100% - 40px));
    margin: 0 auto;
    padding: 0 0 72px;
}

.hero-header {
    width: 100%;
    margin: 0 auto 42px;
    text-align: center;
}

.hero__banner {
    position: relative;
    display: grid;
    width: 100vw;
    height: clamp(230px, 30vw, 410px);
    margin-left: calc(50% - 50vw);
    overflow: hidden;
    border-bottom: 1px solid var(--line);
    place-items: center;
    background:
        radial-gradient(circle at 50% 50%, rgba(143, 38, 55, 0.2), transparent 48%),
        #0a090d;
    box-shadow: 0 28px 65px rgba(0, 0, 0, 0.32);
    isolation: isolate;
}

.hero__banner::before,
.hero__banner::after {
    position: absolute;
    inset: 0;
    z-index: 1;
    content: "";
    pointer-events: none;
}

.hero__banner::before {
    background:
        linear-gradient(90deg, rgba(9, 9, 13, 0.72), transparent 22%, transparent 78%, rgba(9, 9, 13, 0.72)),
        linear-gradient(180deg, rgba(9, 9, 13, 0.34), transparent 28%, rgba(9, 9, 13, 0.48));
}

.hero__banner::after {
    box-shadow:
        inset 0 -42px 54px rgba(9, 9, 13, 0.34),
        inset 0 22px 42px rgba(9, 9, 13, 0.22);
}

.hero__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    object-fit: cover;
    object-position: center center;
    opacity: 0.78;
    filter: saturate(0.9) contrast(1.08) brightness(0.78);
}

.hero__logo {
    position: relative;
    z-index: 2;
    display: block;
    width: auto;
    max-width: 92vw;
    height: clamp(135px, 10vw, 165px);
    object-fit: contain;
    margin: 0 auto;
    image-rendering: pixelated;
    filter:
        drop-shadow(0 10px 24px rgba(0, 0, 0, 0.58))
        drop-shadow(0 0 34px rgba(167, 121, 190, 0.12));
}

.hero__ornament {
    position: relative;
    display: grid;
    grid-template-columns: minmax(30px, 150px) auto minmax(30px, 150px);
    gap: 14px;
    align-items: center;
    justify-content: center;
    margin: 34px auto 22px;
    color: var(--blood-bright);
}

.hero__ornament span {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--line-bright));
}

.hero__ornament span:last-child {
    background: linear-gradient(90deg, var(--line-bright), transparent);
}

.hero__ornament i {
    color: var(--gold);
    font-size: 0.62rem;
    font-style: normal;
    filter: drop-shadow(0 0 8px rgba(226, 178, 98, 0.45));
}

.hero__back-link {
    position: absolute;
    top: 50%;
    left: calc(50% + 42px);
    z-index: 1;
    padding: 2px 9px;
    color: var(--gold-pale);
    background: #0d0c11;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
    transform: translateY(-50%);
    transition: color 160ms ease, transform 160ms ease;
}

.hero__back-link:hover,
.hero__back-link:focus-visible {
    color: var(--gold);
    outline: none;
    transform: translate(-2px, -50%);
}

.hero__back-link:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 4px;
}

h1,
h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 600;
    letter-spacing: 0.015em;
}

h1 {
    color: var(--gold-pale);
    font-size: clamp(2.25rem, 6vw, 4.7rem);
    line-height: 1.02;
    text-shadow: 0 3px 32px rgba(200, 133, 55, 0.18);
}

.subtitle {
    max-width: 650px;
    margin: 18px auto 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.65;
}

.leaderboard-layout {
    display: grid;
    grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.filter-panel,
.ranking-panel {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: linear-gradient(165deg, var(--panel), var(--panel-deep));
    box-shadow: var(--shadow);
}

.filter-panel {
    position: sticky;
    top: 20px;
    padding: 24px;
}

.panel-heading {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
    color: var(--gold-pale);
    font-size: 1.35rem;
}

.ornament {
    color: var(--blood);
    font-size: 0.8rem;
}

form > label,
legend {
    display: block;
    margin: 18px 0 8px;
    color: var(--gold-pale);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

select,
.player-name-input {
    width: 100%;
    padding: 11px 38px 11px 12px;
    border: 1px solid rgba(229, 180, 99, 0.25);
    border-radius: 3px;
    color: var(--text);
    background: #111016;
    font: inherit;
}

.player-name-input {
    display: block;
    height: 42px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 5px;
    font-size: 0.9rem;
    line-height: 42px;
    appearance: none;
}

.player-name-input::placeholder {
    color: #77727e;
}

select:focus-visible,
.player-name-input:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible + span,
input:focus-visible + .hero-filter-card {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.board-fieldset,
.hero-fieldset {
    margin-top: 0;
}

.board-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.board-option {
    position: relative;
    cursor: pointer;
}

.board-option input,
.hero-filter-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.board-option span {
    display: flex;
    min-height: 43px;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border: 1px solid rgba(229, 180, 99, 0.18);
    border-radius: 4px;
    color: var(--muted);
    background: rgba(0, 0, 0, 0.16);
    font-size: 0.76rem;
    font-weight: 800;
    text-align: center;
    transition: 140ms ease;
}

.board-option:hover span {
    color: var(--text);
    border-color: var(--line-bright);
}

.board-option input:checked + span {
    color: #1a1109;
    border-color: #d4a259;
    background: linear-gradient(#e4bd75, #ba7d3c);
}

.hero-fieldset {
    margin-top: 22px;
}

.hero-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
}

.hero-filter-option {
    position: relative;
    min-width: 0;
    cursor: pointer;
}

.hero-filter-all {
    grid-column: 1 / -1;
}

.hero-filter-card {
    display: flex;
    min-height: 78px;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
    padding: 6px 3px;
    overflow: hidden;
    border: 1px solid rgba(229, 180, 99, 0.14);
    border-radius: 5px;
    color: #958a82;
    background: rgba(7, 7, 10, 0.42);
    font-size: 0.64rem;
    font-weight: 750;
    line-height: 1.15;
    text-align: center;
    text-overflow: ellipsis;
    transition: 140ms ease;
}

.hero-filter-card img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    image-rendering: pixelated;
    filter: grayscale(0.45) brightness(0.72);
    transition: 140ms ease;
}

.hero-filter-option:hover .hero-filter-card {
    color: var(--text);
    border-color: var(--line-bright);
    transform: translateY(-1px);
}

.hero-filter-option input:checked + .hero-filter-card {
    color: var(--gold-pale);
    border-color: rgba(229, 180, 99, 0.72);
    background: linear-gradient(160deg, rgba(143, 38, 55, 0.24), rgba(229, 180, 99, 0.08));
    box-shadow: inset 0 0 0 1px rgba(229, 180, 99, 0.08);
}

.hero-filter-option input:checked + .hero-filter-card img {
    filter: none;
}

.hero-filter-option input:indeterminate + .hero-filter-card {
    color: var(--gold);
    border-color: rgba(229, 180, 99, 0.42);
    background: rgba(229, 180, 99, 0.06);
}

.hero-filter-all .hero-filter-card {
    min-height: 42px;
    flex-direction: row;
    gap: 9px;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.all-heroes-mark {
    display: inline-grid;
    min-width: 34px;
    min-height: 23px;
    place-items: center;
    border: 1px solid currentColor;
    border-radius: 3px;
    font-size: 0.57rem;
    letter-spacing: 0.08em;
}

fieldset {
    margin: 20px 0 0;
    padding: 0;
    border: 0;
}

legend {
    margin-bottom: 4px;
}

.field-hint {
    margin: 0 0 11px;
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.4;
}

.challenge-list {
    display: grid;
    gap: 6px;
}

.challenge-option {
    display: flex;
    gap: 9px;
    align-items: center;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 3px;
    color: #cfc6bd;
    cursor: pointer;
    font-size: 0.83rem;
    transition: 140ms ease;
}

.challenge-option:hover {
    border-color: var(--line);
    color: var(--text);
    background: rgba(229, 180, 99, 0.045);
}

.challenge-option input {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--blood);
}

.filter-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    margin-top: 23px;
}

button {
    padding: 11px 15px;
    border: 1px solid #b4783c;
    border-radius: 3px;
    color: #17100a;
    background: linear-gradient(#e4bd75, #ba7d3c);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
}

button:hover {
    filter: brightness(1.08);
}

.filter-actions a {
    color: var(--muted);
    font-size: 0.8rem;
    text-decoration: none;
}

.filter-actions a:hover {
    color: var(--gold-pale);
}

.ranking-panel {
    min-width: 0;
    overflow: hidden;
}

.ranking-header {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    padding: 26px 30px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(90deg, rgba(143, 38, 55, 0.08), transparent 55%);
}

.ranking-header h2 {
    color: var(--gold-pale);
    font-size: clamp(1.35rem, 3vw, 2rem);
}

.ranking-subtitle {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.run-badge {
    flex: 0 0 auto;
    padding: 7px 11px;
    border: 1px solid var(--line-bright);
    border-radius: 999px;
    color: var(--gold);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

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

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

th,
td {
    padding: 17px 24px;
    border-bottom: 1px solid rgba(216, 163, 83, 0.105);
    text-align: left;
}

th {
    color: #968a80;
    background: rgba(0, 0, 0, 0.16);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

th:first-child,
td:first-child {
    width: 86px;
    text-align: center;
}

th:nth-child(2),
td:nth-child(2) {
    width: 92px;
    text-align: center;
}

th:last-child,
td:last-child {
    width: 180px;
    text-align: right;
}

tbody tr {
    transition: background 140ms ease;
}

tbody tr:hover:not(.empty-row) {
    background: rgba(229, 180, 99, 0.045);
}

tbody tr:last-child td {
    border-bottom: 0;
}

.rank-cell {
    color: var(--gold);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.08rem;
    font-weight: 700;
}

.player-link {
    min-width: 0;
    color: var(--text);
    font-weight: 650;
    overflow-wrap: anywhere;
    text-decoration: none;
}

.player-link::after {
    margin-left: 7px;
    color: #746c66;
    content: "↗";
    font-size: 0.75em;
}

.player-link:hover {
    color: var(--gold-pale);
}

.rainbow-player-name {
    color: transparent;
    background: linear-gradient(
        90deg,
        #ff5964 0%,
        #ffb347 16%,
        #fff275 32%,
        #62e6a7 48%,
        #55c7ff 64%,
        #9f7aea 80%,
        #ff72c6 92%,
        #ff5964 100%
    );
    background-size: 300% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: rainbow-player-name-shift 5s linear infinite;
    filter: drop-shadow(0 1px 5px rgba(111, 203, 255, 0.2));
}

.player-link:hover .rainbow-player-name {
    filter: brightness(1.16) drop-shadow(0 1px 7px rgba(255, 114, 198, 0.3));
}

.supporter-promo {
    margin: 8px 0 20px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.supporter-promo a {
    color: var(--gold-pale);
    font-weight: 700;
    text-decoration-color: rgba(241, 217, 164, 0.48);
    text-underline-offset: 3px;
}

.supporter-promo a:hover {
    color: #fff1c9;
    text-decoration-color: currentColor;
}

@keyframes rainbow-player-name-shift {
    to {
        background-position: 300% 0;
    }
}

.player-identity {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    gap: 7px 9px;
    align-items: center;
}

.supporter-badges {
    display: inline-flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.supporter-badge-icon {
    display: block;
    width: 24px;
    height: 24px;
    object-fit: contain;
    image-rendering: pixelated;
    filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.48));
}

.hero-cell {
    padding-top: 9px;
    padding-bottom: 9px;
}

.leaderboard-hero-icon {
    display: block;
    width: 48px;
    height: 48px;
    margin: 0 auto;
    object-fit: contain;
    image-rendering: pixelated;
    filter: drop-shadow(0 5px 12px rgba(0, 0, 0, 0.35));
}

.depth-cell {
    color: var(--gold-pale);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.18rem;
    font-weight: 700;
}

.empty-row td {
    padding: 72px 24px;
    color: var(--muted);
    text-align: center;
}

.ranking-footer {
    display: flex;
    gap: 18px;
    justify-content: space-between;
    padding: 14px 24px;
    border-top: 1px solid var(--line);
    color: #786f68;
    background: rgba(0, 0, 0, 0.18);
    font-size: 0.72rem;
}

@media (max-width: 850px) {
    .page-shell {
        width: min(100% - 24px, 720px);
    }

    .hero__banner {
        height: 220px;
    }

    .hero__logo {
        height: 100px;
    }

    .hero__ornament {
        margin-top: 20px;
    }

    .leaderboard-layout {
        grid-template-columns: 1fr;
    }

    .filter-panel {
        position: static;
    }

    .challenge-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

@media (max-width: 580px) {
    .hero__banner {
        height: 190px;
    }

    .challenge-list {
        grid-template-columns: 1fr;
    }

    .hero-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .ranking-header,
    .ranking-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .ranking-header {
        padding: 22px 18px;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    tbody tr {
        display: grid;
        grid-template-columns: 54px 58px minmax(0, 1fr) auto;
        align-items: center;
        padding: 15px 14px;
        border-bottom: 1px solid rgba(216, 163, 83, 0.105);
    }

    tbody td,
    tbody td:first-child,
    tbody td:last-child {
        width: auto;
        padding: 0 8px;
        border: 0;
        text-align: left;
    }

    tbody td:last-child {
        text-align: right;
    }

    tbody .hero-cell {
        text-align: center;
    }

    .leaderboard-hero-icon {
        width: 42px;
        height: 42px;
    }

    .supporter-badge-icon {
        width: 21px;
        height: 21px;
    }

    .empty-row {
        display: block;
    }

    .empty-row td {
        grid-column: 1 / -1;
        padding: 54px 12px;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }

    .rainbow-player-name {
        animation: none;
    }
}
