/* ============================================================
   PlayPulse - Global Stylesheet
   Design: dark arcade theme, mobile-first, ad-slot ready
   ============================================================ */

:root {
  --bg:            #0d1117;
  --bg-elev:       #161b22;
  --bg-elev-2:     #1c2230;
  --border:        #262d3a;
  --border-light:  #333c4d;
  --text:          #e6edf3;
  --text-muted:    #8b97a8;
  --accent:        #5b8cff;
  --accent-2:      #a855f7;
  --accent-3:      #22d3ee;
  --success:       #3fb950;
  --danger:        #f85149;
  --warning:       #d29922;
  --radius:        14px;
  --radius-sm:     9px;
  --shadow:        0 4px 20px rgba(0, 0, 0, .35);
  --shadow-lg:     0 10px 40px rgba(0, 0, 0, .5);
  --header-h:      60px;
  --max-w:         1200px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Subtle animated background glow */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 12% -8%,  rgba(91, 140, 255, .13), transparent 60%),
    radial-gradient(800px 500px at 88% 5%,   rgba(168, 85, 247, .11), transparent 60%),
    radial-gradient(700px 400px at 50% 100%, rgba(34, 211, 238, .07), transparent 60%);
}

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-3); }

img { max-width: 100%; display: block; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; }

/* ---------------- Header ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: rgba(13, 17, 23, .88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.4px;
  color: var(--text);
  flex-shrink: 0;
}
.logo:hover { color: var(--text); }
.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 16px;
  box-shadow: 0 3px 12px rgba(91, 140, 255, .4);
}
.logo-text { background: linear-gradient(90deg, #fff, #9fb4d8); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.main-nav a {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  transition: all .15s;
}
.main-nav a:hover { color: var(--text); background: var(--bg-elev-2); }

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 38px;
  height: 34px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ---------------- Layout ---------------- */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
  position: relative;
  z-index: 1;
}

main { flex: 1 0 auto; position: relative; z-index: 1; padding-bottom: 48px; }

/* ---------------- Hero ---------------- */
.hero {
  text-align: center;
  padding: 46px 0 30px;
}
.hero h1 {
  font-size: clamp(30px, 6.2vw, 50px);
  letter-spacing: -1.2px;
  margin-bottom: 14px;
  background: linear-gradient(120deg, #ffffff 10%, #7aa2ff 55%, #c084fc 95%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  color: var(--text-muted);
  font-size: clamp(14px, 2.4vw, 17px);
  max-width: 620px;
  margin: 0 auto;
}
.hero-badges {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.badge {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}

/* ---------------- Section titles ---------------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 34px 0 16px;
  flex-wrap: wrap;
}
.section-head h2 { font-size: 21px; margin: 0; }
.section-head .hint { color: var(--text-muted); font-size: 13px; }

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

.game-card {
  display: block;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .18s cubic-bezier(.2,.8,.2,1), border-color .18s, box-shadow .18s;
  position: relative;
}
.game-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  color: inherit;
}
.game-thumb {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  font-size: 42px;
  position: relative;
  overflow: hidden;
}
.game-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(0,0,0,.45));
}
.game-card:hover .game-thumb .emoji { transform: scale(1.14) rotate(-5deg); }
.emoji { transition: transform .25s cubic-bezier(.2,.8,.2,1); position: relative; z-index: 1; filter: drop-shadow(0 4px 10px rgba(0,0,0,.45)); }

.game-info { padding: 11px 13px 13px; }
.game-title { font-weight: 700; font-size: 14.5px; margin: 0 0 2px; }
.game-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 8px; }
.game-meta .tag {
  background: var(--bg-elev-2);
  padding: 1px 7px;
  border-radius: 5px;
}

/* thumbnail gradients per game */
.t-2048   { background: linear-gradient(135deg, #f2b179, #edc22e); }
.t-snake  { background: linear-gradient(135deg, #134e2e, #3fb950); }
.t-tetris { background: linear-gradient(135deg, #1e3a8a, #a855f7); }
.t-mine   { background: linear-gradient(135deg, #374151, #6b7280); }
.t-memory { background: linear-gradient(135deg, #7c3aed, #ec4899); }
.t-break  { background: linear-gradient(135deg, #b45309, #f59e0b); }

/* ---------------- Ad slots ---------------- */
.ad-slot {
  width: 100%;
  margin: 20px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  text-align: center;
}

/* Placeholder shown before AdSense script is configured or while loading */
.ad-placeholder {
  width: 100%;
  min-height: 90px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(45deg, var(--bg-elev), var(--bg-elev) 10px, var(--bg-elev-2) 10px, var(--bg-elev-2) 20px);
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: .5px;
  padding: 8px;
}

/* Remove placeholder styling once real ad fills the slot */
.ad-slot[data-filled="true"] .ad-placeholder { display: none; }

.ad-leaderboard { max-width: 728px; min-height: 90px; }
.ad-rectangle   { max-width: 336px; min-height: 280px; }
.ad-mobile      { max-width: 336px; min-height: 100px; }
.ad-infeed      { max-width: 100%;  min-height: 100px; }

.ad-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 6px;
  opacity: .75;
}

/* In-grid native ad card */
.ad-card {
  background: var(--bg-elev);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  min-height: 200px;
  display: grid;
  place-items: center;
  padding: 12px;
}

/* ---------------- Game page ---------------- */
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
  margin-top: 8px;
}

.game-stage {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.stage-head h1 { font-size: 20px; margin: 0; }

.scoreboard {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.score-box {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 5px 12px;
  text-align: center;
  min-width: 68px;
}
.score-box .label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
}
.score-box .value { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }

.game-canvas-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

canvas {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-sm);
  background: #0a0e14;
  touch-action: none;
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 9px;
  border: 1px solid var(--border-light);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--border); border-color: var(--accent); color: var(--text); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 14px rgba(91, 140, 255, .35);
}
.btn-primary:hover { filter: brightness(1.12); color: #fff; }
.btn-lg { padding: 12px 26px; font-size: 15.5px; }

.controls-row {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 14px;
  justify-content: center;
}

/* ---------------- Overlay (start / game over) ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 11, 16, .9);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border-radius: var(--radius-sm);
  z-index: 20;
  padding: 18px;
  text-align: center;
}
.overlay[hidden] { display: none; }
.overlay-inner { max-width: 340px; }
.overlay h2 { font-size: 26px; margin-bottom: 6px; }
.overlay .final-score { font-size: 34px; font-weight: 800; color: var(--accent-3); font-variant-numeric: tabular-nums; }
.overlay p { color: var(--text-muted); font-size: 14px; margin: 8px 0 16px; }

/* ---------------- Sidebar ---------------- */
.sidebar { display: flex; flex-direction: column; gap: 16px; }

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.panel h3 { font-size: 14px; margin: 0 0 9px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-muted); }
.panel ul { margin: 0; padding-left: 18px; color: var(--text-muted); font-size: 13.5px; }
.panel li { margin-bottom: 4px; }

.leaderboard-list { list-style: none; margin: 0; padding: 0; }
.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.leaderboard-list li:last-child { border-bottom: none; }
.leaderboard-list .rank { color: var(--text-muted); width: 20px; }
.leaderboard-list .score { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent-3); }

/* ---------------- How-to section on game page ---------------- */
.how-to {
  margin-top: 26px;
}
.how-to h2 { font-size: 18px; }
.how-to p, .how-to li { color: var(--text-muted); font-size: 14px; }

/* ---------------- Content pages (privacy, about...) ---------------- */
.content-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 34px 16px 10px;
}
.content-page h1 { font-size: 30px; }
.content-page h2 { font-size: 19px; margin-top: 30px; }
.content-page p, .content-page li { color: var(--text-muted); }
.content-page .updated { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; }

/* ---------------- Footer ---------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: rgba(13, 17, 23, .6);
  padding: 26px 0 18px;
  position: relative;
  z-index: 1;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  text-align: center;
}
.footer-nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 13.5px;
}
.footer-nav a { color: var(--text-muted); }
.footer-nav a:hover { color: var(--accent); }
.footer-copy { font-size: 12.5px; color: var(--text-muted); opacity: .8; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .sidebar > * { flex: 1 1 300px; }
}

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .main-nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    padding: 8px;
    display: none;
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 10px 12px; }
  .hero { padding: 30px 0 18px; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .game-stage { padding: 12px; }
  .game-thumb { font-size: 34px; }
}

@media (max-width: 400px) {
  .game-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Accessibility: respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------- Growth: share bar ---------------- */
.share-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.share-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-right: 2px;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  background: var(--bg-elev-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.share-btn:hover {
  border-color: var(--accent);
  background: var(--bg-elev);
  transform: translateY(-1px);
}
.share-btn:active { transform: translateY(0); }
.share-btn[data-net="reddit"]:hover   { border-color: #ff4500; }
.share-btn[data-net="x"]:hover        { border-color: #e6edf3; }
.share-btn[data-net="whatsapp"]:hover { border-color: #25d366; }
.share-btn.copied {
  background: var(--success);
  border-color: var(--success);
  color: #04140a;
}

/* ---------------- Growth: up-next grid ---------------- */
.upnext-grid {
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  margin-top: 4px;
}
.up-next {
  margin-top: 34px;
  padding-top: 6px;
}
.up-next .section-head { margin-top: 0; }

@media (max-width: 400px) {
  .upnext-grid { grid-template-columns: repeat(2, 1fr); }
  .share-label { width: 100%; text-align: center; }
}
