﻿/* Let's Draw Animals: bright, touch-first styles */
:root {
  --bg: #fff6d9;
  --card: #ffffff;
  --ink: #3f3252;
  --soft: #7d6f8f;
  --line: #f0e3c4;
  --accent: #ff9f43;
  --accent-bg: #fff1e0;
  --green: #2fc46f;
  --green-dark: #1f9a53;
  --pink: #ff6f9a;
  --shadow: 0 5px 0 rgba(120, 90, 40, .13), 0 10px 22px rgba(120, 90, 40, .12);
  font-family: Fredoka, 'Comic Sans MS', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100vh; min-height: 100dvh; color: var(--ink); display: flex; flex-direction: column;
  background:
    radial-gradient(circle at 22px 22px, rgba(255, 159, 67, .12) 5px, transparent 6px) 0 0 / 88px 88px,
    radial-gradient(circle at 66px 66px, rgba(91, 184, 255, .12) 5px, transparent 6px) 0 0 / 88px 88px,
    linear-gradient(#fff9e6, #ffefc9) fixed; }
h1, h2, p { margin: 0; }
h1, h2 { font-weight: 700; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; border: 0; }
button:disabled { cursor: default; opacity: .4; }
button:focus-visible, a:focus-visible { outline: 4px solid #5bb8ff; outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: #d4682a; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; max-width: 1240px; width: 100%; margin: 0 auto; }
.title { font-size: clamp(20px, 5vw, 30px); color: var(--accent); text-shadow: 0 2px 0 #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { text-decoration: none; font-weight: 600; color: var(--soft); background: var(--card); border-radius: 999px; padding: 10px 16px; box-shadow: var(--shadow); min-height: 48px; display: inline-flex; align-items: center; white-space: nowrap; }
.top-btns { display: flex; gap: 8px; }
.icon-btn { width: 48px; height: 48px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 22px; }
.icon-btn.off { opacity: .45; filter: grayscale(1); }

.app { width: 100%; max-width: 1240px; margin: 0 auto; padding: 4px 12px 12px; flex: 1; }

/* ---------- buttons ---------- */
.btn { min-height: 56px; padding: 10px 20px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); font-size: 20px; font-weight: 600; transition: transform .1s; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 rgba(120, 90, 40, .15); }
.btn.primary { background: var(--green); color: #fff; box-shadow: 0 5px 0 var(--green-dark), 0 10px 22px rgba(31, 154, 83, .25); }
.pill { min-height: 44px; padding: 6px 14px; border-radius: 999px; background: var(--accent-bg); font-size: 16px; font-weight: 600; }

/* ---------- pick screen ---------- */
.pick-hello { text-align: center; padding: 8px 4px 16px; }
.pick-hello h2 { font-size: clamp(26px, 6vw, 40px); color: var(--ink); }
.pick-hello p { color: var(--soft); font-size: clamp(16px, 3.6vw, 20px); margin-top: 4px; }
.animal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 44vw), 1fr)); gap: 14px; }
.animal-card { position: relative; background: var(--card); border-radius: 28px; box-shadow: var(--shadow); padding: 10px 10px 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform .12s; }
.animal-card:hover { transform: translateY(-3px) rotate(-1deg); }
.animal-card:active { transform: scale(.97); }
.animal-card svg { width: 100%; aspect-ratio: 1; border-radius: 20px; background: var(--abg); }
.animal-card .name { font-size: clamp(20px, 4.4vw, 26px); font-weight: 700; color: var(--acol); }
.animal-card .meta { font-size: 14px; color: var(--soft); }
.animal-card .badge { position: absolute; top: 4px; right: 4px; background: #ffd43b; color: #6b4a00; border-radius: 999px; padding: 4px 10px; font-size: 15px; font-weight: 700; box-shadow: 0 3px 0 #e0a800; transform: rotate(8deg); }

/* ---------- draw screen ---------- */
.draw { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "side" "board" "nav" "tools"; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.board-wrap { grid-area: board; display: flex; justify-content: center; align-items: flex-start; min-width: 0; }
.tools-area { grid-area: tools; position: relative; z-index: 5; }
.nav-area { grid-area: nav; position: relative; z-index: 5; }
.nav { display: flex; gap: 10px; }

.coach { background: var(--card); border-radius: 26px; box-shadow: var(--shadow); padding: 12px 14px; border: 4px solid var(--accent); }
.coach.pop { animation: pop .45s ease; }
.step-count { font-size: 15px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.say-row { display: flex; gap: 12px; align-items: center; margin: 4px 0 8px; }
.step-icon { flex: none; width: 54px; height: 54px; border-radius: 18px; background: var(--accent-bg); display: grid; place-items: center; font-size: 30px; }
.say { font-size: clamp(19px, 4.2vw, 24px); font-weight: 500; line-height: 1.25; }
.coach-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.steps { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.steps button { min-width: 44px; height: 44px; border-radius: 14px; background: var(--card); box-shadow: 0 3px 0 rgba(120, 90, 40, .13); font-size: 20px; position: relative; padding: 0 6px; }
.steps button.done { background: #e4f8ec; }
.steps button.done::after { content: '✓'; position: absolute; right: -4px; top: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--green); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.steps button.star::after { content: '⭐'; background: none; font-size: 16px; }
.steps button.now { background: var(--accent); box-shadow: 0 3px 0 rgba(0, 0, 0, .15), 0 0 0 4px #fff, 0 0 0 7px var(--accent); }

.board { --bs: min(100%, calc(100dvh - 400px)); width: max(260px, var(--bs)); aspect-ratio: 1; position: relative; background: #fff; border-radius: 26px; box-shadow: var(--shadow), inset 0 0 0 4px var(--line); overflow: hidden; }
.board svg, .board canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.board canvas { touch-action: none; cursor: crosshair; }
.board svg { transition: opacity .3s; }
.board.no-guide svg { opacity: 0; }

/* guide parts */
.part path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.part .dot { stroke: none; }
.part.future path { stroke: #d6d6dc; stroke-width: 4; }
.part.future .dot { fill: #e2e2e7; }
.part.done path { stroke: #a9a9b4; stroke-width: 4.5; }
.part.done .dot { fill: #b8b8c2; }
.part.now path { stroke: var(--accent); stroke-width: 7; stroke-dasharray: 2 13; animation: march 1s linear infinite; }
.part.now .dot { fill: var(--accent); opacity: .35; animation: blink 1.2s ease-in-out infinite; }
.part.now path.demo { stroke-dasharray: var(--len) var(--len); stroke-dashoffset: var(--len); stroke-width: 9; opacity: .85; animation: demo var(--dur, 1.4s) ease-in-out var(--delay, 0s) forwards, fade .5s ease var(--fade, 2s) forwards; }
.pen { font-size: 34px; }
@keyframes march { to { stroke-dashoffset: -15; } }
@keyframes blink { 50% { opacity: .75; } }
@keyframes demo { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 0; } }
@keyframes pop { 0% { transform: scale(.94); } 55% { transform: scale(1.03); } 100% { transform: scale(1); } }

/* praise bubble: pops up just under the crayon panel, never over the drawing */
.praise { position: absolute; left: 50%; top: calc(100% + 12px); transform: translateX(-50%) scale(.4); opacity: 0; pointer-events: none; width: max-content; max-width: 100%;
  background: #fff; border: 5px solid #ffd43b; color: var(--ink); border-radius: 28px; padding: 14px 20px; text-align: center; font-size: clamp(22px, 5vw, 32px); font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.praise small { display: block; font-size: .6em; font-weight: 500; color: var(--soft); }
.praise.show { animation: praise 1.9s ease forwards; }
.praise.mini { font-size: clamp(18px, 4vw, 24px); border-color: var(--green); padding: 8px 16px; }
@keyframes praise {
  0% { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(.4) rotate(-6deg); }
  14% { opacity: 1; transform: translateX(-50%) scale(1.08) rotate(2deg); }
  22% { transform: translateX(-50%) scale(1) rotate(0); }
  80% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(8px) scale(.9); }
}

/* tools */
.tools { background: var(--card); border-radius: 26px; box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.colors { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.colors button { width: 44px; height: 44px; border-radius: 50%; background: var(--c); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18); transition: transform .1s; }
.colors button[aria-checked="true"] { transform: scale(1.18); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18), 0 0 0 4px #fff, 0 0 0 7px var(--c); }
.colors button.white { box-shadow: inset 0 0 0 2px #ddd, inset 0 -4px 0 rgba(0, 0, 0, .1); }
.tool-row { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
.sizes { display: flex; gap: 4px; background: #f6f1e6; border-radius: 16px; padding: 4px; }
.sizes button { width: 48px; height: 48px; border-radius: 12px; background: transparent; display: grid; place-items: center; }
.sizes button i { width: var(--d); height: var(--d); border-radius: 50%; background: var(--ink); }
.sizes button[aria-checked="true"] { background: #fff; box-shadow: 0 2px 0 rgba(0, 0, 0, .1); }
.tool { min-width: 64px; height: 56px; border-radius: 16px; background: #f6f1e6; font-size: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; padding: 4px 8px; }
.tool span { font-size: 12px; font-weight: 600; color: var(--soft); margin-top: 3px; }
.tool[aria-pressed="true"] { background: #ffe1ec; box-shadow: 0 0 0 3px var(--pink); }

/* step navigation */
.nav-prev { flex: none; width: 64px; padding: 0; font-size: 22px; }
.nav-next { flex: 1; background: var(--green); color: #fff; font-size: clamp(22px, 5vw, 28px); box-shadow: 0 5px 0 var(--green-dark), 0 10px 22px rgba(31, 154, 83, .25); }
.nav-next.wiggle { animation: wiggle 1.4s ease-in-out infinite; }
@keyframes wiggle { 0%, 60%, 100% { transform: rotate(0) scale(1); } 70% { transform: rotate(-2deg) scale(1.04); } 80% { transform: rotate(2deg) scale(1.04); } 90% { transform: rotate(-1deg) scale(1.02); } }

/* finished */
.finish { background: var(--card); border-radius: 26px; box-shadow: var(--shadow); padding: 14px; text-align: center; border: 4px solid #ffd43b; animation: pop .5s ease; }
.finish-big { font-size: 46px; line-height: 1; animation: bounce 1s ease infinite alternate; }
.finish h2 { font-size: clamp(26px, 6vw, 36px); color: var(--accent); }
.finish p { font-size: 19px; color: var(--soft); margin: 2px 0 10px; }
.finish-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.finish-btns .btn { font-size: 17px; min-height: 52px; padding: 8px 10px; }
@keyframes bounce { to { transform: translateY(-6px) scale(1.08); } }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(60, 40, 80, .35); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-box { background: #fff; border-radius: 28px; padding: 22px; max-width: 380px; width: 100%; text-align: center; box-shadow: 0 14px 40px rgba(0, 0, 0, .25); animation: pop .35s ease; }
.modal-box p { font-size: 24px; font-weight: 600; margin-bottom: 16px; }
.modal-btns { display: flex; gap: 10px; }
.modal-btns .btn { flex: 1; }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti i { position: absolute; top: -40px; font-style: normal; font-size: 26px; animation: fall var(--t, 2.6s) cubic-bezier(.3, .2, .6, 1) var(--d, 0s) forwards; }
@keyframes fall { to { transform: translate(var(--x, 0), 110vh) rotate(var(--r, 360deg)); } }

.site-footer { text-align: center; padding: 14px 12px 20px; color: var(--soft); font-size: 14px; }
.site-footer a { color: var(--soft); }

/* ---------- wide screens and tablets held sideways: board left, everything else right ---------- */
@media (min-width: 700px) and (min-aspect-ratio: 1/1) {
  .draw { grid-template-columns: auto minmax(300px, 1fr); grid-template-rows: auto auto 1fr; align-items: start;
    grid-template-areas: "board side" "board nav" "board tools"; }
  .board { --bs: min(calc(100dvh - 90px), calc(100vw - 420px), 760px); width: max(300px, var(--bs)); }
  /* keep the crayon panel short so the praise bubble fits under it */
  .tool-row { gap: 6px; flex-wrap: nowrap; }
  .tool { min-width: 52px; padding: 4px 6px; }
  .sizes button { width: 42px; }
  .colors { gap: 6px; }
  .colors button { width: 40px; height: 40px; }
  .praise { top: calc(100% + 8px); padding: 8px 16px; font-size: clamp(20px, 2.4vw, 26px); }
}
/* phones held sideways */
@media (orientation: landscape) and (max-height: 500px) {
  .draw { grid-template-columns: auto minmax(260px, 1fr); grid-template-areas: "board side" "board nav" "board tools"; align-items: start; gap: 8px; }
  .board { --bs: calc(100dvh - 76px); width: max(220px, var(--bs)); }
  .say { font-size: 18px; }
  .step-icon { width: 42px; height: 42px; font-size: 24px; }
  .coach { padding: 8px 10px; }
  .colors button { width: 36px; height: 36px; }
  .steps { display: none; }
}
@media (max-width: 420px) {
  .wide-only { display: none; }
  .steps { gap: 4px; }
  .steps button { min-width: 38px; height: 40px; font-size: 18px; border-radius: 12px; padding: 0 4px; }
  .colors button { width: 38px; height: 38px; }
  .tool { min-width: 56px; }
  .sizes button { width: 42px; }
}
.praise-slot { display: none; }
/* ---------- one column (phones and tablets held upright): the praise bubble gets its own
   reserved row between the drawing and the Next button, so nothing jumps when it pops up ---------- */
@media (max-aspect-ratio: 999/1000) {
  .draw { grid-template-areas: "side" "board" "praise" "nav" "tools"; }
  .tools-area { display: contents; }
  .tools { grid-area: tools; }
  .praise { grid-area: praise; position: relative; top: 0; left: 50%; justify-self: start; align-self: center; margin: -4px 0; }
  .praise-slot { display: block; grid-area: praise; height: 64px; }
  .board { --bs: min(100%, calc(100dvh - 440px)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .part.now path.demo { display: none; }
}
