@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ===== SHADCN-INSPIRED CSS VARIABLES ===== */
:root {
  --background: #09090b;
  --foreground: #fafafa;
  --card: rgba(12, 12, 16, 0.7);
  --card-foreground: #fafafa;
  --popover: #09090b;
  --primary: #a855f7;
  --primary-hover: #9333ea;
  --primary-glow: rgba(168, 85, 247, 0.4);
  --secondary: rgba(39, 39, 42, 0.8);
  --secondary-hover: #3f3f46;
  --accent: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.3);
  --neon-green: #22d3ee;
  --neon-pink: #f472b6;
  --destructive: #ef4444;
  --success: #22c55e;
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);
  --input: #27272a;
  --ring: #a855f7;
  --gold: #fbbf24;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --gradient-bg: linear-gradient(150deg, #1a0a2e 0%, #2d1045 20%, #1a1040 40%, #0f1a3a 60%, #1a0a2e 80%, #2a0e35 100%);
  --nav-bg: rgba(20, 8, 35, 0.75);
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
  --background: #f0f0f5;
  --foreground: #18181b;
  --card: rgba(255, 255, 255, 0.8);
  --card-foreground: #18181b;
  --popover: #ffffff;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-glow: rgba(124, 58, 237, 0.3);
  --secondary: rgba(0, 0, 0, 0.05);
  --secondary-hover: rgba(0, 0, 0, 0.1);
  --muted: #e4e4e7;
  --muted-foreground: #71717a;
  --border: rgba(0,0,0,0.1);
  --border-hover: rgba(0,0,0,0.18);
  --input: #e4e4e7;
  --ring: #7c3aed;
  --gold: #d97706;
  --gradient-bg: linear-gradient(150deg, #ede9fe 0%, #e0d4fc 20%, #fce7d6 40%, #ddd6fe 60%, #e0e7ff 80%, #ede9fe 100%);
  --nav-bg: rgba(255, 255, 255, 0.75);
}

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

body {
  font-family: var(--font);
  background: var(--gradient-bg);
  background-attachment: fixed;
  color: var(--foreground);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s, color 0.3s;
}

a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-hover); }

/* ===== ANIMATED BACKGROUND ===== */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(ellipse 70% 50% at 30% 10%, rgba(249, 115, 22, 0.1), transparent),
    radial-gradient(ellipse 60% 40% at 70% 90%, rgba(168, 85, 247, 0.12), transparent),
    radial-gradient(ellipse 50% 50% at 80% 20%, rgba(251, 191, 36, 0.06), transparent);
}

[data-theme="light"] .bg-grid {
  background-image:
    radial-gradient(ellipse 70% 50% at 30% 10%, rgba(249, 115, 22, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 70% 90%, rgba(168, 85, 247, 0.08), transparent),
    radial-gradient(ellipse 50% 50% at 80% 20%, rgba(251, 191, 36, 0.06), transparent);
}

/* ===== NAV ===== */
.nav {
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-brand {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  text-shadow: none;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav-links a {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.nav-links a:hover {
  color: var(--foreground);
  background: var(--secondary);
  text-decoration: none;
}

.nav-user {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 0 var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 20px var(--primary-glow);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--foreground);
  border: 1px solid var(--border);
}

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

.btn-danger {
  background: var(--destructive);
  color: #fff;
}

.btn-danger:hover { background: #dc2626; }

.btn-success {
  background: var(--success);
  color: #000;
  font-weight: 600;
}

.btn-success:hover { background: #16a34a; }

.btn-small {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
  border: none;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}

.theme-toggle:hover {
  background: var(--secondary-hover);
  border-color: var(--border-hover);
}

.btn-ghost:hover {
  background: var(--secondary);
  color: var(--foreground);
}

/* ===== AUTH PAGE ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 2rem;
  background: rgba(12, 12, 16, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.03),
    0 20px 50px rgba(0,0,0,0.5);
}

.auth-container h1 {
  text-align: center;
  margin-bottom: 0.5rem;
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}

.auth-subtitle {
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.auth-tabs {
  display: flex;
  margin-bottom: 1.5rem;
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 0.5rem;
  text-align: center;
  background: transparent;
  cursor: pointer;
  border: none;
  color: var(--muted-foreground);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: calc(var(--radius) - 4px);
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--foreground);
}

.form-group input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font);
  font-size: 0.875rem;
  transition: all 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.form-group input::placeholder {
  color: var(--muted-foreground);
}

.auth-form .btn {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.65rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.error-msg {
  color: var(--destructive);
  font-size: 0.825rem;
  margin-top: 0.75rem;
  text-align: center;
}

/* ===== PORTAL ===== */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--foreground);
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--muted-foreground);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.game-card {
  position: relative;
  background: var(--card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.game-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  padding: 1px;
  background: linear-gradient(135deg, transparent, transparent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  transition: background 0.3s;
  pointer-events: none;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: transparent;
  box-shadow:
    0 0 30px rgba(168, 85, 247, 0.15),
    0 20px 40px rgba(0,0,0,0.3);
}

.game-card:hover::before {
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.game-card-image {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.5rem;
  position: relative;
  overflow: hidden;
}

.game-card-logo {
  height: 150px;
  width: auto;
  object-fit: contain;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}

.game-card:hover .game-card-logo {
  transform: scale(1.08) rotate(-2deg);
}

.game-card-image::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--card));
}

.game-card-body {
  padding: 1rem 1.25rem 1.25rem;
}

.game-card-body h3 {
  margin-bottom: 0.3rem;
  color: var(--foreground);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.game-card-body p {
  color: var(--muted-foreground);
  font-size: 0.825rem;
  line-height: 1.4;
}

.game-card-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: rgba(168, 85, 247, 0.15);
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.6rem;
}

/* ===== FRIENDS ===== */
.friends-section {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.friends-section h2 {
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.friends-section h2::before {
  content: '';
  display: block;
  width: 3px;
  height: 1rem;
  background: var(--primary);
  border-radius: 2px;
}

.search-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-box input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font);
  font-size: 0.875rem;
  transition: all 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.friend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.friend-item:last-child { border-bottom: none; }

.friend-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.friend-actions { display: flex; gap: 0.35rem; }

.empty-state {
  color: var(--muted-foreground);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.875rem;
}

/* ===== LEADERBOARD ===== */
.leaderboard {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 1.25rem;
}

.leaderboard h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.leaderboard-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 3px;
}

.leaderboard-tab {
  flex: 1;
  padding: 0.35rem 0.6rem;
  border: none;
  border-radius: calc(var(--radius) - 3px);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s;
}

.leaderboard-tab.active {
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.leaderboard-list {
  list-style: none;
}

.leaderboard-list li {
  display: flex;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(39, 39, 42, 0.5);
  font-size: 0.875rem;
}

.leaderboard-list li:last-child { border-bottom: none; }

.leaderboard-rank {
  width: 1.75rem;
  font-weight: 700;
  font-size: 0.8rem;
}

.leaderboard-rank-1 { color: #fbbf24; }
.leaderboard-rank-2 { color: #94a3b8; }
.leaderboard-rank-3 { color: #d97706; }

.leaderboard-name {
  flex: 1;
  font-weight: 500;
}

.leaderboard-score {
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* ===== BADGE ===== */
.badge-count {
  background: var(--destructive);
  color: #fff;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0 5px;
  margin-left: 4px;
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--secondary-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #52525b; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .nav { padding: 0.6rem 1rem; }
  .nav-brand { font-size: 1.1rem; }
  .nav-links a { padding: 0.4rem 0.5rem; font-size: 0.8rem; }
  .container { padding: 1.25rem; }
  .page-title { font-size: 1.4rem; }
  .auth-container { padding: 1.5rem; }
}
