/* Layout: a bright playroom. White ground, soft pink and sky-blue shapes drifting
   behind rounded game cards. Pink is the action color; blue is the calm companion.
   Follows the device's light or dark theme automatically. */
:root {
  --bg: #ffffff;          /* page ground */
  --surface: #ffffff;     /* cards */
  --tint-pink: #fff1f7;   /* soft pink panels */
  --tint-blue: #eef7ff;   /* soft blue panels */
  --line: #f2dde8;        /* borders */
  --text: #2e2a4f;        /* main text (deep indigo, not black) */
  --muted: #6d6890;       /* secondary text */
  --pink: #ff8fbd;        /* action color: buttons, active chips */
  --pink-ink: #3d0f29;    /* text on pink */
  --pink-deep: #d9467f;   /* links */
  --blue: #8cc9ff;        /* companion color */
  --shape-pink: #ffd6e7;  /* background shapes */
  --shape-blue: #d6ecff;
  --shadow: rgba(217, 70, 127, .16);
  --new: #6fd3a8;         /* NEW badge */

  --display: "Fredoka", "Nunito", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --max: 1180px;
  --gutter: clamp(16px, 4vw, 32px);
  --r: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17182c; --surface: #212340; --tint-pink: #2b2140; --tint-blue: #1d2a48;
    --line: #353861; --text: #f5f2ff; --muted: #b7b3d9; --pink: #ff9cc6; --pink-ink: #3d0f29;
    --pink-deep: #ffa9cd; --blue: #8cc9ff; --shape-pink: #33244a; --shape-blue: #1e3152;
    --shadow: rgba(0, 0, 0, .35); --new: #6fd3a8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17182c; --surface: #212340; --tint-pink: #2b2140; --tint-blue: #1d2a48;
  --line: #353861; --text: #f5f2ff; --muted: #b7b3d9; --pink: #ff9cc6; --pink-ink: #3d0f29;
  --pink-deep: #ffa9cd; --blue: #8cc9ff; --shape-pink: #33244a; --shape-blue: #1e3152;
  --shadow: rgba(0, 0, 0, .35); --new: #6fd3a8;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}
img { max-width: 100%; }
a { color: var(--pink-deep); font-weight: 700; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
main, .marquee, .foot { position: relative; z-index: 1; }
main { flex: 1; }

/* ---------- Floating background shapes ---------- */
.shapes { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.shapes span { position: absolute; display: block; }
.shapes .blob { border-radius: 50%; }
.shapes .s1 { width: 340px; height: 340px; background: var(--shape-pink); top: -120px; right: -90px; }
.shapes .s2 { width: 220px; height: 220px; background: var(--shape-blue); top: 38%; left: -110px; }
.shapes .s3 { width: 120px; height: 120px; background: var(--shape-blue); top: 14%; left: 46%; border-radius: 34px; transform: rotate(18deg); }
.shapes .s4 { width: 180px; height: 180px; background: var(--shape-pink); bottom: -60px; right: 12%; border-radius: 48px; transform: rotate(-14deg); }
.shapes .s5 { width: 70px; height: 70px; background: var(--shape-pink); top: 62%; right: 6%; }
.shapes .s6 { width: 54px; height: 54px; background: var(--shape-blue); bottom: 18%; left: 8%; border-radius: 16px; transform: rotate(30deg); }
.shapes .star {
  width: 46px; height: 46px; background: var(--shape-blue);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.shapes .st1 { top: 24%; left: 6%; }
.shapes .st2 { top: 8%; right: 30%; width: 30px; height: 30px; background: var(--shape-pink); }
.shapes .st3 { bottom: 30%; left: 52%; width: 36px; height: 36px; background: var(--shape-pink); }
@media (prefers-reduced-motion: no-preference) {
  .shapes span { animation: drift 14s ease-in-out infinite alternate; }
  .shapes span:nth-child(2n) { animation-duration: 18s; animation-direction: alternate-reverse; }
  @keyframes drift { to { translate: 0 22px; } }
}

/* ---------- Header ---------- */
.marquee {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
}
.marquee-in {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 66px;
}
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none;
  font: 700 25px/1 var(--display);
}
.logo .coin { width: 40px; height: 40px; flex: none; }
.logo:hover .coin { transform: rotate(-10deg); }
.logo .coin { transition: transform .2s ease; }
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--text); text-decoration: none; font-weight: 800; font-size: 15px;
  padding: 8px 14px; border-radius: 999px;
}
.nav a:hover { background: var(--tint-blue); }
.nav a[aria-current="page"] { background: var(--tint-pink); color: var(--pink-deep); }

/* ---------- Home hero ---------- */
.hero {
  display: grid; gap: 28px; align-items: center;
  padding-block: clamp(28px, 6vw, 60px) 8px;
}
@media (min-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 48px; }
}
.free-play {
  display: inline-block; margin: 0 0 14px; padding: 6px 14px; border-radius: 999px;
  background: var(--tint-blue); color: var(--text);
  font: 600 14px/1.2 var(--display); letter-spacing: .02em;
}
.hero h1 {
  margin: 0; font: 700 clamp(34px, 6.2vw, 58px)/1.06 var(--display);
  text-wrap: balance;
}
.hero h1 .hl {
  background: linear-gradient(transparent 62%, var(--shape-pink) 62%);
  padding-inline: 4px; border-radius: 6px;
}
.lede { margin: 18px 0 0; max-width: 46ch; color: var(--muted); font-size: 18px; }
.hero-facts {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 0; padding: 0; list-style: none;
}
.hero-facts li {
  font: 700 14px/1 var(--body);
  padding: 10px 14px; border-radius: 999px; color: var(--text);
  background: var(--surface); border: 2px solid var(--line);
  display: inline-flex; align-items: center; gap: 8px;
}
.hero-facts li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--pink); }
.hero-facts li:nth-child(2)::before { background: var(--blue); border-radius: 3px; }
.hero-facts li:nth-child(3)::before { background: var(--new); }

.feature {
  display: grid; color: inherit; text-decoration: none; font-weight: 400;
  background: var(--surface); border: 2px solid var(--line); border-radius: 28px; overflow: hidden;
  box-shadow: 0 10px 30px var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.feature:hover, .feature:focus-visible {
  transform: translateY(-5px) rotate(-.4deg); box-shadow: 0 18px 40px var(--shadow); outline: none;
}
.feature-art { aspect-ratio: 16 / 9; background: var(--tint-blue); overflow: hidden; max-width: 100%; }
.feature-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feature-body { display: grid; gap: 8px; padding: 18px 22px 22px; }
.feature-tag {
  justify-self: start; font: 600 13px/1 var(--display); color: var(--pink-ink);
  background: var(--shape-pink); padding: 6px 12px; border-radius: 999px;
}
:root[data-theme="dark"] .feature-tag { color: var(--text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .feature-tag { color: var(--text); } }
.feature-title { font: 700 clamp(26px, 3.4vw, 34px)/1.1 var(--display); }
.feature-blurb { color: var(--muted); margin: 0; }
.feature-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font: 800 16px/1 var(--body); color: var(--pink-ink); background: var(--pink);
  border: 0; border-radius: 999px; padding: 14px 24px; cursor: pointer; text-decoration: none;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--pink) 60%, #7a1d47);
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 color-mix(in srgb, var(--pink) 60%, #7a1d47); }
.btn svg { width: 16px; height: 16px; }

/* ---------- Game shelf ---------- */
.shelf-head {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px;
  margin-block: 8px 20px;
}
.shelf-head h2 { margin: 0; font: 700 clamp(24px, 3vw, 30px)/1.1 var(--display); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 800 14px/1 var(--body); color: var(--text); background: var(--surface);
  border: 2px solid var(--line); border-radius: 999px; padding: 9px 16px; cursor: pointer;
}
.chip:hover { border-color: var(--blue); }
.chip[aria-pressed="true"] { background: var(--pink); border-color: var(--pink); color: var(--pink-ink); }
.search {
  font: 400 15px var(--body); color: var(--text); background: var(--tint-blue);
  border: 2px solid transparent; border-radius: 999px; padding: 9px 18px; width: 210px; max-width: 100%;
}
.search:focus { border-color: var(--blue); outline: none; }
.search::placeholder { color: var(--muted); }

.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 22px; } }

.cart {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r);
  overflow: hidden; color: inherit; text-decoration: none; font-weight: 400;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.cart:hover, .cart:focus-visible {
  transform: translateY(-5px) rotate(-1deg); box-shadow: 0 14px 30px var(--shadow);
  border-color: var(--pink); outline: none;
}
.grid .cart:nth-child(2n):hover { transform: translateY(-5px) rotate(1deg); border-color: var(--blue); }
.cart-art { display: block; aspect-ratio: 4 / 3; background: var(--tint-blue); overflow: hidden; max-width: 100%; }
.cart-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cart-art.fallback {
  display: grid; place-items: center;
  background: linear-gradient(135deg, hsl(var(--h) 90% 86%), hsl(calc(var(--h) + 50) 90% 80%));
  font: 700 clamp(40px, 9vw, 64px)/1 var(--display); color: #3a2a4a;
}
.cart-label { display: grid; gap: 4px; padding: 12px 14px 14px; min-width: 0; }
.cart-cat {
  justify-self: start; font: 600 12px/1 var(--display); color: var(--muted);
  background: var(--tint-blue); padding: 5px 9px; border-radius: 999px;
}
.cart:nth-child(2n) .cart-cat { background: var(--tint-pink); }
.cart-title { font: 600 18px/1.2 var(--display); overflow-wrap: anywhere; }
.badge-new {
  position: absolute; top: 10px; left: 10px; font: 700 12px/1 var(--display);
  background: var(--new); color: #0d3324; padding: 6px 10px; border-radius: 999px;
}
.empty { color: var(--muted); padding: 24px 0; }

/* ---------- Ad slots ---------- */
.ad-slot { display: grid; gap: 6px; justify-items: center; margin-block: 32px; }
.ad-slot:empty { display: none; }
.ad-label { font: 700 11px/1 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ad-box { width: 100%; max-width: 970px; min-height: 90px; }
.ad-ph {
  width: 100%; max-width: 728px; min-height: 90px; padding: 14px;
  display: grid; place-items: center; align-content: center; gap: 2px; text-align: center;
  border: 2px dashed var(--line); border-radius: 16px; color: var(--muted); font-size: 14px; font-weight: 800;
  background: var(--surface);
}
.ad-ph small { font-weight: 400; font-size: 12px; }
.rail .ad-slot { margin-block: 0; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 90px); }
.rail .ad-ph { max-width: 300px; min-height: 600px; }
.rail .ad-box { max-width: 300px; min-height: 250px; }

/* ---------- Play page ---------- */
.play-grid { display: grid; gap: 24px; }
.rail { display: none; }
@media (min-width: 1100px) {
  /* 160px keeps ads clear of the game, as Google recommends (150px+) */
  .play-grid { grid-template-columns: minmax(0, 1fr) 300px; column-gap: 160px; }
  .rail { display: block; padding-top: 76px; }
}
.stage { min-width: 0; }
.stage-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin-block: 22px 16px;
}
.back {
  color: var(--muted); text-decoration: none; font-weight: 800; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px; width: 100%;
}
.back:hover { color: var(--text); }
.stage-head h1 { margin: 0; font: 700 clamp(28px, 4.4vw, 40px)/1.1 var(--display); text-wrap: balance; }
.stage-cat {
  font: 600 13px/1 var(--display); border-radius: 999px; padding: 7px 12px;
  background: var(--tint-blue); color: var(--text);
}
.tool {
  margin-left: auto; font: 800 14px/1 var(--body); color: var(--text); background: var(--surface);
  border: 2px solid var(--line); border-radius: 999px; padding: 10px 16px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.tool:hover { border-color: var(--blue); }
.tool svg { width: 16px; height: 16px; }

.frame {
  --arw: 4; --arh: 5;
  position: relative; margin-inline: auto; max-width: 100%;
  width: min(100%, calc(74vh * var(--arw) / var(--arh)));
  aspect-ratio: var(--arw) / var(--arh);
  background: var(--tint-blue); border: 4px solid var(--surface); border-radius: 26px; overflow: hidden;
  box-shadow: 0 0 0 2px var(--line), 0 14px 36px var(--shadow);
}
@supports (height: 1svh) {
  .frame { width: min(100%, calc(74svh * var(--arw) / var(--arh))); }
}
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.frame:fullscreen { width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border: 0; border-radius: 0; }
.frame-start {
  position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 16px;
  padding: 20px; text-align: center; cursor: pointer; border: 0; width: 100%; color: #2e2a4f;
  background-color: var(--tint-blue); background-size: cover; background-position: center;
  font: inherit;
}
.frame-start::before { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, .45); }
.frame-start > * { position: relative; }
.coin-btn {
  width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center;
  background: var(--pink); color: var(--pink-ink);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, .7), 0 8px 0 color-mix(in srgb, var(--pink) 60%, #7a1d47);
  font: 700 24px/1 var(--display);
  transition: transform .15s ease;
}
.frame-start:hover .coin-btn { transform: scale(1.06) rotate(-4deg); }
.frame-start:focus-visible { outline: none; }
.frame-start:focus-visible .coin-btn { outline: 3px solid var(--blue); outline-offset: 10px; }
.frame-hint {
  font: 600 15px/1.4 var(--display); background: rgba(255, 255, 255, .85); color: #2e2a4f;
  padding: 6px 14px; border-radius: 999px;
}

.info {
  display: grid; gap: 28px; margin-top: 36px;
  border-top: 2px dashed var(--line); padding-top: 28px;
}
@media (min-width: 760px) { .info { grid-template-columns: 1fr 1fr; gap: 48px; } }
.info h2 { margin: 0 0 12px; font: 700 22px/1.2 var(--display); }
.info p { margin: 0; max-width: 62ch; }
.how { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 10px; }
.how li { position: relative; padding-left: 28px; max-width: 60ch; }
.how li::before {
  content: ""; position: absolute; left: 0; top: .42em; width: 14px; height: 14px; border-radius: 50%;
  background: var(--pink);
}
.how li:nth-child(2n)::before { background: var(--blue); border-radius: 4px; }
.more { margin-top: 12px; }
.more h2 { margin: 0 0 16px; font: 700 24px/1.2 var(--display); }

/* ---------- Text pages (About, Privacy, 404) ---------- */
.prose { max-width: 70ch; padding-block: clamp(28px, 5vw, 56px); }
.prose h1 { font: 700 clamp(32px, 5vw, 46px)/1.08 var(--display); margin: 0 0 8px; text-wrap: balance; }
.prose h2 { font: 700 22px/1.25 var(--display); margin: 36px 0 10px; }
.prose p, .prose li { color: var(--text); }
.prose .meta {
  display: inline-block; font: 600 14px var(--display); color: var(--muted);
  background: var(--tint-blue); padding: 5px 12px; border-radius: 999px; margin: 0 0 28px;
}
.prose ul { padding-left: 22px; }
.callout {
  border: 2px solid var(--line); border-radius: var(--r); padding: 16px 18px; background: var(--tint-pink);
}
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.copy-row code {
  font: 700 15px var(--body); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 999px; user-select: all; overflow-wrap: anywhere;
}
.big-404 { font: 700 clamp(56px, 16vw, 120px)/1 var(--display); color: var(--pink); margin: 0; }

/* ---------- Footer ---------- */
.foot { margin-top: 56px; background: var(--tint-pink); border-top: 2px solid var(--line); }
.foot-in {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 24px;
  padding-block: 24px calc(24px + env(safe-area-inset-bottom, 0px));
}
.foot p { margin: 0; color: var(--muted); font-size: 14px; }
.foot-brand { font: 600 16px var(--display); color: var(--text) !important; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot nav a { color: var(--text); font-size: 14px; }
.foot-small { width: 100%; }

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