/* ── Reset & Variables ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0e0e10;
  --bg2:          #18181b;
  --bg3:          #1f1f23;
  --bg4:          #26262c;
  --purple:       #9147ff;
  --purple-light: #b580ff;
  --purple-dim:   #9147ff22;
  --live:         #eb0400;
  --live-dim:     #eb040022;
  --text:         #efeff1;
  --muted:        #adadb8;
  --dim:          #53535f;
  --border:       #2a2a35;
  --mono:         'Space Mono', monospace;
  --sans:         'DM Sans', sans-serif;
}

/* ── Base ──────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scanline overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 2px,
    rgba(255,255,255,0.012) 2px, rgba(255,255,255,0.012) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ── Header ────────────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo { display: flex; align-items: center; gap: 0.6rem; }

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--purple);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon svg { display: block; }

.logo-text {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.logo-text span { color: var(--purple-light); }

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pulse {
  width: 8px;
  height: 8px;
  background: var(--live);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 #eb040066; }
  50%       { opacity: 0.7; box-shadow: 0 0 0 6px #eb040000; }
}

.live-count { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.live-count strong { color: var(--live); }

/* ── Main layout ───────────────────────────────────────────── */
main { padding: 2rem; max-width: 1200px; margin: 0 auto; }

/* ── Controls ──────────────────────────────────────────────── */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 2rem;
}

.toggle-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.55rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s;
  white-space: nowrap;
}

.toggle-btn:hover { border-color: var(--purple); color: var(--text); }

.toggle-btn.active {
  background: var(--purple-dim);
  border-color: var(--purple);
  color: var(--purple-light);
}

.dot-live { width: 7px; height: 7px; background: var(--live); border-radius: 50%; flex-shrink: 0; }

.btn-refresh {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.55rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s;
}

.btn-refresh:hover { border-color: var(--purple); color: var(--text); }
.btn-refresh:disabled { opacity: 0.5; cursor: default; }

.spinning { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Stats bar ─────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 1px;
  margin-bottom: 1.75rem;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.stat {
  flex: 1;
  background: var(--bg2);
  padding: 0.9rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-val { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; line-height: 1; }
.stat-val.purple { color: var(--purple-light); }
.stat-val.live   { color: var(--live); }
.stat-val.amber  { color: #ffaa3b; }
.stat-val.muted  { color: var(--muted); }

.stat-label {
  font-size: 0.7rem;
  color: var(--dim);
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Category chips ────────────────────────────────────────── */
.cat-filter-wrap {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.cat-label {
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.cat-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.chip {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-family: var(--mono);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--muted);
  transition: all 0.15s;
}

.chip:hover  { border-color: var(--purple); color: var(--text); }
.chip.active { background: var(--purple-dim); border-color: var(--purple); color: var(--purple-light); }

/* ── Error banner ──────────────────────────────────────────── */
.error-banner {
  background: #2a1010;
  border: 1px solid #5a2020;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: #ff7070;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.error-banner button {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #ff7070;
  cursor: pointer;
  font-size: 1rem;
}

/* ── Grid ──────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

/* ── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
  cursor: pointer;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.card:hover       { border-color: #3a3a46; transform: translateY(-2px); }
.card.is-live     { border-color: #2a1515; }
.card.is-live:hover { border-color: #4a2020; }

/* Thumbnail */
.card-thumb {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: var(--bg3);
  overflow: hidden;
}

.card-thumb-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.thumb-art {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--dim);
  background: var(--bg4);
  text-transform: uppercase;
}

.live-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(235,4,0,0.08) 0%, transparent 60%);
}

.badge-live {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--live);
  color: white;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.badge-live .dot {
  width: 5px;
  height: 5px;
  background: white;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

.badge-viewers {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(14,14,16,0.85);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Card body */
.card-body { padding: 0.9rem 1rem; }

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg4);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--purple-light);
  flex-shrink: 0;
  text-transform: uppercase;
}

.card.is-live .avatar { border-color: var(--live); }

.card-info { flex: 1; min-width: 0; }

.card-username {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-status { font-size: 0.75rem; color: var(--dim); margin-top: 0.1rem; font-family: var(--mono); }
.card-status.live { color: var(--live); }

.rank {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--dim);
  background: var(--bg4);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.card-title {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card.is-offline .card-title { color: var(--dim); font-style: italic; }

.card-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.tag-category {
  background: var(--purple-dim);
  color: var(--purple-light);
  border: 1px solid rgba(145,71,255,0.25);
  font-size: 0.68rem;
  font-family: var(--mono);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.tag-uptime { color: var(--dim); font-size: 0.68rem; font-family: var(--mono); }

/* ── Skeletons ─────────────────────────────────────────────── */
.shimmer {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

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

.loading-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.loading-thumb { width: 100%; padding-top: 56.25%; position: relative; }
.loading-thumb-inner { position: absolute; inset: 0; }
.loading-body { padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }

/* ── Empty state ───────────────────────────────────────────── */
.empty { grid-column: 1 / -1; text-align: center; padding: 4rem 2rem; color: var(--dim); }
.empty-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.4; }
.empty p { font-size: 0.9rem; line-height: 1.6; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  main   { padding: 1rem; }
  header { padding: 1rem; }
  .stats-bar { flex-wrap: wrap; }
  .stat { min-width: calc(50% - 0.5px); }
}
