:root{--ink:#48225f;--ink-soft:#765986;--pink:#ff4e9b;--pink-deep:#e63087;--yellow:#ffd85a;--paper:rgba(255,255,255,.92);--shadow:0 20px 55px rgba(90,47,120,.15)}
*{box-sizing:border-box}html,body{min-height:100%}body{margin:0;color:var(--ink);background:radial-gradient(circle at 12% 8%,rgba(255,255,255,.98) 0 3%,transparent 3.2%),radial-gradient(circle at 88% 18%,rgba(255,255,255,.86) 0 2%,transparent 2.2%),linear-gradient(145deg,#fff9da 0%,#ffe8f2 43%,#def6ff 100%);font-family:ui-rounded,"SF Pro Rounded","Nunito",system-ui,sans-serif;overflow-x:hidden;-webkit-tap-highlight-color:transparent;touch-action:manipulation;user-select:none}button{font:inherit}button:focus-visible{outline:4px solid #6f55ff;outline-offset:4px}
.sky{position:fixed;inset:0;pointer-events:none;overflow:hidden}.cloud{position:absolute;width:140px;height:48px;border-radius:99px;background:rgba(255,255,255,.7)}.cloud:before,.cloud:after{content:"";position:absolute;border-radius:50%;background:inherit}.cloud:before{width:64px;height:64px;left:22px;bottom:6px}.cloud:after{width:84px;height:84px;right:16px;bottom:1px}.cloud-one{top:16%;left:-45px;transform:scale(.8)}.cloud-two{right:-20px;bottom:17%;transform:scale(1.05)}.sparkle{position:absolute;color:#fff;text-shadow:0 0 18px #ff77be;animation:twinkle 2.2s infinite ease-in-out}.s1{top:12%;left:40%;font-size:28px}.s2{top:28%;right:7%;font-size:36px;animation-delay:-.7s}.s3{bottom:9%;left:12%;font-size:24px;animation-delay:-1.3s}
.app-shell{width:min(1260px,100%);min-height:100dvh;margin:auto;padding:max(18px,env(safe-area-inset-top)) max(22px,env(safe-area-inset-right)) max(20px,env(safe-area-inset-bottom)) max(22px,env(safe-area-inset-left));position:relative;z-index:1}.topbar{display:flex;align-items:center;justify-content:space-between;min-height:76px}.brand{display:flex;align-items:center;gap:12px;border:0;color:var(--ink);background:transparent;cursor:pointer;text-align:left}.brand-unicorn{display:grid;place-items:center;width:58px;height:58px;font-size:36px;border-radius:20px;background:#fff;box-shadow:0 8px 22px rgba(140,67,129,.14);transform:rotate(-4deg)}.brand strong{display:block;font-size:24px;line-height:1;letter-spacing:.08em}.brand small{display:block;margin-top:5px;color:var(--pink-deep);font-weight:900;font-size:11px;letter-spacing:.17em}.score{display:flex;align-items:center;gap:9px;min-width:92px;padding:10px 18px;border:3px solid #fff;border-radius:99px;background:rgba(255,255,255,.78);box-shadow:0 8px 24px rgba(90,47,120,.1);font-size:24px}
.screen{display:none;min-height:calc(100dvh - 120px);animation:screenIn .45s ease both}.screen.is-active{display:flex}.welcome-screen{position:relative;align-items:center;gap:30px;padding:38px 3% 60px}.welcome-copy{width:52%;position:relative;z-index:2}.eyebrow{display:inline-flex;align-items:center;gap:9px;color:var(--pink-deep);font-weight:950;font-size:clamp(12px,1.5vw,16px);letter-spacing:.16em}.eyebrow:before{content:"";width:35px;height:5px;border-radius:9px;background:var(--yellow)}h1{margin:18px 0 20px;font-size:clamp(48px,7.2vw,92px);line-height:.88;letter-spacing:-.055em}h1 em{color:var(--pink);font-family:"Snell Roundhand","Comic Sans MS",cursive;font-weight:800;letter-spacing:-.02em}.welcome-copy p{max-width:580px;margin:0 0 30px;color:var(--ink-soft);font-size:clamp(18px,2vw,24px);line-height:1.42;font-weight:650}.primary-button{min-height:74px;padding:0 16px 0 28px;display:inline-flex;align-items:center;gap:28px;border:0;border-radius:24px;color:#fff;background:linear-gradient(135deg,var(--pink),#f238a5);box-shadow:0 16px 30px rgba(235,48,139,.28),inset 0 2px rgba(255,255,255,.35);font-weight:950;letter-spacing:.04em;cursor:pointer}.primary-button b{display:grid;place-items:center;width:48px;height:48px;border-radius:16px;background:rgba(255,255,255,.22);font-size:26px}
.welcome-art{width:48%;aspect-ratio:1;max-height:610px;position:relative}.rainbow-ring{position:absolute;border-radius:50%;inset:8%;border:28px solid rgba(255,112,182,.25)}.ring-two{inset:20%;border-color:rgba(255,215,86,.6);border-width:18px}.hero-unicorn{position:absolute;inset:22%;display:grid;place-items:center;font-size:clamp(130px,21vw,285px);filter:drop-shadow(0 20px 24px rgba(92,57,120,.18));animation:float 3s ease-in-out infinite}.letter-bubble{position:absolute;display:grid;place-items:center;width:76px;height:76px;border:5px solid #fff;border-radius:25px;color:#fff;font-size:39px;font-weight:950;box-shadow:var(--shadow);transform:rotate(-8deg)}.letter-a{left:2%;top:18%;background:var(--pink)}.letter-l{right:1%;top:20%;background:#7457df;transform:rotate(9deg)}.letter-i{left:10%;bottom:11%;background:#39c8a8;transform:rotate(5deg)}.mini-star{position:absolute;color:var(--yellow);font-size:42px;text-shadow:0 5px #fff}.ms1{top:7%;right:28%;transform:rotate(15deg)}.ms2{right:12%;bottom:15%;transform:rotate(-12deg)}.words-entry{position:absolute;left:4%;bottom:10px;display:flex;align-items:center;gap:14px;border:3px solid #fff;border-radius:22px;padding:10px 16px;color:var(--ink);background:rgba(255,255,255,.72);box-shadow:0 10px 30px rgba(80,39,111,.12);cursor:pointer;text-align:left}.words-entry-icon{font-size:34px}.words-entry small,.words-entry strong{display:block}.words-entry small{color:var(--ink-soft);font-weight:800;font-size:10px;letter-spacing:.14em}.words-entry strong{margin-top:3px;font-size:15px}.words-entry b{color:var(--pink);font-size:24px}
.words-screen{flex-direction:column;padding:28px 3% 50px}.section-heading{display:flex;align-items:center;gap:22px;margin-bottom:28px}.round-back{flex:0 0 auto;width:58px;height:58px;border:3px solid #fff;border-radius:20px;color:var(--ink);background:rgba(255,255,255,.8);box-shadow:0 8px 22px rgba(90,47,120,.12);font-size:28px;font-weight:900;cursor:pointer}h2{margin:5px 0 0;font-size:clamp(32px,5vw,58px);line-height:1;letter-spacing:-.035em}.word-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:18px}.word-card{min-height:175px;position:relative;overflow:hidden;display:flex;flex-direction:column;justify-content:space-between;align-items:flex-start;padding:20px;border:4px solid #fff;border-radius:28px;color:var(--ink);background:var(--card,#ffe3ef);box-shadow:0 14px 34px rgba(87,49,116,.12);cursor:pointer;text-align:left;transition:transform .18s ease,box-shadow .18s ease}.word-card:active{transform:scale(.97)}.word-card-icon{font-size:48px;filter:drop-shadow(0 7px 8px rgba(77,42,95,.12))}.word-card strong{position:relative;z-index:2;font-size:clamp(22px,3vw,34px);letter-spacing:.02em}.word-card:after{content:attr(data-letter);position:absolute;right:-7px;bottom:-28px;color:rgba(255,255,255,.52);font-size:120px;font-weight:950;transform:rotate(-8deg)}.word-card.is-done:before{content:"✓";position:absolute;right:14px;top:14px;display:grid;place-items:center;width:34px;height:34px;border-radius:50%;color:#fff;background:#45c99f;font-weight:950;z-index:3}
.trace-screen{flex-direction:column;padding:16px 2% 30px}.trace-topline{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:18px;margin-bottom:14px}.lesson-title h2{font-size:clamp(30px,4vw,48px)}.letter-progress{display:flex;gap:8px;align-items:center;justify-content:flex-end;flex-wrap:wrap}.progress-letter{display:grid;place-items:center;width:44px;height:44px;border:3px solid rgba(255,255,255,.85);border-radius:15px;color:#9b82aa;background:rgba(255,255,255,.55);font-weight:950}.progress-letter.is-current{color:#fff;background:var(--pink);transform:translateY(-4px);box-shadow:0 8px 15px rgba(237,58,144,.25)}.progress-letter.is-done{color:#fff;background:#4acba5}.trace-layout{flex:1;min-height:0;display:grid;grid-template-columns:minmax(170px,.72fr) minmax(430px,1.55fr) minmax(130px,.52fr);gap:18px;align-items:stretch}.coach-card,.canvas-card,.action-rail{border:4px solid #fff;box-shadow:var(--shadow)}.coach-card{align-self:center;padding:24px 20px;border-radius:30px;background:rgba(255,255,255,.74);text-align:center}.coach-face{font-size:clamp(65px,8vw,102px);animation:facePop .35s ease both}.coach-card p{min-height:84px;margin:13px 0 18px;color:var(--ink-soft);font-size:clamp(15px,1.7vw,20px);line-height:1.35;font-weight:750}.coach-card.is-sad{background:#f2ecff}.coach-card.is-sad .coach-face{animation:sadWiggle .5s ease}.coach-tip{display:flex;align-items:center;justify-content:center;gap:8px;min-height:48px;padding:9px 12px;border-radius:17px;color:#7d5b00;background:#fff3b6;font-size:13px}.coach-tip span{font-size:22px}.canvas-card{min-height:470px;position:relative;overflow:hidden;border-radius:38px;background:rgba(255,255,255,.9)}.canvas-card:before{content:"";position:absolute;inset:18px;border:3px dashed #eeddf2;border-radius:27px;pointer-events:none}.letter-chip{position:absolute;z-index:2;top:22px;left:25px;padding:9px 15px;border-radius:15px;color:var(--ink-soft);background:#fff4c6;font-size:12px;font-weight:900;letter-spacing:.08em;pointer-events:none}.letter-chip strong{color:var(--pink-deep);font-size:20px;margin-left:4px}#traceCanvas{display:block;width:100%;height:100%;min-height:470px;touch-action:none;cursor:crosshair}.canvas-message{position:absolute;left:50%;bottom:28px;transform:translateX(-50%) translateY(20px);padding:10px 18px;border-radius:99px;color:#fff;background:var(--pink);font-weight:900;opacity:0;pointer-events:none;white-space:nowrap;transition:.25s ease}.canvas-message.is-visible{opacity:1;transform:translateX(-50%) translateY(0)}.action-rail{align-self:center;display:grid;gap:14px;padding:17px;border-radius:30px;background:rgba(255,255,255,.68)}.tool-button{min-height:116px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;border:0;border-radius:23px;color:var(--ink);cursor:pointer}.tool-button span{font-size:38px}.tool-button b{font-size:12px;letter-spacing:.06em}.hint-button{background:#fff0aa}.clear-button{background:#e8dcff}
.celebration{position:fixed;inset:0;z-index:20;display:grid;place-items:center;visibility:hidden;opacity:0;background:radial-gradient(circle at center,rgba(255,245,252,.2),rgba(62,20,82,.46));backdrop-filter:blur(5px);transition:opacity .25s ease,visibility .25s}.celebration.is-active{visibility:visible;opacity:1}#fireworksCanvas{position:absolute;inset:0;width:100%;height:100%}.celebration-card{position:relative;z-index:2;width:min(560px,84vw);padding:28px;border:6px solid #fff;border-radius:42px;background:linear-gradient(145deg,#ffedf7,#fff9c9);box-shadow:0 30px 90px rgba(69,24,91,.3);text-align:center;transform:scale(.5) rotate(-5deg);opacity:0}.celebration.is-active .celebration-card{animation:celebrateCard .58s cubic-bezier(.2,1.4,.45,1) forwards}.celebration-unicorn{font-size:clamp(100px,18vw,180px);animation:unicornDance .7s ease-in-out infinite alternate}.celebration-stars{color:#ffb900;font-size:34px;letter-spacing:14px}.celebration-card h2{color:var(--pink-deep);font-size:clamp(37px,7vw,72px)}.celebration-card p{margin:10px 0 0;color:var(--ink-soft);font-size:clamp(17px,2.4vw,24px);font-weight:750}
@media(max-width:900px){.app-shell{padding-left:16px;padding-right:16px}.welcome-screen{align-items:flex-start;padding-top:42px}.welcome-copy{width:57%}.welcome-art{width:43%;margin-top:28px}.letter-bubble{width:58px;height:58px;border-radius:19px;font-size:30px}.word-grid{grid-template-columns:repeat(2,1fr)}.trace-layout{grid-template-columns:150px 1fr;grid-template-rows:1fr auto}.action-rail{grid-column:1/-1;grid-template-columns:1fr 1fr;width:100%;padding:10px}.tool-button{min-height:72px;flex-direction:row}.canvas-card,#traceCanvas{min-height:500px}}
@media(max-width:640px){.topbar{min-height:64px}.brand-unicorn{width:48px;height:48px;font-size:30px;border-radius:16px}.brand strong{font-size:19px}.score{min-width:78px;padding:8px 13px}.welcome-screen{flex-direction:column;padding:25px 4% 100px}.welcome-copy,.welcome-art{width:100%}.welcome-art{height:300px;order:-1;margin:-15px auto -40px}.hero-unicorn{font-size:155px}.welcome-copy{text-align:center}.welcome-copy p{margin-left:auto;margin-right:auto}.primary-button{width:100%;justify-content:space-between}.words-entry{left:4%;right:4%;bottom:15px;justify-content:space-between}.word-card{min-height:145px;padding:16px}.trace-topline{grid-template-columns:auto 1fr}.letter-progress{grid-column:1/-1;justify-content:center}.trace-layout{display:flex;flex-direction:column}.coach-card{display:grid;grid-template-columns:auto 1fr;align-items:center;gap:12px;width:100%;padding:12px 16px;text-align:left}.coach-face{font-size:52px}.coach-card p{min-height:0;margin:0;font-size:15px}.coach-tip{grid-column:1/-1;min-height:38px}.canvas-card,#traceCanvas{min-height:390px}}
@media(orientation:landscape) and (max-height:700px){.app-shell{padding-top:10px;padding-bottom:10px}.topbar{min-height:58px}.brand-unicorn{width:44px;height:44px;font-size:28px}.screen{min-height:calc(100dvh - 78px)}.welcome-screen{padding-top:8px}.welcome-art{max-height:450px}.trace-screen{padding-top:4px}.trace-topline{margin-bottom:7px}.canvas-card,#traceCanvas{min-height:400px}.coach-card{padding:16px 14px}.tool-button{min-height:95px}}
@keyframes twinkle{50%{opacity:.25;transform:scale(.6) rotate(30deg)}}@keyframes float{50%{transform:translateY(-14px) rotate(2deg)}}@keyframes screenIn{from{opacity:0;transform:translateY(12px)}}@keyframes facePop{from{transform:scale(.65)}70%{transform:scale(1.1)}}@keyframes sadWiggle{25%{transform:rotate(-7deg)}75%{transform:rotate(7deg)}}@keyframes celebrateCard{to{transform:scale(1) rotate(0);opacity:1}}@keyframes unicornDance{to{transform:translateY(-14px) rotate(5deg) scale(1.04)}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation-duration:.001ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important}}

/* Simple, child-friendly welcome typography and mode buttons. */
h1 em{display:block;margin-top:12px;color:var(--pink);font-family:ui-rounded,"SF Pro Rounded","Arial Rounded MT Bold",system-ui,sans-serif;font-size:.72em;font-style:normal;font-weight:950;line-height:1;letter-spacing:-.035em}
.welcome-copy p{margin-bottom:22px}.welcome-actions{display:flex;gap:10px;margin-top:14px}.choice-button{flex:1;min-height:68px;display:flex;align-items:center;gap:10px;padding:9px 12px;border:3px solid #fff;border-radius:21px;color:var(--ink);background:rgba(255,255,255,.78);box-shadow:0 10px 26px rgba(80,39,111,.11);cursor:pointer;text-align:left}.choice-icon{font-size:28px}.choice-button small,.choice-button strong{display:block}.choice-button small{color:var(--ink-soft);font-size:8px;font-weight:850;letter-spacing:.08em}.choice-button strong{margin-top:3px;font-size:13px}.choice-button b{margin-left:auto;color:var(--pink);font-size:22px}
@media(max-width:640px){.welcome-screen{padding-bottom:34px}.welcome-actions{display:grid;grid-template-columns:1fr 1fr}.choice-button{min-width:0;padding:8px}.choice-icon{font-size:25px}.choice-button small{font-size:7px}.choice-button strong{font-size:11px}h1 em{font-size:.68em}}

/* The coach now sits beside the lesson title; the writing field gets the full width. */
.trace-topline{grid-template-columns:auto minmax(180px,.72fr) minmax(300px,1.05fr) auto;gap:16px;margin-bottom:12px}
.trace-topline .coach-card{align-self:stretch;display:grid;grid-template-columns:auto 1fr;grid-template-rows:1fr auto;align-items:center;column-gap:12px;row-gap:4px;min-width:0;padding:10px 14px;border-radius:24px;text-align:left}
.trace-topline .coach-face{grid-row:1/-1;font-size:clamp(46px,5vw,66px)}
.trace-topline .coach-card p{min-height:0;margin:0;font-size:clamp(13px,1.35vw,17px);line-height:1.24}
.trace-topline .coach-tip{justify-content:flex-start;min-height:0;width:max-content;padding:5px 10px;font-size:11px}
.trace-topline .coach-tip span{font-size:16px}
.trace-layout{display:block;flex:1;min-height:0}
.canvas-card,#traceCanvas{min-height:clamp(520px,calc(100dvh - 225px),720px)}
@media(max-width:900px){.trace-topline{grid-template-columns:auto minmax(0,1fr) auto}.trace-topline .coach-card{grid-column:2/4}.letter-progress{grid-column:1/-1}.trace-layout{display:block}.canvas-card,#traceCanvas{min-height:clamp(480px,calc(100dvh - 300px),660px)}}
@media(max-width:640px){.trace-topline{grid-template-columns:auto 1fr;gap:10px}.trace-topline .coach-card{grid-column:1/-1}.trace-topline .coach-face{font-size:45px}.trace-topline .coach-card p{font-size:14px}.canvas-card,#traceCanvas{min-height:430px}}

/* Big, unmistakable activity cards for small hands. */
.choice-button{display:grid;grid-template-columns:1fr auto;grid-template-rows:auto auto;min-height:126px;padding:13px 15px;transition:transform .18s ease,box-shadow .18s ease,background .18s ease}
.choice-button:hover{transform:translateY(-3px);box-shadow:0 16px 34px rgba(80,39,111,.17);background:#fff}
.choice-button:active{transform:scale(.97)}
.mode-preview{grid-column:1/-1;display:flex;align-items:center;gap:7px;min-height:48px}
.mode-preview i{display:grid;place-items:center;height:44px;border:3px solid #fff;border-radius:14px;box-shadow:0 7px 15px rgba(73,40,99,.13);font-style:normal;font-weight:950;transform:rotate(-4deg);animation:tileFloat 2.6s ease-in-out infinite}
.number-preview i{width:44px;color:#fff;background:var(--tile,#ff4e9b);font-size:24px}
.number-preview i:nth-child(2){--tile:#7457df;transform:rotate(4deg);animation-delay:-.35s}.number-preview i:nth-child(3){--tile:#39c8a8;animation-delay:-.7s}.number-preview i:nth-child(4){--tile:#ffb92e;transform:rotate(5deg);animation-delay:-1.05s}
.word-preview i{padding:0 11px;color:var(--ink);background:var(--tile,#ffe2ef);font-size:13px}.word-preview i:nth-child(2){--tile:#dff3ff;transform:rotate(3deg);animation-delay:-.45s}.word-preview i:nth-child(3){--tile:#ddf5c9;animation-delay:-.9s}
.choice-copy{align-self:center}.choice-button small{font-size:9px}.choice-button strong{font-size:16px}.choice-button b{align-self:center;display:grid;place-items:center;width:40px;height:40px;border-radius:13px;color:#fff;background:var(--pink);font-size:25px}
@keyframes tileFloat{50%{translate:0 -3px}}

/* Welcome and tracing fit exactly inside a portrait tablet viewport. */
.no-page-scroll{height:100dvh;overflow:hidden;overscroll-behavior:none}
.no-page-scroll .app-shell{display:flex;flex-direction:column;height:100dvh;min-height:0;overflow:hidden}
.no-page-scroll .topbar{flex:0 0 auto}
.no-page-scroll .screen.is-active{flex:1;min-height:0}
@media(max-width:640px){
  .no-page-scroll .app-shell{padding-top:max(8px,env(safe-area-inset-top));padding-bottom:max(8px,env(safe-area-inset-bottom))}
  .topbar{min-height:58px}
  .welcome-screen{justify-content:center;gap:0;padding:0 2% 6px;overflow:hidden}
  .welcome-art{flex:0 0 195px;width:min(100%,360px);height:195px;margin:-12px auto -10px;max-height:none}
  .hero-unicorn{font-size:112px}.letter-bubble{width:46px;height:46px;border-width:4px;border-radius:16px;font-size:24px}.mini-star{font-size:29px}
  .welcome-copy{display:flex;flex-direction:column;width:100%;align-items:stretch;text-align:center}
  .welcome-copy>.eyebrow{align-self:center;font-size:10px}.welcome-copy h1{margin:5px 0 8px;font-size:40px;line-height:.94}.welcome-copy h1 em{margin-top:5px}
  .welcome-copy p{display:none}.primary-button{min-height:58px;padding-left:20px;border-radius:20px}.primary-button b{width:42px;height:42px}
  .welcome-actions{grid-template-columns:1fr 1fr;gap:10px;margin-top:10px}
  .choice-button{min-height:118px;padding:10px;border-radius:22px}.mode-preview{justify-content:center;gap:4px;min-height:45px}.mode-preview i{height:39px;border-radius:12px}
  .number-preview i{width:32px;font-size:19px}.word-preview i{padding:0 7px;font-size:10px}.choice-button small{font-size:7px}.choice-button strong{font-size:12px}.choice-button b{width:34px;height:34px;font-size:21px}
  .trace-screen{height:auto;min-height:0;padding:2px 1% 6px;overflow:hidden}.trace-topline{gap:7px;margin-bottom:7px}.round-back{width:50px;height:50px;border-radius:17px}.lesson-title h2{font-size:32px}.lesson-title .eyebrow{font-size:10px}
  .trace-topline .coach-card{grid-template-columns:auto 1fr auto;grid-template-rows:1fr;column-gap:9px;padding:7px 10px;border-radius:20px}.trace-topline .coach-face{grid-row:auto;font-size:42px}.trace-topline .coach-card p{font-size:13px}.trace-topline .coach-tip{padding:5px 8px;white-space:nowrap}
  .letter-progress{gap:5px}.progress-letter{width:37px;height:37px;border-radius:12px}
  .trace-layout{flex:1;height:auto;min-height:0}.canvas-card,#traceCanvas{height:100%;min-height:0}.canvas-card{border-radius:28px}.canvas-card:before{inset:12px;border-radius:20px}
}

/* The lesson already has its own navigation, so the global header only used space. */
.topbar{display:none}

/* Pink success fireworks always fly above the game and celebration card. */
#successFireworksCanvas{position:fixed;inset:0;z-index:40;width:100%;height:100%;pointer-events:none;opacity:0;transition:opacity .12s ease;mix-blend-mode:screen}
#successFireworksCanvas.is-active{opacity:1}
