/* Pixelsprout — design system, built from the logo
   Space navy:     #0B0E1A
   Sprout green:   #7ED957
   Star gold:      #F5B942
   Heart pink:     #FF6B9D
   Sky blue:       #4FC3F7
   Paper (text):   #EAF2FF
*/

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --ink: #0B0E1A;
  --panel: #141A2E;
  --panel-2: #1C2540;
  --paper: #EAF2FF;
  --muted: #8A93B8;
  --gold: #F5B942;
  --signal: #FF6B9D;
  --teal: #7ED957;
  --blue: #4FC3F7;
  --border: #263156;

  --soil: var(--ink);
  --soil-2: var(--panel);
  --sprout: var(--teal);
  --sprout-lt: #9BE87A;
  --amber: var(--gold);
  --rust: var(--signal);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  background-image: radial-gradient(circle at 15% 0%, #16204a 0%, transparent 45%),
                     radial-gradient(circle at 90% 15%, #1a1440 0%, transparent 40%);
  color: var(--paper);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

a { color: inherit; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

.pixel { font-family: 'Press Start 2P', 'IBM Plex Mono', monospace; }

/* ---------- Sidebar layout ---------- */

.layout {
  max-width: 1280px;
  margin: 0 auto;
}

.layout-main {
  width: 100%;
}

.sidebar-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--paper);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  font-size: 17px;
  cursor: pointer;
  z-index: 150;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.sidebar-toggle:hover { border-color: var(--teal); color: var(--teal); }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 220px;
  background: var(--ink);
  border-right: 1px solid var(--border);
  padding: 70px 12px 16px;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  z-index: 100;
  overflow-y: auto;
}

.sidebar.open { transform: translateX(0); }

.sidebar-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-left: 10px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: block;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-link:hover { background: var(--panel); color: var(--paper); }

.sidebar-link.active {
  background: var(--panel-2);
  color: var(--teal);
  font-weight: 600;
}

/* ---------- Ad slots on game pages (banner above, ribbon below) ---------- */

.ad-slot {
  width: 100%;
  max-width: 480px;
  margin: 4px 0 8px;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-slot-banner { margin-top: 8px; }
.ad-slot-ribbon { margin-top: 4px; }

/* ---------- Similar games recommendations (per game page) ---------- */

.similar-games {
  width: 100%;
  max-width: 480px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.similar-games-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--paper);
  margin: 0 0 10px;
}

.similar-games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

.similar-card {
  text-decoration: none;
  color: var(--paper);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.similar-card:hover { transform: translateY(-2px); border-color: var(--teal); }

.similar-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.similar-card span {
  font-size: 10.5px;
  padding: 5px 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Hero "trending" pop-in widget ---------- */

.hero-trending {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin: 4px 0 8px;
}

.hero-trending-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
  text-decoration: none;
  color: var(--paper);
  font-size: 12.5px;
  opacity: 0;
  animation: pop-in 0.4s ease forwards;
}

.hero-trending-card:hover { border-color: var(--teal); background: var(--panel-2); }
.hero-trending-card img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.8) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 16px 68px;
  max-width: 1280px;
  margin: 0 auto;
  flex-wrap: wrap;
  gap: 10px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--paper);
}

.logo-mark {
  width: 36px;
  height: 36px;
  object-fit: contain;
  image-rendering: pixelated;
}

.logo-word {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  line-height: 1;
}

.logo-word .sprout-part { color: var(--teal); }

.tagline {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--blue);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Hero ---------- */

.hero { padding: 20px 20px 0; }

.hero-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.hero-text { flex: 1; min-width: 260px; }

.hero-logo {
  width: 160px;
  max-width: 35vw;
  image-rendering: pixelated;
}

.hero h1 {
  font-family: 'Press Start 2P', monospace;
  font-weight: 400;
  font-size: clamp(15px, 3vw, 24px);
  line-height: 1.7;
  margin: 0 0 14px;
  max-width: 620px;
}

.hero h1 .accent { color: var(--teal); }

.hero p {
  max-width: 540px;
  color: var(--muted);
  font-size: 15px;
  margin: 0 0 18px;
}

.hero-stats {
  display: flex;
  gap: 24px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.hero-stats strong {
  color: var(--paper);
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  display: block;
  margin-bottom: 3px;
}

.hero-stats div { display: flex; flex-direction: column; }
.hero-stats strong::after { content: ' '; }

/* ---------- Marquee ticker ---------- */

.marquee {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
  white-space: nowrap;
  margin-bottom: 8px;
  margin-top: 16px;
}

.marquee-track {
  display: inline-flex;
  animation: scroll-marquee 40s linear infinite;
  padding: 10px 0;
}

.marquee-track span {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--gold);
  padding: 0 22px;
  text-transform: uppercase;
}

.marquee-track span::after {
  content: '★';
  color: var(--muted);
  margin-left: 22px;
  font-size: 9px;
}

@keyframes scroll-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ---------- Search ---------- */

.search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 24px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  background: transparent;
  z-index: 20;
  padding: 12px 0;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #6B7280;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  background: var(--paper);
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 10px 14px 10px 38px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

.search-box input::placeholder { color: #6B7280; }
.search-box input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(126,217,87,0.25); }

/* Dim the page behind the sidebar when it's open */
body.sidebar-open-backdrop::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

.result-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.no-results {
  color: var(--muted);
  font-size: 14px;
  padding: 30px 0;
  text-align: center;
}

/* ---------- Genre sections ---------- */

.category {
  margin: 32px 0 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.category .bar {
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--gold);
}

.category.teal .bar { background: var(--teal); }
.category.signal .bar { background: var(--signal); }

.category h2 {
  font-family: 'Press Start 2P', monospace;
  font-weight: 400;
  font-size: 13px;
  margin: 0;
  color: var(--paper);
}

.category .count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}

/* ---------- Game cards — thumbnail-forward grid ---------- */
/* This is a CSS-only redesign: it re-skins every existing card (all ~2,889
   of them) into a big-thumbnail, image-led tile without needing to touch
   the underlying HTML of a single one. */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: var(--paper);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:hover, .card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--teal);
  outline: none;
}

.card:focus-visible { box-shadow: 0 0 0 2px var(--teal); }

/* The old "icon-tile" is repurposed as the full-width thumbnail area */
.icon-tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  overflow: hidden;
}

.icon-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0 !important;
  display: block;
}

.icon-tile svg { width: 46px; height: 46px; }

.icon-tile.gold { background: var(--gold); }
.icon-tile.teal { background: var(--teal); }
.icon-tile.signal { background: var(--signal); color: var(--paper); }

.card-body {
  padding: 8px 9px 10px;
}

.card-body h3 {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Descriptions stay in the HTML (useful for search/SEO) but are hidden
   visually now, matching the dense visual-grid style of portals like
   Poki/CrazyGames rather than a text-heavy list. */
.card-body p {
  display: none;
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: 1280px;
  margin: 48px auto 24px;
  padding: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.site-footer a { color: var(--muted); text-decoration: underline; }
.site-footer a:hover { color: var(--teal); }

/* ---------- Game page shell ---------- */

.game-shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 50px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--teal);
  text-decoration: none;
  margin-bottom: 18px;
}

.back-link:hover { color: var(--gold); }

.game-title {
  font-family: 'Press Start 2P', monospace;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 8px;
}

.game-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 18px;
}

.game-board-frame {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.hud {
  display: flex;
  gap: 18px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--paper);
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.hud .label { color: var(--muted); margin-right: 4px; }

button.action {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--teal);
  color: var(--ink);
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-weight: 500;
}

button.action:hover { background: var(--sprout-lt); }

.how-to {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  max-width: 420px;
}

/* ---------- Responsive breakpoints ---------- */

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .hero-inner { flex-direction: column; gap: 12px; }
  .hero-logo { width: 90px; max-width: 30vw; align-self: flex-end; margin-top: -60px; }

  /* Embedded games get real height on mobile/tablet instead of being
     squeezed by a fixed aspect-ratio — this is what was causing games to
     render too small for their own "rotate/fullscreen" logic to properly
     detect a usable screen size. */
  .embed-frame-wrap {
    max-width: 100%;
    aspect-ratio: unset;
    height: 65vh;
    min-height: 380px;
  }
}

/* Fullscreen: the game genuinely fills the entire screen, overriding the
   aspect-ratio/height constraints above, matching whatever orientation
   the device is actually in. */
.embed-frame-wrap:fullscreen,
.embed-frame-wrap:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  aspect-ratio: unset !important;
}

@media (max-width: 480px) {
  .site-header { padding: 10px 14px 10px 60px; }
  .sidebar-toggle { width: 34px; height: 34px; font-size: 15px; top: 10px; left: 10px; }
  .logo-mark { width: 28px; height: 28px; }
  .logo-word { font-size: 9px; }
  .tagline { display: none; }
  .hero { padding: 10px 14px 0; }
  .hero-logo { display: none; }
  .hero-inner { flex-direction: column; gap: 0; }
  .hero h1 { font-size: clamp(12px, 4vw, 16px); line-height: 1.7; margin-bottom: 8px; }
  .hero p { font-size: 12px; margin-bottom: 10px; }
  .hero-stats { gap: 14px; margin-bottom: 10px; }
  .hero-stats strong { font-size: 12px; }
  .marquee { margin-top: 8px; }
  .marquee-track { padding: 6px 0; }
  .marquee-track span { font-size: 10px; padding: 0 14px; }
  .search-row { margin-top: 10px; padding: 8px 4px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 7px; }
  .card-body { padding: 6px 7px 8px; }
  .card-body h3 { font-size: 11.5px; }
  .category { margin: 22px 0 10px; }
  .category h2 { font-size: 11px; }
}
