:root {
  --bg: #0a0d14;
  --bg-2: #0f1420;
  --panel: #121826;
  --panel-2: #161e2e;
  --line: #1f2938;
  --line-2: #2a3648;
  --text: #e6edf7;
  --muted: #8a97ab;
  --dim: #5d6a80;
  --accent: #4ade80;
  --accent-dim: #1c3a2a;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --amber: #fbbf24;
  --rose: #fb7185;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

::selection {
  background: rgba(74, 222, 128, 0.28);
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 12px 22px;
  background: rgba(10, 13, 20, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.brand svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.brand-accent {
  color: var(--accent);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 620px;
  width: 100%;
  justify-self: center;
}

.search svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--dim);
  pointer-events: none;
}

.search input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px 9px 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12);
}

.search input::placeholder {
  color: var(--dim);
}

.search select {
  width: 130px;
  padding: 9px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  cursor: pointer;
}

.nav {
  display: flex;
  gap: 4px;
}

.nav a {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--text);
  background: var(--panel);
}

.nav a.active {
  color: var(--text);
  background: var(--panel-2);
}

/* ---------------------------------------------------------------- layout */
main {
  max-width: 1380px;
  margin: 0 auto;
  padding: 26px 22px 60px;
  min-height: 60vh;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: -0.6px;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: -0.2px;
}

h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.muted {
  color: var(--muted);
}

.dim {
  color: var(--dim);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.card.tight {
  padding: 0;
  overflow: hidden;
}

/* ---------------------------------------------------------------- stats */
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--dim);
}

.up {
  color: var(--accent);
}

.down {
  color: var(--rose);
}

/* ---------------------------------------------------------------- tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  padding: 10px 14px;
  text-align: right;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--dim);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

td {
  padding: 9px 14px;
  text-align: right;
  border-bottom: 1px solid rgba(31, 41, 56, 0.55);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--panel-2);
}

tbody tr:last-child td {
  border-bottom: none;
}

.rank {
  display: inline-block;
  width: 26px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 12px;
}

.game-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.game-cell img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-2);
  flex: none;
}

.game-cell .gname {
  font-weight: 550;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-cell .gmeta {
  font-size: 11.5px;
  color: var(--dim);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  color: var(--muted);
}

.pill.green {
  color: var(--accent);
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.25);
}

.pill.blue {
  color: var(--blue);
  background: rgba(96, 165, 250, 0.1);
  border-color: rgba(96, 165, 250, 0.25);
}

.bar {
  position: relative;
  height: 5px;
  width: 84px;
  margin-left: auto;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
}

.bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  border-radius: 3px;
}

.bar.blue > i {
  background: var(--blue);
}

.bar.amber > i {
  background: var(--amber);
}

/* ---------------------------------------------------------------- chips */
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.chip {
  padding: 6px 13px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.12s;
}

.chip:hover {
  border-color: var(--line-2);
  color: var(--text);
}

.chip.active {
  background: var(--accent-dim);
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--accent);
}

/* ---------------------------------------------------------------- detail */
.hero {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  margin-bottom: 22px;
}

.hero img.icon {
  width: 140px;
  height: 140px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.7px;
  line-height: 1.2;
}

.hero .meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

.hero .desc {
  color: var(--muted);
  font-size: 13px;
  max-width: 720px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.kv div span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--dim);
}

.kv div b {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chart-card {
  padding: 16px 16px 6px;
}

.chart-card svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 4px 0 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: middle;
}

/* ---------------------------------------------------------------- misc */
.search-results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.empty {
  padding: 50px 20px;
  text-align: center;
  color: var(--muted);
}

.skeleton-wrap {
  padding: 40px 0;
}

.skeleton {
  height: 220px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 50%, var(--panel) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.footer {
  border-top: 1px solid var(--line);
  padding: 22px;
  max-width: 1380px;
  margin: 0 auto;
  font-size: 12px;
  color: var(--dim);
}

.footer p {
  margin: 0 0 4px;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.22);
  color: #f5d488;
  font-size: 12.5px;
  margin-bottom: 18px;
}

.trend-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trend-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 48px;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
}

.trend-row .t-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend-row .t-bar {
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
}

.trend-row .t-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  border-radius: 3px;
}

.trend-row .t-count {
  text-align: right;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11.5px;
}

#toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translate(-50%, 80px);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
  z-index: 80;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1000px) {
  .topbar {
    grid-template-columns: auto 1fr;
    gap: 12px;
  }
  .search {
    grid-column: 1 / -1;
    order: 3;
    max-width: none;
  }
  .nav {
    justify-content: flex-end;
    overflow-x: auto;
  }
  .grid-4,
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  main {
    padding: 18px 14px 50px;
  }
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  .hero {
    grid-template-columns: 90px 1fr;
  }
  .hero img.icon {
    width: 90px;
    height: 90px;
  }
  .hero h1 {
    font-size: 20px;
  }
  th:nth-child(n + 5),
  td:nth-child(n + 5) {
    display: none;
  }
  .nav a {
    padding: 6px 9px;
    font-size: 12px;
  }
}
