:root {
  color-scheme: dark;
  --cyan: #40e0ff;
  --cyan-soft: rgba(64, 224, 255, 0.18);
  --panel: rgba(7, 20, 38, 0.82);
  --muted: rgba(255, 255, 255, 0.66);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 280px;
  background: #020912;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: #fff;
  background: #020912 url('/static/img/bg1.png') center top / cover fixed;
  font-family: 'Kanit', sans-serif;
}

a {
  color: inherit;
}

.stats-stars {
  position: fixed;
  z-index: -1;
  inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(64, 224, 255, 0.13), transparent 25%),
    radial-gradient(circle at 82% 35%, rgba(82, 92, 236, 0.12), transparent 28%),
    linear-gradient(180deg, rgba(2, 9, 18, 0.28), rgba(2, 9, 18, 0.92));
}

.stats-header {
  display: flex;
  width: min(1180px, calc(100% - 2rem));
  min-height: 76px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.stats-brand,
.back-home {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  text-decoration: none;
}

.stats-brand {
  gap: 0.7rem;
  font-weight: 500;
}

.stats-brand img {
  width: 48px;
  height: auto;
}

.back-home {
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(64, 224, 255, 0.3);
  border-radius: 999px;
  color: var(--cyan);
  background: rgba(5, 20, 36, 0.68);
}

.stats-main {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6rem) 0;
}

.stats-hero {
  max-width: 780px;
  margin: 0 auto clamp(2rem, 5vw, 3.5rem);
  text-align: center;
}

.stats-eyebrow {
  margin: 0 0 0.5rem;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.stats-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.7rem);
  font-weight: 500;
  line-height: 1.16;
}

.stats-hero > p:last-child {
  margin: 1rem auto 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 2vw, 1.1rem);
}

.stats-overview {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  padding: clamp(1.25rem, 4vw, 2rem);
  border: 1px solid rgba(64, 224, 255, 0.28);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(13, 56, 81, 0.68), var(--panel));
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.25), inset 0 0 45px rgba(64, 224, 255, 0.04);
}

.overview-label,
.overview-unit {
  color: var(--muted);
}

.overview-label {
  display: block;
  margin-bottom: 0.25rem;
}

.stats-overview strong {
  color: var(--cyan);
  font-size: clamp(2.5rem, 7vw, 5rem);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1;
}

.overview-unit {
  margin-left: 0.4rem;
}

.stats-overview p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.period-tabs {
  display: flex;
  margin: 1.25rem 0 clamp(2.5rem, 7vw, 5rem);
  padding: 0.35rem;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(2, 12, 24, 0.72);
  scrollbar-width: none;
}

.period-tabs::-webkit-scrollbar {
  display: none;
}

.period-tab {
  min-width: max-content;
  flex: 1;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  text-decoration: none;
}

.period-tab.is-active {
  color: #03101b;
  background: var(--cyan);
  box-shadow: 0 0 22px rgba(64, 224, 255, 0.2);
}

.ranking-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.ranking-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  font-weight: 500;
}

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

.ranking-list {
  display: grid;
  gap: 0.85rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-card {
  display: grid;
  grid-template-columns: 54px 100px minmax(0, 1fr) auto;
  min-width: 0;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.ranking-card.rank-1 {
  border-color: rgba(255, 208, 91, 0.48);
  background: linear-gradient(100deg, rgba(90, 67, 18, 0.28), var(--panel) 45%);
}

.rank-number {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(64, 224, 255, 0.3);
  border-radius: 50%;
  color: var(--cyan);
  background: rgba(64, 224, 255, 0.08);
  font-size: 1.15rem;
  font-weight: 600;
}

.rank-1 .rank-number {
  color: #ffe39b;
  border-color: rgba(255, 208, 91, 0.55);
  background: rgba(255, 208, 91, 0.1);
}

.rank-cover {
  width: 100px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
}

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

.rank-title-row {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.rank-title-row > div:first-child {
  min-width: 0;
}

.rank-code {
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.rank-content h3 {
  margin: 0.12rem 0 0;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-content p {
  margin: 0.15rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-count {
  flex: 0 0 auto;
  text-align: right;
}

.rank-count strong {
  display: block;
  color: #fff;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.rank-count span {
  color: var(--muted);
  font-size: 0.7rem;
}

.rank-progress {
  height: 5px;
  margin-top: 0.7rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.rank-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1598c0, var(--cyan));
  box-shadow: 0 0 10px rgba(64, 224, 255, 0.7);
}

.rank-visit {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(64, 224, 255, 0.3);
  border-radius: 10px;
  color: var(--cyan);
  text-decoration: none;
}

.back-home:hover,
.rank-visit:hover,
.back-home:focus-visible,
.rank-visit:focus-visible {
  color: #03101b;
  background: var(--cyan);
}

.empty-note {
  margin: 1.5rem 0 0;
  padding: 1rem;
  border-radius: 12px;
  color: var(--muted);
  background: rgba(64, 224, 255, 0.06);
  text-align: center;
}

.stats-footer {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 max(2rem, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.stats-footer p {
  margin: 0.25rem 0;
}

@media (max-width: 767.98px) {
  body {
    background-attachment: scroll;
  }

  .stats-header,
  .stats-main,
  .stats-footer {
    width: min(100% - 1.25rem, 1080px);
  }

  .stats-brand span {
    display: none;
  }

  .stats-overview {
    align-items: flex-start;
    flex-direction: column;
  }

  .ranking-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .ranking-card {
    grid-template-columns: 42px 76px minmax(0, 1fr);
    gap: 0.65rem;
  }

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

  .rank-cover {
    width: 76px;
    height: 68px;
  }

  .rank-visit {
    grid-column: 2 / -1;
    justify-content: center;
  }
}

@media (max-width: 479.98px) {
  .stats-main {
    padding-top: 2.5rem;
  }

  .stats-brand img {
    width: 42px;
  }

  .back-home {
    font-size: 0.82rem;
  }

  .period-tab {
    padding-inline: 0.8rem;
    font-size: 0.86rem;
  }

  .ranking-card {
    grid-template-columns: 36px 62px minmax(0, 1fr);
    padding: 0.65rem;
  }

  .rank-number {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
  }

  .rank-cover {
    width: 62px;
    height: 62px;
  }

  .rank-title-row {
    gap: 0.45rem;
  }

  .rank-content h3 {
    font-size: 0.88rem;
  }

  .rank-content p {
    display: none;
  }

  .rank-count strong {
    font-size: 0.96rem;
  }
}

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