:root {
  --bg: #0c0f15;
  --surface: rgba(255, 255, 255, .045);
  --text: #f7f7f8;
  --muted: #9399a6;
  --metric: #ffd66d;
  --provider: #ff625c;
  --font-rounded: "SF Pro Rounded", "Arial Rounded MT Bold", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-number: "SF Pro Rounded", "Avenir Next", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-rounded);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { -webkit-tap-highlight-color: transparent; }
.ranking-page {
  width: min(760px, calc(100% - 36px));
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 0 34px;
}
.provider-tabs {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  gap: 14px;
  margin: 0 0 26px;
}
.provider-tab {
  position: relative;
  min-width: 0;
  height: 68px;
  padding: 8px 4px 13px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  opacity: .7;
  cursor: pointer;
  transition: opacity .18s ease, transform .18s ease;
}
.provider-tab::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transform: translateX(-50%) scale(.5);
  transition: opacity .18s ease, transform .18s ease;
}
.provider-tab:hover { opacity: .9; }
.provider-tab.is-active { opacity: 1; transform: translateY(-1px); }
.provider-tab.is-active::after { opacity: .92; transform: translateX(-50%) scale(1); }
.provider-tab:disabled { cursor: wait; }
.provider-tab:focus-visible { outline: 3px solid rgba(255, 214, 109, .45); outline-offset: 2px; border-radius: 12px; }
.provider-tab-logo { max-width: 100%; display: block; object-fit: contain; }
.logo-pg { width: 92px; max-height: 43px; }
.logo-pp { width: 78px; max-height: 48px; }
.logo-jdb { width: 82px; max-height: 44px; }
.logo-fc { width: 98px; max-height: 36px; }
.logo-cq9 { width: 84px; max-height: 49px; }
.provider-board { --provider: #ff625c; }
.provider-pp { --provider: #ef922f; }
.provider-jdb { --provider: #e4ad45; }
.provider-fc { --provider: #ff6d2d; }
.provider-cq9 { --provider: #f4ef18; }
.rank-list { display: grid; gap: 19px; }
.rank-card {
  min-width: 0;
  height: 136px;
  display: grid;
  grid-template-columns: 42px 136px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 0 12px 0 0;
  border-radius: 28px;
  background: transparent;
  transition: background-color .2s ease, transform .2s ease;
}
.rank-card:hover { background: var(--surface); transform: translateY(-1px); }
.rank-number {
  color: var(--provider);
  font-family: var(--font-number);
  font-size: 2.15rem;
  font-weight: 950;
  line-height: 1;
  text-align: center;
}
.game-image {
  position: relative;
  width: 136px;
  height: 136px;
  display: block;
  overflow: hidden;
  border-radius: 27px;
  background: #171b23;
}
.game-image img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .24s ease; }
.game-image:hover img { transform: scale(1.035); }
.image-unavailable { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .78rem; font-weight: 800; }
.game-info { min-width: 0; }
.rank-card h2 {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(1.22rem, 3vw, 1.55rem);
  font-weight: 900;
  line-height: 1.32;
  letter-spacing: .01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ranking-metric { margin: 7px 0 0; display: flex; align-items: baseline; gap: 8px; }
.ranking-metric span { color: var(--muted); font-size: .68rem; font-weight: 800; }
.ranking-metric strong { color: var(--metric); font-family: var(--font-number); font-size: 1rem; font-weight: 950; }
.game-metrics { margin-top: 9px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.game-metric { min-width: 0; margin: 0; }
.game-metric span, .game-metric strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-metric span { color: var(--muted); font-size: .58rem; font-weight: 800; }
.game-metric strong { margin-top: 2px; color: #77d8ff; font-family: var(--font-number); font-size: .78rem; font-weight: 900; }
.game-metric strong.is-unavailable { color: var(--muted); font-size: .68rem; }
.refresh-controls { margin-top: 31px; display: grid; justify-items: center; }
.refresh-controls h1 { margin: 0 0 12px; font-size: 1rem; font-weight: 950; line-height: 1; }
.window-buttons { width: min(540px, 100%); display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.window-button {
  min-width: 84px;
  height: 38px;
  padding: 0 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, .055);
  border: 0;
  border-radius: 999px;
  font-family: var(--font-rounded);
  font-size: .78rem;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
  transition: color .18s ease, background-color .18s ease, transform .18s ease;
}
.window-button:hover { color: var(--text); background: rgba(255, 255, 255, .1); }
.window-button.is-active { color: #101219; background: #f5f5f6; }
.window-button:focus-visible, .refresh-button:focus-visible { outline: 3px solid rgba(255, 214, 109, .42); outline-offset: 3px; }
.window-button:disabled { cursor: wait; opacity: .62; }
.refresh-button {
  min-width: 168px;
  height: 50px;
  margin: 14px auto 0;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #111319;
  background: #f4f4f5;
  border: 0;
  border-radius: 999px;
  font-family: var(--font-rounded);
  font-size: .95rem;
  font-weight: 950;
  cursor: pointer;
  transition: transform .18s ease, background-color .18s ease;
}
.refresh-button:hover { background: #fff; transform: translateY(-1px); }
.refresh-button:disabled { cursor: wait; opacity: .62; transform: none; }
.refresh-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.refresh-button.is-loading svg { animation: spin .75s linear infinite; }
.refresh-status { max-width: 100%; margin-top: 12px; color: var(--muted); text-align: center; line-height: 1.6; }
.refresh-status p { margin: 0; font-size: .74rem; font-weight: 800; }
.refresh-status #refreshTime { margin-top: 2px; color: var(--muted); font-size: .65rem; font-weight: 600; }
.refresh-status[data-state="updated"] { color: #77d8ff; }
.refresh-status[data-state="stale"] { color: var(--metric); }
.refresh-status[data-state="error"] { color: #ff9b9b; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state, .error-panel { min-height: 450px; display: grid; place-items: center; color: var(--muted); font-weight: 800; text-align: center; }
.error-panel { min-height: 160px; color: #ff9b9b; }
.error-panel p { margin: 0; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 11px 18px;
  color: #15171c;
  background: #f4f4f5;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 850;
  text-align: center;
  transform: translateX(-50%);
}
[hidden] { display: none !important; }
@media (max-width: 680px) {
  .ranking-page { width: calc(100% - 22px); padding-top: max(15px, env(safe-area-inset-top)); }
  .provider-tabs { min-height: 59px; gap: 4px; margin-bottom: 17px; }
  .provider-tab { height: 57px; padding: 6px 3px 12px; }
  .logo-pg { width: 65px; max-height: 35px; }
  .logo-pp { width: 56px; max-height: 37px; }
  .logo-jdb { width: 58px; max-height: 34px; }
  .logo-fc { width: 68px; max-height: 31px; }
  .logo-cq9 { width: 57px; max-height: 39px; }
  .rank-list { gap: 14px; }
  .rank-card { height: 119px; grid-template-columns: 30px 108px minmax(0, 1fr); gap: 12px; padding-right: 3px; border-radius: 23px; }
  .rank-number { font-size: 1.55rem; }
  .game-image { width: 108px; height: 108px; border-radius: 22px; }
  .rank-card h2 { font-size: 1.08rem; }
  .ranking-metric { margin-top: 5px; gap: 5px; }
  .ranking-metric span { font-size: .57rem; }
  .ranking-metric strong { font-size: .82rem; }
  .game-metrics { margin-top: 6px; gap: 5px; }
  .game-metric span { font-size: .5rem; }
  .game-metric strong { font-size: .67rem; }
  .game-metric strong.is-unavailable { font-size: .58rem; }
  .refresh-controls { margin-top: 24px; }
  .window-buttons { gap: 6px; }
  .window-button { min-width: 62px; height: 35px; padding: 0 9px; font-size: .67rem; }
}
@media (max-width: 380px) {
  .rank-card { grid-template-columns: 27px 98px minmax(0, 1fr); gap: 9px; }
  .game-image { width: 98px; height: 98px; }
  .logo-fc { width: 61px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
