:root{
  --ink:#1f2a44; --paper:#fdfcf6; --line:#cfdaf0; --line2:#a9bde3; --vline:#ecd6ee; --margin:#ef6b6b;
  --chalk:#2f5d50; --wood:#b97c45; --sun:#ffc83d; --ok:#2fa36b; --bad:#e2574c;
  --c0:#ff8a3d; --c1:#2fa36b; --c2:#2d7be0; --c3:#9b4fd1; --lc:var(--c0);
  font-size:clamp(12px, calc(min(2.3vh, 1.65vw) + 4px), 28px);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%;margin:0;overflow:hidden;background:var(--paper)}
body{font-family:"Trebuchet MS","Segoe UI",system-ui,-apple-system,Roboto,Arial,sans-serif;color:var(--ink);touch-action:manipulation;user-select:none;-webkit-user-select:none;
  background-color:var(--paper);
  background-image:
    linear-gradient(90deg, transparent 2.6rem, var(--margin) 2.6rem, var(--margin) calc(2.6rem + 2px), transparent calc(2.6rem + 2px)),
    repeating-linear-gradient(90deg, transparent 0 31px, var(--vline) 31px 32px),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--line2) 31px 32px),
    repeating-linear-gradient(180deg, transparent 0 7px, var(--line) 7px 8px);
}
button{font:inherit;color:inherit;border:0;background:none;cursor:pointer;padding:0}
svg{display:block}
#app{position:fixed;inset:0;display:flex;flex-direction:column}
#top{flex:0 0 auto;display:flex;align-items:center;gap:.5rem;padding:.35rem .6rem;height:3rem;background:rgba(255,255,255,.88);border-bottom:3px solid #e8e1cf;z-index:5}
.brand{font-weight:900;font-size:1.25rem;letter-spacing:.2px;color:var(--chalk);white-space:nowrap}
.sp{flex:1}
.hbtn{width:2.3rem;height:2.3rem;border-radius:.8rem;background:#fff;border:2.5px solid var(--ink);display:grid;place-items:center;box-shadow:0 3px 0 var(--ink);flex:0 0 auto}
.hbtn svg{width:1.3rem;height:1.3rem}
.hbtn:active{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
#bHome{visibility:hidden}
.hstat{display:flex;align-items:center;gap:.25rem;background:#fff8df;border:2.5px solid var(--ink);border-radius:2rem;padding:.15rem .6rem .15rem .35rem;font-weight:900;font-size:1.05rem}
.hstat svg{width:1.4rem;height:1.4rem}.hstat small{opacity:.55;font-size:.8rem}
.screen{position:absolute;inset:3rem 0 0 0;display:none;flex-direction:column;align-items:center;justify-content:center;padding:.6rem;padding-left:3.1rem}
.screen.on{display:flex}
.card{background:#fff;border:3px solid var(--ink);border-radius:1.4rem;box-shadow:0 .4rem 0 var(--ink);padding:1rem 1.2rem}

/* start */
.startcard{display:flex;align-items:center;gap:1.2rem;max-width:54rem;width:100%;max-height:100%}
.heroP{height:min(17rem,52vh);width:auto;flex:0 0 auto;animation:bob 2.6s ease-in-out infinite}
.stxt{flex:1;min-width:0;display:flex;flex-direction:column;align-items:flex-start;gap:.6rem}
h1{margin:0;font-size:2.4rem;line-height:1.05;color:var(--chalk)}
h1 span{display:block;font-size:1.15rem;color:var(--margin);margin-top:.25rem}
.intro{margin:0;font-size:1rem;line-height:1.35}
.big{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;font-weight:900;font-size:1.35rem;color:#fff;background:var(--ok);border:3px solid var(--ink);border-radius:1rem;padding:.55rem 1.3rem;box-shadow:0 .3rem 0 var(--ink)}
.big svg{width:1.4rem;height:1.4rem}
.big:active{transform:translateY(3px);box-shadow:0 1px 0 var(--ink)}
.big.play{font-size:1.6rem;padding:.6rem 2.2rem;animation:pulse 1.6s ease-in-out infinite}
.big.alt{background:#2d7be0}.big.ghost{background:#fff;color:var(--ink)}
.howrow{display:flex;flex-wrap:wrap;gap:.35rem 1rem;font-size:.85rem;opacity:.85}
.howrow span{display:inline-flex;align-items:center;gap:.2rem}
.kbd{display:inline-block;min-width:1.3rem;padding:0 .3rem;height:1.3rem;line-height:1.1rem;border:2px solid var(--ink);border-bottom-width:3px;border-radius:.35rem;font-style:normal;font-weight:800;font-size:.75rem;text-align:center;background:#fff}
.kbd.tap{background:radial-gradient(circle,var(--ink) 30%,transparent 34%) center/100% 100% no-repeat,#fff;border-radius:50%;min-width:1.3rem}

/* map */
#map{justify-content:flex-start;gap:.5rem}
.tabs{display:flex;gap:.4rem;width:100%;max-width:62rem;flex:0 0 auto}
.tab{flex:1;min-width:0;border:3px solid var(--ink);border-radius:1rem 1rem .5rem .5rem;background:#fff;padding:.3rem .3rem;box-shadow:0 .25rem 0 var(--ink);display:flex;flex-direction:column;align-items:center;line-height:1.1}
.tab b{font-size:1.15rem;white-space:nowrap}.tab small{font-size:.72rem;opacity:.8;white-space:nowrap}
.tab .tst{font-size:.72rem;font-weight:800;color:#7a4b00}
.tab.on{background:var(--tc);color:#fff;transform:translateY(-2px)}
.tab.on .tst{color:#fff}
.lvl{flex:1;min-height:0;width:100%;max-width:62rem;display:flex;flex-direction:column;gap:.3rem}
.lvlhead{display:flex;align-items:center;gap:.5rem;flex:0 0 auto}
.mapP{height:3.2rem;width:auto}
.bubble{position:relative;background:#fff;border:2.5px solid var(--ink);border-radius:1rem;padding:.35rem .8rem;font-weight:800;font-size:1rem}
.bubble:before{content:"";position:absolute;left:-.55rem;top:50%;margin-top:-.4rem;border:.4rem solid transparent;border-right:.55rem solid var(--ink);border-left:0}
.path{position:relative;flex:1;min-height:0;display:flex}
.pathline{position:absolute;inset:8% 2%;width:96%;height:84%;z-index:0}
.cards{position:relative;z-index:1;flex:1;max-height:24rem;align-self:center;width:100%;display:flex;gap:1rem;align-items:stretch;justify-content:center;min-height:0}
.gcard{flex:1;max-width:17rem;min-width:0;background:#fff;border:3px solid var(--ink);border-radius:1.2rem;box-shadow:0 .35rem 0 var(--ink);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.25rem;padding:.5rem;position:relative;overflow:hidden}
.gcard:nth-child(2){margin-top:1.4rem}
.gcard .num{position:absolute;left:.45rem;top:.35rem;width:1.6rem;height:1.6rem;border-radius:50%;background:var(--lc);color:#fff;font-weight:900;display:grid;place-items:center;font-size:.9rem;border:2px solid var(--ink)}
.gcard .gi{height:min(7.5rem,20vh);width:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}
.gcard .gi svg,.gcard .gi img{height:100%;width:auto;max-width:90%;object-fit:contain}
.gcard .gi .glyph{font-size:min(4.2rem,12vh);font-weight:900;color:var(--lc);line-height:1;white-space:nowrap}
.gcard b{font-size:1.1rem;text-align:center;line-height:1.1}
.gcard small{font-size:.8rem;opacity:.75;text-align:center;line-height:1.15}
.gcard:active{transform:translateY(3px);box-shadow:0 1px 0 var(--ink)}
.gcard.sel{outline:4px solid var(--sun);outline-offset:2px}
.st3{display:flex;gap:.1rem}.st3 svg{width:1.25rem;height:1.25rem}
.trail{flex:0 0 auto;display:flex;align-items:center;gap:.25rem;background:rgba(255,255,255,.9);border:2.5px dashed #b9c3d6;border-radius:2rem;padding:.25rem .6rem;max-width:62rem;width:100%;justify-content:center;flex-wrap:nowrap}
.trail .tl{font-weight:800;font-size:.8rem;margin-right:.3rem;white-space:nowrap}
.trail i{width:1.45rem;height:1.45rem;border-radius:50%;border:2px solid var(--ink);display:grid;place-items:center;font-style:normal;font-size:.7rem;font-weight:900;background:#fff;flex:0 0 auto}
.trail i.done{background:var(--sun)}
.trail i.cur{box-shadow:0 0 0 3px var(--tc,#2d7be0)}
.trail .sep{width:.5rem;height:2px;background:#b9c3d6;flex:0 1 auto}

/* play */
#play{justify-content:flex-start;gap:.5rem}
.board{flex:0 0 auto;width:100%;max-width:62rem;display:flex;align-items:center;gap:.6rem;background:var(--chalk);border:.35rem solid var(--wood);border-radius:1rem;padding:.4rem .7rem;color:#fff;box-shadow:0 .3rem 0 #7a4f27}
.cue{flex:1;font-size:1.35rem;font-weight:800;line-height:1.2;min-height:1.6rem}
.cue b{color:var(--sun)}
.ear{background:#fff;color:var(--ink)}
.dots{display:flex;gap:.3rem}.dots i{width:.8rem;height:.8rem;border-radius:50%;border:2px solid #fff;opacity:.85}
.dots i.ok{background:var(--sun);border-color:var(--sun)}.dots i.now{background:#fff}
.stage{flex:1;min-height:0;width:100%;max-width:62rem;display:flex;gap:1rem;align-items:center;justify-content:center}
.visual{flex:1 1 50%;min-width:0;height:100%;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:.4rem}
.visual:empty{display:none}
.answers{flex:1 1 50%;min-width:0;display:grid;grid-template-columns:1fr 1fr;gap:.7rem;align-content:center;max-height:100%}
.answers.dict{display:flex;flex-direction:column;align-items:center;gap:.7rem}
.answers.row{grid-template-columns:repeat(var(--n,3),1fr)}
.opt{position:relative;background:#fff;border:3px solid var(--ink);border-radius:1.1rem;box-shadow:0 .35rem 0 var(--ink);min-height:min(8rem,20vh);display:grid;place-items:center;font-weight:900;font-size:min(3rem,9vh);padding:.3rem;color:var(--ink)}
.opt .k{position:absolute;left:.35rem;top:.2rem;font-size:.75rem;opacity:.45;font-weight:800}
.opt svg{width:min(7rem,17vh);height:min(7rem,17vh)}
.opt.txt{font-size:min(2.1rem,6.5vh)}
.opt:active{transform:translateY(3px);box-shadow:0 1px 0 var(--ink)}
.opt.good{background:#d9f7e6;border-color:var(--ok);animation:pop .4s}
.opt.bad{background:#ffe1de;animation:shake .4s}
.opt.off{opacity:.35;pointer-events:none}
.objs{display:flex;flex-wrap:wrap;justify-content:center;align-content:center;gap:.4rem;max-width:100%}
.objs img{height:min(6.2rem,16vh);width:auto;cursor:pointer;transition:transform .15s}
.objs img.cnt{transform:scale(.88);filter:drop-shadow(0 0 0 #fff) saturate(.7)}
.objs .badge{position:relative}
.sumrow{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;justify-content:center}
.sumrow .grp{display:flex;flex-wrap:wrap;gap:.15rem;max-width:9rem;justify-content:center}
.sumrow .grp img{height:min(2.6rem,7.5vh);width:auto}
.sumrow .op{font-size:2rem;font-weight:900}
.eq{font-size:min(3.2rem,11vh);font-weight:900;background:#fff;border:3px solid var(--ink);border-radius:1rem;padding:.1rem 1rem;box-shadow:0 .3rem 0 var(--ink);white-space:nowrap}
.eq u{text-decoration:none;color:var(--margin)}
.pic{height:min(11rem,36vh);width:auto;filter:drop-shadow(0 .25rem 0 rgba(0,0,0,.12))}
.word{font-size:min(2.6rem,9vh);font-weight:900;letter-spacing:.1em}
.word u{text-decoration:none;color:var(--margin);border-bottom:4px solid var(--margin)}
.clock{width:min(20rem,44vh,40vw);height:min(20rem,44vh,40vw)}
.dict{flex:1 1 55%;display:flex;flex-direction:column;align-items:center;gap:.7rem;min-width:0}
.slots,.tiles{display:flex;gap:.35rem;flex-wrap:wrap;justify-content:center}
.slot{width:min(3.2rem,11vh,9.5vw);height:min(3.8rem,13vh,11vw);border-bottom:4px solid var(--ink);display:grid;place-items:center;font-size:min(2.4rem,9vh,7vw);font-weight:900;background:rgba(255,255,255,.75);border-radius:.4rem .4rem 0 0;cursor:pointer}
.slot.bad{color:var(--bad);animation:shake .4s}.slot.good{color:var(--ok)}
.tile{width:min(3.2rem,11vh,10vw);height:min(3.2rem,11vh,10vw);background:#fff8df;border:3px solid var(--ink);border-radius:.7rem;box-shadow:0 .25rem 0 var(--ink);font-size:min(2rem,7.5vh,6.5vw);font-weight:900;display:grid;place-items:center}
.tile.used{visibility:hidden}
.tile:active{transform:translateY(3px);box-shadow:0 1px 0 var(--ink)}
.kbdnote{font-size:.8rem;opacity:.7}
.playP{position:absolute;right:.6rem;bottom:.4rem;height:min(6.5rem,17vh);width:auto;pointer-events:none;transition:transform .2s}
.playP.hop{animation:hop .5s}
.praise{position:absolute;left:50%;top:45%;transform:translate(-50%,-50%) scale(.6);font-size:min(3.4rem,12vh);font-weight:900;color:var(--ok);-webkit-text-stroke:2px #fff;paint-order:stroke;text-shadow:0 .2rem 0 rgba(0,0,0,.15);opacity:0;pointer-events:none;white-space:nowrap}
.praise.show{animation:praise .9s ease-out}

/* end */
.endcard{display:flex;align-items:center;gap:1.2rem;max-width:44rem;width:100%;max-height:100%}
.endP{height:min(14rem,45vh);width:auto;animation:bob 2.2s ease-in-out infinite}
.etxt{flex:1;display:flex;flex-direction:column;align-items:center;gap:.5rem;text-align:center;min-width:0}
h2{margin:0;font-size:2.2rem;color:var(--chalk)}
.stars3{display:flex;gap:.4rem}.stars3 svg{width:min(3.6rem,12vh);height:min(3.6rem,12vh)}
.stars3 svg.in{animation:starin .5s backwards}
.endline{margin:0;font-size:1rem}
.endbtns{display:flex;flex-wrap:wrap;gap:.5rem;justify-content:center}
.endbtns .big{font-size:1.1rem;padding:.45rem .9rem}

#fx{position:fixed;inset:0;width:100%;height:100%;pointer-events:none;z-index:20}

@keyframes bob{50%{transform:translateY(-6px)}}
@keyframes pulse{50%{transform:scale(1.05)}}
@keyframes pop{40%{transform:scale(1.08)}}
@keyframes shake{20%,60%{transform:translateX(-6px)}40%,80%{transform:translateX(6px)}}
@keyframes hop{40%{transform:translateY(-14px) rotate(-6deg)}}
@keyframes praise{0%{opacity:0;transform:translate(-50%,-50%) scale(.5)}25%{opacity:1;transform:translate(-50%,-50%) scale(1.1)}75%{opacity:1;transform:translate(-50%,-60%) scale(1)}100%{opacity:0;transform:translate(-50%,-75%) scale(.95)}}
@keyframes starin{0%{transform:scale(0) rotate(-40deg)}70%{transform:scale(1.25)}}

/* portrait / phone */
@media (orientation:portrait){
  .screen{padding-left:.6rem}
  body{background-image:repeating-linear-gradient(90deg, transparent 0 31px, var(--vline) 31px 32px),repeating-linear-gradient(180deg, transparent 0 31px, var(--line2) 31px 32px),repeating-linear-gradient(180deg, transparent 0 7px, var(--line) 7px 8px)}
  :root{font-size:clamp(12px, calc(3.2vw + 2px), 20px)}
  .startcard,.endcard{flex-direction:column;text-align:center}
  .stxt{align-items:center}
  .heroP{height:min(13rem,28vh)}.endP{height:min(10rem,22vh)}
  .howrow{justify-content:center}
  .tab small{display:none}
  .tab b{font-size:.95rem}
  .gcard .gi .glyph{font-size:2rem}
  .cards{max-height:none;flex-direction:column;gap:.6rem}
  .gcard{max-width:none;flex-direction:row;justify-content:flex-start;padding:.5rem .8rem .5rem 2.4rem;gap:.8rem}
  .gcard:nth-child(2){margin-top:0}
  .gcard .gi{height:min(5rem,10vh);width:5rem;flex:0 0 auto}
  .gcard .gt{display:flex;flex-direction:column;align-items:flex-start;flex:1;min-width:0}
  .gcard .gt b,.gcard .gt small{text-align:left}
  .pathline{display:none}
  .trail i{width:1.2rem;height:1.2rem;font-size:.6rem}.trail .sep{width:.15rem}.trail .tl{display:none}
  .stage{flex-direction:column;gap:.6rem}
  .visual{flex:1 1 auto;height:auto;min-height:0}
  .answers{flex:0 0 auto;width:100%}
  .opt{min-height:min(7rem,13vh)}
  .clock{width:min(15rem,34vh,70vw);height:min(15rem,34vh,70vw)}
  .pic{height:min(10rem,22vh)}
  .playP{display:none}
  .slot{width:min(3.2rem,11vw);height:min(3.8rem,13vw);font-size:min(2.4rem,8vw)}
  .tile{width:min(3.4rem,12vw);height:min(3.4rem,12vw);font-size:min(2rem,7vw)}
}
.gt{display:flex;flex-direction:column;align-items:center;gap:.15rem;min-width:0}

/* short frames (store page 794x447, 640x360) */
@media (max-height:560px) and (orientation:landscape){
  #top{height:2.5rem;padding:.2rem .5rem}
  .screen{inset:2.5rem 0 0 0;padding:.4rem .5rem .4rem 3rem}
  .hbtn{width:2rem;height:2rem}
  .card{padding:.6rem .9rem;border-radius:1rem}
  h1{font-size:1.9rem}
  .big.play{font-size:1.35rem;padding:.45rem 1.6rem}
  .stxt{gap:.4rem}
  .gcard .gi{height:min(6rem,19vh)}
  .board{padding:.25rem .6rem;border-width:.25rem}
  .cue{font-size:1.15rem}
  .stage{gap:.7rem}
  .answers{gap:.5rem}
  .playP{height:15vh}
}
@media (max-height:420px) and (orientation:landscape){
  .mapP{display:none}
  .lvlhead .bubble:before{display:none}
  .howrow{display:none}
  .intro{font-size:.9rem}
  .gcard small{display:none}
  .gcard:nth-child(2){margin-top:.6rem}
  .tab small{display:none}
  .trail{padding:.1rem .5rem}
  .trail i{width:1.25rem;height:1.25rem}
}
