@font-face {
  font-family: "Fredoka";
  src: url("../fonts/Fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --navy: #1e3a5f;
  --navy-2: #16304f;
  --teal: #2a9d8f;
  --coral: #e76f51;
  --gold: #f0c14b;
  --pink: #f7b2bd;
  --cream: #fff6e0;
  --paper: #fffdf8;
  --ink: #1c2430;
  --muted: #5b6573;
  --shadow: 0 8px 24px rgba(30, 58, 95, 0.12);
  --tap: 56px;
  --radius: 22px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Fredoka", "Nunito", system-ui, sans-serif;
  background: linear-gradient(180deg, #fff6e0 0%, #fde8c8 40%, #f7d7b0 100%);
  color: var(--ink);
  overflow: hidden;
}

#app { height: 100%; display: flex; flex-direction: column; max-width: 900px; margin: 0 auto; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 8px;
  background: var(--navy);
  color: #fff;
  min-height: 58px;
}
.topbar img.logo-maya { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--gold); background: #fff; }
.topbar h1 { font-size: 1.05rem; margin: 0; font-weight: 600; line-height: 1.15; flex: 1; }
.topbar h1 span { display: block; font-size: 0.75rem; font-weight: 400; color: #ffd98a; }
.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  border: 0; border-radius: 16px;
  background: rgba(255,255,255,0.12);
  color: #fff; font-size: 1.2rem; cursor: pointer;
  display: grid; place-items: center;
  font-family: inherit;
}
.icon-btn.on { background: var(--teal); }
.icon-btn:active { transform: scale(0.96); }
.star-chip {
  display: flex; align-items: center; gap: 4px;
  background: rgba(240, 193, 75, 0.2);
  border-radius: 999px; padding: 6px 10px;
  font-weight: 600; color: var(--gold);
}
.star-chip img { width: 22px; height: 22px; }

/* Screens */
.screens { flex: 1; overflow: auto; position: relative; -webkit-overflow-scrolling: touch; }
.screen { display: none; padding: 14px 14px 24px; }
.screen.active { display: block; }
.screen.paint-screen { padding: 8px 8px 16px; }

/* Home hero */
.hero {
  display: flex; gap: 12px; align-items: center;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.hero img { width: 92px; height: 92px; border-radius: 50%; border: 3px solid var(--gold); }
.hero p { margin: 0; font-size: 1.05rem; line-height: 1.35; }
.hero strong { color: var(--navy); }

.progress-card, .card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.progress-card h2, .section-title {
  margin: 0 0 8px; font-size: 1.15rem; color: var(--navy);
}
.bar { height: 14px; background: #efe4c8; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), #7ed3c5); border-radius: 99px; width: 0%; transition: width .3s; }
.hint { color: var(--muted); font-size: 0.92rem; margin: 8px 0 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.page-card, .pack-card, .story-card, .badge-card {
  background: var(--paper);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  border: 0;
  padding: 0;
  text-align: left;
  font-family: inherit;
  color: inherit;
  width: 100%;
}
.page-card img.thumb, .pack-card img.thumb { width: 100%; aspect-ratio: 3/4; object-fit: cover; background: #fff; display: block; }
.page-card .meta, .pack-card .meta, .story-card .meta { padding: 8px 10px 10px; }
.page-card h3, .pack-card h3, .story-card h3 { margin: 0 0 2px; font-size: 0.98rem; color: var(--navy); }
.tag { display: inline-block; font-size: 0.75rem; font-weight: 600; border-radius: 999px; padding: 2px 8px; margin-top: 4px; }
.tag.free { background: #d6f5ee; color: #0d6b5e; }
.tag.locked { background: #eee; color: #666; }
.tag.prize { background: #fff1c2; color: #8a5a00; }
.tag.pack { background: #fde0d6; color: #9a3b22; }
.tag.done { background: #e1f0c8; color: #3b6b10; }
.lock-veil { position: relative; }
.lock-veil::after {
  content: "🔒";
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(255,255,255,0.55); font-size: 1.8rem;
}

/* Bottom nav */
.nav {
  display: flex; background: var(--navy); color: #fff;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav button {
  flex: 1; border: 0; background: transparent; color: #d7e0ec;
  font-family: inherit; font-size: 0.72rem; font-weight: 600;
  min-height: 58px; cursor: pointer; border-radius: 14px;
}
.nav button .ico { display: block; font-size: 1.35rem; line-height: 1.1; }
.nav button.active { background: rgba(255,255,255,0.12); color: var(--gold); }

/* Paint */
.paint-head {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px 8px;
}
.paint-head h2 { flex: 1; margin: 0; font-size: 1.05rem; color: var(--navy); }
.paint-stats { font-size: 0.85rem; color: var(--muted); }
.canvas-wrap {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow);
  overflow: hidden; position: relative; touch-action: none;
}
#paintCanvas { display: block; width: 100%; height: auto; cursor: pointer; }
#biscuitEl {
  position: absolute; width: 44px; height: 44px; cursor: pointer;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.25));
  transition: transform .15s;
  z-index: 3;
}
#biscuitEl.found { transform: scale(1.3); opacity: 0; pointer-events: none; }

.palette {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 4px 8px;
  -webkit-overflow-scrolling: touch;
}
.swatch {
  flex: 0 0 auto;
  width: 58px; height: 58px; border-radius: 50%;
  border: 4px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.18);
  cursor: pointer; position: relative;
  font-family: inherit; font-weight: 700; font-size: 1.1rem;
  color: #1c2430;
  text-shadow: 0 1px 0 rgba(255,255,255,.6);
}
.swatch.selected { outline: 4px solid var(--navy); transform: scale(1.08); }
.swatch.done::after {
  content: "✓"; position: absolute; right: -2px; bottom: -2px;
  background: var(--teal); color: #fff; width: 18px; height: 18px;
  border-radius: 50%; font-size: 12px; display: grid; place-items: center;
}
.toolbar { display: flex; gap: 8px; padding: 4px; }
.toolbar button, .btn {
  min-height: var(--tap); border: 0; border-radius: 16px;
  padding: 0 16px; font-family: inherit; font-weight: 600;
  font-size: 1rem; cursor: pointer;
}
.btn.primary { background: var(--teal); color: #fff; }
.btn.navy { background: var(--navy); color: #fff; }
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.ghost { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.btn.wide { width: 100%; margin-top: 8px; }

.combo { min-height: 24px; text-align: center; font-weight: 600; color: var(--coral); }

/* Overlays */
.overlay {
  display: none; position: fixed; inset: 0; background: rgba(20, 30, 45, 0.55);
  z-index: 40; align-items: center; justify-content: center; padding: 18px;
}
.overlay.show { display: flex; }
.modal {
  background: var(--paper); border-radius: 24px; padding: 20px;
  width: min(440px, 100%); max-height: 90vh; overflow: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,.25); text-align: center;
}
.modal img.maya { width: 88px; height: 88px; border-radius: 50%; }
.modal h2 { margin: 8px 0 6px; color: var(--navy); }
.modal p { margin: 0 0 12px; }
.code-row { display: flex; gap: 8px; margin: 10px 0; }
.code-row input {
  flex: 1; min-height: var(--tap); border: 2px solid #e6d9b8; border-radius: 14px;
  padding: 0 12px; font-family: inherit; font-size: 1rem;
}
.stars-row img { width: 36px; height: 36px; }

/* Now playing dock */
.nowplay {
  display: none; align-items: center; gap: 8px;
  background: var(--navy-2); color: #fff;
  padding: 6px 10px;
  font-size: 0.85rem;
}
.nowplay.show { display: flex; }
.nowplay strong { color: var(--gold); font-weight: 600; }
.nowplay .grow { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.timer {
  font-weight: 700; color: var(--coral); min-width: 64px; text-align: right;
}

.pack-card .price { color: var(--coral); font-weight: 600; font-size: 0.9rem; }
.story-card { display: flex; align-items: center; gap: 10px; padding: 10px; }
.story-card .num {
  width: 48px; height: 48px; border-radius: 14px; background: var(--teal);
  color: #fff; display: grid; place-items: center; font-size: 1.2rem; font-weight: 700;
}

.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.badge-card { padding: 12px; text-align: center; }
.badge-card.off { opacity: 0.45; filter: grayscale(1); }
.badge-card .emoji { font-size: 1.8rem; }

.kofi-note { font-size: 0.88rem; color: var(--muted); }

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .topbar h1 { font-size: 1.2rem; }
}

/* Parent account + shop sections */
.account-btn { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.01em; min-width: 56px; padding: 0 8px; }
.account-btn.in { background: var(--teal); color: #fff; }
.account-bar {
  background: #fff7e8;
  border: 2px solid #f3d9a4;
  border-radius: 16px;
  padding: 12px 14px;
  margin: 0 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.account-bar p { margin: 0; flex: 1 1 200px; color: var(--navy); }
.account-bar .btn { min-height: 44px; }
.pass-feature {
  background: linear-gradient(135deg, #1E3A5F, #2a6f6f);
  color: #fff;
  border-radius: 20px;
  padding: 16px 16px 14px;
  margin: 0 0 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  cursor: pointer;
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
}
.pass-feature h3 { margin: 0; font-size: 1.2rem; color: #ffd98a; }
.pass-feature p { margin: 0; color: #fff; }
.pass-feature .price { color: #ffd98a; font-weight: 700; font-size: 1.05rem; }
.pass-feature .tag { display: inline-block; background: #ffd98a; color: #1E3A5F; border-radius: 999px; padding: 2px 10px; font-size: 0.8rem; font-weight: 700; margin-top: 4px; }
.form-stack { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; text-align: left; }
.form-stack label { font-weight: 600; color: var(--navy); font-size: 0.9rem; }
.form-stack input {
  min-height: 46px;
  border-radius: 12px;
  border: 2px solid #d7c4a3;
  padding: 8px 12px;
  font: inherit;
  width: 100%;
  box-sizing: border-box;
}
.form-error { color: #c0392b; font-weight: 600; min-height: 1.2em; }
.kofi-note { margin: 0 16px 12px; color: #4a3b2a; }
#shopBooks, #shopStories, #shopSongs { margin-bottom: 18px; }
.pack-card .price { color: var(--coral); font-weight: 700; }
.pack-card .price.yours { color: #2a6f6f; }

.pack-card.coming-soon {
  cursor: default;
  opacity: 0.92;
  background: #f7f3ea;
}
.pack-card.coming-soon .price,
.pack-card .price.soon {
  color: #6b5a43;
  font-weight: 700;
}
.pack-card .tag.soon {
  background: #e8dcc4;
  color: #4a3b2a;
}

.pack-card .buy-kofi,
.pass-feature .buy-kofi {
  display: inline-block;
  width: auto;
  margin-top: 8px;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  min-height: 44px;
  padding: 8px 12px;
}
.pack-card .buy-kofi { width: 100%; }

/* Keep the bottom tabs above the "Powered by Netlify" badge on phones */
.nav { padding-bottom: calc(52px + env(safe-area-inset-bottom)); }
