:root {
  --page: #050e0b;
  --panel: #0b1c16;
  --panel-strong: #11271f;
  --border: #294036;
  --gold-border: #7b693b;
  --gold: #e5c778;
  --gold-soft: #d8be82;
  --text: #f4f0e5;
  --muted: #a1b5a9;
  --subtle: #96958e;
  --font-serif: "Noto Serif SC", "Songti SC", serif;
  --font-sans: "Noto Sans SC", "PingFang SC", sans-serif;
  --font-number: 'Playfair Display', Georgia, serif;
  --font-mono: "Roboto Mono", monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body { margin: 0; min-width: 320px; background: var(--page); color: var(--text); font-family: var(--font-sans); }
button, input { font: inherit; }
img { max-width: 100%; }
a { color: inherit; text-decoration: none; }

.shell { min-height: 100vh; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-logo { width: 44px; height: 44px; border-radius: 6px; object-fit: contain; }
.brand b { color: var(--gold); font-family: var(--font-serif); font-size: 18px; letter-spacing: .08em; }
.topbar nav { display: flex; gap: 24px; margin-left: 40px; color: var(--muted); font-size: 13px; }
.topbar nav a.active { color: var(--gold); }
.menu-icon { display: none; }
body[data-page="ranking"] .topbar,
body[data-page="ranking"] .site-footer { display: none; }

#app { min-height: 0; }
.ranking-page { min-height: 100vh; background: var(--page); }
.ranking-grid { display: grid; }
.ranking-board { min-width: 0; background: var(--panel); border: 1px solid var(--gold-border); border-radius: 14px; overflow: hidden; }
.board-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.board-header h2 { margin: 0; color: var(--gold); font-family: var(--font-serif); font-size: 36px; font-weight: 700; line-height: 1.1; }
.board-period { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; color: var(--text); font-family: var(--font-serif); font-size: 20px; white-space: nowrap; }
.board-period img { width: 20px; height: 22px; object-fit: contain; }
.podium { display: grid; align-items: end; }
.medal-card { position: relative; display: flex; min-width: 0; flex-direction: column; align-items: center; border: 1px solid var(--gold-border); border-radius: 12px; background: var(--panel); text-align: center; }
.medal-second { border-color: #7b693b; }
.medal-first { border-color: var(--gold); }
.medal-third { border-color: #7b693b; }
.crown-wrap { position: absolute; left: 50%; display: flex; align-items: center; justify-content: center; transform: translateX(-50%); pointer-events: none; }
.crown-wrap img { width: 100%; height: 100%; object-fit: contain; }
.medal-name { width: 100%; overflow: hidden; color: #eee9de; font-family: var(--font-serif); font-weight: 500; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.medal-rule { width: 40px; height: 1px; margin: 8px 0 8px; background: currentColor; opacity: .45; }
.champion-caption { color: var(--subtle); font-size: 13px; line-height: 1.3; }
.champion-count { display: flex; align-items: flex-end; gap: 5px; line-height: 1; }
.champion-count strong { font-family: var(--font-number); font-size: 56px; font-weight: 500; line-height: 0.7;}
.champion-count span { font-family: var(--font-serif); font-size: 14px; }
.medal-second .champion-count, .medal-second .medal-rule { color: #bcc9d2; }
.medal-first .champion-count, .medal-first .medal-rule { color: var(--gold-soft); }
.medal-third .champion-count, .medal-third .medal-rule { color: #c99a75; }
.medal-stats { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; color: var(--muted); white-space: nowrap; }
.metric { display: inline-flex; align-items: baseline; gap: 3px; }
.metric b { font-family: var(--font-serif); font-size: 13px; font-weight: 500; }
.metric strong { font-family: var(--font-number); font-size: 22px; font-weight: 500; }
.plaque-wrap { position: absolute; bottom: -20px; display: flex; align-items: center; justify-content: center; width: 100%; margin-top: auto; overflow: hidden; }
.plaque-wrap img { width: 100%; height: 100%; object-fit: contain; }
.plaque-wrap span { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-family: var(--font-serif); font-size: 20px; font-weight: 700; white-space: nowrap; }
.medal-second .plaque-wrap span { color: #c7d4de; }
.medal-first .plaque-wrap span { color: #e3bf6e; }
.medal-third .plaque-wrap span { color: #dba36e; }
.details-heading { display: flex; align-items: center; gap: 8px; color: var(--muted); font-family: var(--font-serif); font-weight: 700; }
.details-heading img { object-fit: contain; }
.ranking-table { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ranking-table-head, .ranking-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) repeat(4, 96px); align-items: center; gap: 8px; padding: 0 16px; }
.ranking-table-head { min-height: 48px; border-bottom: 1px solid var(--gold-border); background: var(--panel-strong); color: var(--muted); font-family: var(--font-serif); font-size: 16px; }
.ranking-table-head span:not(:nth-child(2)), .rank-value { text-align: center; }
.ranking-table-head span:nth-child(3), .rank-wins { color: var(--gold); font-weight: 700; }
.ranking-table-window { min-height: 0; overflow: hidden; }
.ranking-table-body { background: var(--panel); }
.ranking-row { min-height: 58px; border-bottom: 1px solid var(--border); }
.ranking-row:last-child { border-bottom: 0; }
.rank-number { color: var(--muted); font-family: var(--font-mono); font-size: 17px; font-weight: 700; }
.rank-player { min-width: 0; overflow: hidden; color: var(--text); font-family: var(--font-serif); font-size: 17px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.rank-value { color: var(--text); font-family: var(--font-number); font-size: 25px; }
.empty-state { padding: 22px 16px; color: var(--muted); font-size: 14px; text-align: center; }
.data-note { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font-family: var(--font-serif); }
.data-note b { color: var(--gold); font-family: "Playfair Display", Georgia, serif; font-size: 14px; font-weight: 400; white-space: nowrap; }
.cycle-tabs { display: flex; }
.cycle-tabs a { flex: 1; color: var(--muted); text-align: center; }
.cycle-tabs a.active { color: var(--gold); }
.loading-board { min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); }
.loading-mark { color: var(--gold); font-size: 32px; }

@media (min-width: 1025px) {
  body { overflow: hidden; }
  .ranking-page { height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 24px; }
  .cycle-tabs { display: none; }
  .ranking-grid { min-height: 0; flex: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
  .ranking-board { min-height: 0; height: 100%; display: flex; flex-direction: column; gap: 20px; padding: 12px; }
  .board-header h2 { font-size: 32px; }
  .board-period { font-size: 20px; }
  .board-period img { width: 26px; height: 30px; }
  .podium { height: 260px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 20px; }
  .medal-card { height: 224px; padding: 22px 0 0; }
  .medal-first { height: 248px; padding-top: 24px; border-bottom: none;}
  .medal-third { height: 216px; padding-top: 18px; }
  .crown-wrap { top: -40px; width: unset; height: 50px; }
  .medal-first .crown-wrap { top: -50px; width: unset; height: 62px; }
  .medal-third .crown-wrap { top: -38px; width: 64px; height: unset; }
  .medal-first .champion-count strong { font-size: 66px; }
  .medal-name { font-size: 26px; letter-spacing: 4px; }
  .medal-first .medal-name { font-size: 30px; }
  .medal-third .medal-name { font-size: 24px; }
  .champion-caption { font-size: 14px; }
  .medal-stats { gap: 8px; margin-top: 18px; }
  .medal-first .medal-stats { margin-top: 28px; }
  .medal-stats .metric:first-child { display: none;}
  .metric b { font-size: 13px; }
  .metric strong { font-size: 21px; }
  .plaque-wrap { height: 52px; margin-top: 0px; }
  .medal-first .plaque-wrap { height: 52px; width: 120%; bottom: -24px;}
  .details-heading { min-height: 22px; font-size: 20px; }
  .details-heading img { width: 16px; height: 30px; }
  .ranking-table { min-height: 0; flex: 1; display: flex; flex-direction: column; }
  .ranking-table-head { flex: 0 0 auto; font-size: 20px; }
  .ranking-row { min-height: 5  8px; }
  .rank-number { font-size: 30px; }
  .rank-player { font-size: 26px; }
  .rank-value { font-size: 32px; }
  .ranking-table-window { flex: 1; }
  .ranking-table-body.is-scrolling { animation: ranking-scroll 24s linear infinite; }
  .data-note { flex: 0 0 auto; font-size: 14px; }
}

@media (min-width: 1025px) and (max-width: 1199px) {
  .ranking-page { padding-left: 24px; padding-right: 24px; gap: 16px; }
  .ranking-grid { gap: 16px; }
  .ranking-board { padding: 20px; gap: 16px; }
  .board-header h2 { font-size: 30px; }
  .board-period { font-size: 20px; }
  .board-period img { width: 20px; height: 22px; }
  .podium { gap: 10px; }
  .details-heading { font-size: 20px; }
  .details-heading img { width: 20px; height: 20px; }
  .ranking-table-head, .ranking-row { grid-template-columns: 42px minmax(0, 1fr) repeat(4, minmax(34px, 46px)); gap: 4px; padding-left: 8px; padding-right: 8px; }
  .ranking-table-head { min-height: 48px; font-size: 14px; }
  .rank-number { font-size: 18px; }
  .rank-player { font-size: 16px; }
  .rank-value { font-size: 22px; }
}

@media (max-width: 1024px) {
  body { overflow-x: hidden; }
  .ranking-page { padding: 20px 16px 24px; }
  .cycle-tabs { height: 42px; margin-bottom: 20px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: #10251d; }
  .cycle-tabs a { display: grid; place-items: center; border-radius: 6px; font-family: var(--font-serif); font-size: 16px; }
  .cycle-tabs a.active { background: #132d23; box-shadow: inset 0 -2px 0 var(--gold); }
  .ranking-grid { display: block; }
  .ranking-board { border: none; display: none; gap: 18px; padding: 14px 8px 12px; border-radius: 10px; }
  .ranking-board.is-active { display: flex; flex-direction: column; }
  .board-header h2 { font-size: 26px; }
  .board-period { gap: 7px; font-size: 15px; }
  .board-period img { width: 15px; height: 17px; }
  .podium { height: 190px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }
  .medal-card { height: 160px; padding: 14px 4px 0;; border-width: 1px; border-radius: 6px; }
  .medal-first { height: 171px; padding-top: 16px; }
  .crown-wrap { top: -26px; width: 60px; height: 33px; }
  .medal-first .crown-wrap { top: -38px; width: 70px; height: 48px; }
  .medal-third .crown-wrap { top: -23px; width: 50px; height: 30px; }
  .medal-name { font-size: 16px; letter-spacing: 1px; }
  .medal-first .medal-name { font-size: 22px; }
  .medal-rule { width: 26px; margin: 5px 0; }
  .champion-caption { font-size: 10px; }
  .champion-count { gap: 3px; }
  .champion-count strong { font-size: 32px; }
  .medal-first .champion-count strong { font-size: 38px; }
  .champion-count span { font-size: 11px; }
  .medal-stats { display: grid; grid-template-columns: repeat(2, auto); justify-content: center; gap: 2px 8px; font-size: 12px;
        margin-top: 8px;}
  .metric b { font-size: 10px; }
  .metric strong { font-size: 17px; }
  .plaque-wrap { height: 28px; margin-top: 7px; }
  .medal-first .plaque-wrap { height: 34px; }
  .plaque-wrap span { font-size: 11px; }
  .details-heading { min-height: 26px; font-size: 17px; }
  .details-heading img { width: 18px; height: 18px; }
  .ranking-table-head, .ranking-row { grid-template-columns: 28px minmax(0, 1fr) repeat(4, 40px); gap: 6px; padding: 0 8px; }
  .ranking-table-head { min-height: 42px; font-size: 12px; }
  .ranking-row { min-height: 44px; }
  .rank-number { font-size: 14px; }
  .rank-player { font-size: 14px; line-height: 1.3; white-space: normal; overflow-wrap: anywhere; }
  .rank-value { font-size: 18px; }
  .data-note { display: flex; flex-direction: column; gap: 18px; padding: 4px 0 0; font-size: 12px; text-align: center; }
  .data-note b { font-size: 13px; }
}

@keyframes ranking-scroll { from { transform: translateY(0); } to { transform: translateY(-50%); } }
@media (prefers-reduced-motion: reduce) { .ranking-table-body.is-scrolling { animation: none; } }

/* Admin surface */
body[data-page="admin"] { background: #101514; overflow: auto !important;}
.site-footer { padding: 20px 24px 28px; border-top: 1px solid var(--border); color: var(--muted); font: 11px var(--font-mono); text-align: center; }
.admin, .login { width: min(100% - 36px, 960px); margin: 0 auto; padding: 46px 0 70px; }
.login { max-width: 420px; padding-top: 100px; }
.kicker { color: var(--gold); font: 11px var(--font-mono); letter-spacing: .16em; }
.admin h1, .login h1 { margin: 12px 0 24px; font-family: var(--font-serif); font-size: 34px; }
.login p { color: var(--muted); font-size: 13px; }
.admin-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 18px; }
.admin-toolbar label, .admin-field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.admin-toolbar input, .admin-field input, .admin-table input { min-height: 36px; border: 1px solid var(--border); background: #111715; color: var(--text); padding: 7px 9px; outline: 0; }
.admin-toolbar input:focus, .admin-field input:focus, .admin-table input:focus { border-color: var(--gold); }
.admin-card { display: grid; gap: 18px; padding: 24px; border: 1px solid var(--border); background: #171e1b; }
.button { border: 1px solid var(--border); background: transparent; color: var(--text); padding: 9px 14px; cursor: pointer; font-size: 12px; }
.button:hover { border-color: var(--gold); }
.button.primary { border-color: var(--gold); background: var(--gold); color: #171c17; font-weight: 700; }
.button:disabled { cursor: wait; opacity: .6; }
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--border); }
.admin-table { width: 100%; min-width: 700px; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.admin-table th { background: var(--panel-strong); color: var(--muted); font-weight: 500; }
.admin-table td:not(:nth-child(2)), .admin-table th:not(:nth-child(2)) { text-align: center; }
.admin-table input { width: 100%; min-width: 60px; }
.row-delete { border: 0; background: transparent; color: #d18a82; cursor: pointer; font-size: 18px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.cycle-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 20px; padding: 10px 12px; border: 1px solid var(--border); color: var(--muted); }
.cycle-settings legend { padding: 0 6px; color: var(--gold); font-size: 12px; }
.cycle-settings label { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.cycle-settings input { accent-color: var(--gold); }
#toast { position: fixed; left: 50%; bottom: 24px; z-index: 10; transform: translate(-50%, 12px); opacity: 0; padding: 11px 15px; background: var(--gold); color: #171c17; font-size: 12px; font-weight: 700; pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 700px) {
  .topbar { height: 64px; }
  .topbar nav { margin-left: 20px; gap: 12px; font-size: 11px; }
  .admin, .login { width: min(100% - 28px, 960px); padding-top: 32px; }
  .admin-toolbar { align-items: stretch; }
  .admin-toolbar label { flex: 1 1 140px; }
  .admin-toolbar .button { flex: 1 1 auto; }
}
