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

:root {
  --accent: #4A90D9;
  --text: #1a1a1a;
  --muted: #555;
  --border: #ddd;
  --bg: #fff;
  --bg-alt: #f7f7f7;
  --radius: 6px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #7ab6ff;
  --text: #e8eefc;
  --muted: #b8c4e6;
  --border: rgba(255, 255, 255, 0.14);
  --bg: #0b1220;
  --bg-alt: #111a2e;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Nav */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
nav:has(.search-bar) {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 720px) 1fr;
  align-items: center;
  gap: 16px;
}
nav:has(.search-bar) .site-name-wrap { justify-self: start; }
nav:has(.search-bar) .search-bar { width: 100%; box-sizing: border-box; }
nav:has(.search-bar) .nav-end { justify-self: end; display: flex; align-items: center; gap: 12px; }
nav .site-name-wrap { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
nav .site-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  text-decoration: underline;
}
nav .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
}
nav .theme-toggle:hover { background: var(--bg); }
nav .theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
nav .theme-toggle .icon { line-height: 1; font-size: 16px; }
nav .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] nav .theme-toggle .icon-sun { display: inline; }
:root[data-theme="dark"] nav .theme-toggle .icon-moon { display: none; }
nav .nav-links { display: flex; gap: 20px; white-space: nowrap; }
nav .nav-links a { color: var(--muted); font-size: 0.95rem; }
nav .nav-links a:hover { color: var(--accent); }

/* Game page nav: centered title */
nav:has(.nav-center) {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
nav:has(.nav-center) .site-name-wrap { justify-self: start; }
nav:has(.nav-center) .nav-center { justify-self: center; }
nav:has(.nav-center) .nav-end { justify-self: end; display: flex; align-items: center; gap: 12px; }
nav .nav-center .game-title {
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
  margin: 0;
}

/* Search — lives inside nav */
nav .search-bar {
  flex: 1;
  width: 100%;
  max-width: 720px;
  min-width: 0;
  padding: 8px 12px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  background: var(--bg-alt);
}
nav .search-bar:focus { border-color: var(--accent); background: var(--bg); }

/* Tap to Hide — key graphic + label in nav */
nav .tap-to-hide {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  margin-left: auto;
}
nav .tap-to-hide:hover { color: var(--accent); text-decoration: none; }
nav .nav-privacy { color: var(--muted); font-size: 0.95rem; white-space: nowrap; }
nav .nav-privacy:hover { color: var(--accent); }

/* Home intro text */
.home-intro {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 40px;
  margin-bottom: 40px;
  width: 100%;
  text-align: center;
}

/* Home promo banner */
.promo-banner {
  display: block;
  width: 100%;
  margin-top: 22px;
  margin-bottom: 18px;
  padding: 22px 20px;
  text-align: center;
  font-size: clamp(1.15rem, 2.2vw, 1.85rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: #ffffff;
  border-radius: 14px;
  background: linear-gradient(135deg, #6f39d8, #9d62ff);
  box-shadow: 0 14px 26px rgba(111, 57, 216, 0.36);
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.promo-banner:hover,
.promo-banner:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow: 0 18px 32px rgba(111, 57, 216, 0.45);
  text-decoration: none;
}

:root[data-theme="dark"] .promo-banner {
  box-shadow: 0 14px 28px rgba(157, 98, 255, 0.42);
}
nav .key-cap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 32px;
  padding: 2px 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  line-height: 1.1;
  color: var(--text);
}
nav .key-cap .key-key { display: block; }
nav .tap-to-hide-label { font-size: 0.85rem; }

/* Category filters */
.filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}
.filters-row {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 4px;
  min-height: 36px;
}
.filters-row::-webkit-scrollbar {
  height: 6px;
}
.filters-row::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.filters button {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.filters button:hover,
.filters button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Game grid — 10 columns on laptop/desktop; 2x2 positions set in JS */
.game-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  margin-bottom: 40px;
}

.game-card {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  line-height: 0;
  opacity: 0.92;
}
.game-card:hover { opacity: 1; text-decoration: none; }

/* 2x2 featured tiles — scattered in grid */
.game-card--featured {
  grid-column: span 2;
  grid-row: span 2;
}

.game-card img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  display: block;
  background: var(--bg-alt);
}

.game-card--featured img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
}

/* No results */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* Game page layout */
.game-page {
  padding: 16px 20px 40px;
}


/* Three-column main: rail | center | rail */
.game-main {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.game-center {
  flex: 1;
  min-width: 0;
}

/* Ad slots */
.ad-slot {
  background: transparent;
  /* background: var(--bg-alt);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.75rem;
  flex-shrink: 0; */
}
/* .ad-slot::after { content: 'Ad'; } */

.ad-rail {
  width: 160px;
  height: 600px;
}
.ad-leaderboard {
  width: 100%;
  height: 90px;
  margin-top: 16px;
  margin-bottom: 16px;
}

/* Iframe */
.game-iframe-wrap {
  position: relative;
  width: 100%;
  height: 600px;
  margin-bottom: 0;
}
.game-loading-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  color: var(--muted);
  font-size: 1rem;
  text-align: center;
  padding: 24px;
  z-index: 1;
}
.game-iframe {
  width: 100%;
  height: 600px;
  border: none;
  display: block;
  margin-bottom: 0;
}

/* How to play */
.game-howtoplay {
  margin-top: 8px;
  max-width: 100%;
}
.game-howtoplay h2 {
  font-size: 1rem;
  margin-bottom: 6px;
}
.game-howtoplay p { color: var(--muted); font-size: 0.9rem; }

/* Content pages */
.page-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}
.page-content h1 {
  font-size: 1.75rem;
  margin-bottom: 24px;
}
.page-content h2 {
  font-size: 1.25rem;
  margin-top: 32px;
  margin-bottom: 12px;
}
.page-content p {
  margin-bottom: 12px;
  color: var(--muted);
}
.page-content ul {
  margin: 0 0 12px 24px;
  color: var(--muted);
}
.page-content ul li { margin-bottom: 6px; }
.page-content a { color: var(--accent); }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}
footer a { margin: 0 10px; }

/* Filters top padding */
.filters { padding-top: 20px; }

/* Responsive: clear explicit placement so grid reflows; dense avoids gaps */
@media (max-width: 1100px) {
  .game-grid { grid-template-columns: repeat(6, 1fr); grid-auto-flow: dense; }
  .game-grid .game-card { grid-column: auto; grid-row: auto; }
  .game-card--featured { grid-column: span 2; grid-row: span 2; }
}
@media (max-width: 800px) {
  .game-grid { grid-template-columns: repeat(4, 1fr); grid-auto-flow: dense; }
  .game-grid .game-card { grid-column: auto; grid-row: auto; }
  .game-card--featured { grid-column: span 2; grid-row: span 2; }
  .ad-rail { display: none; }
  .ad-leaderboard { height: 60px; }
}
@media (max-width: 500px) {
  .game-grid { grid-template-columns: repeat(2, 1fr); grid-auto-flow: dense; }
  .game-grid .game-card { grid-column: auto; grid-row: auto; }
  .game-card--featured { grid-column: span 1; grid-row: span 1; }
  .game-iframe-wrap,
  .game-iframe { height: 350px; }
  nav { flex-wrap: wrap; }
  nav:has(.search-bar) { display: flex; grid-template-columns: none; }
  nav:has(.search-bar) .site-name { justify-self: auto; }
  nav:has(.search-bar) .nav-end { justify-self: auto; }
  nav .search-bar { order: 3; flex-basis: 100%; max-width: none; justify-self: auto; }
  .game-title-row { flex-wrap: wrap; }
  .ad-leaderboard { display: none; }
}
