:root {
  --bg: #0e1626;
  --bg-soft: #16213c;
  --card: #18233f;
  --card-2: #223154;
  --line: #2e3c60;
  --text: #eaf0fb;
  --muted: #9aa6c2;
  --brand: #7c5cff;
  --brand-2: #19c8ff;
  --hot: #ff4d6d;
  --radius: 16px;
  --header-h: 60px;
  --footer-h: 84px;
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

body {
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* only pages that carry the fixed bottom inter banner reserve space for it */
body.has-inter {
  padding-bottom: calc(50px + 12px);
}

/* anchored sections stop below the fixed header when jumped to */
section[id] { scroll-margin-top: calc(var(--header-h) + 12px); }

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

/* ---------- Fixed header ---------- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 60;
  background: rgba(14, 22, 38, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: .3px;
}
.brand .logo {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center;
  font-size: 17px;
}
.brand b { color: var(--brand-2); }

.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: .15s;
}
.nav a:hover, .nav a.active { color: var(--text); background: var(--card-2); }

.hamburger {
  display: none;
  width: 42px; height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

/* ---------- Sections ---------- */
.section { margin: 22px 0; }
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 14px;
}
.section-head h2 {
  font-size: 19px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-head .emo { font-size: 20px; }
.section-head .sub { color: var(--muted); font-size: 13px; }

.hero {
  margin-top: 16px;
  border-radius: var(--radius);
  padding: 22px 20px;
  background: radial-gradient(120% 140% at 0% 0%, rgba(124,92,255,.35), transparent 55%),
              radial-gradient(120% 140% at 100% 0%, rgba(25,200,255,.28), transparent 55%),
              var(--bg-soft);
  border: 1px solid var(--line);
}
.hero h1 { margin: 0 0 6px; font-size: 26px; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; max-width: 620px; }

/* ---------- Game grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.card:active { transform: scale(.98); }
.card:hover { border-color: var(--brand); }
.card .thumb {
  height: 96px;
  display: grid;
  place-items: center;
  font-size: 40px;
  position: relative;
}
.card .thumb .cat {
  position: absolute;
  left: 8px; top: 8px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  color: #fff;
  letter-spacing: .4px;
}
.card .thumb .hot {
  position: absolute;
  right: 8px; top: 8px;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--hot);
  color: #fff;
}
.card .body { padding: 10px 12px 13px; }
.card .body h3 { margin: 0 0 4px; font-size: 15px; }
.card .body p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Ad slots ---------- */
.ad-slot {
  width: 100%;
  height: auto;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.02);
  color: var(--muted);
  text-align: center;
  overflow: hidden;
}
.ad-slot:empty::before {
  content: "advertisement";
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}
.ad-slot:not(:empty) {
  border: none;
  background: transparent;
  min-height: 0;
}
.ad-slot:not(:empty)::before { content: none; }
.ad-slot iframe, .ad-slot ins { display: block; width: 100%; }

.ad-block-lead { margin: 8px 0 2px; }

/* home2 sits inline between game sections (no blank spacer) */

/* ---------- Interstitial overlay ---------- */
#adInterstitial {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  background: rgba(8, 14, 26, .92);
  align-items: center;
  justify-content: center;
  padding: 18px;
}
#adInterstitial.show { display: flex; }
#adInterstitial .inter-box {
  width: 100%;
  max-width: 360px;
  min-height: 280px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 14px;
}
#adInterstitial .inter-close {
  position: absolute;
  top: -14px; right: -10px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #223154;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  opacity: .35;
  pointer-events: none;
}
#adInterstitial .inter-close.ready { opacity: 1; pointer-events: auto; }
#adInterstitial .ad-slot { border: none; background: transparent; margin: 0; min-height: 250px; }

/* ---------- Bottom inter banner (fixed to screen bottom, does not scroll) ---------- */
.inter-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 55;
  margin: 0;
}
.inter-banner .ad-slot {
  width: 100%;
  height: 50px;
  min-height: 50px;
  margin: 0;
}
/* inter placeholder ad: opaque background (only while empty / not yet filled) */
.inter-banner .ad-slot:empty { background: var(--card); }

/* ---------- Back to top button ---------- */
.to-top {
  position: fixed;
  right: 14px;
  bottom: 68px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 70;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  -webkit-tap-highlight-color: transparent;
}
.to-top.show { display: flex; }
/* on pages with the fixed bottom inter banner, sit above it */
body.has-inter .to-top { bottom: calc(50px + 12px + 16px + 50px); }

/* ---------- Footer (in normal flow, scrolls with the page) ---------- */
.site-footer {
  margin-top: 12px;
  height: var(--footer-h);
  background: rgba(14,22,38,.95);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
}
.site-footer .wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 3px;
}
.site-footer .foot-copy {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  letter-spacing: .2px;
}
.site-footer .foot-links {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  gap: 4px;
}
.site-footer .foot-links a {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 2px;
  border-radius: 8px;
}
.site-footer .foot-links a:active { background: var(--card-2); color: var(--text); }

/* ---------- Detail page ---------- */
.detail-hero {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  margin-top: 16px;
}
.detail-hero .cover {
  height: 150px;
  display: grid;
  place-items: center;
  font-size: 64px;
}
.detail-hero .meta { padding: 14px 16px; background: var(--card); }
.detail-hero .meta .cat {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  background: var(--card-2); color: var(--brand-2);
  margin-bottom: 8px;
}
.detail-hero .meta h1 { margin: 0 0 6px; font-size: 22px; }
.detail-hero .meta p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.play-btn {
  display: block;
  width: 100%;
  margin: 16px 0 4px;
  padding: 15px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(124,92,255,.35);
}
.play-btn:active { transform: scale(.99); }

.back-link {
  display: inline-block;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.back-link:hover { color: var(--text); }

/* ---------- Static page (compliance) ---------- */
.page { margin-top: 16px; }
.page h1 { font-size: 24px; margin: 4px 0 12px; }
.page h2 { font-size: 17px; margin: 22px 0 8px; color: var(--brand-2); }
.page p { color: var(--muted); line-height: 1.7; font-size: 14.5px; }
.page ul { color: var(--muted); line-height: 1.7; font-size: 14.5px; padding-left: 20px; }
.cookie-note {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---------- Game play page ---------- */
.game-page { position: fixed; inset: 0; background: #0a1322; z-index: 1; display: flex; flex-direction: column; }
.game-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; color: #fff; gap: 10px;
}
.game-top .gname { font-weight: 700; font-size: 15px; }
.game-top .gback {
  border: 1px solid #2a3550; background: #11friend; background: #141c2e;
  color: #fff; border-radius: 10px; padding: 7px 12px; font-size: 13px; cursor: pointer;
}
.game-canvas { flex: 1; width: 100%; display: block; background: #0c1526; touch-action: none; }
.game-hud {
  position: absolute; top: 54px; left: 0; right: 0;
  display: flex; justify-content: space-between; padding: 6px 16px;
  color: #cfe; font-size: 14px; pointer-events: none; font-weight: 700;
}

/* ---------- Responsive header/footer ---------- */
@media (max-width: 720px) {
  .nav { display: none; }
  .hamburger { display: block; }
  .nav.open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--line);
    padding: 8px;
    gap: 2px;
    z-index: 59;
  }
  .nav.open a { padding: 12px; }
  .hero h1 { font-size: 22px; }
}

/* ---------- Search page ---------- */
.search-hero { margin: 18px 0 4px; }
.search-hero h1 { font-size: 24px; font-weight: 800; margin: 0 0 4px; }
.search-hero p { color: var(--muted); margin: 0; font-size: 14px; }
.search-bar { position: relative; margin: 14px 0 4px; }
.search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 15px 46px 15px 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--brand); }
.search-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 16px; pointer-events: none;
}
.search-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  border: none; background: var(--card-2); color: var(--muted);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 14px;
  display: none;
}
.search-clear.show { display: block; }
.search-meta { color: var(--muted); font-size: 13px; margin: 12px 0 2px; }
.no-result { text-align: center; color: var(--muted); padding: 44px 16px; font-size: 15px; }
.card { cursor: pointer; }
