*{box-sizing:border-box}
:root{--ink:#22184a;--card:#ffffff;--soft:#f3efff;--accent:#5a7cff;--pink:#ff7fc4;--gold:#ffcf3d;--ok:#3fbf7f;--thumb:72px;--safe-b:env(safe-area-inset-bottom,0px)}
html,body{margin:0;height:100%}
body{font-family:system-ui,-apple-system,"Segoe UI",sans-serif;color:var(--ink);background:linear-gradient(160deg,#2a2160 0%,#4b3b9a 40%,#e9b8f2 100%);background-attachment:fixed;
  display:grid;grid-template-rows:auto auto auto 1fr auto;grid-template-columns:100%;height:100dvh;overflow:hidden;-webkit-tap-highlight-color:transparent}
button{font:inherit;cursor:pointer;touch-action:manipulation}
button:focus-visible,input:focus-visible,a:focus-visible,summary:focus-visible{outline:3px solid var(--gold);outline-offset:3px}
[hidden]{display:none!important}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

.topbar{display:flex;align-items:center;gap:10px;padding:8px 12px 4px;padding-top:max(8px,env(safe-area-inset-top));color:#fff}
.topbar h1{flex:1;margin:0;font-size:24px;display:flex;align-items:center;gap:8px;letter-spacing:.3px}
.logo{width:30px;height:auto;filter:drop-shadow(0 2px 6px #ff7fc488)}
.icon-btn{min-width:48px;min-height:48px;border:0;border-radius:14px;background:#ffffff26;color:#fff;font-size:22px;display:inline-flex;align-items:center;justify-content:center;text-decoration:none}
.icon-btn:active{transform:scale(.94)}

/* Kubby lives in the top corner: information up top, thumbs stay free at the bottom. */
.kubby-corner{display:flex;align-items:flex-start;gap:8px;padding:2px 12px 6px;min-height:104px}
.kubby{flex:none;border:0;background:none;padding:0;width:70px;height:104px;position:relative}
.kubby img{width:70px;height:auto;display:block;filter:drop-shadow(0 4px 10px #0005);transform-origin:50% 100%;animation:idle 3.2s ease-in-out infinite}
.kubby.talking img{animation:talk .45s ease-in-out infinite}
.kubby::after{content:"";position:absolute;left:32px;top:58px;width:12px;height:12px;border-radius:50%;background:#ff9be0;opacity:0;box-shadow:0 0 16px 8px #ff7fc4}
.kubby.talking::after{animation:glow .45s ease-in-out infinite}
@keyframes idle{50%{transform:translateY(-3px) rotate(-1deg)}}
@keyframes talk{50%{transform:translateY(-4px) rotate(2deg) scale(1.02)}}
@keyframes glow{50%{opacity:.75}}
.bubble{position:relative;flex:1;background:var(--card);border-radius:18px;padding:10px 14px;font-size:16px;line-height:1.35;font-weight:600;box-shadow:0 6px 16px #0003;max-height:104px;overflow:auto;margin-top:6px}
/* The arcade Shop button sits at the top right; the bubble flows its words around it. */
.bubble::before{content:"";float:right;width:var(--shop-gap,0px);height:66px;margin:-10px -14px 0 6px}
.kubby-corner{position:relative}
.kubby-corner::after{content:"";position:absolute;left:79px;top:28px;border:10px solid transparent;border-right-color:var(--card);border-left:0}
html[data-arcade-game] .kubby-corner{--shop-gap:118px}
.bubble.pop{animation:pop .25s ease-out}
@keyframes pop{from{transform:scale(.96);opacity:.6}}

.tabs{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;padding:0 12px 8px}
.tab{min-height:52px;border:3px solid transparent;border-radius:16px;background:#ffffff2e;color:#fff;font-weight:800;font-size:15px;display:flex;align-items:center;justify-content:center;gap:4px;padding:0 4px}
.tab[aria-pressed="true"]{background:#fff;color:var(--ink);border-color:var(--gold)}
.count{background:var(--gold);color:var(--ink);border-radius:999px;padding:0 7px;font-size:13px;min-width:22px}
.count:empty{display:none}

main{overflow:auto;padding:0 12px 12px;-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
.view{background:#ffffffeb;border-radius:22px;padding:14px;min-height:100%;box-shadow:0 8px 24px #0002}
.hint{margin:0 0 10px;color:#5b4f86;font-size:15px}
.small-title{font-size:17px;margin:16px 0 8px}
.small-title:first-of-type{margin-top:4px}

/* Chat */
.chat{display:flex;flex-direction:column;gap:10px}
.msg{display:flex;flex-direction:column;gap:8px;max-width:92%}
.msg p{margin:0;padding:10px 14px;border-radius:18px;font-size:17px;line-height:1.35}
.msg.from-kubby{align-self:flex-start}
.msg.from-kubby p{background:var(--soft);border-top-left-radius:6px}
.msg.from-me{align-self:flex-end;align-items:flex-end}
.msg.from-me p{background:var(--accent);color:#fff;border-top-right-radius:6px}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{min-height:48px;padding:8px 14px;border-radius:999px;border:2px solid #c9bff5;background:#fff;color:var(--ink);font-weight:700;font-size:15px}
.chip:active{background:var(--soft)}
.topic-card{display:flex;align-items:center;gap:12px;width:100%;min-height:72px;padding:10px 14px;border:3px solid var(--gold);border-radius:18px;background:#fff8dd;color:var(--ink);text-align:left}
.topic-card b{display:block;font-size:18px}
.topic-card small{color:#6a5f8f;font-size:14px}
.topic-emoji{font-size:34px}
.topic-card .go{margin-left:auto;background:var(--ok);color:#fff;font-weight:800;padding:10px 14px;border-radius:14px;white-space:nowrap}

/* Skill book */
.skill-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:10px}
.skill-tile{position:relative;min-height:96px;border:3px solid #e2dcfb;border-radius:18px;background:#fff;color:var(--ink);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:10px;font-weight:700;font-size:15px;line-height:1.2}
.tile-emoji{font-size:34px}
.skill-tile.done{border-color:var(--gold);background:#fffbe8}
.skill-tile.done::after{content:"⭐";position:absolute;top:6px;right:8px;font-size:20px}
.skill-tile:active{transform:scale(.97)}

/* Steps */
.step-head{display:flex;align-items:center;gap:8px}
.step-head h2{flex:1;margin:0;font-size:22px}
.step-head .icon-btn{order:-1}
.step-head .icon-btn{background:var(--soft);color:var(--ink)}
.ingredients{margin:10px 0;background:#fff8dd;border-radius:14px;padding:6px 12px}
.ingredients summary{min-height:44px;display:flex;align-items:center;font-weight:800;cursor:pointer}
.ingredients ul{margin:0 0 8px;padding-left:22px;font-size:16px;line-height:1.5}
.dots{display:flex;gap:6px;justify-content:center;margin:12px 0}
.dot{width:14px;height:14px;border-radius:50%;background:#ddd6f7}
.dot.done{background:var(--ok)}
.dot.now{background:var(--accent);transform:scale(1.3)}
.step-card{text-align:center;background:linear-gradient(180deg,#fff,#f6f2ff);border:3px solid #d9d0fb;border-radius:22px;padding:14px 12px}
.step-card.slide{animation:slide .3s ease-out}
@keyframes slide{from{transform:translateX(24px);opacity:0}}
.step-card.needs-grownup{border-color:#ff9f5a;background:linear-gradient(180deg,#fff,#fff1e6)}
.step-emoji{font-size:60px;line-height:1.1}
.step-text{font-size:24px;line-height:1.35;font-weight:700;margin:10px 0}
.grownup{display:inline-block;margin:4px 0 0;background:#ff9f5a;color:#fff;font-weight:800;border-radius:999px;padding:8px 14px}
.celebrate{text-align:center;padding:10px}
.big-star{font-size:96px;animation:spin-in .8s ease-out}
@keyframes spin-in{from{transform:scale(.2) rotate(-180deg)}}
.celebrate p{font-size:22px;font-weight:700}
.celebrate-actions,.movie-actions{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.big-btn{min-height:72px;border:0;border-radius:20px;background:var(--ok);color:#fff;font-size:20px;font-weight:800;box-shadow:0 5px 0 #2b8c5c}
.big-btn.alt{background:var(--accent);box-shadow:0 5px 0 #3550b8}
.big-btn:active{transform:translateY(3px);box-shadow:none}

/* Art studio */
.art-frame{border-radius:20px;overflow:hidden;aspect-ratio:4/3;background:var(--soft);box-shadow:inset 0 0 0 3px #e2dcfb}
.art-frame svg{display:block;width:100%;height:100%}
.art-empty{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:18px;font-size:17px}
.art-empty span{font-size:56px}
.art-tools{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:10px}
.tool-btn{min-height:56px;border:3px solid #e2dcfb;border-radius:16px;background:#fff;color:var(--ink);font-weight:800;font-size:15px}
.tool-btn:first-child{background:var(--pink);border-color:var(--pink);color:#fff}
.gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(110px,1fr));gap:8px}
.thumb-pic{padding:0;border:3px solid #e2dcfb;border-radius:14px;overflow:hidden;background:none;aspect-ratio:4/3;min-height:64px}
.thumb-pic svg{display:block;width:100%;height:100%}

/* Picture styles and real pictures */
.art-styles,.lyric-mode{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:10px}
.lyric-mode{grid-template-columns:1fr 1fr}
.style-btn{min-height:52px;border:3px solid #e2dcfb;border-radius:16px;background:#fff;color:var(--ink);font-weight:800;font-size:15px}
.style-btn[aria-pressed="true"]{border-color:var(--gold);background:#fff8dd;box-shadow:0 0 0 2px var(--gold) inset}
.art-note{background:#fff1e6;border-radius:12px;padding:8px 12px}
.art-frame .real-pic{display:block;width:100%;height:100%;object-fit:cover}
.thumb-pic img{display:block;width:100%;height:100%;object-fit:cover}
.art-working{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;padding:16px;font-weight:800;font-size:17px}
.art-working p{margin:0}
.art-working img{width:64px;animation:talk .45s ease-in-out infinite}
.working-bar{width:80%;height:12px;border-radius:999px;background:#e2dcfb;overflow:hidden}
.working-bar span{display:block;height:100%;width:30%;border-radius:999px;background:linear-gradient(90deg,var(--pink),var(--accent));animation:working 1.4s ease-in-out infinite}
@keyframes working{0%{transform:translateX(-100%)}100%{transform:translateX(340%)}}

/* Song studio */
.song-styles{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:10px}
.song-style{min-height:72px;border:3px solid #e2dcfb;border-radius:18px;background:#fff;color:var(--ink);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-size:15px}
.song-style span{font-size:28px}
.song-style[aria-pressed="true"]{border-color:var(--gold);background:#fff8dd;box-shadow:0 0 0 2px var(--gold) inset}
.own-words{width:100%;border:3px solid #e2dcfb;border-radius:16px;padding:10px 12px;font:600 17px system-ui,sans-serif;color:var(--ink);resize:vertical;margin-bottom:8px}
.song-player{background:linear-gradient(160deg,#2a2160,#5a3fb0);color:#fff;border-radius:20px;padding:12px;margin:6px 0 4px}
.song-head{display:flex;align-items:center;gap:10px}
.song-head div{flex:1;min-width:0}
.song-head b{display:block;font-size:18px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.song-head small{color:#ffffffbb}
.song-head .tool-btn{min-height:52px;padding:0 12px;background:#ffffff22;border-color:transparent;color:#fff}
.play-btn{flex:none;width:64px;height:64px;border:0;border-radius:50%;background:var(--ok);color:#fff;font-size:28px;box-shadow:0 4px 0 #2b8c5c}
.karaoke{max-height:240px;overflow:auto;margin-top:10px;padding:4px 6px}
.karaoke h3{margin:10px 0 2px;font-size:13px;text-transform:uppercase;letter-spacing:1px;color:#ffd84d}
.lyric{margin:4px 0;font-size:18px;line-height:1.35;color:#ffffffaa;transition:color .2s,transform .2s;transform-origin:left center}
.lyric.now{color:#fff;font-weight:800;transform:scale(1.06)}
.song-list{display:flex;flex-direction:column;gap:8px}
.song-item{min-height:56px;text-align:left;padding:8px 14px;border:3px solid #e2dcfb;border-radius:16px;background:#fff;color:var(--ink);font-weight:700;font-size:16px}

/* Movie */
.movie{position:fixed;inset:0;z-index:100;background:#120c2be6;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;padding:16px}
.movie-stage{position:relative;width:min(100%,calc((100dvh - 140px) * 4 / 3));aspect-ratio:4/3;border-radius:22px;overflow:hidden;box-shadow:0 10px 40px #000a}
.movie-stage svg{width:100%;height:100%;display:block;transition:transform 4s ease-out}
.movie-stage.shot-0 svg{animation:zoom-out 4.2s ease-out both}
.movie-stage.shot-1 svg{animation:zoom-in 4.2s ease-out both}
.movie-stage.shot-2 svg{animation:pan 4.2s ease-in-out both}
@keyframes zoom-out{from{transform:scale(1.25)}to{transform:scale(1)}}
@keyframes zoom-in{from{transform:scale(1)}to{transform:scale(1.35) translateY(-6%)}}
@keyframes pan{from{transform:scale(1.15) translateX(5%)}to{transform:scale(1.15) translateX(-5%)}}
.hearts{position:absolute;inset:0;display:flex;justify-content:space-around;align-items:flex-end;font-size:40px;pointer-events:none}
.hearts{animation:float-up 2s ease-out both}
@keyframes float-up{from{transform:translateY(40%);opacity:0}to{transform:translateY(-40%);opacity:1}}
.movie-actions{width:min(100%,520px)}
@media (prefers-reduced-motion:reduce){.movie-stage svg,.hearts,.kubby img,.step-card.slide,.big-star{animation:none!important}}

/* The two-thumb bar: left thumb helps, right thumb does the main action. */
.thumbbar{display:flex;align-items:center;gap:10px;padding:10px 12px;padding-bottom:calc(10px + var(--safe-b));background:#1d1647ee;backdrop-filter:blur(6px);box-shadow:0 -6px 18px #0003}
.thumb{flex:none;min-width:var(--thumb);min-height:var(--thumb);border:0;border-radius:22px;font-weight:900;font-size:24px;color:#fff;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.thumb.left{background:#ffffff2e;font-size:26px}
.thumb.right{min-width:122px;background:var(--ok);font-size:21px;box-shadow:0 5px 0 #2b8c5c}
.thumb:active{transform:translateY(3px);box-shadow:none}
.thumb:disabled{opacity:.35;cursor:default}
body[data-mode="name"] .thumb.left{font-size:18px}
body[data-mode="art"] .thumb.right{background:var(--pink);box-shadow:0 5px 0 #c4498c}
.ask-form{flex:1;min-width:0}
.ask-form input{width:100%;min-height:58px;border:3px solid #ffffff55;border-radius:18px;padding:0 14px;font:600 18px system-ui,sans-serif;background:#fff;color:var(--ink)}
.step-count{flex:1;text-align:center;color:#fff;font-weight:800;font-size:18px}
.build{position:fixed;right:6px;bottom:0;margin:0;font:9px monospace;color:#fff6;pointer-events:none;z-index:1}

/* Landscape phones: Kubby and the tabs move to a side column so the content keeps its height. */
@media (orientation:landscape) and (max-height:540px){
  body{grid-template-columns:240px 1fr;grid-template-rows:auto auto 1fr auto}
  .topbar{grid-column:1/-1;grid-row:1;padding-top:4px;padding-bottom:2px}
  .topbar h1{font-size:20px}
  .icon-btn{min-height:44px;min-width:44px}
  .kubby-corner{grid-column:1;grid-row:2;min-height:0;padding-right:4px}
  .kubby{width:52px;height:80px}
  .kubby img{width:52px}
  .bubble{max-height:96px;font-size:14px;margin-top:0;padding:8px 10px}
  .kubby-corner::after{left:62px;top:22px}
  html[data-arcade-game] .kubby-corner{--shop-gap:0px}
  html[data-arcade-game] main{padding-right:136px}
  .tabs{grid-column:1;grid-row:3;align-content:start;grid-template-columns:1fr 1fr;gap:6px;padding-right:4px}
  .tab{min-height:44px;font-size:15px}
  .song-style{min-height:60px}
  main{grid-column:2;grid-row:2/4;padding-top:0}
  .thumbbar{grid-column:1/-1;grid-row:4;padding-top:8px;padding-bottom:calc(8px + var(--safe-b));padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right))}
  .step-emoji{font-size:48px}
  .step-text{font-size:20px}
  .art-frame{max-height:calc(100dvh - 200px);margin:auto}
}

.reading-box{margin:8px 12px;padding:12px;background:var(--card);border-radius:14px}
.reading-box summary{cursor:pointer;min-height:44px;display:flex;align-items:center}
.reading-box label{display:block;margin:8px 0}
.reading-box textarea{box-sizing:border-box;width:100%;font:inherit;border-radius:8px;padding:10px}
.msg p{white-space:pre-wrap;overflow-wrap:anywhere}
.msg p a{color:inherit;text-decoration:underline;text-underline-offset:3px}
