/* ==========================================================
   Drawing Focus – calm, soft, focused
   The white coloring page is the brightest thing on screen;
   everything around it is muted so attention stays on coloring.
   ========================================================== */
:root {
  --ink: #3a3557;
  --card: #ffffff;
  --mist: #f4f2f8;
  --calm: #8f86c9;
  --calm-deep: #6f66ad;
  --sage: #9fd3b8;
  --sky: #a9d6ee;
  --peach: #f7c9a8;
  --butter: #f6e3a1;
  --radius: 26px;
  --soft-shadow: 0 8px 24px rgba(40, 34, 80, 0.14);
  --font: 'Fredoka', 'Baloo 2', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* the whole app always fits the screen: no page scrolling on any device (popups scroll inside themselves) */
html, body { overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font);
  color: var(--ink);
  /* the same calm night sky as the welcome – the white page is the only bright thing */
  background: radial-gradient(ellipse at 50% 30%, #13224f 0%, #0d1838 60%, #091129 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
h1, h2 { margin: 0.2em 0; line-height: 1.15; font-weight: 600; }
h2 { font-size: clamp(1.5rem, 4.4vw, 1.9rem); }
.lead { font-size: clamp(1.05rem, 3vw, 1.2rem); line-height: 1.45; margin: 0.4em 0 1em; }
.small { font-size: 1rem; }
.muted { opacity: 0.65; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 12px 0; }

#bg-deco { display: none; }
#bg-deco i { position: absolute; animation: drift linear infinite; opacity: 0.18; }
#bg-deco .emo { font-size: clamp(24px, 4vw, 40px); font-style: normal; }
@keyframes drift { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(16px, -24px); } }
/* a still, softly twinkling star field behind the coloring page */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.5;
  background-image:
    radial-gradient(1.6px 1.6px at 22px 34px, #fff, transparent), radial-gradient(1px 1px at 128px 84px, #fff, transparent),
    radial-gradient(1.3px 1.3px at 206px 168px, #fff, transparent), radial-gradient(1px 1px at 64px 214px, #fff, transparent),
    radial-gradient(1.6px 1.6px at 266px 44px, #fff, transparent), radial-gradient(1px 1px at 300px 252px, #fff, transparent),
    radial-gradient(1.2px 1.2px at 90px 120px, #fff, transparent), radial-gradient(1.8px 1.8px at 380px 300px, #fff, transparent),
    radial-gradient(1px 1px at 420px 60px, #fff, transparent), radial-gradient(1.4px 1.4px at 180px 360px, #fff, transparent);
  background-size: 320px 280px, 320px 280px, 320px 280px, 320px 280px, 320px 280px, 320px 280px, 470px 390px, 470px 390px, 470px 390px, 470px 390px;
  animation: star-field 7s ease-in-out infinite;
}
@keyframes star-field { 50% { opacity: 0.3; } }
#app {
  position: relative; z-index: 1; display: flex; flex-direction: column;
  height: 100vh; height: 100dvh; /* dvh follows the mobile browser bars */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- buttons ---------- */
.btn {
  --b: var(--butter);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 3px solid var(--ink); border-radius: 999px; background: var(--b);
  font-weight: 600; font-size: 1.1rem; padding: 12px 24px; box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.1s, box-shadow 0.1s; text-decoration: none; color: var(--ink);
  user-select: none; min-height: 52px;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn-big { font-size: clamp(1.2rem, 3.4vw, 1.4rem); padding: 14px 38px; margin-top: 6px; }
.btn-calm { --b: var(--calm); color: #fff; }
.btn-yellow { --b: var(--butter); }
.btn-blue { --b: var(--sky); }
.btn-orange { --b: var(--peach); }
.btn-green { --b: var(--sage); }
.btn-purple { --b: var(--calm); color: #fff; }
.btn-mini { min-height: 38px; padding: 4px 14px; font-size: 0.95rem; }
.btn-ghost { background: transparent; border: none; font-weight: 600; text-decoration: underline; padding: 10px; }
.icon-btn {
  width: 46px; height: 46px; display: grid; place-items: center; font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 14px;
}
.icon-btn:active { transform: scale(0.94); }

/* ---------- top bar: logo · today's title · stars / pictures / sound ---------- */
.topbar {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  padding: 10px 16px 4px; color: #e9e6f5;
}
.logo-mark { display: block; flex: none; border-radius: 10px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 4px 14px rgba(0, 0, 0, 0.35); }
@keyframes logo-bob { 50% { transform: translateY(-3px); } }
/* wordmark: "drawing" in soft white, "focus" in rainbow letters */
.wordmark { font-size: 1.35rem; font-weight: 700; letter-spacing: 0.01em; line-height: 1; }
.wm-drawing { color: #f0edfa; }
.wm-focus span { display: inline-block; text-shadow: 0 0 12px rgba(255, 255, 255, 0.12); }
.wm-com { color: #c9c2ee; font-size: 0.7em; font-weight: 600; }
.today { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.corner { justify-self: end; display: flex; gap: 6px; align-items: center; opacity: 0.7; }
.chip {
  display: flex; align-items: center; gap: 4px; height: 42px; padding: 0 12px; font-size: 1.05rem;
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 999px;
}
.corner .icon-btn { width: 42px; height: 42px; font-size: 1.1rem; }
.chip.bump { animation: bump 0.5s; }
@keyframes bump { 40% { transform: scale(1.15); } }

/* ---------- coloring screen ----------
   Column: drawing (takes all the space that is left, always square) → tools → crayons.
   The canvas area is a size container, so the page is min(width, height) of what's left. */
.main { flex: 1 1 auto; min-height: 0; display: flex; padding: 6px 12px 12px; }
.board { flex: 1; min-width: 0; min-height: 0; width: 100%; max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.page-col { flex: 1 1 0; min-height: 0; min-width: 0; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.canvas-area { flex: 1 1 0; min-height: 0; min-width: 0; width: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
/* under the coloring card: back into the book */
.page-nav { flex: none; display: flex; justify-content: center; }
.open-book-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 22px; border-radius: 999px;
  font-size: 1.05rem; font-weight: 600; color: #f0edfa; background: rgba(255, 255, 255, 0.09); border: 1px solid rgba(255, 255, 255, 0.18);
  transition: background 0.2s, transform 0.15s;
}
.open-book-btn:hover { background: rgba(255, 255, 255, 0.16); }
.open-book-btn:active { transform: scale(0.95); }
.title-pill { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: clamp(1rem, 2.6vw, 1.25rem); color: #e9e6f5; opacity: 0.8; white-space: nowrap; }
.title-pill b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.title-pill small { font-weight: 500; opacity: 0.7; }
.canvas-card {
  position: relative; flex: none; background: var(--card); border-radius: var(--radius);
  width: min(100%, calc(100dvh - 300px)); /* until board.js measures the space and sets the exact width */
  padding: 0; overflow: hidden; /* the canvas fills the whole card, so kids can color right up to its edge */
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 20px 60px rgba(0, 0, 0, 0.45);
}
.progress { height: 4px; border-radius: 999px; overflow: hidden; background: #f0eef6; }
/* inside the card (fallback when no slot is given) */
.canvas-card > .progress { position: absolute; z-index: 2; pointer-events: none; top: 8px; left: 25%; width: 50%; }
/* under the title in the top bar */
.title-block { display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 0; }
.progress-slot { width: min(240px, 100%); }
.progress-slot .progress { height: 6px; background: rgba(255, 255, 255, 0.12); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); }
.progress-fill { height: 100%; width: 0; transition: width 0.6s; background: linear-gradient(90deg, var(--sage), var(--sky), var(--calm)); }
.canvas-wrap { position: relative; width: 100%; aspect-ratio: 1; }
.canvas { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.canvas[data-tool='fill'] .fillable { cursor: pointer; }
.canvas[data-tool='crayon'] { cursor: crosshair; }
.canvas:not([data-tool='eraser']) .stroke-layer { pointer-events: none; }
.canvas[data-tool='crayon'] .fillable { pointer-events: none; }
.shape { transform-box: fill-box; transform-origin: center; }
.shape.pop { animation: shape-pop 0.4s ease-out; }
@keyframes shape-pop { 40% { transform: scale(1.03); } }
.ripple { animation: ripple 0.8s ease-out forwards; }
@keyframes ripple { to { r: 60; opacity: 0; stroke-width: 1; } }
.floaters { position: absolute; inset: 0; pointer-events: none; }
.floater { position: absolute; transform: translate(-50%, -50%); font-weight: 600; font-size: 1.2rem; color: var(--ink); white-space: nowrap; animation: float-up 1.2s ease-out forwards; }
@keyframes float-up { from { opacity: 0.9; margin-top: 0; } to { opacity: 0; margin-top: -50px; } }

.tool-panel { flex: none; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
/* one calm toolbar: tools on top (Draw / Erase left, Print / Save right), crayons below */
.dock {
  padding: 10px 12px 12px; border-radius: 24px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.tool-row { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.tool-group { display: flex; gap: 8px; }
.tool {
  display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 16px 0 12px;
  font-size: 1.25rem; line-height: 1; color: #e9e6f5; background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 999px;
  transition: background 0.2s, transform 0.15s, opacity 0.2s;
}
.tool small { font-size: 0.98rem; font-weight: 600; }
.tool:hover { background: rgba(255, 255, 255, 0.12); }
.tool.active { background: #fff; color: var(--ink); border-color: #fff; }
.tool:active { transform: scale(0.95); }
.tool-quiet { opacity: 0.7; background: transparent; }
.tool-quiet:hover { opacity: 1; }
/* crayon size follows the space: never wider than the screen, never so tall that the page shrinks too much */
.palette {
  --cols: 12; --gap: 8px;
  --sw: min(46px, 6dvh, calc((100vw - 56px - (var(--cols) - 1) * var(--gap)) / var(--cols)));
  display: grid; grid-template-columns: repeat(var(--cols), var(--sw)); gap: var(--gap); justify-content: center;
}
.swatch {
  width: var(--sw); aspect-ratio: 1; padding: 0; border-radius: 50%; background: var(--c); border: 3px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); transition: transform 0.2s ease;
}
.swatch.active { transform: scale(1.16); border-color: #fff; }
.swatch:hover:not(.active) { transform: scale(1.06); }

/* landscape with limited height (phones on their side, tablets, laptops): the toolbar moves beside the page */
@media (orientation: landscape) and (max-height: 820px) and (min-aspect-ratio: 5/4) {
  .board { flex-direction: row; align-items: center; justify-content: center; max-width: none; gap: clamp(12px, 2.5vw, 28px); }
  .page-col { flex: 1 1 0; height: 100%; width: auto; max-width: calc(100dvh - 20px); }
  .tool-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .tool-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .tool { justify-content: center; padding: 0 10px; }
  .palette { --cols: 4; --sw: min(48px, calc((100dvh - 236px) / 3), 6vw); }
}

/* book view: nothing but the book – the top bar keeps only the quiet corner icons
   (and a "Today's book" button when an older book is open) */
.view-book .topbar { grid-template-columns: 1fr auto 1fr; }
.view-book .title-block { grid-column: 2; }
.view-book .done-note, .view-book .progress-slot { display: none; }
.view-book .corner { opacity: 0.55; }
.view-book .corner:hover { opacity: 0.9; }
.title-block { grid-column: 2; }

/* "What's your name?" */
.name-input {
  display: block; width: min(300px, 100%); margin: 4px auto 14px; padding: 12px 18px; border-radius: 18px;
  font: 600 1.5rem var(--font); text-align: center; color: #3a3557; background: #fffaf1;
  border: 3px solid #c9c2ee; outline: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.name-input:focus { border-color: #ffd23f; }
.name-input::placeholder { color: #b7b1cf; font-weight: 500; }
.rotate-skip { background: none; border: none; color: #e9e6f5; opacity: 0.55; font-size: 0.95rem; text-decoration: underline; padding: 8px; }
.adv-card .rotate-skip { display: block; margin: 6px auto 0; }
.name-card { display: flex; flex-direction: column; align-items: center; }
.name-card .name-input { border-color: #ddd8f0; box-shadow: none; }

.book-view { position: relative; }

/* landscape phones: the book uses the full height; the corner icons float over the sky */
@media (orientation: landscape) and (max-height: 500px) {
  .view-book .topbar { position: absolute; inset: 0 0 auto 0; z-index: 3; pointer-events: none; padding-top: 6px; }
  .view-book .topbar > * { pointer-events: auto; }
  .view-book .main { padding-top: 4px; }
  .view-book .book-ui { position: absolute; left: 0; right: 0; bottom: 2px; z-index: 2; pointer-events: none; }
  .view-book .book-hint { font-size: 0.85rem; opacity: 0.6; }
}

/* ---------- the daily coloring book (3D) ----------
   Book view: the three.js book fills the space under the top bar, page dots + buttons below.
   Coloring view: the board. Only one of the two is shown. */
.view-book .board, .view-color .book-view { display: none; }
.book-view { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.book-stage { position: relative; flex: 1 1 0; min-height: 0; width: 100%; }
.book-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
/* soft top/bottom fade so the 3D area never shows a hard edge against the sky */
.book-canvas { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 4%, #000 96%, transparent 100%); mask-image: linear-gradient(to bottom, transparent 0, #000 4%, #000 96%, transparent 100%); }
.zooming .book-canvas { -webkit-mask-image: none; mask-image: none; }
.book-ui { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; transition: opacity 0.35s, transform 0.35s; }
.zooming .book-ui, .arriving .book-ui { opacity: 0; transform: translateY(12px); pointer-events: none; }
.zooming .topbar { opacity: 0.4; transition: opacity 0.4s; }
.view-color .board { animation: page-enter 0.45s ease-out; }
@keyframes page-enter { from { opacity: 0; transform: scale(1.04); } }
.book-hint { margin: 0; padding: 2px 12px 4px; color: #e9e6f5; opacity: 0.75; font-size: 1rem; font-weight: 500; text-align: center; }
.book-hint.pulse { opacity: 1; font-size: 1.15rem; animation: float 3s ease-in-out infinite; }
.note-stars i { font-style: normal; opacity: 0.45; }
.title-pill small { font-size: 0.8em; }
/* no WebGL: one flat page at a time */
.flat-book { position: absolute; inset: 0; overflow: hidden; padding: 8px; }
.flat-book img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.45)); }
/* the teaser in the last adventure card */
.book-teaser { display: grid; place-items: center; height: min(170px, 22dvh); margin: 6px 0 4px; }
.teaser-cover { display: block; height: 100%; aspect-ratio: 1 / 1.3; border-radius: 3px 9px 9px 3px; background: var(--board) center / cover no-repeat; border-left: 6px solid color-mix(in srgb, var(--board) 65%, #000); box-shadow: 0 0 34px rgba(255, 220, 150, 0.45), 0 10px 24px rgba(0, 0, 0, 0.5); animation: teaser 3s ease-in-out infinite; }
@keyframes teaser { 50% { transform: translateY(-6px) rotate(-2deg); } }
/* My books: a night-sky bookshelf – every book stands on a little wooden shelf */
.shelf-modal .modal {
  width: min(760px, 100%); color: #e6e3f3; padding: 22px clamp(14px, 4vw, 30px) 18px;
  background: radial-gradient(ellipse at 50% 0%, #24306a 0%, #141c45 55%, #0e1434 100%);
  border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.shelf-modal h2 { color: #f0edfa; }
.shelf-modal .lead { color: #cfcbe3; margin: 0.2em 0 0.6em; }
.shelf-modal .close-x { background: rgba(255, 255, 255, 0.1); color: #e6e3f3; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 18px; margin-top: 8px; padding: 6px 4px 8px; }
.shelf-book { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0 0 6px; background: none; border: none; color: #f0edfa; }
.shelf-book b { margin-top: 14px; font-size: 0.98rem; font-weight: 600; }
.shelf-cover {
  position: relative; display: grid; place-items: center; width: 86%; aspect-ratio: 1 / 1.3; border-radius: 3px 10px 10px 3px;
  background: var(--board, #4c40b0) center / cover no-repeat; border-left: 7px solid color-mix(in srgb, var(--board, #4c40b0) 65%, #000);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.45), inset -2px 0 0 rgba(255, 255, 255, 0.25); transition: transform 0.25s;
}
/* the wooden shelf under each book */
.shelf-plank { display: block; width: 112%; height: 12px; margin-top: -2px; border-radius: 3px; background: linear-gradient(#b07a4f, #8a5a3a); box-shadow: 0 6px 10px rgba(0, 0, 0, 0.4); }
.shelf-book:not(.locked):hover .shelf-cover, .shelf-book:not(.locked):focus-visible .shelf-cover { transform: translateY(-8px) rotate(-2deg); }
.shelf-book:not(.locked):active .shelf-cover { transform: translateY(-4px) scale(0.98); }
.shelf-book.current .shelf-cover { outline: 3px solid #ffd23f; outline-offset: 4px; }
.shelf-next { display: inline-block; margin: 0 0 4px; padding: 4px 14px; border-radius: 999px; font-size: 0.92rem; color: #ffe9a8; background: rgba(255, 210, 63, 0.12); }
.shelf-next b { color: #ffd23f; }
.shelf-book.locked .shelf-cover { background: rgba(255, 255, 255, 0.06); border: 2px dashed rgba(201, 194, 238, 0.4); box-shadow: none; }
.shelf-book.locked .lock { font-size: 2.6rem; animation: wobble-gift 2.4s ease-in-out infinite; }
.shelf-stars { font-size: 0.85rem; font-weight: 500; color: #cfcbe3; }
.shelf-stars i { font-style: normal; opacity: 0.45; }
@media (max-width: 640px) {
  .shelf { grid-template-columns: repeat(2, 1fr); gap: 24px 16px; }
  .shelf-modal .modal { padding: 18px 14px 14px; }
}
/* celebrations */
.book-progress { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; font-size: 1.4rem; }
.book-progress span { position: relative; width: 44px; height: 44px; border-radius: 10px; overflow: visible; background: #fff; opacity: 0.55; }
.book-progress span img { width: 100%; height: 100%; border-radius: 10px; display: block; }
.book-progress span.done { opacity: 1; box-shadow: 0 0 0 3px #ffd23f; }
.book-progress span.done::after { content: '⭐'; position: absolute; right: -8px; top: -9px; font-size: 0.85rem; }
.book-progress p { width: 100%; margin: 2px 0 0; font-size: 0.95rem; color: #cfcbe3; text-align: center; }
.fan { display: flex; justify-content: center; padding: 8px 0 4px; }
.fan span { margin: 0 -14px; transform: rotate(calc(var(--k) * 7deg)) translateY(calc(var(--k) * var(--k) * 3px)); }
.fan img { display: block; width: min(96px, 19vw, 13dvh); border-radius: 12px; background: #fff; box-shadow: 0 0 0 3px #fff, 0 8px 20px rgba(0, 0, 0, 0.4); }
.print-book { grid-column: 1 / -1; }
.print-book-fan { display: flex; gap: 4px; }
.print-book-fan img { width: 20%; border-radius: 8px; }

/* ---------- the daily adventure (welcome → breathe → reveal → choose) ----------
   A night sky: dark blue with a few stars (like from Earth). On each in-breath it slowly
   deepens into a near-black galaxy full of stars; on the out-breath it settles back. */
body.adventuring #app { visibility: hidden; } /* never flash today's picture before the reveal */
.adventure {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; overflow: auto;
  background: radial-gradient(ellipse at 50% 30%, #13224f 0%, #0d1838 60%, #091129 100%); /* dark navy night */
  color: #e6e3f3;
}
.sky { position: absolute; inset: 0; pointer-events: none; }
.sky-galaxy {
  opacity: 0; transition: opacity 4s ease-in-out;
  background: #000; /* full black on the in-breath */
}
.adventure.inhale .sky-galaxy { opacity: 1; }
.adventure.exhale .sky-galaxy { opacity: 0; }
.tw { position: absolute; border-radius: 50%; background: #fff; opacity: 0.55; animation: twinkle ease-in-out infinite; }
.tw.dim { opacity: 0.4; }
@keyframes twinkle { 50% { opacity: 0.12; } }
.adv-column { position: relative; z-index: 1; width: 100%; display: flex; flex-direction: column; align-items: center; gap: clamp(10px, 2.4dvh, 22px); }
.adv-stage { position: relative; z-index: 1; width: 100%; display: grid; place-items: center; }
/* the logo greets you above every welcome card */
.adv-brand { display: flex; align-items: center; gap: 12px; animation: brand-float 6s ease-in-out infinite; }
.adv-brand .logo-mark { width: clamp(40px, 7dvh, 56px); height: auto; border-radius: 14px; }
.adv-brand .wordmark { font-size: clamp(1.5rem, 4.2dvh, 2.1rem); text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35); }
@keyframes brand-float { 50% { transform: translateY(-4px); } }
.adventure.leaving { animation: fade-out 0.6s forwards; }
@keyframes fade-out { to { opacity: 0; } }
.adv-card {
  width: min(440px, 100%); background: rgba(14, 20, 48, 0.62); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 32px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4); padding: 24px 22px 26px; text-align: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.adv-card h2 { color: #f0edfa; font-weight: 500; }
.adv-card .lead { color: #cfcbe3; }
.adv-card .mascot { opacity: 0.92; }
.adventure .btn { border-color: rgba(255, 255, 255, 0.15); box-shadow: none; }
.btn-calm { --b: #5e5a9c; color: #f0edfa; }
.how-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 18px; text-align: left; }
.how-item { display: flex; align-items: center; gap: 12px; background: rgba(255, 255, 255, 0.05); border-radius: 18px; padding: 10px 14px; }
.how-item > span { font-size: 1.7rem; }
.how-item b { display: block; font-size: 1.05rem; font-weight: 500; color: #f0edfa; }
.how-item small { font-size: 0.9rem; color: #b9b4d4; }

.power { display: flex; justify-content: center; gap: 12px; margin-bottom: 6px; }
.power span { font-size: 1.5rem; filter: grayscale(1) brightness(0.6); opacity: 0.35; transition: all 1.2s ease; }
.power span.on { filter: none; opacity: 0.95; text-shadow: 0 0 14px rgba(255, 220, 140, 0.6); }

.intro-card { min-height: min(380px, calc(100dvh - 32px)); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.intro-dots { display: flex; gap: 8px; margin-bottom: 10px; }
.intro-dots span { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); transition: background 0.4s; }
.intro-dots span.on { background: #c9c2ee; }
.intro-art { min-height: 150px; display: grid; place-items: center; }
.intro-emoji { font-size: 5rem; animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
.intro-card .lead { max-width: 340px; }

/* Fluffy breathes with you: bigger on the in-breath, smaller on the out-breath */
.sky-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.breathe-stage { height: min(230px, 30dvh); display: grid; place-items: center; }
.breathe-puff .mascot { transition: transform 4s ease-in-out; }
.adventure.inhale .breathe-puff .mascot { transform: scale(1.55); }
.adventure.exhale .breathe-puff .mascot { transform: scale(1); }
.breathe-word { margin: 4px 0 0; }
.sky-spot { min-height: 1.4em; margin: 6px 0 0; font-size: 0.95rem; color: #b9b4d4; transition: opacity 0.6s; }

.mystery { width: min(190px, 26dvh); height: min(190px, 26dvh); margin: 10px auto 16px; perspective: 1000px; }
.mystery-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 1.1s ease; }
.mystery.flipped { width: min(250px, 30dvh); height: min(250px, 30dvh); transition: width 0.7s, height 0.7s; }
.mystery.flipped .mystery-inner { transform: rotateY(180deg); }
.mystery-front, .mystery-back { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 26px; display: grid; place-items: center; }
.mystery-front { background: linear-gradient(145deg, #3d4380, #2c3166); border: 1px solid rgba(255, 255, 255, 0.1); }
.mystery-front .q { font-size: 5rem; opacity: 0.85; }
.mystery-back { background: #eeecf5; transform: rotateY(180deg); }
.mystery-back svg { width: 100%; height: 100%; }
.glow .mystery-front { box-shadow: 0 0 40px rgba(200, 190, 255, 0.25); }
.wobble { animation: wobble 0.3s ease-in-out infinite; }
@keyframes wobble { 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }
.key-btn { animation: breathe-btn 3s ease-in-out infinite; }
@keyframes breathe-btn { 50% { transform: scale(1.03); } }
.choose { font-weight: 500; margin: 14px 0 10px; color: #f0edfa; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 8px; font-size: 1.05rem; font-weight: 500;
  color: #f0edfa; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 22px;
  transition: background 0.2s, transform 0.15s;
}
.choice span { font-size: 2.2rem; }
.choice:hover { background: rgba(255, 255, 255, 0.1); }
.choice:active { transform: scale(0.97); }
.rainbow-text { color: var(--calm-deep); }
.adv-card .rainbow-text { color: #d9cffd; }

/* the adventure cards shrink on short screens so they never need scrolling */
.adv-card .mascot { max-height: 18dvh; width: auto; }
@media (max-height: 700px) {
  .adv-card { padding: 18px 18px 20px; border-radius: 26px; }
  .intro-art { min-height: 0; }
  .intro-emoji { font-size: clamp(2.6rem, 10dvh, 4.4rem); }
  .adv-card .lead { margin: 0.3em 0 0.7em; }
  .choice { padding: 10px 8px; }
  .choice span { font-size: 1.8rem; }
  .choose { margin: 8px 0 8px; }
}
@media (max-height: 520px) {
  /* landscape phones: the logo moves to the top-left corner so the card keeps its room */
  .adv-brand { position: fixed; top: 8px; left: 10px; animation: none; }
  .adv-brand .wordmark { display: none; }
  .adv-brand .logo-mark { width: 34px; }
}
@media (max-height: 500px) {
  .adventure { padding: 8px; }
  .adv-card { width: min(560px, 100%); padding: 12px 16px 14px; }
  .adv-card h2 { font-size: 1.3rem; }
  .adv-card .lead { font-size: 0.98rem; }
  .intro-emoji { font-size: 2.4rem; }
  .btn-big { padding: 8px 28px; min-height: 44px; font-size: 1.1rem; }
  .power span { font-size: 1.15rem; }
  .breathe-stage { height: 22dvh; }
  .choice { flex-direction: row; justify-content: center; padding: 8px; gap: 8px; }
  .choice span { font-size: 1.4rem; }
}

/* ---------- modals ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(30, 26, 60, 0.45); display: grid; place-items: center; padding: 16px; animation: fade 0.3s; }
.modal {
  position: relative; width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: #fff;
  border-radius: 32px; box-shadow: 0 20px 60px rgba(10, 10, 40, 0.3); padding: 28px clamp(16px, 4vw, 32px); text-align: center;
}
.modal-backdrop.wide .modal { width: min(800px, 100%); }
.close-x { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--mist); font-size: 1.1rem; }
@keyframes fade { from { opacity: 0; } }
.pop-in { animation: pop-in 0.5s ease-out; }
@keyframes pop-in { from { transform: scale(0.94) translateY(10px); opacity: 0; } }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; margin-top: 12px; }
.gallery-card { border: 2px solid rgba(58, 53, 87, 0.15); border-radius: 20px; background: var(--mist); padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 500; }
.gallery-card img { width: 100%; aspect-ratio: 1; background: #fff; border-radius: 14px; }
.gallery-card.locked { justify-content: center; min-height: 170px; }
.lock { font-size: 2.6rem; }
/* ---------- "You did it!" + see you tomorrow ---------- */
.modal-backdrop.party { background: rgba(6, 10, 30, 0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.party .modal {
  width: min(440px, 100%); color: #e6e3f3; padding: clamp(16px, 3dvh, 26px) clamp(16px, 4vw, 28px);
  background: radial-gradient(ellipse at 50% 0%, #24306a 0%, #141c45 55%, #0e1434 100%);
  border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.party .close-x { background: rgba(255, 255, 255, 0.1); color: #e6e3f3; }
.celebrate { display: flex; flex-direction: column; align-items: center; gap: clamp(6px, 1.4dvh, 12px); }
.celebrate-top { display: flex; flex-direction: column; align-items: center; }
.celebrate .trophy { font-size: clamp(2.6rem, 7dvh, 3.6rem); line-height: 1; animation: trophy-bounce 1.6s ease-in-out infinite; }
@keyframes trophy-bounce { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
.rainbow-letters { margin: 4px 0 0; font-size: clamp(1.8rem, 5dvh, 2.3rem); font-weight: 700; }
.rainbow-letters span { display: inline-block; animation: letter-hop 1.8s ease-in-out infinite; animation-delay: calc(var(--i) * 0.08s); }
.rainbow-letters span:nth-child(5n + 1) { color: #ff8fab; }
.rainbow-letters span:nth-child(5n + 2) { color: #ffd23f; }
.rainbow-letters span:nth-child(5n + 3) { color: #6ee7b7; }
.rainbow-letters span:nth-child(5n + 4) { color: #7cc8ff; }
.rainbow-letters span:nth-child(5n + 5) { color: #b9a6ff; }
@keyframes letter-hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }
.star-badge { margin: 4px 0 0; padding: 3px 14px; border-radius: 999px; font-weight: 600; color: #3a3557; background: #ffd23f; box-shadow: 0 0 18px rgba(255, 210, 63, 0.45); }
.celebrate-thumb img { display: block; width: min(220px, 60vw, 24dvh); border-radius: 18px; background: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 12px 30px rgba(0, 0, 0, 0.45); transform: rotate(-2deg); }
.celebrate-actions { margin: 4px 0 0; }
.party .btn { border-color: rgba(255, 255, 255, 0.18); box-shadow: none; }
.tomorrow {
  width: 100%; padding: 12px 14px 14px; border-radius: 22px; text-align: center;
  background: rgba(255, 255, 255, 0.05); border: 2px dashed rgba(201, 194, 238, 0.35);
}
.tomorrow h3 { margin: 2px 0 2px; font-size: 1.3rem; font-weight: 600; color: #f0edfa; }
.tomorrow p { margin: 3px 0; font-size: 0.98rem; color: #cfcbe3; }
.tomorrow-art { position: relative; height: clamp(58px, 10dvh, 80px); display: flex; align-items: center; justify-content: center; }
.tomorrow-art .mascot { width: auto; height: 100%; animation: sleepy-breathe 4s ease-in-out infinite; }
@keyframes sleepy-breathe { 50% { transform: scale(1.06); } }
.tomorrow-art .moon { position: absolute; left: 18%; top: 0; font-size: 1.6rem; animation: float 5s ease-in-out infinite; }
.tomorrow-art .gift { position: absolute; right: 16%; bottom: 0; font-size: 1.8rem; animation: wobble-gift 2.4s ease-in-out infinite; }
@keyframes wobble-gift { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-12deg) scale(1.08); } 86% { transform: rotate(10deg) scale(1.08); } }
.zzz { position: absolute; left: calc(50% + 34px); top: 0; font-weight: 700; color: #c9c2ee; font-size: 0.9rem; }
.zzz, .zzz span { display: inline-block; animation: zzz 3s ease-in-out infinite; }
.zzz span { font-size: 1.2em; animation-delay: 0.4s; }
.zzz span span { animation-delay: 0.8s; }
@keyframes zzz { 0% { opacity: 0; transform: translate(0, 6px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translate(6px, -8px); } }
.countdown { display: inline-block; margin-top: 6px !important; padding: 4px 14px; border-radius: 999px; background: rgba(124, 200, 255, 0.14); color: #e6f4ff !important; }
.streak { font-size: 0.92rem !important; color: #ffd9a8 !important; }

/* top bar after finishing: the progress bar becomes a small countdown */
.done-note { display: none; font-size: 0.85rem; color: #c9c2ee; white-space: nowrap; }
.done-note b { color: #ffd23f; font-weight: 600; }
.title-block.is-done .progress-slot { display: none; }
.title-block.is-done .done-note { display: block; }
/* shorter screens: everything a bit more compact so the card never needs scrolling */
@media (max-height: 780px) {
  .party .modal { padding: 14px 16px 16px; }
  .celebrate { gap: 6px; }
  .celebrate-thumb img { width: min(200px, 22dvh); }
  .tomorrow { padding: 8px 12px 10px; }
  .tomorrow-art { height: 50px; }
  .tomorrow h3 { font-size: 1.15rem; }
  .tomorrow p { font-size: 0.9rem; margin: 2px 0; }
  .countdown { margin-top: 4px !important; }
  .party .btn-big { padding: 10px 26px; min-height: 46px; font-size: 1.1rem; }
}
@media (max-width: 480px) {
  .celebrate-thumb img { width: min(180px, 20dvh); }
  .tomorrow p { font-size: 0.88rem; }
}
@media (max-height: 680px) and (max-width: 480px) {
  .tomorrow-art { display: none; }
  .tomorrow h3::after { content: ' 🎁'; }
  .celebrate .trophy { font-size: 2rem; }
  .rainbow-letters { font-size: 1.6rem; margin: 0; }
  .celebrate-thumb img { width: 17dvh; }
  .party .modal { padding: 12px 14px 14px; }
  .celebrate { gap: 5px; }
  .party .btn-big { min-height: 42px; padding: 8px 22px; }
}
/* landscape phones: picture on the left, "see you tomorrow" on the right */
@media (max-height: 520px) {
  .party .modal { width: min(680px, 100%); max-height: calc(100dvh - 16px); }
  .modal-backdrop.party { padding: 8px; }
  .celebrate { display: grid; grid-template-columns: auto 1fr; column-gap: 18px; row-gap: 6px; align-items: center; }
  .celebrate-top { grid-area: 1 / 1; }
  .celebrate-thumb { grid-area: 2 / 1; justify-self: center; }
  .celebrate-actions { grid-area: 3 / 1; }
  .tomorrow { grid-area: 1 / 2 / 3 / 3; }
  .celebrate > .btn-big { grid-area: 3 / 2; justify-self: center; }
  .celebrate .trophy { font-size: 2rem; }
  .rainbow-letters { font-size: 1.5rem; }
  .celebrate-thumb img { width: 34dvh; }
}
.print-options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.print-opt { border: 2px solid rgba(58, 53, 87, 0.15); border-radius: 20px; background: var(--mist); padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 1.05rem; }
.print-opt img { width: 100%; border-radius: 12px; background: #fff; }

/* ---------- toasts ---------- */
#toasts { position: fixed; z-index: 60; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, 0.95); border-radius: 999px; box-shadow: var(--soft-shadow); padding: 8px 22px; font-size: 1.1rem; animation: pop-in 0.4s ease-out; }
.toast.out { animation: toast-out 0.5s forwards; }
.toast-emoji { font-size: 1.6rem; }
@keyframes toast-out { to { transform: translateY(20px); opacity: 0; } }
.confetti-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 70; }

/* ---------- mascot (Fluffy the cloud) ---------- */
.mascot { display: block; margin: 0 auto; overflow: visible; }
.mascot-arm-wave { transform-origin: 136px 128px; animation: wave 1.8s ease-in-out infinite; }
.mascot-eyes { animation: blink 5s infinite; transform-origin: 80px 118px; }
@keyframes wave { 50% { transform: rotate(-18deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(0.1); } }
.wiggle { display: inline-block; }

/* ---------- phone (portrait) ---------- */
@media (max-width: 640px) {
  .topbar { grid-template-columns: auto 1fr auto; padding: 8px 10px 2px; gap: 8px; }
  .today { justify-content: flex-start; }
  .title-block { align-items: stretch; gap: 5px; }
  .progress-slot { width: min(200px, 100%); }
  .title-pill small { display: none; }
  .chip { height: 38px; padding: 0 10px; font-size: 0.95rem; }
  .corner .icon-btn { width: 38px; height: 38px; font-size: 1rem; border-radius: 12px; }
  .main { padding: 4px 8px 10px; }
  .board { gap: 10px; }
  .canvas-card { border-radius: 20px; }
  .dock { width: 100%; padding: 8px 10px 10px; border-radius: 20px; }
  .tool { height: 42px; padding: 0 12px 0 10px; }
  .palette { --cols: 6; --gap: 10px; --sw: min(46px, 6dvh, calc((100vw - 48px - 5 * var(--gap)) / 6)); }
}
@media (max-width: 640px) {
}
@media (max-height: 560px) {
  .open-book-btn { height: 36px; padding: 0 16px; font-size: 0.95rem; }
  .page-col { gap: 4px; }
  .book-ui { gap: 2px; }
  .book-hint { font-size: 0.9rem; }
}
/* narrow phones: Print / Save become icon-only so everything stays on one line */
@media (max-width: 420px) {
  .tool-quiet small { display: none; }
  .tool-quiet { padding: 0 10px; }
}
@media (max-width: 340px) {
  .tool { padding: 0 9px; gap: 4px; }
  .tool small { font-size: 0.9rem; }
}
/* short screens (landscape phones): a slimmer top bar */
@media (max-height: 500px) {
  .topbar { padding-top: 6px; padding-bottom: 0; }
  .chip { height: 34px; }
  .corner .icon-btn { width: 34px; height: 34px; }
  .main { padding-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  #bg-deco { display: none; }
}

/* ---------- print ---------- */
#print-sheet { display: none; }
@media print {
  @page { size: auto; margin: 12mm; }
  html, body { background: #fff !important; overflow: visible !important; height: auto !important; }
  #app, #bg-deco, #toasts, #modal-root, .confetti-canvas { display: none !important; }
  #print-sheet { display: flex !important; flex-direction: column; align-items: center; gap: 10px; font-family: var(--font); color: #000; }
  .print-head { width: 100%; display: flex; justify-content: space-between; font-size: 22pt; border-bottom: 3px solid #000; padding-bottom: 6px; }
  .print-head span { font-size: 12pt; align-self: flex-end; }
  .print-art svg { width: 175mm; height: 175mm; max-width: 100%; }
  .print-page { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; break-after: page; page-break-after: always; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-foot { width: 100%; display: flex; justify-content: space-between; align-items: center; font-size: 12pt; margin-top: 8px; }
  .print-brand { display: inline-flex; align-items: center; gap: 6px; }
  .print-brand .logo-mark { box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
