/* Coloring Pages: a warm cream table, white paper, chunky wooden-toy buttons. Calm by design: soft colors, nothing
   moves on its own, the few fades are 0.4 to 0.8 s, nothing loops or flashes. The canvas alone takes every touch
   (touch-action: none) so drawing never scrolls the page; everywhere else the page scrolls as usual. */
:root {
  --table: #f6efe2;
  --table-2: #efe4cf;
  --card: #fffdf7;
  --ink: #3b2a1a;
  --soft: #6d6250;
  --blue: #3f7fc4;
  --blue-d: #1f5fa8;
  --green: #3fa34d;
  --green-d: #2a7a36;
  --sun: #f4c55a;
  --radius: 20px;
  color-scheme: light;
}
/* Evening: dimmer and warmer (rule 4). The paper stays white so colors read true; the room around it dims. */
body.evening { --table: #e6dcc8; --table-2: #dacdb4; --card: #f6eedc; --green: #3d8a47; }
body.evening main, body.evening .top { filter: brightness(.9); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: radial-gradient(circle at 12% 8%, #fbf7ef 0 14%, transparent 15%), radial-gradient(circle at 92% 40%, var(--table-2) 0 11%, transparent 12%), var(--table);
  color: var(--ink);
  font: 500 18px/1.45 'Fredoka', system-ui, sans-serif;
  overscroll-behavior: none;
  overflow-x: hidden;
}
h1, h2 { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; line-height: 1.1; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
a { color: var(--blue-d); }

/* top bar */
.top { display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 16px 6px; min-height: 64px; }
.grow { flex: 1; }
.brand { display: inline-flex; }
.back, .round {
  min-height: 48px; min-width: 48px; border: 3px solid var(--ink); border-radius: 16px; background: var(--card);
  box-shadow: 0 4px 0 var(--ink); font-weight: 700; padding: 6px; display: inline-flex; align-items: center; justify-content: center;
}
.back:active, .round:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
#sound .mute { display: none; }
#sound[aria-pressed='false'] .mute { display: inline; }
#sound[aria-pressed='false'] .waves { display: none; }

main { max-width: 1600px; margin: 0 auto; padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }
.screen { display: grid; gap: 18px; min-width: 0; }
.screen:not([hidden]) { animation: fade-in .5s ease-in-out both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
body.still .screen { animation: none; }

/* home */
.hero { text-align: center; display: grid; gap: 8px; justify-items: center; padding-top: 4px; }
.hero h1 { font-size: clamp(34px, 10vw, 54px); }
.lede { margin: 0; font-size: 20px; color: var(--soft); max-width: 640px; }
.hero-art { width: 120px; height: 120px; }

.big {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 76px;
  border: 3px solid var(--ink); border-radius: 24px; font-size: 30px; font-weight: 700; box-shadow: 0 7px 0 var(--ink); padding: 10px 20px;
}
.big:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.big.go { background: var(--green); color: #fff; text-shadow: 0 2px 0 #0003; }
.big.plain { background: var(--card); font-size: 24px; min-height: 64px; }

.pick { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; min-width: 0; }
.pick legend { font-weight: 700; font-size: 18px; margin-bottom: 8px; padding: 0; }
.pick button {
  border: 3px solid var(--ink); border-radius: 18px; background: var(--card); box-shadow: 0 4px 0 var(--ink); padding: 10px 4px;
  display: grid; justify-items: center; align-content: start; gap: 4px; font-weight: 700; font-size: 20px; line-height: 1.15; min-height: 96px;
}
.pick button small { font-size: 14px; font-weight: 500; color: var(--soft); }
.pick button[aria-pressed='true'] { background: #dff3e1; border-color: var(--green-d); box-shadow: 0 4px 0 var(--green-d); outline: 3px solid var(--green); outline-offset: 1px; }
.pick button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
/* Level marks: one, two, three dots, so the level reads without color. */
.lv-dot { display: block; height: 14px; background: radial-gradient(circle, var(--ink) 0 5px, transparent 6px) 0 0 / 16px 14px repeat-x; }
.lv-1 { width: 16px; }
.lv-2 { width: 32px; }
.lv-3 { width: 48px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { width: 100%; }
.chips button { display: inline-flex; min-height: 48px; padding: 6px 14px; font-size: 18px; align-items: center; }

.grownups, .about { background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 5px 0 #3b2a1a33; }
.grownups summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.grownups p, .about p { margin: 10px 0 0; }
.gu-h { font-size: 22px; margin-top: 16px; }
.private { color: var(--green-d); }
.pill { margin-top: 10px; min-height: 56px; padding: 6px 20px; border: 3px solid var(--ink); border-radius: 999px; background: #e7f4e8; font-weight: 700; font-size: 19px; box-shadow: 0 4px 0 var(--ink); }
.pill:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.about h2 { font-size: 22px; margin-top: 14px; }
.about h2:first-child { margin-top: 0; }
.about h3 { font-size: 18px; margin: 12px 0 0; }
.about ul { padding-left: 22px; display: grid; gap: 6px; }
.small { font-size: 14px; color: var(--soft); }

/* pick a page */
.pick-title { font-size: 30px; text-align: center; }
.cats { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.cats button { min-height: 52px; padding: 6px 16px; border: 3px solid var(--ink); border-radius: 999px; background: var(--card); font-weight: 700; font-size: 18px; box-shadow: 0 3px 0 var(--ink); }
.cats button[aria-pressed='true'] { background: #fde7b0; outline: 3px solid var(--sun); outline-offset: 1px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.thumb {
  display: grid; gap: 4px; justify-items: center; align-content: start; padding: 8px; min-height: 150px;
  border: 3px solid var(--ink); border-radius: 18px; background: #fff; box-shadow: 0 4px 0 var(--ink); font-weight: 700; font-size: 17px; letter-spacing: .04em;
}
.thumb:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.thumb img { width: 100%; aspect-ratio: 1000 / 780; object-fit: contain; }
.thumbs.art .thumb img { aspect-ratio: 1; }
.thumb.add { background: #f2f8ee; border-style: dashed; align-content: center; letter-spacing: 0; }
.thumb .plus { font-size: 54px; line-height: 1; }
.empty { grid-column: 1 / -1; margin: 0; color: var(--soft); }

/* coloring */
.studio { display: grid; gap: 12px; justify-items: center; }
.paper-wrap { position: relative; width: min(100%, 72dvh, 900px); }
.paper { position: relative; width: 100%; aspect-ratio: 1; background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 6px 0 #3b2a1a55; overflow: hidden; }
.paper canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#wet, #paint { pointer-events: none; }
/* Only the page itself takes the finger: drawing never scrolls or zooms the page. */
#lines { touch-action: none; cursor: crosshair; outline: none; }
#lines:focus-visible { box-shadow: inset 0 0 0 4px var(--blue); }
.cursor { position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px; border: 3px solid var(--blue-d); border-radius: 50%; pointer-events: none; }
.cursor.down { background: #3f7fc455; }
.making { position: absolute; inset: auto 0 40%; margin: 0; text-align: center; font-weight: 700; color: var(--soft); }
.making[hidden] { display: none; }
.hear {
  position: absolute; right: -6px; bottom: -6px; width: 60px; height: 60px; border-radius: 50%; background: var(--sun);
  border: 3px solid var(--ink); display: grid; place-items: center; box-shadow: 0 4px 0 var(--ink);
}
.hear:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.kit { width: min(100%, 900px); display: grid; gap: 10px; }
.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(54px, 1fr)); gap: 8px; }
.tools button {
  min-height: 64px; border: 3px solid var(--ink); border-radius: 16px; background: var(--card); box-shadow: 0 3px 0 var(--ink);
  display: grid; justify-items: center; align-content: center; gap: 0; padding: 4px 2px; font-size: 14px; font-weight: 700; line-height: 1.1;
}
.tools button[aria-pressed='true'] { background: #fde7b0; outline: 3px solid var(--sun); outline-offset: 1px; transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.sizes { display: flex; gap: 8px; }
.sizes[hidden] { display: none; }
.sizes button { flex: 1; min-height: 56px; border: 3px solid var(--ink); border-radius: 16px; background: var(--card); box-shadow: 0 3px 0 var(--ink); display: grid; place-items: center; }
.sizes button i { display: block; border-radius: 50%; background: var(--ink); }
.sizes [data-size='s'] i { width: 8px; height: 8px; }
.sizes [data-size='m'] i { width: 16px; height: 16px; }
.sizes [data-size='l'] i { width: 28px; height: 28px; }
.sizes button[aria-pressed='true'] { background: #fde7b0; outline: 3px solid var(--sun); outline-offset: 1px; }
.tools .undo { background: #eef3fb; }
.sizes button:active, .tools button:active, .swatches button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.swatches.few { grid-template-columns: repeat(5, 1fr); gap: 8px; }
.swatches button {
  aspect-ratio: 1; min-height: 40px; border: 3px solid var(--ink); border-radius: 50%; background: var(--c); box-shadow: inset 0 -5px 0 #0002, 0 3px 0 var(--ink);
  display: grid; place-items: center; padding: 0;
}
.swatches button svg { width: 60%; height: 60%; stroke: #fff; visibility: hidden; }
.swatches [data-color='yellow'] svg, .swatches [data-color='white'] svg, .swatches [data-color='peach'] svg, .swatches [data-color='lime'] svg, .swatches [data-color='pink'] svg, .swatches [data-color='sky'] svg, .swatches [data-color='gray'] svg { stroke: var(--ink); }
.swatches button[aria-pressed='true'] { outline: 4px solid var(--ink); outline-offset: 2px; }
.swatches button[aria-pressed='true'] svg { visibility: visible; }
.done-btn { min-height: 62px; font-size: 26px; }

/* All done */
#finish { text-align: center; padding-top: 10px; justify-items: center; }
#finish > * { width: min(100%, 640px); }
.cheer { font-size: clamp(32px, 9vw, 46px); }
.art-done { width: min(100%, 420px) !important; aspect-ratio: 1; background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 6px 0 #3b2a1a55; }
.used { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 4px; border: 2px solid var(--ink); border-radius: 999px; background: var(--card); font-size: 16px; }
.chip i { width: 20px; height: 20px; border-radius: 50%; background: var(--c); border: 2px solid var(--ink); }
.rest { margin: 0; font-weight: 700; color: var(--green-d); }
.talk { margin: 0; background: #f6fbf2; border: 2px dashed var(--green-d); border-radius: 16px; padding: 12px 14px; text-align: left; font-size: 18px; }
.saved { margin: 0; font-size: 16px; color: var(--soft); }

/* dialogs: My art, and the photo maker */
.art-view .card { width: min(560px, 100%); }
.art-view img { width: 100%; aspect-ratio: 1; border: 3px solid var(--ink); border-radius: 12px; background: #fff; }
.gu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo-maker .card { width: min(620px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; }
.pick-photos { display: inline-flex; align-items: center; justify-content: center; min-height: 60px; border: 3px solid var(--ink); border-radius: 16px; background: #e7f4e8; font-weight: 700; font-size: 20px; cursor: pointer; }
.pm-work { display: grid; gap: 10px; }
.pm-work[hidden] { display: none; }
.pm-count { margin: 0; font-weight: 700; }
.pm-count:empty { display: none; }
.pm-frame { position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 12px; min-height: 120px; display: grid; place-items: center; }
.pm-preview { max-width: 100%; max-height: 46dvh; display: block; }
.pm-wait { position: absolute; margin: 0; padding: 4px 12px; border-radius: 999px; background: var(--card); font-weight: 700; }
.pm-wait[hidden] { display: none; }
.pm-slider { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; font-size: 15px; }
.pm-slider input { width: 100%; min-height: 44px; accent-color: var(--green); }
.pm-word { display: grid; gap: 4px; font-size: 15px; }
.pm-word input { min-height: 48px; border: 3px solid var(--ink); border-radius: 12px; padding: 4px 12px; font: 700 22px 'Fredoka', sans-serif; text-transform: uppercase; }
.pm-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pm-note { margin: 0; font-weight: 600; color: var(--green-d); }
.pm-note:empty { display: none; }
.pm-mine { list-style: none; padding: 0 !important; margin: 0; display: grid; gap: 6px; }
.pm-mine:empty { display: none; }
.pm-mine li { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; }
.pm-mine .pm-h { display: block; font-weight: 700; }
.pm-mine img { width: 64px; height: 50px; object-fit: contain; background: #fff; border: 2px solid var(--ink); border-radius: 8px; }
.kid-dialog .pm-mine button { min-height: 44px; font-size: 16px; padding: 0 12px; }

/* Wide screens: the page on the left, the tools beside it. */
@media (min-width: 900px) {
  .studio { grid-template-columns: auto minmax(300px, 380px); align-items: start; justify-content: center; }
  .paper-wrap { width: min(calc(100dvh - 120px), calc(100vw - 480px), 900px); }
  .kit { width: 100%; }
  .tools { grid-template-columns: repeat(3, 1fr); }
  .swatches { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .swatches.few { grid-template-columns: repeat(5, 1fr); }
}
/* Phones held sideways: same idea, smaller. */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 899px) {
  .studio { grid-template-columns: auto 1fr; align-items: start; }
  .paper-wrap { width: calc(100dvh - 90px); }
  .tools { grid-template-columns: repeat(5, 1fr); }
  .tools button { min-height: 56px; }
}
