/* ===== CSS Variables ===== */
:root {
  --bg-primary: #0d0d14;
  --bg-secondary: #14141f;
  --bg-card: #1c1c2e;
  --bg-card-hover: #252540;
  --bg-sidebar: #111118;
  --bg-header: #111118;
  --accent: #7c3aed;
  --accent-light: #9d6ff7;
  --accent-glow: rgba(124, 58, 237, 0.3);
  --text-primary: #ffffff;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --border: rgba(255, 255, 255, 0.08);
  --badge-top: #f59e0b;
  --badge-hot: #ef4444;
  --badge-new: #10b981;
  --badge-originals: #7c3aed;
  --badge-updated: #3b82f6;
  --sidebar-width: 220px;
  --header-height: 56px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

/* ===== Header ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition);
}

.menu-toggle:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.logo {
  display: flex;
  align-items: center;
}

.logo-icon {
  height: 28px;
  width: auto;
}

.search-bar {
  flex: 1;
  max-width: 480px;
  position: relative;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  height: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0 16px 0 42px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.header-right {
  flex-shrink: 0;
}

.btn-login {
  padding: 8px 20px;
  background: var(--accent);
  border-radius: 20px;
  font-weight: 700;
  font-size: 14px;
  transition: var(--transition);
}

.btn-login:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

/* ===== Layout ===== */
.layout {
  display: flex;
  padding-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-card) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--bg-card);
  border-radius: 4px;
}

.sidebar-nav {
  padding: 12px 8px 24px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent-light);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 8px;
}

.nav-section-title {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ===== Sidebar Bottom (Contact + Links) ===== */
.sidebar-bottom {
  margin-top: 24px;
  padding: 0 8px 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.btn-contact {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: var(--accent);
  border-radius: 24px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 16px;
  transition: var(--transition);
}

.btn-contact:hover {
  background: var(--accent-light);
}

.sidebar-footer-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-footer-links a {
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.sidebar-footer-links a:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.game-card {
  display: block;
  color: inherit;
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 24px 24px 48px;
  max-width: 100%;
}

/* ===== Game Section ===== */
.game-section {
  margin-bottom: 36px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}

.section-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-light);
  transition: var(--transition);
}

.section-link:hover {
  color: var(--text-primary);
}

/* ===== Game Row (Horizontal Scroll) ===== */
.game-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.game-row::-webkit-scrollbar {
  display: none;
}

.game-row-wrapper {
  position: relative;
}

.scroll-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  background: rgba(20, 20, 31, 0.9);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  z-index: 10;
  opacity: 0;
  transition: var(--transition);
  backdrop-filter: blur(8px);
}

.game-row-wrapper:hover .scroll-btn {
  opacity: 1;
}

.scroll-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.scroll-btn.left {
  left: -8px;
}

.scroll-btn.right {
  right: -8px;
}

/* ===== Game Card ===== */
.game-card {
  flex-shrink: 0;
  width: 160px;
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform var(--transition);
}

.game-card:hover {
  transform: translateY(-4px);
}

.game-card.featured {
  width: 280px;
}

.game-card.hero {
  width: 320px;
}

.game-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
}

.game-card.featured .game-thumb,
.game-card.hero .game-thumb {
  aspect-ratio: 16 / 9;
}

.game-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.game-card:hover .game-thumb img {
  transform: scale(1.05);
}

.game-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-top { background: var(--badge-top); color: #000; }
.badge-hot { background: var(--badge-hot); color: #fff; }
.badge-new { background: var(--badge-new); color: #fff; }
.badge-originals { background: var(--badge-originals); color: #fff; }
.badge-updated { background: var(--badge-updated); color: #fff; }

.game-plays {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.game-card:hover .game-plays {
  color: var(--accent-light);
}

.game-title {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Featured Grid ===== */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* ===== Leaderboard Banner ===== */
.leaderboard-banner {
  background: linear-gradient(135deg, #1a1040 0%, #2d1b69 50%, #1a1040 100%);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: var(--radius);
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 36px;
  position: relative;
  overflow: hidden;
}

.leaderboard-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.2) 0%, transparent 70%);
  pointer-events: none;
}

.leaderboard-info h3 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
}

.leaderboard-info p {
  color: var(--text-secondary);
  font-size: 14px;
}

.leaderboard-timer {
  text-align: center;
  flex-shrink: 0;
}

.timer-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.timer-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent-light);
}

.leaderboard-rank {
  text-align: center;
  flex-shrink: 0;
}

.rank-number {
  font-size: 32px;
  font-weight: 800;
  color: var(--badge-top);
}

.rank-label {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-compete {
  padding: 12px 28px;
  background: var(--accent);
  border-radius: 24px;
  font-weight: 700;
  font-size: 15px;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-compete:hover {
  background: var(--accent-light);
  transform: scale(1.03);
}

/* ===== SEO Content Section ===== */
.seo-section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.seo-section h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 16px;
}

.seo-section h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 24px 0 12px;
  color: var(--text-primary);
}

.seo-section p {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 15px;
  margin-bottom: 12px;
}

.seo-section ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.seo-section ul li a {
  padding: 6px 14px;
  background: var(--bg-card);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-light);
  transition: var(--transition);
}

.seo-section ul li a:hover {
  background: var(--accent);
  color: #fff;
}

/* Static site pages (Contact, About) */
.site-page {
  max-width: 720px;
  padding: 8px 0 48px;
}

.site-page-back {
  display: inline-block;
  margin-bottom: 24px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  transition: var(--transition);
}

.site-page-back:hover {
  color: var(--accent);
}

.site-page h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 12px;
}

.site-page-lead {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 28px;
}

.site-page-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
}

.site-page-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.site-page-card p {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 15px;
  margin-bottom: 12px;
}

.site-page-card p:last-child {
  margin-bottom: 0;
}

.site-page-email {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.site-page-email:hover {
  text-decoration: underline;
}

.site-page-muted {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.site-page-muted a {
  color: var(--accent);
  font-weight: 600;
}

.site-page-company {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ===== Footer ===== */
.footer {
  margin-left: var(--sidebar-width);
  padding: 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 16px;
}

.footer-links a {
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--text-primary);
}

.footer-copy {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 520px;
  width: 100%;
  position: relative;
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 24px;
  color: var(--text-muted);
  z-index: 1;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-content {
  padding: 24px;
}

.modal-game-img {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-sm);
  object-fit: cover;
  margin-bottom: 16px;
}

.modal-game-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-game-desc {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.btn-play {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 800;
  transition: var(--transition);
}

.btn-play:hover {
  background: var(--accent-light);
}

/* ===== Search Results ===== */
.search-results {
  margin-bottom: 36px;
}

.search-results .section-title {
  margin-bottom: 16px;
}

.no-results {
  color: var(--text-muted);
  font-size: 15px;
  padding: 24px 0;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .game-card {
    width: 140px;
  }
  .game-card.featured {
    width: 220px;
  }
  .game-card.hero {
    width: 260px;
  }
}

@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content,
  .footer {
    margin-left: 0;
  }

  .main-content {
    padding: 16px;
  }

  .search-bar {
    max-width: none;
  }

  .btn-login {
    display: none;
  }

  .leaderboard-banner {
    flex-direction: column;
    text-align: center;
    padding: 20px;
  }

  .scroll-btn {
    display: none;
  }

  .seo-section h1 {
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  .game-card {
    width: 120px;
  }
  .game-card.featured {
    width: 180px;
  }
  .game-card.hero {
    width: 200px;
  }
  .section-title {
    font-size: 17px;
  }
}
