:root {
    color-scheme: light;
    --ink: #202326;
    --muted: #62676c;
    --line: #d9dde0;
    --surface: #ffffff;
    --canvas: #f3f5f6;
    --brand-blue: #0757df;
    --brand-red: #ed1c24;
    --brand-yellow: #f3c414;
    --red: #b52a2f;
    --red-soft: #f9e9ea;
    --green: #167451;
    --green-soft: #e5f4ee;
    --amber: #a56209;
    --amber-soft: #fff2d9;
    --focus: #2457a7;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--canvas);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--canvas);
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    letter-spacing: 0;
}

button,
input {
    font: inherit;
    letter-spacing: 0;
}

.site-header {
    color: var(--ink);
    background: #ffffff;
    border-bottom: 4px solid var(--brand-blue);
    box-shadow: 0 4px 18px rgba(32, 35, 38, 0.08);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    width: min(100% - 32px, 960px);
    min-height: 142px;
    margin: 0 auto;
}

.brand-logo {
    width: 84px;
    height: 84px;
    flex: 0 0 84px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 6px 18px rgba(7, 87, 223, 0.15);
}

.organization,
.section-label {
    margin: 0;
    color: var(--brand-blue);
    font-size: 13px;
    font-weight: 700;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 2px 0 0;
    font-size: 27px;
    line-height: 1.25;
}

.page-shell {
    width: min(100% - 32px, 960px);
    margin: 28px auto 64px;
}

.search-tool {
    padding: 24px;
    border: 1px solid var(--line);
    border-top: 3px solid var(--brand-blue);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(32, 35, 38, 0.07);
}

.search-tool h2,
.section-heading h2 {
    margin: 0 0 16px;
    font-size: 20px;
    line-height: 1.35;
}

.search-form label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 10px;
}

.search-row input {
    width: 100%;
    min-width: 0;
    height: 52px;
    padding: 0 15px;
    color: var(--ink);
    border: 1px solid #aeb5ba;
    border-radius: 6px;
    outline: none;
    background: #ffffff;
}

.search-row input:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(36, 87, 167, 0.16);
}

.search-row button {
    height: 52px;
    padding: 0 20px;
    color: #ffffff;
    border: 0;
    border-radius: 6px;
    border-bottom: 4px solid var(--brand-yellow);
    background: var(--brand-blue);
    font-weight: 700;
    cursor: pointer;
}

.search-row button:hover {
    background: #0647b9;
}

.search-row button:focus-visible {
    outline: 3px solid rgba(36, 87, 167, 0.35);
    outline-offset: 2px;
}

.leaderboard-entry {
    margin-top: 18px;
    padding-top: 15px;
    border-top: 1px solid var(--line);
}

.leaderboard-entry a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    color: var(--brand-blue);
    text-decoration: none;
}

.leaderboard-entry a:hover strong {
    text-decoration: underline;
}

.leaderboard-entry span {
    font-size: 28px;
    line-height: 1;
}

.message {
    margin-top: 20px;
    padding: 20px 22px;
    border-left: 4px solid #6a7278;
    background: #ffffff;
}

.message strong {
    display: block;
}

.message p {
    margin: 5px 0 0;
    color: var(--muted);
}

.message-not-found,
.message-notice {
    border-left-color: var(--amber);
    background: #fffaf0;
}

.message-error {
    border-left-color: var(--red);
    background: var(--red-soft);
}

.result-summary,
.history {
    margin-top: 40px;
}

.result-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.result-heading .section-label,
.section-heading .section-label {
    color: var(--brand-red);
}

.result-heading h2 {
    margin: 2px 0 0;
    font-size: 28px;
    line-height: 1.25;
}

.record-count {
    margin: 0;
    color: var(--muted);
    white-space: nowrap;
}

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

.stat {
    min-height: 112px;
    padding: 18px;
    border: 1px solid var(--line);
    border-top: 4px solid #596067;
    border-radius: 6px;
    background: var(--surface);
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.stat strong {
    display: block;
    margin-top: 6px;
    font-size: 32px;
    line-height: 1;
}

.stat-win {
    border-top-color: var(--green);
}

.stat-loss {
    border-top-color: var(--red);
}

.stat-draw {
    border-top-color: var(--amber);
}

.rate-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    margin-top: 10px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
}

.rate-row > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.rate-row span {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.rate-row progress {
    display: block;
    width: 100%;
    height: 8px;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: #e7e9eb;
}

.rate-row progress::-webkit-progress-bar {
    background: #e7e9eb;
}

.rate-win progress {
    accent-color: var(--green);
}

.rate-win progress::-webkit-progress-value {
    background: var(--green);
}

.rate-loss progress {
    accent-color: var(--red);
}

.rate-loss progress::-webkit-progress-value {
    background: var(--red);
}

.rate-draw progress {
    accent-color: var(--amber);
}

.rate-draw progress::-webkit-progress-value {
    background: var(--amber);
}

.rate-win progress::-moz-progress-bar {
    background: var(--green);
}

.rate-loss progress::-moz-progress-bar {
    background: var(--red);
}

.rate-draw progress::-moz-progress-bar {
    background: var(--amber);
}

.section-heading {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.section-heading h2 {
    margin: 2px 0 0;
}

.history-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.history-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 24px;
    align-items: center;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
}

.event-meta {
    min-width: 0;
}

.event-meta h3 {
    margin: 0;
    font-size: 18px;
    line-height: 1.35;
}

.event-meta p {
    margin: 5px 0;
    color: var(--ink);
}

.event-meta span {
    color: var(--muted);
    font-size: 14px;
}

.wld-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    min-width: 0;
    margin: 0;
}

.wld-grid div {
    min-width: 0;
    padding: 10px 6px;
    text-align: center;
    border-bottom: 3px solid #7b8287;
    background: #f5f6f7;
}

.wld-grid .win {
    color: var(--green);
    border-bottom-color: var(--green);
    background: var(--green-soft);
}

.wld-grid .loss {
    color: var(--red);
    border-bottom-color: var(--red);
    background: var(--red-soft);
}

.wld-grid .draw {
    color: var(--amber);
    border-bottom-color: var(--amber);
    background: var(--amber-soft);
}

.wld-grid dt {
    font-size: 13px;
    font-weight: 700;
}

.wld-grid dd {
    margin: 2px 0 0;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.15;
}

.ranking-page {
    min-height: calc(100vh - 250px);
}

.back-link {
    display: inline-block;
    margin-bottom: 18px;
    color: var(--brand-blue);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

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

.ranking-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.ranking-heading .section-label {
    color: var(--brand-red);
}

.ranking-heading h2 {
    margin: 2px 0 0;
    font-size: 28px;
    line-height: 1.25;
}

.ranking-heading > span {
    color: var(--muted);
    white-space: nowrap;
}

.ranking-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #e9ecee;
}

.ranking-tabs a {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 48px;
    padding: 8px;
    color: #43494e;
    border-radius: 5px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

.ranking-tabs a[aria-current="page"] {
    color: #ffffff;
    background: var(--brand-blue);
    box-shadow: inset 0 -4px 0 var(--brand-yellow);
}

.ranking-genders {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 360px);
    margin: 14px 0 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
}

.ranking-genders a {
    display: grid;
    place-items: center;
    min-height: 42px;
    padding: 6px 12px;
    color: #43494e;
    font-weight: 700;
    text-decoration: none;
}

.ranking-genders a + a {
    border-left: 1px solid var(--line);
}

.ranking-genders a[aria-current="page"] {
    color: #ffffff;
    background: var(--ink);
}

.ranking-tabs a:focus-visible,
.ranking-genders a:focus-visible,
.rank-player a:focus-visible,
.back-link:focus-visible,
.leaderboard-entry a:focus-visible {
    outline: 3px solid rgba(36, 87, 167, 0.35);
    outline-offset: 2px;
}

.ranking-list {
    display: grid;
    gap: 10px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.ranking-item {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) minmax(240px, 0.8fr);
    gap: 18px;
    align-items: center;
    min-height: 96px;
    padding: 15px 18px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
}

.rank-number {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    color: #4c5358;
    background: #edf0f2;
}

.rank-number span {
    font-size: 10px;
    line-height: 1;
}

.rank-number strong {
    font-size: 23px;
    line-height: 1.15;
}

.rank-1 .rank-number {
    color: #6b4a00;
    background: #ffedb5;
}

.rank-2 .rank-number {
    color: #35424a;
    background: #dfe7eb;
}

.rank-3 .rank-number {
    color: #8b3023;
    background: #f8ded9;
}

.rank-player {
    min-width: 0;
}

.rank-player a {
    display: block;
    color: var(--ink);
    font-size: 20px;
    font-weight: 800;
    line-height: 1.3;
    overflow-wrap: anywhere;
    text-decoration: none;
}

.rank-player a:hover {
    color: var(--brand-blue);
}

.rank-player span,
.rank-score span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.rank-score {
    min-width: 0;
    text-align: right;
}

.rank-score strong {
    display: block;
    color: var(--brand-blue);
    font-size: 24px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

footer {
    padding: 24px 16px 36px;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
}

footer p {
    margin: 0;
}

.visit-count {
    margin-top: 3px;
    color: var(--ink);
    font-weight: 700;
}

@media (max-width: 700px) {
    .header-inner {
        width: min(100% - 24px, 960px);
        min-height: 108px;
    }

    .brand-logo {
        width: 66px;
        height: 66px;
        flex-basis: 66px;
    }

    h1 {
        font-size: 22px;
    }

    .page-shell {
        width: min(100% - 24px, 960px);
        margin-top: 18px;
    }

    .search-tool {
        padding: 18px;
    }

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

    .rate-panel {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .history-item {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .wld-grid {
        width: 100%;
    }

    .ranking-item {
        grid-template-columns: 52px minmax(0, 1fr);
        gap: 12px;
        padding: 14px;
    }

    .rank-number {
        width: 46px;
        height: 46px;
    }

    .rank-score {
        grid-column: 2;
        text-align: left;
    }
}

@media (max-width: 420px) {
    .search-row {
        grid-template-columns: 1fr;
    }

    .search-row button {
        width: 100%;
    }

    .result-heading {
        display: block;
    }

    .record-count {
        margin-top: 5px;
    }

    .ranking-heading {
        display: block;
    }

    .ranking-heading > span {
        display: block;
        margin-top: 5px;
    }

    .ranking-tabs a {
        min-height: 46px;
        padding: 6px 3px;
        font-size: 14px;
    }
}

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