:root {
  --ink: #152c2d;
  --muted: #6e7d7b;
  --teal: #086b67;
  --teal-dark: #054b49;
  --cream: #f5f1e8;
  --paper: #fffdf8;
  --orange: #ed6b3a;
  --line: #deddd5;
  --gold: #e0a92f;
  --silver: #aeb8ba;
  --bronze: #b77850;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 18%, rgba(237,107,58,.09), transparent 23rem),
    linear-gradient(180deg, #e9f0ec 0, var(--cream) 36rem);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.page-shell { min-height: 100vh; overflow: hidden; }
.hero {
  position: relative;
  min-height: 420px;
  color: #fff;
  background:
    linear-gradient(115deg, rgba(3,61,59,.98), rgba(4,100,95,.93)),
    repeating-linear-gradient(135deg, transparent 0 20px, rgba(255,255,255,.03) 20px 21px);
  border-radius: 0 0 42px 42px;
}
.hero::before, .hero::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 50%;
}
.hero::before { width: 460px; height: 460px; right: -105px; top: -180px; box-shadow: 0 0 0 65px rgba(255,255,255,.025), 0 0 0 130px rgba(255,255,255,.018); }
.hero::after { width: 180px; height: 180px; left: -90px; bottom: -60px; }
.nav, .hero-content, main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.nav { height: 86px; display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; border-bottom: 1px solid rgba(255,255,255,.13); }
.brand { display: flex; gap: 12px; align-items: center; color: #fff; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.6); border-radius: 50%; font-family: Georgia, serif; font-size: 18px; }
.brand strong { display: block; letter-spacing: .12em; }
.brand small { display: block; margin-top: 3px; color: rgba(255,255,255,.6); font-size: 9px; letter-spacing: .14em; }
.nav-actions { display: flex; align-items: center; gap: 20px; font-size: 13px; }
.live { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.72); }
.live i { width: 7px; height: 7px; background: #7cdfaa; border-radius: 50%; box-shadow: 0 0 0 5px rgba(124,223,170,.12); }
.live.error i { background: #ff8b6a; }
.docs-link { color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.25); padding: 9px 14px; border-radius: 999px; }
.docs-link:hover { background: rgba(255,255,255,.1); }
.hero-content { min-height: 330px; display: grid; grid-template-columns: 1fr auto; align-items: center; position: relative; z-index: 1; }
.eyebrow, .section-kicker { color: #f0a47f; font-size: 11px; font-weight: 700; letter-spacing: .18em; }
h1 { margin: 14px 0 18px; max-width: 720px; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(38px, 5vw, 66px); line-height: 1.08; font-weight: 500; }
h1 em { color: #f2b08f; font-style: normal; }
.intro { max-width: 600px; margin: 0; color: rgba(255,255,255,.68); line-height: 1.8; font-size: 14px; }
.hero-stat { width: 190px; height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; background: rgba(255,255,255,.035); }
.hero-stat span { color: rgba(255,255,255,.65); font-size: 13px; }
.hero-stat strong { margin: 1px 0; font-family: Georgia, serif; font-size: 56px; font-weight: 400; color: #ffd0b7; }
.hero-stat small { color: rgba(255,255,255,.42); font-size: 8px; letter-spacing: .12em; }

main { position: relative; z-index: 2; margin-top: -34px; padding-bottom: 70px; }
.leader-podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.leader-card { min-height: 115px; display: grid; grid-template-columns: 50px 1fr auto; gap: 14px; align-items: center; padding: 22px 24px; background: var(--paper); border: 1px solid rgba(20,45,45,.08); border-radius: 15px; box-shadow: 0 14px 35px rgba(29,57,53,.08); cursor: pointer; transition: transform .2s, box-shadow .2s; }
.leader-card:hover { transform: translateY(-3px); box-shadow: 0 18px 42px rgba(29,57,53,.13); }
.leader-rank { font: 38px Georgia, serif; color: var(--orange); }
.leader-name strong { display: block; font-size: 16px; }
.leader-name span { color: var(--muted); font-size: 11px; }
.leader-medals { text-align: right; }
.leader-medals strong { display: block; font: 30px Georgia, serif; }
.leader-medals small { color: var(--muted); font-size: 11px; }

.ranking-card { background: var(--paper); border: 1px solid rgba(20,45,45,.08); border-radius: 18px; box-shadow: 0 20px 50px rgba(29,57,53,.08); overflow: hidden; }
.toolbar { min-height: 116px; display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 26px 30px; border-bottom: 1px solid var(--line); }
.section-kicker { margin: 0 0 5px; color: var(--orange); }
h2 { margin: 0; font: 30px Georgia, "Noto Serif SC", serif; }
.controls { display: flex; align-items: center; gap: 10px; }
.search { height: 42px; width: 220px; display: flex; align-items: center; gap: 8px; padding: 0 13px; background: #f4f3ed; border: 1px solid transparent; border-radius: 8px; color: var(--muted); }
.search:focus-within { border-color: var(--teal); background: #fff; }
.search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.sort-tabs { display: flex; padding: 3px; background: #f0efe9; border-radius: 8px; }
.sort-tabs button { height: 36px; padding: 0 14px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.sort-tabs button.active { color: #fff; background: var(--teal); box-shadow: 0 3px 8px rgba(8,107,103,.2); }
.refresh { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--teal); font-size: 21px; cursor: pointer; }
.refresh.spinning { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th { height: 52px; padding: 0 20px; background: #f6f5ef; color: #82908e; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em; }
th.medal, td.number, th.total-col { text-align: center; }
th.medal span { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; }
th.gold span { background: var(--gold); } th.silver span { background: var(--silver); } th.bronze span { background: var(--bronze); }
td { height: 68px; padding: 0 20px; border-top: 1px solid #ebe9e2; font-size: 14px; }
tbody tr { transition: background .15s; cursor: pointer; }
tbody tr:hover { background: #f7faf7; }
td.rank { width: 85px; padding-left: 30px; font: 19px Georgia, serif; color: var(--muted); }
tbody tr:nth-child(-n+3) td.rank { color: var(--orange); font-weight: 700; }
.country-cell { display: flex; align-items: center; gap: 13px; }
.noc-badge { width: 39px; height: 27px; display: grid; place-items: center; flex: 0 0 auto; background: #e3ece7; border: 1px solid #d2ddd7; border-radius: 4px; color: var(--teal-dark); font-size: 9px; font-weight: 800; letter-spacing: .04em; }
.country-cell strong { display: block; font-size: 14px; }
.country-cell small { display: block; margin-top: 2px; color: #96a09e; font-size: 10px; }
td.number { width: 85px; font: 17px Georgia, serif; }
td.total { background: rgba(8,107,103,.035); color: var(--teal); font-weight: 700; }
td.arrow { width: 45px; color: #a6afad; font-size: 18px; }
.loading { padding: 40px; color: var(--muted); text-align: center; }
.loading i { width: 16px; height: 16px; display: inline-block; margin-right: 10px; vertical-align: -3px; border: 2px solid #c7d2cf; border-top-color: var(--teal); border-radius: 50%; animation: spin .7s linear infinite; }
.empty { padding: 50px; text-align: center; color: var(--muted); }
.card-footer { min-height: 58px; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 0 30px; border-top: 1px solid var(--line); color: #909b99; font-size: 11px; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(4,31,30,.48); backdrop-filter: blur(3px); }
.drawer { position: fixed; top: 0; right: 0; z-index: 21; width: min(520px, 100%); height: 100vh; padding: 34px; overflow-y: auto; background: var(--paper); transform: translateX(102%); transition: transform .3s ease; box-shadow: -20px 0 60px rgba(2,35,34,.22); }
.drawer.open { transform: translateX(0); }
.drawer-close { position: absolute; top: 20px; right: 22px; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.drawer-head { padding: 40px 0 25px; border-bottom: 1px solid var(--line); }
.drawer-head .noc-badge { width: 54px; height: 36px; margin-bottom: 16px; }
.drawer-head h3 { margin: 0 0 5px; font: 36px Georgia, "Noto Serif SC", serif; }
.drawer-head p { margin: 0; color: var(--muted); font-size: 12px; }
.totals { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 20px 0 30px; }
.total-box { padding: 14px 8px; background: #f3f2ec; border-radius: 8px; text-align: center; }
.total-box strong { display: block; font: 24px Georgia, serif; }
.total-box span { color: var(--muted); font-size: 10px; }
.sport-title { display: flex; justify-content: space-between; align-items: end; margin-bottom: 10px; }
.sport-title h4 { margin: 0; font-size: 15px; }
.sport-title span { color: var(--muted); font-size: 11px; }
.sport-row { display: grid; grid-template-columns: 1fr repeat(4, 38px); align-items: center; gap: 7px; min-height: 51px; border-bottom: 1px solid #e9e7df; font-size: 12px; }
.sport-name strong { display: block; }
.sport-name small { color: #9ba4a2; font-size: 9px; }
.sport-num { text-align: center; font-family: Georgia, serif; }
.sport-num.total { color: var(--teal); font-weight: 700; }
.drawer-loading { padding-top: 120px; text-align: center; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 30; padding: 11px 18px; border-radius: 8px; background: var(--ink); color: white; font-size: 12px; opacity: 0; transform: translate(-50%, 15px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 800px) {
  .hero { min-height: 450px; border-radius: 0 0 28px 28px; }
  .hero-content { grid-template-columns: 1fr; padding: 45px 0 75px; }
  .hero-stat { display: none; }
  .nav-actions .live { display: none; }
  .leader-podium { grid-template-columns: 1fr; }
  .leader-card { min-height: 88px; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .controls { width: 100%; flex-wrap: wrap; }
  .search { width: 100%; }
  .card-footer { padding: 14px 20px; align-items: flex-start; flex-direction: column; gap: 5px; }
}
@media (max-width: 480px) {
  .nav, .hero-content, main { width: min(100% - 24px, 1180px); }
  h1 { font-size: 38px; }
  .docs-link { padding: 8px 10px; font-size: 11px; }
  .toolbar { padding: 22px 18px; }
  .drawer { padding: 24px 20px; }
}
