@import url('https://api.fontshare.com/v2/css?f[]=clash-display@400,500,600,700,800,900&f[]=satoshi@300,400,500,700&display=swap');

:root {
  --bg: #050505;
  --bg2: #0a0a0a;
  --brand: #007AFF;
  --yellow: #EAE713;
  --green: #34C759;
  --red: #FF3B30;
  --text: #ffffff;
  --text2: #a1a1aa;
  --border: rgba(255,255,255,0.08);
  --glass-bg: rgba(255,255,255,0.04);
  --glass-strong: rgba(255,255,255,0.07);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Satoshi', -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.font-display { font-family: 'Clash Display', sans-serif; }

/* Glass */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.glass-strong {
  background: var(--glass-strong);
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(20px);
}

/* Grid background */
.grid-bg {
  background-image: linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 64px 64px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 0 20px; height: 44px; border-radius: 999px;
  font-family: 'Satoshi', sans-serif; font-weight: 500; font-size: 14px;
  cursor: pointer; transition: all 0.15s; border: none; text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #0066cc; }
.btn-outline { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.2); }
.btn-outline:hover { background: rgba(255,255,255,0.05); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { color: #fff; }
.btn-sm { height: 36px; padding: 0 16px; font-size: 13px; }
.btn-lg { height: 52px; padding: 0 28px; font-size: 16px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #cc2c22; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Inputs */
.inp {
  width: 100%; height: 44px; padding: 0 14px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 12px; color: #fff; font-size: 14px;
  font-family: 'Satoshi', sans-serif; outline: none;
  transition: border-color 0.15s;
}
.inp:focus { border-color: var(--brand); }
.inp::placeholder { color: var(--text2); }
textarea.inp { height: auto; padding: 12px 14px; resize: vertical; }

/* Cards */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: all 0.2s;
}
.card:hover { border-color: rgba(255,255,255,0.15); transform: translateY(-2px); }

/* Navbar */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(5,5,5,0.85); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.navbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.nav-logo {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: #fff;
  font-family: 'Clash Display', sans-serif; font-weight: 700; font-size: 18px;
}
.nav-logo-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--brand); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 20px rgba(0,122,255,0.4);
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link {
  padding: 8px 14px; border-radius: 999px; font-size: 14px;
  text-decoration: none; color: var(--text2); transition: all 0.15s;
}
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(255,255,255,0.05); }
.nav-actions { display: flex; align-items: center; gap: 10px; }

/* User menu */
.user-menu-wrap { position: relative; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 220px; background: #111; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px; padding: 6px; display: none; z-index: 200;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.dropdown.open { display: block; }
.dropdown-label { padding: 8px 12px; }
.dropdown-label .name { font-weight: 500; font-size: 14px; }
.dropdown-label .email { color: var(--text2); font-size: 12px; margin-top: 1px; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; font-size: 14px;
  cursor: pointer; color: var(--text); text-decoration: none;
  transition: background 0.1s;
}
.dropdown-item:hover { background: rgba(255,255,255,0.06); }
.dropdown-item svg { width: 16px; height: 16px; opacity: 0.6; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 40px 24px;
  margin-top: 80px;
}
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.footer p { font-size: 13px; color: var(--text2); }
.footer-links { display: flex; gap: 20px; }
.footer-links a { font-size: 13px; color: var(--text2); text-decoration: none; }
.footer-links a:hover { color: #fff; }

/* Layout containers */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.page { padding-top: 40px; padding-bottom: 80px; }

/* Section labels */
.label-upper {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 8px;
}
.label-yellow { color: var(--yellow); }

/* Grid utilities */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* Toast */
#toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: 10px; font-size: 14px;
  min-width: 280px; animation: slideIn 0.2s ease;
}
.toast-success { background: #1a3a1a; border: 1px solid var(--green); color: var(--green); }
.toast-error { background: #3a1a1a; border: 1px solid var(--red); color: var(--red); }
.toast-info { background: #1a2a3a; border: 1px solid var(--brand); color: var(--brand); }

@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-blue { background: rgba(0,122,255,0.15); color: var(--brand); }
.badge-yellow { background: rgba(234,231,19,0.15); color: var(--yellow); }
.badge-green { background: rgba(52,199,89,0.15); color: var(--green); }
.badge-red { background: rgba(255,59,48,0.15); color: var(--red); }

/* Spinner */
.spin {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15); border-top-color: var(--brand);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Avatar */
.av {
  border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; overflow: hidden; flex-shrink: 0;
}
.av img { width: 100%; height: 100%; object-fit: cover; }
.av-sm { width: 32px; height: 32px; }
.av-md { width: 44px; height: 44px; font-size: 16px; }
.av-lg { width: 72px; height: 72px; font-size: 24px; }
.av-xl { width: 96px; height: 96px; font-size: 32px; }

/* Tab bar */
.tab-bar {
  display: flex; gap: 4px; padding: 6px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: 14px; overflow-x: auto;
}
.tab-item {
  padding: 8px 16px; border-radius: 999px; font-size: 13px;
  cursor: pointer; white-space: nowrap; color: var(--text2);
  background: none; border: none; transition: all 0.15s;
}
.tab-item:hover { color: #fff; }
.tab-item.active { background: var(--brand); color: #fff; }

/* Test card */
.test-card {
  padding: 20px; border-radius: 16px; text-decoration: none;
  background: var(--glass-bg); border: 1px solid var(--border);
  transition: all 0.2s; display: block;
}
.test-card:hover { border-color: rgba(255,255,255,0.2); transform: translateY(-3px); }
.test-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(0,122,255,0.1); border: 1px solid rgba(0,122,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 20px;
}
.test-category { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text2); }
.test-name { font-family: 'Clash Display', sans-serif; font-size: 18px; font-weight: 600; margin: 4px 0; }
.test-desc { font-size: 13px; color: var(--text2); line-height: 1.5; }

/* Level bar */
.level-bar { height: 6px; background: rgba(255,255,255,0.06); border-radius: 999px; overflow: hidden; }
.level-fill { height: 100%; background: linear-gradient(90deg, var(--brand), #60a5fa); border-radius: 999px; transition: width 0.5s; }

/* Pulse animation */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-pulse { animation: pulse 2s infinite; }
@keyframes ping { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(2); opacity: 0; } }
.pulse-ring::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  background: rgba(255,59,48,0.4); animation: ping 1s infinite;
}
.glow-blue { box-shadow: 0 0 20px rgba(0,122,255,0.4); }

/* Stat box */
.stat-box { padding: 24px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text2); margin-bottom: 6px; }
.stat-value { font-family: 'Clash Display', sans-serif; font-size: 36px; font-weight: 700; }

/* Divider */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* Responsive */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .nav-links { display: none; }
  .hamburger { display: flex; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .container { padding: 0 16px; }
  .stat-value { font-size: 28px; }
}

/* Hamburger */
.hamburger {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 6px;
}
.hamburger span { display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px; }

/* Mobile nav */
.mobile-nav {
  display: none; padding: 12px 16px; background: rgba(10,10,10,0.98);
  border-top: 1px solid var(--border);
}
.mobile-nav.open { display: block; }
.mobile-nav a {
  display: block; padding: 12px 8px; color: var(--text2);
  text-decoration: none; border-bottom: 1px solid var(--border); font-size: 15px;
}
.mobile-nav a:hover { color: #fff; }

/* Leaderboard rows */
.lb-row {
  display: grid; grid-template-columns: 40px 1fr 100px 80px 80px;
  padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,0.04);
  align-items: center;
}
.lb-row:hover { background: rgba(255,255,255,0.02); }
@media (max-width: 700px) {
  .lb-row { grid-template-columns: 40px 1fr 80px; }
  .lb-hide-mobile { display: none; }
}

/* Friend card */
.friend-card { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.friend-card:not(:last-child) { border-bottom: 1px solid var(--border); }

/* Blog card */
.blog-card { border-radius: 16px; overflow: hidden; }
.blog-thumb { width: 100%; aspect-ratio: 16/9; background: rgba(255,255,255,0.05); object-fit: cover; }
.blog-body { padding: 20px; }
.blog-title { font-family: 'Clash Display', sans-serif; font-size: 18px; font-weight: 600; line-height: 1.3; margin: 8px 0; }
.blog-excerpt { font-size: 13px; color: var(--text2); line-height: 1.6; }

/* Admin */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { text-align: left; padding: 10px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); border-bottom: 1px solid var(--border); }
.admin-table td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.admin-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: #111; border: 1px solid rgba(255,255,255,0.12); border-radius: 20px; padding: 28px; width: 100%; max-width: 480px; }
.modal-title { font-family: 'Clash Display', sans-serif; font-size: 20px; font-weight: 700; margin-bottom: 16px; }

/* Result card */
.result-card { text-align: center; padding: 40px 24px; }
.result-score { font-family: 'Clash Display', sans-serif; font-size: 72px; font-weight: 900; color: var(--brand); line-height: 1; }
.result-label { color: var(--text2); font-size: 14px; margin-top: 6px; }
.result-extra { font-size: 13px; color: var(--text2); margin-top: 10px; }

/* Test area */
.test-area { max-width: 720px; margin: 0 auto; }
.test-header { margin-bottom: 28px; }
.test-header h1 { font-family: 'Clash Display', sans-serif; font-size: 36px; font-weight: 800; margin-bottom: 6px; }
.test-header p { color: var(--text2); font-size: 15px; }

/* Challenges */
.challenge-card { padding: 28px; border-radius: 20px; }
.challenge-type { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text2); margin-bottom: 8px; }
.challenge-title { font-family: 'Clash Display', sans-serif; font-size: 22px; font-weight: 700; margin-bottom: 4px; }

/* Score trend item */
.activity-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.activity-item:last-child { border-bottom: none; }

/* Compare page */
.compare-col { text-align: center; }
.compare-row { display: grid; grid-template-columns: 1fr 140px 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.04); align-items: center; }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-logo { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 28px; text-decoration: none; color: #fff; font-family: 'Clash Display', sans-serif; font-weight: 700; font-size: 20px; }
.auth-logo-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--brand); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 20px rgba(0,122,255,0.4); }
.form-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); display: block; margin-bottom: 6px; }
.form-group { margin-bottom: 14px; }
.divider-or { display: flex; align-items: center; gap: 12px; color: var(--text2); font-size: 12px; margin: 16px 0; }
.divider-or::before, .divider-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Auth extras */
.auth-card { padding: 2rem; border-radius: 1rem; }
.auth-sub { color: var(--text-muted); margin-bottom: 1.5rem; font-size: .9rem; }
.auth-error { background: rgba(255,59,48,.15); color: var(--red); border: 1px solid rgba(255,59,48,.3); border-radius: .5rem; padding: .75rem 1rem; margin-bottom: 1rem; font-size: .9rem; }
.auth-divider { display: flex; align-items: center; gap: .75rem; color: var(--text-muted); font-size: .8rem; margin: 1rem 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.08); }
.auth-footer { text-align: center; color: var(--text-muted); font-size: .85rem; margin-top: 1.25rem; }
.auth-footer a { color: var(--brand); text-decoration: none; }
.auth-logo a { text-decoration: none; color: inherit; font-family: 'Clash Display', sans-serif; font-weight: 700; font-size: 1.3rem; }

/* Utilities */
.w-full { width: 100%; }

/* Leaderboard me */
.lb-table { border-radius: .75rem; overflow: hidden; }
.lb-header { padding: .6rem 1rem; background: rgba(255,255,255,.04); }
.lb-row { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-top: 1px solid rgba(255,255,255,.04); transition: background .15s; cursor: pointer; }
.lb-row:hover { background: rgba(255,255,255,.03); }
.lb-me { background: rgba(0,122,255,.08) !important; border-left: 3px solid var(--brand); }

/* Badge extras */
.badge-brand { background: rgba(0,122,255,.2); color: var(--brand); }
