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

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  /* Backgrounds - warm dark */
  --bg-primary: #13121E;
  --bg-warm: #18162A;
  --bg-card: #1F1D33;
  --bg-card-hover: #28254A;
  --bg-surface: #242240;

  /* Text */
  --text-primary: #FFF8F0;
  --text-soft: #B8B0D0;
  --text-muted: #7A7498;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.07);

  /* Brand */
  --brand-purple: #7C5CFC;

  /* CTA */
  --cta: #FFB800;
  --cta-hover: #FFC833;
  --cta-glow: rgba(255, 184, 0, 0.3);

  /* Accents */
  --accent-pink: #FF4D8B;
  --accent-orange: #FF6B35;
  --accent-gold: #FFB800;
  --accent-teal: #00D4AA;
  --accent-blue: #4D9EFF;
  --accent-purple: #9B6DFF;
  --accent-red: #FF4757;
  --accent-lime: #7BED5E;

  /* Transitions */
  --transition-fast: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 400ms cubic-bezier(0.22, 1, 0.36, 1);

  /* Shadows */
  --shadow-card: 0 4px 20px rgba(0,0,0,0.3);
  --shadow-card-hover: 0 8px 32px rgba(0,0,0,0.4);
  --radius-card: 16px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-xl: 24px;
}

[data-theme="light"] {
  --bg-primary: #F5F0EB;
  --bg-warm: #EDE7E0;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8F5F0;
  --bg-surface: #FAF7F3;
  --text-primary: #1A1A2E;
  --text-soft: #555555;
  --text-muted: #888888;
  --border-subtle: rgba(0, 0, 0, 0.08);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-base), color var(--transition-base);
}
img, canvas { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
a { color: inherit; text-decoration: none; }
input { font-family: inherit; }

/* ============================================================
   SKIP LINK (ACCESSIBILITY)
   ============================================================ */
.skip-link {
  position: absolute; top: -40px; left: 0; z-index: 9999;
  padding: 8px 16px; background: var(--cta); color: #000;
  font-weight: 700; border-radius: 0 0 8px 0;
  transition: top var(--transition-fast);
}
.skip-link:focus { top: 0; }

/* ============================================================
   CONTAINER
   ============================================================ */
.container {
  width: 100%; max-width: 1200px;
  margin: 0 auto; padding: 0 16px;
}
@media (min-width: 768px) { .container { padding: 0 24px; } }
@media (min-width: 1024px) { .container { padding: 0 32px; } }

/* ============================================================
   HEADER (STICKY, GLASS-MORPHISM)
   ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: 56px;
  background: rgba(19, 18, 30, 0.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  transition: all var(--transition-base);
}
[data-theme="light"] .site-header {
  background: rgba(245, 240, 235, 0.9);
}
.site-header .container {
  height: 100%; display: flex; align-items: center;
  gap: 12px; justify-content: space-between;
}
@media (min-width: 768px) { .site-header { height: 64px; } }

/* Logo */
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; flex-shrink: 0; }
.logo-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-gold));
  flex-shrink: 0;
}
.logo-text {
  font-size: 1.25rem; font-weight: 900; letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
@media (min-width: 768px) {
  .logo-icon { width: 36px; height: 36px; border-radius: 10px; font-size: 16px; }
  .logo-text { font-size: 1.5rem; }
}

/* Header search */
.header-search {
  flex: 1; max-width: 400px; display: none;
}
@media (min-width: 640px) { .header-search { display: flex; } }
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 12px; width: 100%;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border-subtle);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.search-wrap:focus-within {
  border-color: rgba(124, 92, 252, 0.4);
  background: rgba(255,255,255,0.08);
}
.search-wrap input {
  background: transparent; border: none; outline: none;
  color: var(--text-primary); font-size: 0.875rem; width: 100%;
}
.search-wrap input::placeholder { color: var(--text-muted); }
.search-wrap .search-icon { color: var(--text-muted); flex-shrink: 0; }
.search-clear {
  color: var(--text-muted); opacity: 0; pointer-events: none;
  transition: opacity var(--transition-fast); flex-shrink: 0;
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
}
.search-clear.visible { opacity: 1; pointer-events: auto; }

/* Header actions */
.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06); color: var(--text-soft);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}
@media (hover: hover) { .icon-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); } }
.random-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 10px; font-size: 0.8rem; font-weight: 700;
  color: var(--accent-teal);
  background: rgba(0, 212, 170, 0.12);
  border: 1px solid rgba(0, 212, 170, 0.25);
  transition: all var(--transition-fast);
}
@media (hover: hover) { .random-btn:hover { background: rgba(0, 212, 170, 0.2); } }
.random-btn .btn-label { display: none; }
@media (min-width: 480px) { .random-btn .btn-label { display: inline; } }

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero-section {
  padding: 24px 0 20px;
  position: relative; overflow: hidden;
}
.hero-glow {
  position: absolute; pointer-events: none; border-radius: 50%;
  filter: blur(80px); opacity: 0.12;
}
.hero-glow-1 {
  width: 60%; height: 300px; top: -50px; left: 20%;
  background: radial-gradient(ellipse, var(--accent-pink) 0%, transparent 70%);
}
.hero-glow-2 {
  width: 40%; height: 200px; top: 80px; right: 10%;
  background: radial-gradient(ellipse, var(--accent-gold) 0%, transparent 70%);
}
.hero-tagline h1 {
  font-size: clamp(1.5rem, 5vw, 3rem);
  font-weight: 900; line-height: 1.15; letter-spacing: -0.02em;
  color: var(--text-primary);
}
.hero-tagline .gradient-text {
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-pink), var(--accent-purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero-tagline p { margin-top: 8px; font-size: 0.9rem; color: var(--text-soft); }

/* Mobile search (below tagline) */
.mobile-search { display: flex; }
@media (min-width: 640px) { .mobile-search { display: none; } }

/* Hero card (Game of the Day) */
.hero-card {
  display: flex; flex-direction: column;
  border-radius: 20px; overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer; text-align: left; width: 100%;
  transition: transform var(--transition-spring), box-shadow var(--transition-spring);
}
@media (min-width: 640px) { .hero-card { flex-direction: row; border-radius: 24px; } }
@media (hover: hover) {
  .hero-card:hover { transform: scale(1.003); }
}
.hero-card:focus-visible { outline: 3px solid var(--cta); outline-offset: 3px; }

.hero-thumb {
  position: relative; width: 100%; overflow: hidden;
}
.hero-thumb { aspect-ratio: 16/9; }
@media (min-width: 640px) {
  .hero-thumb { width: 50%; min-height: 220px; aspect-ratio: auto; }
}
.hero-thumb canvas { width: 100%; height: 100%; object-fit: cover; }
.hero-thumb-overlay-desktop {
  position: absolute; inset: 0; display: none;
  background: linear-gradient(to right, transparent 40%, var(--bg-primary));
}
.hero-thumb-overlay-mobile {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 30%, var(--bg-primary));
}
@media (min-width: 640px) {
  .hero-thumb-overlay-desktop { display: block; }
  .hero-thumb-overlay-mobile { display: none; }
}
.hero-badge {
  position: absolute; top: 12px; left: 12px;
  padding: 6px 12px; border-radius: 100px;
  font-size: 0.7rem; font-weight: 900; letter-spacing: 0.08em;
  display: flex; align-items: center; gap: 6px;
  background: var(--cta); color: #000;
}
.hero-info {
  display: flex; flex-direction: column; justify-content: center;
  padding: 20px; flex: 1; position: relative;
}
@media (min-width: 640px) { .hero-info { padding: 28px; } }
.hero-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.hero-tag {
  padding: 3px 8px; border-radius: 6px;
  font-size: 0.7rem; font-weight: 700;
}
.hero-title {
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 900; line-height: 1.2; color: var(--text-primary);
}
.hero-desc {
  margin-top: 8px; font-size: 0.875rem; line-height: 1.6;
  color: var(--text-soft);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-cta-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.play-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 14px;
  font-size: 0.875rem; font-weight: 700;
  background: var(--cta); color: #000;
  transition: all var(--transition-fast);
}
@media (hover: hover) {
  .play-btn:hover {
    background: var(--cta-hover);
    box-shadow: 0 6px 20px var(--cta-glow);
    transform: translateX(2px);
  }
}
.play-count { font-size: 0.75rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

/* ============================================================
   STATS BAR
   ============================================================ */
.stats-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.stat-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border-subtle);
}
.stat-pill .stat-num { font-size: 0.8rem; font-weight: 700; color: var(--text-primary); }
.stat-pill .stat-label { font-size: 0.75rem; color: var(--text-muted); }
.streak-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 10px;
  background: rgba(255, 184, 0, 0.12);
  border: 1px solid rgba(255, 184, 0, 0.25);
}
.streak-pill .streak-text { font-size: 0.75rem; font-weight: 700; color: var(--accent-gold); }

/* ============================================================
   TAG FILTER
   ============================================================ */
.tag-bar {
  display: flex; gap: 8px;
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.tag-bar::-webkit-scrollbar { display: none; }
.tag-pill {
  padding: 8px 14px; border-radius: 12px;
  font-size: 0.8rem; font-weight: 700;
  white-space: nowrap; flex-shrink: 0;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-subtle);
  background: rgba(255,255,255,0.05); color: var(--text-muted);
}
.tag-pill.active {
  background: var(--cta); color: #000; border-color: transparent;
}
@media (hover: hover) {
  .tag-pill:not(.active):hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }
}
.tag-pill:focus-visible { outline: 2px solid var(--cta); outline-offset: 2px; }

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-title {
  font-size: 0.875rem; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
@media (min-width: 768px) { .section-title { font-size: 1rem; } }

/* ============================================================
   GAME GRID
   ============================================================ */
.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 768px) { .game-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1024px) { .game-grid { grid-template-columns: repeat(4, 1fr); } }

/* Empty state */
.empty-state {
  grid-column: 1 / -1; text-align: center; padding: 64px 16px;
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.empty-state .reset-btn {
  margin-top: 12px; padding: 8px 20px; border-radius: 12px;
  font-size: 0.8rem; font-weight: 700; background: var(--cta); color: #000;
  transition: background var(--transition-fast);
}

/* ============================================================
   GAME CARDS
   ============================================================ */
.game-card {
  border-radius: var(--radius-card);
  overflow: hidden; cursor: pointer; text-align: left; width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-spring);
  will-change: transform;
}
@media (hover: hover) {
  .game-card:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: transparent;
  }
}
.game-card:focus-visible { outline: 3px solid var(--cta); outline-offset: 2px; }
.game-card.small { border-radius: 12px; }

/* Card thumbnail area */
.card-thumb {
  position: relative; overflow: hidden;
  aspect-ratio: 16/9;
}
.game-card.small .card-thumb { aspect-ratio: 1/1; }
.card-thumb canvas { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Gradient bottom fade */
.card-thumb-fade {
  position: absolute; bottom: 0; left: 0; right: 0; height: 48px;
  background: linear-gradient(transparent, var(--bg-card));
}

/* Play overlay on hover */
.card-play-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  transition: background var(--transition-fast);
}
@media (hover: hover) { .game-card:hover .card-play-overlay { background: rgba(0,0,0,0.4); } }
.card-play-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: white; display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(0.5);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.game-card.small .card-play-btn { width: 36px; height: 36px; }
@media (hover: hover) {
  .game-card:hover .card-play-btn { opacity: 1; transform: scale(1); }
}

/* Badges */
.card-badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 4px; }
.badge {
  padding: 3px 7px; border-radius: 100px;
  font-size: 0.6rem; font-weight: 900; letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 3px;
}
.badge-new { background: var(--brand-purple); color: #fff; }
.badge-hot { background: var(--accent-pink); color: #fff; }
.badge-2p {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.55); color: #fff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}

/* Card body */
.card-body { padding: 12px; }
.game-card.small .card-body { padding: 8px 10px; }
.card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.card-title { font-size: 0.875rem; font-weight: 700; line-height: 1.3; color: var(--text-primary); }
.game-card.small .card-title { font-size: 0.75rem; }
.card-icon { font-size: 1rem; flex-shrink: 0; }
.card-desc {
  font-size: 0.75rem; color: var(--text-soft); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 8px;
}
.card-footer { display: flex; align-items: center; justify-content: space-between; }
.card-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.card-tag {
  padding: 2px 6px; border-radius: 4px;
  font-size: 0.65rem; font-weight: 700;
}
.card-plays { font-size: 0.7rem; color: var(--text-muted); display: flex; align-items: center; gap: 3px; }

/* ============================================================
   RECENTLY PLAYED
   ============================================================ */
.recent-scroll {
  display: flex; gap: 10px;
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.recent-scroll::-webkit-scrollbar { display: none; }
.recent-item { flex-shrink: 0; width: 128px; }
@media (min-width: 640px) { .recent-item { width: 144px; } }

/* ============================================================
   COMING SOON
   ============================================================ */
.coming-grid {
  display: grid; grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 640px) { .coming-grid { grid-template-columns: repeat(3, 1fr); } }
.coming-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: 14px;
}
.coming-icon-wrap {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; flex-shrink: 0;
}
.coming-title { font-size: 0.875rem; font-weight: 700; color: var(--text-primary); }
.coming-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   GAME VIEW
   ============================================================ */
.game-view { min-height: 100vh; background: var(--bg-primary); }
.game-view-header {
  position: sticky; top: 0; z-index: 100;
  height: 52px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  background: rgba(19, 18, 30, 0.9);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}
[data-theme="light"] .game-view-header { background: rgba(245, 240, 235, 0.92); }
.back-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06); color: var(--text-primary);
  flex-shrink: 0; transition: all var(--transition-fast);
}
@media (hover: hover) { .back-btn:hover { background: rgba(255,255,255,0.12); } }
.back-btn:focus-visible { outline: 2px solid var(--cta); }
.game-view-title {
  font-size: 0.9rem; font-weight: 700; color: var(--text-primary);
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tab-group {
  display: flex; gap: 2px; padding: 3px;
  border-radius: 10px; background: rgba(255,255,255,0.06); flex-shrink: 0;
}
.tab-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 8px;
  font-size: 0.75rem; font-weight: 700;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}
.tab-btn.active { color: #fff; }
.tab-btn:focus-visible { outline: 2px solid var(--cta); }

.game-view-content {
  max-width: 1200px; margin: 0 auto; padding: 16px;
  display: flex; flex-direction: column; gap: 20px;
}
@media (min-width: 1024px) {
  .game-view-content { flex-direction: row; align-items: flex-start; padding: 24px 32px; }
}

/* Game area (iframe + meta) */
.game-area { flex: 1; min-width: 0; }
.iframe-wrap {
  position: relative; width: 100%;
  border-radius: 20px; overflow: hidden;
  aspect-ratio: 16/10;
  border: 2px solid transparent;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.iframe-wrap iframe {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: none; display: block;
}
/* Placeholder when iframe not loaded */
.iframe-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(135deg, #7C5CFC, #C9A0FF);
}
.iframe-play-icon {
  width: 72px; height: 72px; border-radius: 20px;
  background: rgba(255,255,255,0.15); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
}
.iframe-placeholder p { color: rgba(255,255,255,0.8); font-size: 0.875rem; font-weight: 700; }

.game-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.game-meta-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.04);
  font-size: 0.75rem; color: var(--text-primary);
}

/* Score form */
.score-form-section { margin-top: 20px; }
.score-form {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px; border-radius: 16px;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
}
.score-form h3 { font-size: 0.875rem; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.score-form-fields { display: flex; gap: 8px; flex-wrap: wrap; }
.score-input {
  flex: 1; min-width: 100px;
  padding: 8px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border-subtle);
  color: var(--text-primary); font-size: 0.875rem; outline: none;
  transition: border-color var(--transition-fast);
}
.score-input:focus { border-color: rgba(124,92,252,0.5); }
.score-submit-btn {
  padding: 8px 18px; border-radius: 10px;
  background: var(--cta); color: #000; font-size: 0.875rem; font-weight: 700;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
@media (hover: hover) {
  .score-submit-btn:hover { background: var(--cta-hover); box-shadow: 0 4px 12px var(--cta-glow); }
}

/* Similar games */
.similar-games { margin-top: 24px; }
.similar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* Leaderboard panel */
.lb-panel {
  width: 100%;
  border-radius: 20px; overflow: hidden;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
}
@media (min-width: 1024px) { .lb-panel { width: 320px; flex-shrink: 0; } }
@media (min-width: 1280px) { .lb-panel { width: 380px; } }
.lb-panel.mobile-hidden { display: none; }
@media (min-width: 1024px) { .lb-panel.mobile-hidden { display: block; } }

.lb-header {
  padding: 16px 20px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.lb-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.lb-header-text h3 { font-size: 0.875rem; font-weight: 700; color: var(--text-primary); }
.lb-header-text p { font-size: 0.75rem; color: var(--text-muted); }
.lb-list { }
.lb-entry {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.025);
  animation: fadeSlideIn var(--transition-base) backwards;
}
.lb-entry:last-child { border-bottom: none; }
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}
.lb-rank {
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; flex-shrink: 0;
}
.lb-name { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-size: 0.8rem; font-weight: 700; font-family: monospace; flex-shrink: 0; }
.lb-empty { padding: 32px; text-align: center; font-size: 0.8rem; color: var(--text-muted); }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%);
  z-index: 9998; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: 12px;
  font-size: 0.8rem; font-weight: 700;
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: toastIn 300ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  white-space: nowrap;
}
.toast.success { background: rgba(0, 212, 170, 0.15); border-color: rgba(0, 212, 170, 0.3); color: var(--accent-teal); }
.toast.error { background: rgba(255, 71, 87, 0.15); border-color: rgba(255, 71, 87, 0.3); color: var(--accent-red); }
.toast.out { animation: toastOut 300ms ease forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-12px); }
}

/* ============================================================
   PAGE TRANSITIONS
   ============================================================ */
.view-enter { animation: viewEnter 300ms ease forwards; }
.view-exit { animation: viewExit 300ms ease forwards; }
@keyframes viewEnter {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes viewExit {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-16px); }
}

/* ============================================================
   SECTION SPACING
   ============================================================ */
.section { padding-bottom: 28px; }
@media (min-width: 768px) { .section { padding-bottom: 40px; } }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  padding: 20px 0;
  border-top: 1px solid var(--border-subtle);
}
.site-footer .container {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; text-align: center;
}
@media (min-width: 640px) {
  .site-footer .container { flex-direction: row; justify-content: space-between; text-align: left; }
}
.footer-brand {
  font-size: 0.875rem; font-weight: 900;
  display: flex; align-items: center; gap: 6px;
}
.footer-brand .footer-logo-text {
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.footer-brand .footer-year { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.footer-tagline { font-size: 0.75rem; color: var(--text-muted); }
.footer-links { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.footer-links a {
  font-size: 0.75rem; color: var(--text-muted);
  transition: color var(--transition-fast);
}
@media (hover: hover) { .footer-links a:hover { color: var(--text-primary); } }
.footer-coming { font-size: 0.7rem; color: var(--text-muted); }
.footer-coming span { color: var(--cta); font-weight: 600; }

/* ============================================================
   FOCUS VISIBLE (GLOBAL)
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--cta);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Remove focus ring from non-keyboard interactions */
:focus:not(:focus-visible) { outline: none; }

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.hidden { display: none !important; }
.text-gold { color: var(--accent-gold); }
.text-muted { color: var(--text-muted); }

/* ============================================================
   SCROLLBAR (DESKTOP)
   ============================================================ */
@media (min-width: 1024px) {
  ::-webkit-scrollbar { width: 8px; }
  ::-webkit-scrollbar-track { background: var(--bg-warm); }
  ::-webkit-scrollbar-thumb { background: var(--bg-surface); border-radius: 4px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
}

/* ============================================================
   COUNTER ANIMATION STATE
   ============================================================ */
.stat-num[data-counting] { transition: none; }

/* ============================================================
   CINEMA GAME VIEW — full-height layout
   ============================================================ */

/* Cinema stage: fills all height between header and bottom of viewport */
.cinema-stage {
  width: 100%;
  height: calc(100svh - 52px);
  background: #0a0910;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* The iframe box: sized to fill the stage preserving 16:9 aspect ratio */
.cinema-iframe-box {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.cinema-iframe-box iframe {
  display: block;
  border: none;
  background: #000;
  /* Fill as much as possible while keeping 16:9 */
  width: 100%;
  height: 100%;
  /* Let the game scale inside */
}

/* Fullscreen: iframe gets border glow from game color */
:fullscreen .cinema-iframe-box,
:-webkit-full-screen .cinema-iframe-box {
  background: #000;
}
:fullscreen .cinema-iframe-box iframe,
:-webkit-full-screen .cinema-iframe-box iframe {
  width: 100vw;
  height: 100vh;
}

/* Below-game panel */
.below-game-panel {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}
@media (min-width: 768px) {
  .below-game-panel { padding: 28px 24px 48px; }
}
@media (min-width: 1024px) {
  .below-game-panel { padding: 32px 32px 56px; }
}

/* 2-column grid for score + leaderboard on desktop */
.below-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 768px) {
  .below-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

/* Leaderboard inside below-panel — not a sidebar, full-width card */
.below-game-panel .lb-panel {
  width: 100%;
}

/* Panel handle (decorative, touch hint on mobile) */
.below-panel-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-subtle);
  margin: 0 auto 20px;
  display: block;
}
@media (min-width: 768px) {
  .below-panel-handle { display: none; }
}

/* Fullscreen button in header */
#fullscreen-btn {
  flex-shrink: 0;
}

/* Leaderboard toggle btn label visible on wider screens */
@media (min-width: 480px) {
  .lb-btn-label { display: inline !important; }
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: 32px 0 20px;
  margin-top: 40px;
}
.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.footer-logo {
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.footer-tagline {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 6px;
  max-width: 260px;
}
.footer-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}
.footer-links a:hover { color: var(--accent-purple); }
.footer-bottom {
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
}
