/* Simply Draw — playful, kid-friendly, blue + pink. No external fonts so it works offline anywhere. */
:root {
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --pink: #ec4899;
  --pink-dark: #db2777;
  --ink: #1f2937;
  --muted: #6b7280;
  --paper: #ffffff;
  --bg: #f4f7ff;
  --faded: #d6dbe6;        /* already-drawn strokes */
  --shadow: 0 6px 18px rgba(59, 130, 246, 0.12);
  --radius: 22px;
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", "Nunito", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

body {
  background-image:
    radial-gradient(circle at 12% 8%, rgba(236, 72, 153, 0.10), transparent 38%),
    radial-gradient(circle at 88% 92%, rgba(59, 130, 246, 0.12), transparent 40%);
  background-attachment: fixed;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin: 0 auto; }
.brand-mark { width: 38px; height: 38px; flex: none; filter: drop-shadow(0 3px 6px rgba(59,130,246,.35)); }
.brand-name { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.5px; color: var(--blue); }
.brand-pink { color: var(--pink); }
.back-btn, .brand-spacer { min-width: 64px; }
.brand-spacer { display: block; }
.back-btn {
  appearance: none; border: none; background: #eef2ff; color: var(--blue-dark);
  font-weight: 700; font-size: 1rem; padding: 9px 14px; border-radius: 14px; cursor: pointer;
}
.back-btn:active { transform: scale(0.96); }

/* ---------- Layout ---------- */
.view { max-width: 880px; margin: 0 auto; padding: 18px 16px 64px; padding-bottom: max(64px, env(safe-area-inset-bottom)); }

.hero { text-align: center; margin: 14px 0 26px; }
.hero h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); margin: 0 0 6px; letter-spacing: -1px; }
.hero h1 .b { color: var(--blue); } .hero h1 .p { color: var(--pink); }
.hero p { color: var(--muted); margin: 0; font-size: 1.05rem; }

.section-title { font-size: 1.15rem; font-weight: 800; margin: 6px 4px 14px; color: var(--ink); }
.crumb { color: var(--muted); font-weight: 600; margin: 0 4px 14px; }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.card {
  border: none; text-align: left; cursor: pointer;
  background: var(--paper); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease;
  display: flex; flex-direction: column; gap: 8px; color: inherit; text-decoration: none;
}
.card:active { transform: scale(0.97); }
@media (hover: hover) { .card:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(59,130,246,.18); } }

.cat-card .emoji { font-size: 2.6rem; line-height: 1; }
.cat-card .cat-name { font-weight: 800; font-size: 1.15rem; }
.cat-card .cat-blurb { color: var(--muted); font-size: .9rem; }
.cat-card { border-top: 5px solid var(--blue); }
.cat-card:nth-child(even) { border-top-color: var(--pink); }
.cat-count { font-size: .8rem; font-weight: 700; color: var(--blue-dark); background: #eef2ff; align-self: flex-start; padding: 3px 10px; border-radius: 999px; }

/* Drawing thumbnail cards */
.draw-card { align-items: center; text-align: center; gap: 10px; }
.thumb { width: 100%; aspect-ratio: 1 / 1; background: #fbfcff; border-radius: 16px; border: 2px dashed #e3e8f4; }
.thumb svg { width: 100%; height: 100%; display: block; }
.draw-name { font-weight: 700; }
.level-row { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.level-dots { display: flex; gap: 4px; justify-content: center; }
.level-dots i { width: 8px; height: 8px; border-radius: 50%; background: #dbe3f4; display: inline-block; }
.level-dots i.on { background: var(--pink); }
.level-label { font-size: .72rem; font-weight: 700; color: var(--muted); }

/* ---------- Lesson view ---------- */
.lesson { display: flex; flex-direction: column; align-items: center; }
.lesson-head { text-align: center; margin-bottom: 10px; }
.lesson-head h2 { margin: 0; font-size: 1.6rem; }
.lesson-head .sub { color: var(--muted); font-weight: 600; }

.stage {
  width: 100%; max-width: 480px; background: var(--paper); border-radius: 26px;
  box-shadow: var(--shadow); padding: 14px; position: relative;
}
.stage svg { width: 100%; aspect-ratio: 1/1; display: block; }
.paper-bg { fill: #fcfdff; }

/* progress bar */
.progress { width: 100%; max-width: 480px; height: 10px; background: #e6ebf7; border-radius: 999px; margin: 14px 0 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--pink)); transition: width .3s ease; }
.step-count { color: var(--muted); font-weight: 700; margin-bottom: 6px; }

.hint {
  max-width: 480px; width: 100%; text-align: center; font-size: 1.25rem; font-weight: 700;
  line-height: 1.35; margin: 8px 0 16px; min-height: 2.6em; color: var(--ink);
}
.hint .num {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.7em; height: 1.7em;
  background: var(--pink); color: #fff; border-radius: 50%; font-size: .8em; margin-right: 8px; vertical-align: middle;
}

.controls { display: flex; gap: 12px; width: 100%; max-width: 480px; }
.btn {
  flex: 1; appearance: none; border: none; cursor: pointer; font-weight: 800; font-size: 1.1rem;
  padding: 16px; border-radius: 18px; transition: transform .1s ease, opacity .1s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary.finish { background: var(--pink); }
.btn-ghost { background: #eef2ff; color: var(--blue-dark); flex: 0 0 30%; }

.tip { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; color: var(--muted); font-weight: 600; font-size: .95rem; text-align: center; }

.done-banner {
  text-align: center; margin-top: 18px; background: linear-gradient(120deg, #eef2ff, #fdf2f8);
  border-radius: 20px; padding: 18px; max-width: 480px; width: 100%;
}
.done-banner .big { font-size: 2.4rem; }
.done-banner p { margin: 6px 0 0; font-weight: 700; color: var(--ink); }

/* drawing strokes */
.stroke { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.stroke.done { stroke: var(--faded); stroke-width: 3; }
.stroke.live { stroke: var(--blue); stroke-width: 5; }
.fill.done { fill: var(--faded); stroke: none; }
.fill.live { fill: var(--pink); stroke: none; }
/* construction guide lines — faint dashed, drawn light then "erased" mentally */
.guide { fill: none; stroke: #c2cde6; stroke-width: 1.6; stroke-dasharray: 4 5; stroke-linecap: round; }
.guide.live { stroke: #93a6d6; stroke-width: 2; }

/* draw-on animation for the live step */
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.live { animation: pop .35s ease; transform-origin: center; transform-box: fill-box; }

.empty { text-align: center; color: var(--muted); padding: 40px; }

@media (prefers-reduced-motion: reduce) {
  .live { animation: none; }
  .card, .btn, .progress > span { transition: none; }
}
