/* ============================================================
   FREAKS GAMES — Main Stylesheet
   Dark gaming theme with neon purple/green accents
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:        #0d0d14;
  --bg2:       #13131e;
  --bg3:       #1a1a2e;
  --surface:   #1e1e30;
  --surface2:  #25253a;
  --border:    #2e2e4a;
  --accent:    #9b59ff;
  --accent2:   #00ffaa;
  --accent3:   #ff4d9e;
  --text:      #e8e8f0;
  --text2:     #9999bb;
  --text3:     #5555775;
  --red:       #ff4d4d;
  --yellow:    #ffd700;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
  --glow:      0 0 20px rgba(155,89,255,0.3);
  --glow2:     0 0 20px rgba(0,255,170,0.3);
  --font:      'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,13,20,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 60px;
}

.site-logo {
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  text-shadow: none;
}

.site-logo span { color: var(--accent3); -webkit-text-fill-color: var(--accent3); }

.header-search {
  flex: 1;
  max-width: 500px;
  position: relative;
  display: flex;
  align-items: center;
}

.header-search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 8px 40px 8px 16px;
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.header-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155,89,255,0.15);
}
.header-search input::placeholder { color: var(--text2); }

#search-clear {
  position: absolute;
  right: 12px;
  background: none;
  color: var(--text2);
  font-size: 1rem;
  padding: 4px;
  transition: color 0.2s;
}
#search-clear:hover { color: var(--text); }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.header-ad-slot {
  display: flex;
  align-items: center;
}

/* ── Top Banner Ad ───────────────────────────────────────────── */
.top-ad-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  min-height: 100px;
}
.ad-label {
  font-size: 0.65rem;
  color: var(--text3);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.ad-unit-leaderboard {
  width: 728px;
  height: 90px;
  background: var(--surface);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 0.8rem;
}
@media (max-width: 768px) {
  .ad-unit-leaderboard { width: 320px; height: 50px; }
}

/* ── Hero / Featured ─────────────────────────────────────────── */
.featured-section {
  padding: 24px 24px 0;
}
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.section-title .accent { color: var(--accent); }
.section-badge {
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: 180px;
  gap: 10px;
}
.featured-card {
  border-radius: var(--radius-lg);
  background-image: var(--thumb);
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.featured-card:hover { transform: translateY(-3px); box-shadow: var(--glow); }
.featured-card.featured-hero {
  grid-column: span 3;
  grid-row: span 1;
}
.featured-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 20%, rgba(0,0,0,0.85) 100%);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
}
.featured-cat {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent2);
  font-weight: 600;
}
.featured-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}
.featured-card.featured-hero .featured-title { font-size: 1.3rem; }
.featured-desc {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.7);
  display: none;
}
.featured-card.featured-hero .featured-desc { display: block; }
.featured-play-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 14px;
  background: var(--accent);
  color: white;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  width: fit-content;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
}
.featured-card:hover .featured-play-btn { opacity: 1; transform: translateY(0); }

/* ── Category Bar ────────────────────────────────────────────── */
.cat-section {
  padding: 20px 24px 0;
}
.cat-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.cat-bar::-webkit-scrollbar { display: none; }
.cat-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text2);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.15s;
}
.cat-btn:hover { border-color: var(--accent); color: var(--text); }
.cat-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: var(--glow);
}
.cat-icon { font-size: 0.9rem; }
.cat-count {
  background: rgba(0,0,0,0.2);
  padding: 1px 6px;
  border-radius: 99px;
  font-size: 0.7rem;
}
.cat-btn.active .cat-count { background: rgba(255,255,255,0.2); }

/* ── Games Section ───────────────────────────────────────────── */
.games-section {
  padding: 20px 24px;
}
.games-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
#game-count {
  font-size: 0.8rem;
  color: var(--text2);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

/* ── Game Grid ───────────────────────────────────────────────── */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  display: block;
}
.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.game-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg3);
  overflow: hidden;
}
.game-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}
.game-card:hover .game-thumb { transform: scale(1.08); }

.game-play-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(155,89,255,0.7);
  color: white;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 2px;
  opacity: 0;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}
.game-card:hover .game-play-btn { opacity: 1; }

/* ── Thumbnail fallback (shown when image fails to load) ─────── */
.game-thumb-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  text-align: center;
}
.game-thumb-fallback.cat-action     { background: linear-gradient(135deg, #1a0a0a, #3d1010); }
.game-thumb-fallback.cat-racing     { background: linear-gradient(135deg, #1a1000, #3d2d00); }
.game-thumb-fallback.cat-puzzle     { background: linear-gradient(135deg, #000d1a, #00203d); }
.game-thumb-fallback.cat-io         { background: linear-gradient(135deg, #001a0d, #003d1e); }
.game-thumb-fallback.cat-sports     { background: linear-gradient(135deg, #1a1500, #3d3200); }
.game-thumb-fallback.cat-casual     { background: linear-gradient(135deg, #1a0015, #3d0033); }
.game-thumb-fallback.cat-adventure  { background: linear-gradient(135deg, #001a1a, #003d3d); }
.game-thumb-fallback.cat-shooting   { background: linear-gradient(135deg, #1a0000, #3d0000); }
.game-thumb-fallback.cat-strategy   { background: linear-gradient(135deg, #0d001a, #1f003d); }
.game-thumb-fallback.cat-platformer { background: linear-gradient(135deg, #001a10, #003d24); }
.game-thumb-fallback.cat-simulation { background: linear-gradient(135deg, #00101a, #00263d); }
.game-thumb-fallback.cat-horror     { background: linear-gradient(135deg, #0d0015, #1a0029); }
/* default */
.game-thumb-fallback:not([class*="cat-"]) { background: linear-gradient(135deg, #13131e, #1e1e30); }

.fallback-icon  { font-size: 2rem; line-height: 1; }
.fallback-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  line-height: 1.3;
  word-break: break-word;
}

.game-cat-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(0,0,0,0.7);
  color: white;
  backdrop-filter: blur(4px);
}
.game-cat-badge.action   { background: rgba(255,77,77,0.85); }
.game-cat-badge.racing   { background: rgba(255,165,0,0.85); }
.game-cat-badge.puzzle   { background: rgba(0,149,255,0.85); }
.game-cat-badge.io       { background: rgba(0,200,100,0.85); }
.game-cat-badge.sports   { background: rgba(255,210,0,0.85); color: #222; }
.game-cat-badge.casual   { background: rgba(255,100,200,0.85); }
.game-cat-badge.adventure{ background: rgba(100,200,255,0.85); color: #222; }
.game-cat-badge.shooting { background: rgba(200,50,50,0.85); }
.game-cat-badge.strategy { background: rgba(150,0,255,0.85); }
.game-cat-badge.platformer{background: rgba(0,220,180,0.85); color: #222; }
.game-cat-badge.simulation{background: rgba(80,180,255,0.85); color: #222; }
.game-cat-badge.horror   { background: rgba(60,0,80,0.95); }

.game-info { padding: 10px; }
.game-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text2);
}
.game-stars { color: var(--yellow); letter-spacing: -1px; }
.game-plays { color: var(--text2); }

/* ── No Results ──────────────────────────────────────────────── */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 24px;
  color: var(--text2);
}
.no-results-icon { font-size: 3rem; margin-bottom: 16px; }
.no-results h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--text); }

/* ── Games Loading Placeholder ───────────────────────────────── */
.games-loading-placeholder {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  gap: 14px;
}
.games-loading-spinner {
  width: 52px;
  height: 52px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: gm-spin 0.8s linear infinite;
}
@keyframes gm-spin { to { transform: rotate(360deg); } }
.games-loading-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}
.games-loading-sub {
  font-size: 0.82rem;
  color: var(--text2);
}

/* ── Load More ───────────────────────────────────────────────── */
.load-more-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px;
}
#load-more {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 99px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}
#load-more:hover {
  background: var(--accent);
  color: white;
  box-shadow: var(--glow);
}

/* ── Mid-page Banner Ad ──────────────────────────────────────── */
.mid-ad-section {
  display: flex;
  justify-content: center;
  padding: 16px 24px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.ad-unit-rect {
  width: 300px;
  height: 250px;
  background: var(--surface);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ── Footer ──────────────────────────────────────────────────── */
.site-footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 40px 24px;
  text-align: center;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 32px;
  max-width: 1000px;
  margin: 0 auto 32px;
  text-align: left;
}
.footer-col h4 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 12px;
}
.footer-col a {
  display: block;
  font-size: 0.85rem;
  color: var(--text2);
  padding: 3px 0;
  transition: color 0.15s;
}
.footer-col a:hover { color: var(--accent2); }
.footer-copy {
  font-size: 0.75rem;
  color: var(--text2);
  border-top: 1px solid var(--border);
  padding-top: 20px;
}
.footer-ad { display: flex; justify-content: center; margin-bottom: 24px; }

/* ── Scroll-to-top ───────────────────────────────────────────── */
#scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 1.2rem;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow);
  transition: transform 0.2s;
  z-index: 50;
}
#scroll-top:hover { transform: scale(1.1); }

/* ── Ad Overlay (Timed Interstitial) ─────────────────────────── */
#ad-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(8px);
}
.ad-overlay-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 60px rgba(0,0,0,0.8);
}
.ad-overlay-logo {
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--accent);
  margin-bottom: 8px;
}
.ad-overlay-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.ad-overlay-sub { font-size: 0.85rem; color: var(--text2); margin-bottom: 20px; }
.ad-container-overlay {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid var(--border);
}
.ad-overlay-unit {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  font-size: 0.8rem;
}
.ad-skip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text2);
}
.skip-btn {
  padding: 6px 16px;
  border-radius: 99px;
  background: var(--surface2);
  color: var(--text2);
  font-size: 0.8rem;
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.skip-btn:not(:disabled):hover, .skip-btn.ready {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.skip-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ════════════════════════════════════════════════════════════
   GAME PAGE (game.html)
   ════════════════════════════════════════════════════════════ */

.game-page-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  grid-template-rows: auto 1fr auto;
  min-height: calc(100vh - 60px);
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
  gap: 16px;
}

.game-main { display: flex; flex-direction: column; gap: 16px; }

.game-player-wrap {
  background: var(--bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  flex: 1;
}
.game-player-wrap::before {
  content: '';
  display: block;
  padding-top: 56.25%; /* 16:9 */
}
.game-player-wrap.fullscreen-active::before { display: none; }

#game-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.game-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.game-controls h2 {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ctrl-btn {
  padding: 6px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.8rem;
  transition: all 0.15s;
  white-space: nowrap;
}
.ctrl-btn:hover { border-color: var(--accent); color: var(--accent); }
.ctrl-btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.ctrl-btn.primary:hover { opacity: 0.85; }

.play-timer-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text2);
  font-family: var(--font-mono);
  background: var(--bg3);
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
}
#play-timer { color: var(--accent2); font-weight: 600; }

/* Sidebar */
.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sidebar-ad {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.ad-unit-skyscraper {
  width: 160px;
  height: 600px;
  background: var(--bg3);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  font-size: 0.75rem;
}
.ad-unit-rect-sm {
  width: 300px;
  height: 250px;
  background: var(--bg3);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  font-size: 0.75rem;
}

.sidebar-related h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.related-list { display: flex; flex-direction: column; gap: 8px; }
.related-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}
.related-item:hover { border-color: var(--accent); }
.related-thumb {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--bg3);
}
.related-info { flex: 1; min-width: 0; }
.related-title {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.related-plays { font-size: 0.68rem; color: var(--text2); margin-top: 2px; }

/* Game description */
.game-description {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.85rem;
  color: var(--text2);
  line-height: 1.6;
}
.game-description h3 { color: var(--text); font-size: 0.9rem; margin-bottom: 8px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .game-page-layout {
    grid-template-columns: 1fr;
  }
  .game-sidebar { order: -1; }
  .ad-unit-skyscraper { display: none; }
  .featured-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .featured-card.featured-hero { grid-column: span 3; }
}
@media (max-width: 600px) {
  .site-header { padding: 0 12px; }
  .featured-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
  }
  .featured-card.featured-hero { grid-column: span 2; height: 160px; }
  .featured-card:nth-child(n+4) { display: none; }
  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }
  .games-section, .featured-section, .cat-section { padding: 12px; }
  .game-page-layout { padding: 8px; gap: 8px; }
}
