:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --text: #1c2624;
  --text-muted: #5b6b67;
  --border: #e2e8e6;
  --brand: #2f8f7a;
  --brand-dark: #1f6b5a;
  --accent: #f4b942;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 40, 35, 0.08), 0 1px 2px rgba(20, 40, 35, 0.06);
  --max-width: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101614;
    --surface: #182220;
    --text: #e9efed;
    --text-muted: #9db0ab;
    --border: #2a3835;
    --brand: #4dbba1;
    --brand-dark: #6ccdb6;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
img { max-width: 100%; display: block; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
p { margin: 0 0 1em; }

.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; gap: 20px; padding: 14px 20px; }
.logo { font-weight: 800; font-size: 1.3rem; color: var(--brand-dark); }
.main-nav { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.main-nav a { color: var(--text); font-weight: 600; font-size: 0.95rem; }
.main-nav a:hover { color: var(--brand-dark); text-decoration: none; }
.header-search { display: flex; gap: 6px; }
.header-search input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); min-width: 160px; }
.header-search button { border: none; background: var(--brand); color: #fff; border-radius: 6px; padding: 8px 12px; cursor: pointer; }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--text); margin: 4px 0; }

@media (max-width: 780px) {
  .header-inner { flex-wrap: wrap; }
  .nav-toggle { display: block; order: 2; margin-left: auto; }
  .main-nav { display: none; width: 100%; order: 4; flex-direction: column; gap: 4px; }
  .main-nav.open { display: flex; }
  .header-search { order: 3; }
}

/* Hero */
.hero { background: linear-gradient(180deg, var(--surface), var(--bg)); padding: 48px 0 36px; text-align: center; border-bottom: 1px solid var(--border); }
.hero h1 { font-size: 2rem; margin-bottom: 0.3em; }
.hero-tagline { color: var(--text-muted); max-width: 640px; margin: 0 auto 1.4em; }
.hero-search { display: flex; justify-content: center; gap: 8px; margin-bottom: 1.4em; }
.hero-search input { padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; width: min(420px, 80vw); background: var(--surface); color: var(--text); }
.hero-search button { border: none; background: var(--brand); color: #fff; border-radius: 8px; padding: 12px 20px; cursor: pointer; font-weight: 600; }
.hero-categories { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.hero-category-link { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 0.9rem; font-weight: 600; color: var(--text); }
.hero-category-link:hover { border-color: var(--brand); text-decoration: none; }

/* Sections */
.game-section { padding: 32px 0; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.section-link { font-size: 0.9rem; font-weight: 600; white-space: nowrap; }
.page-header { padding: 32px 0 8px; }
.page-intro { color: var(--text-muted); max-width: 760px; }

/* Game grid + cards */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.game-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.game-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(20,40,35,0.12); }
.game-card-link { color: inherit; display: block; }
.game-card-link:hover { text-decoration: none; }
.game-card-thumb { position: relative; aspect-ratio: 4 / 3; background: var(--bg); }
.game-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.game-card-thumb-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; font-weight: 700; color: var(--text-muted); background: var(--bg); }
.game-card-badge { position: absolute; top: 8px; right: 8px; background: rgba(20,30,28,0.75); color: #fff; font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.game-card-body { padding: 12px 14px 14px; }
.game-card-title { font-size: 1rem; margin: 0 0 4px; }
.game-card-category { display: inline-block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--brand-dark); margin-bottom: 6px; }
.game-card-rating { display: flex; align-items: center; gap: 2px; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
.game-card-rating .star { color: var(--accent); }
.game-card-rating .star:not(.filled) { color: var(--border); }
.game-card-rating-value { margin-left: 4px; }
.game-card-desc { font-size: 0.85rem; color: var(--text-muted); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Controls: sort/filter */
.category-controls { display: flex; flex-wrap: wrap; gap: 18px; padding: 8px 0 20px; align-items: center; }
.control-label { font-weight: 700; margin-right: 6px; }
.sort-links, .filter-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sort-link { padding: 5px 10px; border-radius: 6px; font-size: 0.88rem; }
.sort-link.active { background: var(--brand); color: #fff; font-weight: 700; }
.filter-chip { padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.85rem; color: var(--text); }
.filter-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.filter-chip:hover { text-decoration: none; border-color: var(--brand); }

.empty-state { color: var(--text-muted); padding: 40px 0; text-align: center; }

/* Pagination */
.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin: 28px 0; }
.page-link { padding: 7px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; color: var(--text); }
.page-link.current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.page-link:hover { border-color: var(--brand); text-decoration: none; }

/* Related categories */
.related-categories { padding: 12px 0 40px; }
.related-category-links { display: flex; flex-wrap: wrap; gap: 8px; }
.related-category-links a { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 0.88rem; }

/* Game detail page */
.game-page { padding: 24px 0 8px; }
.breadcrumbs { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }
.breadcrumbs a { color: var(--text-muted); }
.game-embed-wrap { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; margin: 14px 0; position: relative; }
.game-embed-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
/* CSS-only fullscreen fallback for browsers with no Fullscreen API on iframes (iOS Safari) */
.game-embed-wrap.fake-fullscreen { position: fixed; inset: 0; z-index: 1000; aspect-ratio: unset; border-radius: 0; margin: 0; width: 100vw; height: 100vh; }
body.fake-fullscreen-active { overflow: hidden; }
.game-poster { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #000; }
.game-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.play-button { position: relative; border: none; background: var(--brand); color: #fff; font-size: 1.1rem; font-weight: 700; padding: 16px 32px; border-radius: 999px; cursor: pointer; box-shadow: 0 4px 18px rgba(0,0,0,0.35); }
.play-button:hover { background: var(--brand-dark); }
.game-embed-actions { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.btn-secondary { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.btn-secondary:hover { border-color: var(--brand); text-decoration: none; }
.btn-primary { border: none; background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 8px; font-weight: 700; cursor: pointer; display: inline-block; }
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.game-short-desc { font-size: 1.05rem; color: var(--text-muted); }
.game-meta-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.game-rating { display: flex; align-items: center; gap: 6px; }
.stars-static .star { color: var(--accent); font-size: 1.1rem; }
.stars-static .star:not(.filled) { color: var(--border); }
.rating-count { color: var(--text-muted); font-size: 0.9rem; }
.game-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 0.8rem; }

.rate-widget { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 24px; flex-wrap: wrap; }
.rate-stars { display: flex; gap: 2px; }
.rate-star { background: none; border: none; font-size: 1.4rem; color: var(--border); cursor: pointer; padding: 0 2px; line-height: 1; }
.rate-star:hover, .rate-star.hovered { color: var(--accent); }
.rate-star.selected { color: var(--accent); }
.rate-thanks { color: var(--brand-dark); font-weight: 600; font-size: 0.9rem; }

.game-content { margin: 20px 0; }
.game-content-block { margin-bottom: 24px; }
.screenshot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.screenshot-grid img { border-radius: 8px; border: 1px solid var(--border); }

/* Search */
.page-search-form { display: flex; gap: 8px; margin-top: 10px; max-width: 480px; }
.page-search-form input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.page-search-form button { border: none; background: var(--brand); color: #fff; border-radius: 8px; padding: 10px 18px; cursor: pointer; font-weight: 600; }
.search-summary { color: var(--text-muted); margin-bottom: 16px; }

/* Static pages */
.static-page { padding: 32px 0 60px; max-width: 720px; }
.static-page h2 { margin-top: 1.6em; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; background: var(--surface); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; padding: 32px 20px 12px; }
.footer-brand .logo { font-weight: 800; font-size: 1.1rem; color: var(--brand-dark); }
.footer-brand p { color: var(--text-muted); max-width: 320px; margin-top: 6px; }
.footer-links { display: flex; flex-direction: column; gap: 8px; }
.footer-links a { color: var(--text-muted); font-size: 0.9rem; }
.footer-copy { text-align: center; color: var(--text-muted); font-size: 0.8rem; padding: 10px 0 24px; }

@media (max-width: 600px) {
  .hero h1 { font-size: 1.6rem; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}
