/* ============================================
   GameNest.fun — Design System
   ============================================ */

/* ---- CSS Custom Properties ---- */
:root {
  /* Backgrounds */
  --bg-primary: #0a0a1a;
  --bg-secondary: #1a0a2e;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --bg-glass: rgba(255, 255, 255, 0.06);

  /* Brand colors */
  --accent-blue: #6C63FF;
  --accent-coral: #FF6B6B;
  --accent-mint: #00D68F;
  --accent-gold: #FBBF24;

  /* Text */
  --text-primary: rgba(255, 255, 255, 0.87);
  --text-secondary: rgba(255, 255, 255, 0.65);
  --text-muted: rgba(255, 255, 255, 0.40);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(108, 99, 255, 0.30);

  /* Sizing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Typography */
  --font-display: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent-blue); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: #8B83FF; }
img { max-width: 100%; height: auto; }
ul, ol { list-style: none; }

/* ---- Glass Card ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg,
    rgba(108, 99, 255, 0.06),
    rgba(0, 214, 143, 0.03));
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: 0 8px 40px rgba(79, 70, 229, 0.12);
}

.card:hover::before { opacity: 1; }
.card > * { position: relative; z-index: 1; }

.card-game {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 20px;
  text-decoration: none;
  color: inherit;
}

.card-game .gicon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.card-game h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.card-game p { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), #8B83FF);
  color: #fff;
  box-shadow: 0 4px 20px rgba(108, 99, 255, 0.30);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(108, 99, 255, 0.40);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

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

.btn-large { padding: 16px 40px; font-size: 1.1rem; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}

.badge-hot { background: rgba(255, 107, 107, 0.15); color: var(--accent-coral); }
.badge-new { background: rgba(0, 214, 143, 0.15); color: var(--accent-mint); }
.badge-brain { background: rgba(108, 99, 255, 0.15); color: #A5B4FC; }

/* ---- Tags ---- */
.tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  align-self: flex-start;
}

.tag-green { background: rgba(0, 214, 143, 0.15); color: var(--accent-mint); }
.tag-purple { background: rgba(108, 99, 255, 0.15); color: #A5B4FC; }
.tag-gold { background: rgba(251, 191, 36, 0.15); color: var(--accent-gold); }

/* ---- Header ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 26, 0.90);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  text-decoration: none;
}

.logo:hover { color: var(--text-primary); }

.logo span:last-child {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-mint));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav { display: flex; gap: 8px; flex: 1; }

.nav a {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav a:hover, .nav a.active {
  background: var(--bg-card);
  color: var(--text-primary);
}

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

/* ---- Search ---- */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  width: 200px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  width: 100%;
}

.search-box input::placeholder { color: var(--text-muted); }

/* ---- Score Display ---- */
.score-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-gold);
  font-weight: 600;
  white-space: nowrap;
}

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  display: flex;
  align-items: center; justify-content: center;
  font-size: 1rem;
  cursor: pointer;
}

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: 60px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.footer-links a { color: var(--text-secondary); }
.footer-links a:hover { color: var(--accent-blue); }

/* ---- Container ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

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

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

/* ---- Section Spacing ---- */
.section { padding: 40px 0; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.section-header a {
  font-size: 0.85rem;
  color: var(--accent-blue);
}

/* ---- Hero ---- */
.hero {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, #0f0020 100%);
  padding: 60px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent-blue), #A78BFA, var(--accent-mint));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero .subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 8px;
}

.daily-countdown {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-gold);
  margin-bottom: 24px;
}

.social-proof {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.avatar-stack { display: flex; }

.avatar-stack .mini-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
  margin-left: -8px;
  font-size: 0.65rem;
  display: flex;
  align-items: center; justify-content: center;
  background: var(--bg-card);
}

.avatar-stack .mini-avatar:first-child { margin-left: 0; }

/* ---- Hot Section ---- */
.hot-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 8px 0 16px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.hot-scroll::-webkit-scrollbar { display: none; }

.hot-card {
  min-width: 220px;
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition-normal);
  flex-shrink: 0;
}

.hot-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: 0 8px 40px rgba(79, 70, 229, 0.12);
}

.hot-card .hot-stats {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hot-card .hot-stats span { display: flex; align-items: center; gap: 4px; }

/* ---- Leaderboard ---- */
.leaderboard {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px;
  backdrop-filter: blur(12px);
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

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

.lb-rank {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  width: 32px;
  color: var(--text-muted);
}

.lb-rank.gold { color: var(--accent-gold); }
.lb-rank.silver { color: #C0C0C0; }
.lb-rank.bronze { color: #CD7F32; }

.lb-name { flex: 1; font-weight: 500; }
.lb-score { font-family: var(--font-mono); color: var(--accent-blue); font-weight: 600; }

.lb-myrank {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(108, 99, 255, 0.08);
  border: 1px solid rgba(108, 99, 255, 0.20);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
}

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

.cat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.cat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}

.cat-games {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cat-game {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.cat-game:hover { background: var(--bg-card-hover); }

.cat-game .stars { color: var(--accent-gold); font-size: 0.7rem; letter-spacing: 1px; }

/* ---- Tools Row ---- */
.tools-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

/* ---- Ad Card ---- */
.ad-card {
  background: var(--bg-glass);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.ad-card .ad-label {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ad-placeholder {
  width: 100%;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-shimmer {
  width: 100%;
  height: 90px;
  background: linear-gradient(90deg,
    var(--bg-card) 0%,
    var(--bg-card-hover) 50%,
    var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

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

/* ---- Game Page Specific ---- */
.game-container {
  max-width: 640px;
  margin: 40px auto;
  padding: 0 20px;
  text-align: center;
}

.game-area {
  background: #07070f;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 40px 20px;
  margin: 24px 0;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.game-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin: 16px 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.game-stats span { display: flex; align-items: center; gap: 6px; }
.game-stats .stat-value { color: var(--text-primary); font-family: var(--font-mono); font-weight: 600; }

/* ---- Progress Bar ---- */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-mint));
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ---- Result Page ---- */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 36px 24px;
  margin: 24px 0;
  text-align: center;
}

.result-score {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent-blue);
  margin: 8px 0;
}

.result-percentile {
  width: 120px;
  height: 120px;
  margin: 16px auto;
  position: relative;
}

.result-percentile svg { transform: rotate(-90deg); }
.result-percentile .circle-bg { fill: none; stroke: var(--bg-card); stroke-width: 8; }
.result-percentile .circle-fg {
  fill: none;
  stroke: var(--accent-blue);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  transition: stroke-dashoffset 1s ease;
}

.result-percentile .pct-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text-primary);
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 24px 0;
  flex-wrap: wrap;
}

/* ---- Confirm Dialog ---- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.dialog-overlay.active { opacity: 1; pointer-events: all; }

.dialog {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.dialog h3 { margin-bottom: 12px; font-family: var(--font-display); }
.dialog p { color: var(--text-secondary); margin-bottom: 24px; font-size: 0.9rem; }
.dialog-actions { display: flex; gap: 12px; justify-content: center; }

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 16px 0;
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb .sep { color: var(--text-muted); }

/* ---- Mobile ---- */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.8rem; }
  .hero .subtitle { font-size: 0.93rem; }
  .cat-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .nav { display: none; }
  .search-box { width: 140px; }
  .header-inner { gap: 12px; }
  .game-stats { gap: 16px; font-size: 0.8rem; flex-wrap: wrap; }
  .result-actions { flex-direction: column; }
  .btn-large { width: 100%; justify-content: center; }
  .breadcrumb { font-size: 0.75rem; gap: 4px; }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ---- 404 Page ---- */
.error-page {
  text-align: center;
  padding: 80px 20px;
}

.error-page h1 { font-size: 4rem; font-family: var(--font-display); color: var(--accent-blue); }
.error-page p { color: var(--text-secondary); margin: 16px 0 32px; }

/* ---- Category Landing Pages ---- */
.category-header {
  text-align: center;
  padding: 48px 20px 32px;
}

.category-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.category-header p {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 500px;
  margin: 0 auto;
}

/* ---- Cross-sell / Related Games ---- */
.related-section {
  margin-top: 32px;
  text-align: left;
}

.related-section h3 {
  font-family: var(--font-display);
  margin-bottom: 12px;
}
