/* =========================================================
   TileDash — design tokens
   Palette:
     --ink      #1B2A4A  (headlines, primary text)
     --slate    #232B3A  (dark surfaces, footer)
     --paper    #EEF1F6  (page background)
     --card     #FFFFFF  (card surfaces)
     --amber    #F2A93B  (primary accent — call to action)
     --teal     #2FB6A3  (secondary accent — success/active states)
     --line     #D8DEE9  (hairlines, borders)
   Type:
     display  -> 'Space Grotesk' (headlines, tile numerals)
     body     -> 'Inter' (paragraphs, UI labels)
     mono     -> 'IBM Plex Mono' (scores, timers, counters)
   ========================================================= */

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

:root {
  --ink: #1B2A4A;
  --slate: #232B3A;
  --paper: #EEF1F6;
  --card: #FFFFFF;
  --amber: #F2A93B;
  --amber-dark: #D9922A;
  --teal: #2FB6A3;
  --teal-dark: #229685;
  --line: #D8DEE9;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(27, 42, 74, 0.08);
  --shadow-lift: 0 8px 24px rgba(27, 42, 74, 0.14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}

.mono, .score, .timer { font-family: 'IBM Plex Mono', monospace; }

a { color: inherit; }

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

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 20px;
  text-decoration: none;
  color: var(--ink);
}
.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--amber) 0%, var(--teal) 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 3px;
  padding: 5px;
}
.logo-mark span { background: rgba(255,255,255,0.85); border-radius: 2px; }

.main-nav {
  display: flex;
  gap: 28px;
  font-weight: 600;
  font-size: 15px;
}
.main-nav a {
  text-decoration: none;
  color: var(--ink);
  opacity: 0.75;
  transition: opacity .15s ease;
}
.main-nav a:hover, .main-nav a.active { opacity: 1; }
.main-nav a.active { color: var(--teal-dark); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 72px 0 56px;
  background:
    linear-gradient(180deg, rgba(238,241,246,0) 60%, var(--paper) 100%),
    var(--slate);
}
.tile-grid-bg {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
  padding: 8px;
  opacity: 0.5;
}
.tile-grid-bg div {
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
}
.tile-grid-bg div:nth-child(3n) { background: rgba(242,169,59,0.10); }
.tile-grid-bg div:nth-child(7n) { background: rgba(47,182,163,0.10); }

.hero .container { position: relative; z-index: 1; }
.hero h1 {
  color: #fff;
  font-size: clamp(32px, 5vw, 52px);
  max-width: 14ch;
}
.hero p {
  color: rgba(255,255,255,0.78);
  font-size: 18px;
  max-width: 46ch;
  margin-bottom: 28px;
}
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--amber); color: #1B2A4A; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--amber-dark); }
.btn-ghost { background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.25); }
.btn-ghost:hover { background: rgba(255,255,255,0.16); }

/* ---------- Section headers ---------- */
.section { padding: 56px 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 8px;
}
.section-head h2 { font-size: 28px; }
.section-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-dark);
  font-weight: 600;
}
.section-link { font-size: 14px; font-weight: 600; color: var(--teal-dark); text-decoration: none; }

/* ---------- Game cards ---------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.game-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  transition: transform .15s ease, box-shadow .15s ease;
  display: flex;
  flex-direction: column;
}
.game-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.game-card-art {
  aspect-ratio: 4/3;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  padding: 14px;
}
.game-card-art div { border-radius: 5px; }
.game-card-body { padding: 16px 18px 20px; }
.game-card-body h3 { font-size: 17px; margin-bottom: 4px; }
.game-card-body p { font-size: 14px; color: #5A6478; margin: 0; }
.game-card-tag {
  display: inline-block;
  margin-top: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(47,182,163,0.12);
  color: var(--teal-dark);
  padding: 3px 8px;
  border-radius: 100px;
}

/* palette variants for card art, cycling per game */
.art-amber div:nth-child(odd) { background: rgba(242,169,59,0.55); }
.art-amber div:nth-child(even) { background: rgba(242,169,59,0.22); }
.art-teal div:nth-child(odd) { background: rgba(47,182,163,0.55); }
.art-teal div:nth-child(even) { background: rgba(47,182,163,0.22); }
.art-ink div:nth-child(odd) { background: rgba(27,42,74,0.55); }
.art-ink div:nth-child(even) { background: rgba(27,42,74,0.22); }

/* ---------- Ad slots (clearly marked placeholders) ----------
   Launch strategy: no ads while building traffic. Slots stay in the
   markup (data-slot attributes untouched) so real ad code can be
   dropped in later — for now `display: none !important` below hides
   them. Delete that one declaration when it's time to turn ads on. */
.ad-slot {
  display: none !important;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: repeating-linear-gradient(45deg, rgba(27,42,74,0.02), rgba(27,42,74,0.02) 10px, rgba(27,42,74,0.04) 10px, rgba(27,42,74,0.04) 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8891A5;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 32px auto;
}
.ad-slot[data-slot="leaderboard"] { max-width: 728px; height: 90px; }
.ad-slot[data-slot="sidebar"] { width: 100%; max-width: 300px; height: 250px; }
.ad-slot[data-slot="in-feed"] { max-width: 1120px; height: 100px; }

/* ---------- Game shell (played page) ---------- */
.game-shell {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 900px) {
  .game-shell { grid-template-columns: 1fr; }
}
.game-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.hud-stat {
  background: var(--paper);
  border-radius: 8px;
  padding: 8px 14px;
  text-align: center;
}
.hud-stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5A6478;
  display: block;
}
.hud-stat .value { font-size: 20px; font-weight: 600; }

.td-sound-toggle {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.td-sound-toggle:hover { background: var(--paper); }

.td-level-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.td-level-btn {
  padding: 7px 16px;
  border-radius: 100px;
  border: 1px solid var(--line);
  background: var(--card);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}
.td-level-btn.active { background: var(--teal); color: #fff; border-color: var(--teal); }

.td-milestones { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.td-milestone {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 100px;
  background: var(--paper);
  color: #8891A5;
  border: 1px solid var(--line);
}
.td-milestone.reached { background: rgba(47,182,163,0.14); color: var(--teal-dark); border-color: transparent; }

.game-board-wrap { display: flex; justify-content: center; }

.how-to-play {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-top: 20px;
}
.how-to-play h2 { font-size: 18px; }
.how-to-play ol, .how-to-play ul { padding-left: 20px; margin: 0; }
.how-to-play li { margin-bottom: 6px; font-size: 15px; color: #3B4560; }

.faq details {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.faq summary {
  font-weight: 600;
  cursor: pointer;
  font-size: 15px;
}
.faq p { margin: 10px 0 0; color: #3B4560; font-size: 14px; }

/* ---------- Kids section variant ---------- */
.kids-theme .hero { background: linear-gradient(135deg, #2FB6A3 0%, #1B2A4A 100%); }
.kids-badge {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 100px;
  margin-bottom: 14px;
  letter-spacing: 0.05em;
}
.age-tabs { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }
.age-tab {
  padding: 8px 18px;
  border-radius: 100px;
  border: 1px solid var(--line);
  background: var(--card);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.age-tab.active { background: var(--teal); color: #fff; border-color: var(--teal); }
.no-ads-note {
  font-size: 13px;
  color: #5A6478;
  background: var(--paper);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 24px;
  display: inline-block;
}

/* ---------- Win/game-over modal (centered over the game board) ---------- */
@keyframes tdFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes tdPop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.td-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(27, 42, 74, 0.6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: tdFadeIn .18s ease;
}
.td-modal-card {
  background: var(--card);
  border-radius: 16px;
  padding: 32px 36px;
  text-align: center;
  max-width: 260px;
  box-shadow: 0 20px 50px rgba(27, 42, 74, 0.4);
  animation: tdPop .22s ease;
}
.td-modal-emoji { font-size: 42px; margin-bottom: 6px; }
.td-modal-card h3 { font-size: 22px; margin-bottom: 8px; }
.td-modal-stat { color: var(--ink); font-size: 15px; margin: 0 0 4px; }
.td-modal-record { font-size: 13px; font-weight: 600; color: #8891A5; margin: 0 0 20px; }
.td-modal-record.is-new { color: var(--teal-dark); }
.td-modal-btn { width: 100%; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--slate);
  color: rgba(255,255,255,0.65);
  padding: 40px 0 28px;
  margin-top: 40px;
  font-size: 14px;
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}
.site-footer a { text-decoration: none; color: rgba(255,255,255,0.65); }
.footer-cols { display: flex; gap: 48px; flex-wrap: wrap; }
.footer-col h4 {
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  margin-bottom: 10px;
}
.footer-col a { display: block; margin-bottom: 6px; opacity: 0.75; }
.footer-col a:hover { opacity: 1; }

@media (max-width: 640px) {
  .main-nav { display: none; }
  .site-footer .container { flex-direction: column; }
}
