* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Baloo 2', 'Comic Sans MS', cursive, sans-serif;
  background: #FAF3E3;
  background-image:
    radial-gradient(#17408B08 1.2px, transparent 1.2px),
    radial-gradient(#E8762C07 1.2px, transparent 1.2px);
  background-size: 26px 26px, 34px 34px;
  background-position: 0 0, 13px 17px;
  color: #17408B;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }

.hd-blue { color: #17408B; }
.hd-orange { color: #D8641F; }

/* ================= HERO ================= */
.hero {
  position: relative;
  background: linear-gradient(180deg, #BFE3F5 0%, #DDF1FB 70%, #FAF3E3 100%);
  padding: clamp(28px, 6vw, 72px) 20px 90px;
}
.hero-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(240px, 380px) 1fr;
  gap: clamp(24px, 5vw, 64px);
  align-items: center;
}
.hero-book { perspective: 1000px; }
.hero-cover {
  border-radius: 14px;
  border: 5px solid #17408B;
  box-shadow: 18px 22px 0 #17408B22, 0 24px 50px #17408B33;
  transform: rotate(-2.5deg);
  transition: transform .4s ease;
}
.hero-cover:hover { transform: rotate(-1deg) scale(1.015); }
.hero-kicker {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: clamp(14px, 2.4vw, 17px);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #2B6C8F;
}
.hero-title {
  margin: 0;
  font-weight: 800;
  font-size: clamp(44px, 8.5vw, 84px);
  line-height: .95;
  text-shadow: 3px 3px 0 #ffffffd0;
}
.hero-wave { margin: 10px 0 2px; }
.hero-sub {
  margin: 6px 0 10px;
  font-weight: 800;
  font-size: clamp(22px, 4vw, 34px);
  color: #D8641F;
}
.hero-lede {
  margin: 0 0 18px;
  font-weight: 600;
  font-size: clamp(16px, 2.6vw, 20px);
  color: #23477E;
  max-width: 46ch;
}
.hero-badges { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.badge {
  background: #17408B;
  color: #fff;
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 999px;
  font-size: clamp(14px, 2.2vw, 17px);
  box-shadow: 0 3px 0 #0E2A5E;
}
.badge-orange { background: #E8762C; box-shadow: 0 3px 0 #A34A12; }
.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #E8762C;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: clamp(18px, 3vw, 22px);
  padding: 14px 30px;
  border-radius: 999px;
  border: 3px solid #B4531C;
  box-shadow: 0 6px 0 #8F3F18, 0 14px 26px #8F3F1833;
  transition: transform .15s ease, box-shadow .15s ease;
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #8F3F18, 0 18px 30px #8F3F1833; }
.cta:active { transform: translateY(3px); box-shadow: 0 2px 0 #8F3F18; }
.hero-sand {
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 60px;
  background: #FAF3E3;
  clip-path: ellipse(60% 100% at 50% 100%);
}

/* ================= SHARED ================= */
.section-title {
  margin: 0 0 14px;
  font-weight: 800;
  font-size: clamp(26px, 4.6vw, 40px);
  line-height: 1.05;
}
.panel {
  background: #FFFDF6;
  border: 4px solid #17408B;
  border-radius: 26px;
  box-shadow: 0 8px 0 #17408B1f, 0 18px 40px #17408B1a;
}
.panel-orange { border-color: #E8962C; box-shadow: 0 8px 0 #E8962C33, 0 18px 40px #E8962C22; }

/* ================= STUDIO ================= */
.studio { max-width: 1040px; margin: 0 auto; padding: 10px 16px 30px; }
.studio-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.icon-btn {
  border: 3px solid #17408B;
  background: #fff;
  color: #17408B;
  border-radius: 50%;
  width: 50px; height: 50px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 0 #0E2A5E;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #0E2A5E; }

.page-picker {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 10px 4px 16px;
  scrollbar-width: thin;
}
.thumb-card {
  flex: 0 0 auto;
  width: 118px;
  border: 3px solid #17408B;
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 0 #17408B22;
  transition: transform .15s ease;
  font-family: inherit;
}
.thumb-card:hover { transform: translateY(-3px); }
.thumb-card img { width: 100%; height: 128px; object-fit: cover; object-position: top; }
.thumb-card .thumb-label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  color: #17408B;
  padding: 5px 6px 7px;
  background: #FFF7E6;
  border-top: 2px solid #17408B22;
}
.thumb-card.active { border-color: #E8762C; box-shadow: 0 4px 0 #B4531C; }
.thumb-card.active .thumb-label { background: #E8762C; color: #fff; }
.coming-soon { margin: 0 0 14px; font-weight: 600; color: #2B6C8F; font-size: 15px; }

.stage-panel { padding: 12px; background: #FFFDF6; border: 4px solid #17408B; border-radius: 26px; box-shadow: 0 8px 0 #17408B1f, 0 18px 40px #17408B1a; }
.stage { border-radius: 16px; overflow: hidden; position: relative; background: #fff; }
.stage svg, .stage canvas { display: block; width: 100%; height: auto; touch-action: manipulation; }
.stage svg .colorable { cursor: pointer; transition: fill .12s ease; }
.stage svg .colorable:hover { filter: brightness(0.96); }
.stage canvas { cursor: pointer; }
.loading { padding: 70px 20px; text-align: center; font-weight: 700; font-size: 20px; color: #2B6C8F; }

/* sparkles overlay for raster come-alive */
.sparkles { position: absolute; inset: 0; pointer-events: none; display: none; }
.stage.alive-raster .sparkles { display: block; }
.sparkles span {
  position: absolute;
  width: 14px; height: 14px;
  background: radial-gradient(circle, #FFD84D 0 35%, #E8762C 60%, transparent 70%);
  border-radius: 50%;
  animation: sparkle 2.6s ease-in-out infinite;
}
@keyframes sparkle {
  0%, 100% { transform: scale(.3); opacity: 0; }
  50% { transform: scale(1.15); opacity: 1; }
}
.sparkles .bub {
  background: none;
  border: 2.5px solid #4FC3F7cc;
  box-shadow: inset -2px 2px 0 #ffffffaa;
  animation: bubble-rise linear infinite;
  bottom: -30px;
  top: auto;
}
@keyframes bubble-rise {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: .9; }
  50% { transform: translateY(-45vh) translateX(10px); }
  100% { transform: translateY(-92vh) translateX(-8px); opacity: 0; }
}
.stage.alive-raster canvas { animation: breathe 4s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  30% { transform: translateY(-10px) rotate(-.7deg) scale(1.012); }
  65% { transform: translateY(4px) rotate(.6deg) scale(1.005); }
}

/* come-alive animations (SVG pages) */
.stage svg .anim-hero, .stage svg .anim-bounce, .stage svg .anim-sway,
.stage svg .anim-wiggle, .stage svg .anim-float, .stage svg .anim-spin-slow,
.stage svg .anim-wave, .stage svg .anim-drift, .stage svg .anim-rock {
  transform-box: fill-box;
  transform-origin: center;
}
.stage svg .anim-sway { transform-origin: center bottom; }
.stage svg .anim-wave { transform-origin: left bottom; }
svg.alive .anim-hero   { animation: hero-wander 9s ease-in-out infinite; }
svg.alive .anim-bounce { animation: bounce 1.5s ease-in-out infinite; }
svg.alive .anim-sway   { animation: sway 3.2s ease-in-out infinite; }
svg.alive .anim-wiggle { animation: wiggle 1.1s ease-in-out infinite; }
svg.alive .anim-float  { animation: floaty 4.5s ease-in-out infinite; }
svg.alive .anim-spin-slow { animation: spin 14s linear infinite; }
svg.alive .anim-wave   { animation: wave 1.4s ease-in-out infinite; }
svg.alive .anim-drift  { animation: drift 7s ease-in-out infinite alternate; }
svg.alive .anim-rock   { animation: rock 3.5s ease-in-out infinite; }
@keyframes hero-wander {
  0%   { transform: translate(0,0) rotate(0deg); }
  15%  { transform: translate(-55px,-18px) rotate(-4deg); }
  35%  { transform: translate(40px,-34px) rotate(3deg); }
  55%  { transform: translate(70px,6px) rotate(5deg); }
  75%  { transform: translate(-30px,14px) rotate(-3deg); }
  100% { transform: translate(0,0) rotate(0deg); }
}
@keyframes bounce { 0%,100% { transform: translateY(0) scale(1,1); } 40% { transform: translateY(-26px) scale(0.98,1.02); } 55% { transform: translateY(0) scale(1.03,0.97); } 70% { transform: translateY(-8px); } }
@keyframes sway { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes wiggle { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes floaty { 0%,100% { transform: translate(0,0); } 50% { transform: translate(26px,-14px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wave { 0%,100% { transform: rotate(0deg); } 40% { transform: rotate(-22deg); } 70% { transform: rotate(8deg); } }
@keyframes drift { from { transform: translateX(-30px); } to { transform: translateX(30px); } }
@keyframes rock { 0%,100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(3deg) translateY(-8px); } }

/* ================= TOOLBAR ================= */
.toolbar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin-top: 14px;
  padding: 10px 0 12px;
  background: linear-gradient(180deg, transparent, #FAF3E3 26%);
}
.palette-tray {
  background: #FFFDF6;
  border: 3px solid #17408B;
  border-radius: 20px;
  box-shadow: 0 5px 0 #17408B22;
  padding: 8px 14px 12px;
}
.tray-label { margin: 0 0 6px; font-weight: 800; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: #2B6C8F; }
.palette { display: grid; grid-template-columns: repeat(18, 1fr); gap: 8px; }
.crayon {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  outline: 2px solid #17408B33;
  cursor: pointer;
  padding: 0;
  min-width: 26px;
  transition: transform .12s ease;
}
.crayon:hover { transform: scale(1.12); }
.crayon.selected { outline: 4px solid #17408B; transform: scale(1.18); }
.crayon.eraser { background: repeating-linear-gradient(45deg, #fff 0 6px, #e8e8e8 6px 12px) !important; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding-top: 10px; }
.action-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(14px, 2.6vw, 17px);
  padding: 10px 18px;
  border-radius: 999px;
  border: 3px solid #17408B;
  background: #fff;
  color: #17408B;
  cursor: pointer;
  box-shadow: 0 4px 0 #0E2A5E;
}
.action-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0E2A5E; }
.action-btn.magic {
  background: #E8762C; border-color: #B4531C; color: #fff;
  box-shadow: 0 4px 0 #8F3F18;
  animation: magic-pulse 2.4s ease-in-out infinite;
}
.action-btn.magic.on { background: #1D9E75; border-color: #0F6E56; box-shadow: 0 4px 0 #085041; animation: none; }
@keyframes magic-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ================= PROMISE / AUTHOR ================= */
.promise, .author { padding: 34px 16px; }
.promise-inner, .author-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(200px, 320px) 1fr;
  gap: clamp(18px, 4vw, 44px);
  align-items: center;
  padding: clamp(20px, 4vw, 40px);
}
.promise-art img, .author-art img {
  border-radius: 18px;
  border: 4px solid #17408B;
  box-shadow: 0 10px 24px #17408B26;
}
.author-art img { border-color: #E8962C; box-shadow: 0 10px 24px #E8962C33; }
.promise-list { list-style: none; margin: 8px 0 0; padding: 0; }
.promise-list li {
  position: relative;
  padding: 7px 0 7px 44px;
  font-weight: 700;
  font-size: clamp(17px, 2.8vw, 22px);
  color: #17408B;
}
.promise-list li::before {
  content: '';
  position: absolute;
  left: 0; top: 8px;
  width: 28px; height: 28px;
  background: #E8762C;
  clip-path: polygon(50% 0%, 63% 34%, 98% 37%, 71% 59%, 79% 94%, 50% 74%, 21% 94%, 29% 59%, 2% 37%, 37% 34%);
}
.author-copy p { font-weight: 600; font-size: clamp(16px, 2.6vw, 19px); color: #23477E; line-height: 1.55; }
.verse { font-style: italic; color: #17408B; margin-top: 16px; }
.verse-ref { font-style: normal; font-weight: 800; color: #D8641F; }

/* ================= FOOTER ================= */
.foot { text-align: center; padding: 10px 16px 40px; color: #2B6C8F; font-weight: 600; }
.foot-motto { font-weight: 800; color: #17408B; font-size: clamp(16px, 2.8vw, 20px); margin: 10px 0 6px; }
.foot p { margin: 4px 0; font-size: clamp(13px, 2.2vw, 15px); }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti span { position: absolute; top: -20px; font-size: 22px; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; } }

/* ================= RESPONSIVE ================= */
@media (max-width: 760px) {
  .hero-inner { grid-template-columns: 1fr; text-align: center; }
  .hero-book { max-width: 250px; margin: 0 auto; }
  .hero-badges, .hero-wave { justify-content: center; display: flex; }
  .promise-inner, .author-inner { grid-template-columns: 1fr; }
  .promise-art, .author-art { max-width: 260px; margin: 0 auto; }
  .palette { grid-template-columns: repeat(9, 1fr); }
  .thumb-card { width: 100px; }
  .thumb-card img { height: 108px; }
}
