@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Noto+Sans+JP:wght@300;400;500;700;900&family=Share+Tech+Mono&display=swap');

/* ═══════════════════════════════════════════════════════════
   JJK THEME — Cursed Energy Design System
   Palette: deep ink black, cursed purple, blood crimson, bone white
═══════════════════════════════════════════════════════════ */
:root {
  --bg:           #05040a;
  --surface:      #0b0912;
  --card:         #0f0d18;
  --border:       #1e1a2e;
  --border2:      #2d2845;

  --accent:       #7c3aed;
  --accent-light: #9d5af5;
  --accent-bright:#b97eff;
  --accent-dim:   rgba(124,58,237,0.18);
  --accent-glow:  rgba(157,90,245,0.35);
  --pattern-accent: rgba(124,58,237,0.15);
  --pattern-hatch:  rgba(124,58,237,0.045);

  --cursed-red:   #c0192e;
  --cursed-red-dim: rgba(192,25,46,0.15);
  --green:        #22c55e;
  --green-dim:    rgba(34,197,94,0.1);
  --orange:       #f59e0b;
  --red:          #ef4444;
  --text:         #e8e4f0;
  --text2:        #7a7090;
  --muted:        #3d3555;

  --mono:   'Share Tech Mono', monospace;
  --sans:   'Noto Sans JP', sans-serif;
  --display:'Bebas Neue', sans-serif;
  --radius: 12px;
  --radius-sm: 6px;

  --topbar-h: 44px;
}

/* ─── Block auto-translation ─────────────────────────────── */
/* .notranslate + translate="no" — fully blocked */

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

#bgCanvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--topbar-h);
}

/* ─── Cursed energy ambient ──────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 10% 0%,   rgba(124,58,237,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 90% 100%,  rgba(192,25,46,0.08)  0%, transparent 60%),
    radial-gradient(ellipse 30% 50% at 50% 50%,   rgba(124,58,237,0.04) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* Subtle ink-wash grid */
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(124,58,237,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,58,237,0.018) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none; z-index: 0;
}

/* ═══════════════════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(5,4,10,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 0;
}

/* Cursed energy left accent line */
.topbar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--cursed-red) 50%, transparent 100%);
  opacity: 0.7;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 28px;
  text-decoration: none;
}

.topbar-sigil {
  width: 24px; height: 24px;
  position: relative;
  flex-shrink: 0;
}

.topbar-sigil svg {
  width: 100%; height: 100%;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.topbar-wordmark {
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--text);
  line-height: 1;
}

.topbar-wordmark em {
  font-style: normal;
  color: var(--accent-bright);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.topbar-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text2);
  text-decoration: none;
  border: 1px solid transparent;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.topbar-link:hover {
  color: var(--text);
  background: rgba(124,58,237,0.08);
}

.topbar-link.active {
  color: var(--accent-bright);
  background: rgba(124,58,237,0.12);
  border-color: rgba(124,58,237,0.25);
}

.topbar-link svg { opacity: 0.7; flex-shrink: 0; }
.topbar-link.active svg { opacity: 1; }

.topbar-live {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--green);
  padding: 4px 10px;
  background: var(--green-dim);
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: 99px;
}

/* ─── Layout ─────────────────────────────────────────────── */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  position: relative; z-index: 1;
}

/* ─── Header ─────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

/* Diagonal slash decoration */
header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 80px; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

.logo-hex {
  width: 44px; height: 44px;
  background: var(--accent);
  clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%);
  flex-shrink: 0;
  position: relative;
  animation: hex-pulse 3s ease-in-out infinite;
}
.logo-hex::after {
  content: '';
  position: absolute; inset: 6px;
  background: var(--bg);
  clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%);
}

@keyframes hex-pulse {
  0%, 100% { filter: drop-shadow(0 0 8px var(--accent-glow)); }
  50%       { filter: drop-shadow(0 0 24px var(--accent-glow)); }
}

.header-copy h1 {
  font-family: var(--display);
  font-size: 28px;
  letter-spacing: 3px;
  line-height: 1;
  color: var(--text);
}
.header-copy h1 em { font-style: normal; color: var(--accent-bright); }
.header-copy small {
  font-family: var(--mono); font-size: 10px;
  color: var(--muted); letter-spacing: 1.5px;
  text-transform: uppercase; display: block; margin-top: 5px;
}

.live-pill {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  background: var(--green-dim);
  border: 1px solid rgba(34,197,94,0.25);
  border-radius: 99px; padding: 5px 13px;
  font-family: var(--mono); font-size: 10px;
  color: var(--green); letter-spacing: 1.5px;
  text-transform: uppercase; flex-shrink: 0;
}

/* ─── Blink ──────────────────────────────────────────────── */
.dot-blink {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
  display: inline-block;
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.15; }
}

/* ─── Tab row ────────────────────────────────────────────── */
.tab-row {
  display: flex; align-items: center;
  gap: 8px; margin-bottom: 24px;
  flex-wrap: wrap;
}

.tabs {
  display: inline-flex; flex-wrap: nowrap; gap: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px;
  width: fit-content; flex-shrink: 1;
  min-width: 0; overflow: hidden;
}

.tab-btn {
  flex: 0 0 160px; width: 160px; min-width: 0;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 4px);
  color: var(--muted);
  font-family: var(--mono); font-size: 12px; font-weight: 400;
  letter-spacing: 0.8px; text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: center;
}
.tab-btn.active {
  background: var(--card);
  border-color: rgba(124,58,237,0.3);
  color: var(--accent-bright);
  box-shadow: 0 0 16px var(--accent-dim);
}
.tab-btn:not(.active):hover {
  color: var(--text2);
  background: rgba(255,255,255,0.03);
}

/* ─── Icon buttons ───────────────────────────────────────── */
.icon-btn {
  flex-shrink: 0;
  width: 40px; height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.icon-btn:hover,
.icon-btn.active {
  color: var(--accent-bright);
  border-color: rgba(124,58,237,0.4);
  background: var(--accent-dim);
  box-shadow: 0 0 12px var(--accent-dim);
}

/* ─── Overlay / Modal ────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(5,4,10,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 300;
  display: flex; align-items: flex-start;
  justify-content: center; padding-top: 80px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  width: 100%; margin: 0 16px;
  overflow: hidden;
  transform: translateY(-14px);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 40px 100px rgba(0,0,0,0.7), 0 0 0 1px rgba(124,58,237,0.1);
}
/* cursed line at top of modal */
.modal::before {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--cursed-red), transparent);
}
.overlay.open .modal { transform: translateY(0); }

/* ─── Search modal ───────────────────────────────────────── */
#searchOverlay .modal { max-width: 480px; }

.search-modal-header { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.search-modal-title {
  font-family: var(--mono); font-size: 10px;
  color: var(--muted); letter-spacing: 1.5px;
  text-transform: uppercase; margin-bottom: 12px;
}
.search-input-wrap {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 10px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input-wrap:focus-within {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.search-input-wrap svg { flex-shrink: 0; color: var(--muted); }
.search-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--mono); font-size: 13px;
  color: var(--text); caret-color: var(--accent-bright); min-width: 0;
}
.search-input::placeholder { color: var(--muted); }
.search-go-btn {
  flex-shrink: 0;
  background: var(--accent); color: #fff; border: none;
  border-radius: 4px; padding: 6px 14px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.5px;
  text-transform: uppercase; cursor: pointer;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.search-go-btn:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.search-result { padding: 0 20px 20px; }
.search-result.hidden { display: none; }

.search-result-card {
  margin-top: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.search-result-inner { display: flex; align-items: center; gap: 14px; padding: 14px; }
.search-result-icon {
  width: 56px; height: 56px; border-radius: 8px;
  object-fit: cover; border: 1px solid var(--border2);
  flex-shrink: 0; background: var(--card);
}
.search-result-icon-ph {
  width: 56px; height: 56px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.search-result-info { flex: 1; min-width: 0; }
.search-result-name {
  font-size: 14px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px;
}
.search-result-creator { font-size: 11px; color: var(--text2); margin-bottom: 6px; }
.search-result-stats {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 10px; color: var(--muted);
}
.search-result-stats span { display: flex; align-items: center; gap: 4px; }
.search-result-stats .visits-val { color: var(--accent-bright); }
.search-result-stats .active-val { color: var(--green); }
.search-result-actions {
  display: flex; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}
.search-open-btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff;
  text-decoration: none; border-radius: 6px; padding: 7px 14px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase;
  transition: background 0.15s, transform 0.15s;
}
.search-open-btn:hover { background: var(--accent-light); transform: translateY(-1px); }
.search-error {
  margin-top: 14px; padding: 12px 14px;
  background: rgba(192,25,46,0.06);
  border: 1px solid rgba(192,25,46,0.2);
  border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 11px; color: #b07070; line-height: 1.6;
}
.search-loading {
  margin-top: 14px; padding: 12px 14px;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent-bright);
  border-radius: 50%;
  animation: spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-close-hint {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-close-hint kbd {
  background: var(--border); border-radius: 3px;
  padding: 2px 6px; font-family: var(--mono); font-size: 10px; color: var(--text2);
}

/* ─── Settings modal ─────────────────────────────────────── */
#settingsOverlay .modal { max-width: 500px; }

.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.settings-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  font-family: var(--display); letter-spacing: 2px;
}
.settings-title span {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  letter-spacing: 1px; text-transform: uppercase;
  display: block; margin-top: 3px; font-weight: 400;
}
.settings-close-x {
  width: 30px; height: 30px; border-radius: 4px;
  background: transparent; border: 1px solid transparent;
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.settings-close-x:hover { color: var(--text); background: var(--border); border-color: var(--border2); }

.settings-body { padding: 20px; display: flex; flex-direction: column; gap: 26px; }

.settings-section-label {
  font-family: var(--mono); font-size: 9.5px; color: var(--muted);
  letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.settings-section-label::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.color-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.color-swatch-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 4px;
  cursor: pointer; border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); box-shadow: 0 0 0 3px rgba(255,255,255,0.1); }

.color-custom-wrap { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.color-custom-label { font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap; }
.color-picker-input {
  width: 36px; height: 28px;
  border: 1px solid var(--border2); border-radius: 4px;
  background: var(--surface); cursor: pointer; padding: 2px;
}
.color-hex-input {
  width: 90px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 4px; padding: 5px 9px;
  font-family: var(--mono); font-size: 12px; color: var(--text);
  outline: none; transition: border-color 0.2s;
}
.color-hex-input:focus { border-color: var(--accent-light); }

.pinned-games-list { display: flex; flex-direction: column; gap: 10px; }
.pinned-game-row { display: flex; align-items: center; gap: 10px; }
.pinned-game-num { font-family: var(--mono); font-size: 10px; color: var(--muted); width: 18px; flex-shrink: 0; text-align: right; }
.pinned-game-input {
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 9px 12px;
  font-family: var(--mono); font-size: 12px; color: var(--text);
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.pinned-game-input:focus { border-color: var(--accent-light); box-shadow: 0 0 0 3px var(--accent-dim); }
.pinned-game-input::placeholder { color: var(--muted); }
.pinned-game-status { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; }

.settings-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}
.settings-save-msg {
  font-family: var(--mono); font-size: 10px;
  color: var(--green); opacity: 0; transition: opacity 0.3s; letter-spacing: 0.5px;
}
.settings-save-msg.show { opacity: 1; }

.settings-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase;
  cursor: pointer; transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.settings-btn-secondary { background: var(--surface); color: var(--text2); border: 1px solid var(--border2); }
.settings-btn-secondary:hover { background: var(--border); color: var(--text); }
.settings-btn-primary { background: var(--accent); color: #fff; }
.settings-btn-primary:hover {
  background: var(--accent-light); transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

/* ─── Panel ──────────────────────────────────────────────── */
.game-panel { display: none; }
.game-panel.active {
  display: block;
  animation: slide-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-loading, .panel-error {
  padding: 48px 24px; text-align: center;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.panel-error { color: #b05560; }

/* ─── Card ───────────────────────────────────────────────── */
.game-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; position: relative;
}
/* Cursed energy top line */
.game-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--cursed-red) 50%, transparent 100%);
  z-index: 2;
}

/* Animated crosshatch */
@keyframes crosshatch-drift {
  0%   { background-position: 0 0, 0 0; }
  100% { background-position: 30px 30px, 30px 30px; }
}

.card-header,
.stat-visits,
.stat-active,
.stat-ratio {
  background-color: var(--card);
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 14px, var(--pattern-hatch) 14px, var(--pattern-hatch) 15px),
    repeating-linear-gradient(90deg, transparent, transparent 14px, var(--pattern-hatch) 14px, var(--pattern-hatch) 15px);
  background-size: 15px 15px, 15px 15px;
  animation: crosshatch-drift 6s linear infinite;
}

.card-header {
  display: flex; align-items: center; gap: 22px;
  padding: 24px 24px 20px; border-bottom: 1px solid var(--border);
  position: relative;
}
.game-icon-wrap { flex-shrink: 0; }
.game-icon {
  width: 96px; height: 96px; border-radius: 10px;
  object-fit: cover; border: 1px solid var(--border2);
  display: block; background: var(--surface);
}
.game-icon-placeholder {
  width: 96px; height: 96px; border-radius: 10px;
  background: linear-gradient(135deg, #120d1e, #0b0912);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.game-icon-placeholder svg { opacity: 0.15; }

.game-title-area { flex: 1; min-width: 0; }
.place-id-tag {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 5px;
}
.game-name {
  font-family: var(--display);
  font-size: 24px; letter-spacing: 1.5px;
  line-height: 1.1; margin-bottom: 6px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.game-creator { font-family: var(--mono); font-size: 11px; color: var(--text2); margin-bottom: 14px; }

.play-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff;
  text-decoration: none; border-radius: var(--radius-sm);
  padding: 8px 16px; font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.8px; text-transform: uppercase;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.play-btn:hover {
  background: var(--accent-light); transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

/* Stats grid */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--border);
}
.stat-cell { padding: 18px 20px 20px; }
.stat-cell + .stat-cell { border-left: 1px solid var(--border); }

.stat-label {
  font-family: var(--mono); font-size: 9.5px; color: var(--muted);
  letter-spacing: 1.5px; text-transform: uppercase;
  margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
}
.stat-icon { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.stat-visits .stat-icon  { background: var(--accent-bright); }
.stat-active .stat-icon  { background: var(--green); animation: blink 1.6s infinite; }
.stat-ratio  .stat-icon  { background: var(--orange); }

.stat-value {
  font-family: var(--display);
  font-size: 32px; letter-spacing: 1px; line-height: 1;
  margin-bottom: 4px;
}
.stat-visits .stat-value { color: var(--accent-bright); }
.stat-active .stat-value { color: var(--green); }
.stat-ratio  .stat-value { color: var(--orange); }

.stat-sub { font-family: var(--mono); font-size: 10px; color: var(--muted); line-height: 1.4; }

.vote-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 9px; font-family: var(--mono); font-size: 10px;
}
.vote-likes    { color: var(--green); }
.vote-sep      { color: var(--muted); }
.vote-dislikes { color: var(--red); }

.ratio-track {
  margin-top: 6px; height: 3px;
  background: rgba(124,58,237,0.15); border-radius: 99px; overflow: hidden;
}
.ratio-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 99px;
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1); width: 0%;
}

.update-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 20px; border-top: 1px solid var(--border);
  background: var(--surface);
}
.update-bar span { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.4px; }
.update-time { margin-left: auto; }

/* ═══════════════════════════════════════════════════════════
   POPULAR SECTION
═══════════════════════════════════════════════════════════ */
.popular-section { margin-top: 48px; }

.popular-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.popular-title { display: flex; align-items: center; gap: 10px; }
.popular-title h2 {
  font-family: var(--display);
  font-size: 18px; letter-spacing: 2px; color: var(--text);
}
.popular-title .flame { font-size: 16px; }

.popular-meta {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  letter-spacing: 0.5px; display: flex; align-items: center; gap: 8px;
}

.popular-refresh-btn {
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--muted); cursor: pointer;
  padding: 4px 10px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.5px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  display: flex; align-items: center; gap: 5px;
}
.popular-refresh-btn:hover {
  color: var(--accent-bright); border-color: rgba(124,58,237,0.4); background: var(--accent-dim);
}
.popular-refresh-btn.spinning svg { animation: spin 0.7s linear infinite; }

.popular-table-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; position: relative;
}
.popular-table-wrap::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--cursed-red) 50%, transparent 100%);
}

.popular-cols {
  display: grid; grid-template-columns: 36px 56px 1fr 110px 110px 110px 80px;
  align-items: center; gap: 0; padding: 10px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.popular-col-label {
  font-family: var(--mono); font-size: 9px; color: var(--muted);
  letter-spacing: 1.3px; text-transform: uppercase;
}
.popular-col-label.right { text-align: right; }

.popular-loading {
  padding: 40px 24px; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.popular-error {
  padding: 32px 24px; text-align: center;
  font-family: var(--mono); font-size: 11px; color: #b05560; line-height: 1.6;
}

.popular-row {
  display: grid; grid-template-columns: 36px 56px 1fr 110px 110px 110px 80px;
  align-items: center; gap: 0; padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s; text-decoration: none; color: inherit;
}
.popular-row:last-child { border-bottom: none; }
.popular-row:hover { background: rgba(124,58,237,0.04); }

.pop-rank {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--muted); text-align: center;
}
.pop-rank.top3 { color: var(--accent-bright); }

/* ── Top 3 Medal Rows ── */
.popular-row.rank-1,
.popular-row.rank-2,
.popular-row.rank-3 { position: relative; border-bottom: 1px solid transparent; }

.popular-row.rank-1::before,
.popular-row.rank-2::before,
.popular-row.rank-3::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
}

/* Gold */
.popular-row.rank-1 {
  background: linear-gradient(90deg, rgba(212,175,55,0.16) 0%, rgba(212,175,55,0.06) 50%, transparent 100%);
  border-bottom-color: rgba(212,175,55,0.12);
  box-shadow: inset 3px 0 0 rgba(212,175,55,0.7);
}
.popular-row.rank-1::before {
  background-image: repeating-linear-gradient(55deg, transparent, transparent 12px, rgba(212,175,55,0.055) 12px, rgba(212,175,55,0.055) 13px);
}
.popular-row.rank-1 .pop-rank { color: #f5c842; text-shadow: 0 0 12px rgba(212,175,55,0.8); font-size: 15px; }

/* Silver */
.popular-row.rank-2 {
  background: linear-gradient(90deg, rgba(180,180,200,0.13) 0%, rgba(180,180,200,0.05) 50%, transparent 100%);
  border-bottom-color: rgba(180,180,200,0.1);
  box-shadow: inset 3px 0 0 rgba(192,192,210,0.55);
}
.popular-row.rank-2::before {
  background-image: repeating-linear-gradient(55deg, transparent, transparent 12px, rgba(192,192,210,0.045) 12px, rgba(192,192,210,0.045) 13px);
}
.popular-row.rank-2 .pop-rank { color: #c0c8d8; text-shadow: 0 0 10px rgba(192,192,210,0.7); font-size: 14px; }

/* Bronze */
.popular-row.rank-3 {
  background: linear-gradient(90deg, rgba(184,115,51,0.13) 0%, rgba(184,115,51,0.05) 50%, transparent 100%);
  border-bottom-color: rgba(184,115,51,0.1);
  box-shadow: inset 3px 0 0 rgba(184,115,51,0.55);
}
.popular-row.rank-3::before {
  background-image: repeating-linear-gradient(55deg, transparent, transparent 12px, rgba(184,115,51,0.055) 12px, rgba(184,115,51,0.055) 13px);
}
.popular-row.rank-3 .pop-rank { color: #cd8b4a; text-shadow: 0 0 10px rgba(184,115,51,0.7); font-size: 13px; }

.popular-row.rank-1 > *, .popular-row.rank-2 > *, .popular-row.rank-3 > * { position: relative; z-index: 1; }
.popular-row.rank-1:hover, .popular-row.rank-2:hover, .popular-row.rank-3:hover { filter: brightness(1.07); }

.pop-icon { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border2); background: var(--surface); display: block; }
.pop-icon-ph {
  width: 40px; height: 40px; border-radius: 6px;
  background: linear-gradient(135deg, #0f0b1a, #080612);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.pop-info { min-width: 0; padding: 0 12px; }
.pop-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; margin-bottom: 2px; }
.pop-creator { font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop-stat { text-align: right; padding-right: 8px; }
.pop-stat-val { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; margin-bottom: 1px; }
.pop-stat-label { font-family: var(--mono); font-size: 9px; color: var(--muted); letter-spacing: 0.5px; }
.pop-visits .pop-stat-val { color: var(--accent-bright); }
.pop-active .pop-stat-val { color: var(--green); }
.pop-ratio  .pop-stat-val { color: var(--orange); }
.pop-ratio-bar { height: 2px; background: rgba(124,58,237,0.15); border-radius: 99px; overflow: hidden; margin-top: 3px; }
.pop-ratio-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); border-radius: 99px; }
.pop-updated { text-align: right; font-family: var(--mono); font-size: 9.5px; color: var(--muted); line-height: 1.4; padding-right: 4px; }

/* Skeleton */
.pop-skeleton {
  display: grid; grid-template-columns: 36px 56px 1fr 110px 110px 110px 80px;
  align-items: center; gap: 0; padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.pop-skeleton:last-child { border-bottom: none; }
.skel {
  height: 12px; border-radius: 4px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%);
  background-size: 300% 100%; animation: shimmer 1.6s infinite;
}
.skel-icon {
  width: 40px; height: 40px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%);
  background-size: 300% 100%; animation: shimmer 1.6s infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 700px) {
  .popular-cols, .popular-row, .pop-skeleton { grid-template-columns: 28px 44px 1fr 80px 80px; }
  .pop-updated, .pop-ratio, .popular-col-label:nth-child(6), .popular-col-label:nth-child(7),
  .pop-skeleton > *:nth-child(6), .pop-skeleton > *:nth-child(7) { display: none; }
  .pop-icon, .pop-icon-ph { width: 36px; height: 36px; }
}

@media (max-width: 580px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-cell + .stat-cell { border-left: none; border-top: 1px solid var(--border); }
  .card-header { flex-direction: column; align-items: flex-start; }
  .live-pill { margin-left: 0; }
  .stat-value { font-size: 26px; }
  .tab-row { gap: 6px; }
  .tabs { width: 100%; }
  .tab-btn { flex: 1 1 0; width: auto; font-size: 10px; padding: 8px 6px; }
  .icon-btn { width: 36px; height: 36px; }
  .settings-footer { flex-direction: column; align-items: stretch; }
  .topbar-wordmark { font-size: 15px; }
  .topbar-link span { display: none; }
}

@media (max-width: 400px) {
  .tab-btn { font-size: 10px; padding: 7px 4px; }
  .icon-btn { width: 32px; height: 32px; }
}
