*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;height:100dvh;overflow:hidden;overscroll-behavior:none}
body{font-family:"Varela Round","Fredoka","Segoe UI",system-ui,-apple-system,Arial,sans-serif;color:#4a2c6b;background:linear-gradient(#ffe9a8,#ffc7d9);user-select:none;-webkit-user-select:none}
body.sea{background:linear-gradient(#bfe9ff,#7cc7e8)}
button{font-family:inherit;color:inherit;cursor:pointer;touch-action:manipulation}
.app{position:fixed;top:0;left:0;right:0;height:100dvh;padding-bottom:env(safe-area-inset-bottom);box-sizing:border-box;display:flex;flex-direction:column;align-items:center;overflow:hidden}
.screen{display:none;width:100%;height:100%;flex-direction:column;align-items:center}
.screen.on{display:flex}
.iconbtn{width:46px;height:46px;min-width:46px;border-radius:50%;border:none;background:#fff;box-shadow:0 3px 0 rgba(74,44,107,.25);font-size:22px;display:flex;align-items:center;justify-content:center;padding:0}
.big{display:block;width:100%;min-height:52px;border:none;border-radius:999px;background:#ff7a3d;color:#fff;font-size:clamp(18px,5vw,22px);font-weight:700;box-shadow:0 5px 0 #b84c1c;padding:8px 14px}
.big:active{transform:translateY(3px);box-shadow:0 2px 0 #b84c1c}
.big.alt{background:#7c5cff;box-shadow:0 5px 0 #4b33b8}
.big.soft{background:#fff;color:#4a2c6b;box-shadow:0 5px 0 rgba(74,44,107,.25)}
.link{background:none;border:none;text-decoration:underline;font-size:15px;min-height:44px;padding:6px 10px;color:#4a2c6b}
/* start */
.an-menu{--an-accent:#c2570c}
#start .an-emoji img.tig{height:72px;width:auto;display:block;margin:0 auto}
#start h1 small{display:block;font-size:.6em;font-weight:500;color:var(--an-soft)}
#start,#won,#lose,#pause,#rpause,#rend{z-index:10}
#rend .an-in{gap:10px}
/* game */
#game{max-width:640px}
.top{width:100%;display:flex;align-items:center;gap:8px;padding:max(6px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) 6px max(8px,env(safe-area-inset-left));min-height:58px}
.top .info{flex:1;min-width:0}
.top .rname{font-weight:700;font-size:clamp(14px,4vw,18px);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top .rnum{font-size:12px;font-weight:700;opacity:.8}
.bar{display:flex;gap:4px;margin-top:3px}
.bar span{flex:1;height:6px;border-radius:3px;background:rgba(255,255,255,.7)}
.bar span.d{background:#ff7a3d}
.wstars{font-size:46px;line-height:1;direction:ltr;letter-spacing:4px}.wstars span{display:inline-block;opacity:.25;filter:grayscale(1)}
.wstars span.on{opacity:1;filter:none}
@keyframes starpop{0%{transform:scale(.1) rotate(-120deg);opacity:0}65%{transform:scale(1.5) rotate(15deg);opacity:1}100%{transform:scale(1) rotate(0)}}
.card{animation:cardin .4s cubic-bezier(.2,1.4,.4,1)}@keyframes cardin{from{transform:scale(.5) translateY(30px);opacity:0}}
.pb{position:fixed;pointer-events:none;z-index:60;font-size:24px}
.rbanner{position:fixed;left:50%;top:30%;transform:translate(-50%,-50%);z-index:70;pointer-events:none;background:#fff;border:4px solid #ff7a3d;border-radius:22px;padding:10px 22px;font-size:26px;font-weight:900;color:#e8581c;text-align:center;animation:rbn 2.2s forwards;max-width:90vw}
@keyframes rbn{0%{transform:translate(-50%,-50%) scale(.2);opacity:0}15%{transform:translate(-50%,-50%) scale(1.15);opacity:1}25%{transform:translate(-50%,-50%) scale(1)}80%{opacity:1}100%{transform:translate(-50%,-90%);opacity:0}}
.starspill{background:#fff;border-radius:999px;padding:6px 10px;font-size:20px;font-weight:700;white-space:nowrap;box-shadow:0 3px 0 rgba(74,44,107,.2);direction:ltr}
.stage{flex:1;min-height:0;width:100%;display:flex;align-items:center;justify-content:center;padding:0 6px}
.box{position:relative;border-radius:18px;overflow:hidden;box-shadow:0 6px 18px rgba(74,44,107,.3);direction:ltr}
.box img{width:100%;height:100%;display:block;pointer-events:none}
.hot{position:absolute;min-width:46px;min-height:46px;border-radius:22px;border:3px dashed rgba(255,214,79,.75);background:rgba(255,255,255,.05);animation:pulse 1.8s ease-in-out infinite;padding:0}
.hot:active{background:rgba(255,214,79,.45)}
.hot.got{border-color:rgba(124,92,255,.0);animation:none;background:none}
@keyframes pulse{0%,100%{opacity:.45}50%{opacity:1}}
.say{width:100%;display:flex;align-items:flex-end;gap:6px;padding:6px 8px 4px;height:clamp(86px,15vh,110px)}
.say img{height:100%;max-height:96px;aspect-ratio:1;animation:wig 1.2s ease-in-out infinite;filter:drop-shadow(0 3px 3px rgba(0,0,0,.25))}
.bubble{flex:1;min-width:0;align-self:stretch;background:#fffaf0;border:3px solid #ff7a3d;border-radius:20px;padding:6px 10px;font-size:clamp(14px,3.9vw,17px);font-weight:600;line-height:1.3;display:flex;align-items:center;overflow:hidden}
.bubble.pop{animation:pop .35s cubic-bezier(.3,1.6,.6,1)}
@keyframes wig{0%,100%{transform:rotate(-4deg)}50%{transform:rotate(4deg)}}
@keyframes pop{0%{transform:scale(.7);opacity:0}100%{transform:scale(1);opacity:1}}
@keyframes wob{0%,100%{transform:rotate(0)}20%{transform:rotate(-5deg) scale(1.05)}40%{transform:rotate(5deg)}60%{transform:rotate(-3deg)}80%{transform:rotate(3deg)}}
.msg.wob{animation:wob .5s ease-in-out}
/* overlays */
.ov{position:absolute;inset:0;display:none;align-items:center;justify-content:center;padding:10px;background:rgba(53,30,80,.55);z-index:10}
.ov.on{display:flex}
.card{width:min(100%,420px);max-height:100%;overflow:auto;background:#fffaf0;border:6px solid #ffd64f;border-radius:28px;padding:clamp(10px,2.4vh,20px) 14px;text-align:center;animation:pop .35s cubic-bezier(.3,1.6,.6,1);display:flex;flex-direction:column;gap:clamp(6px,1.3vh,12px)}
.card>*{flex-shrink:0}
.card h2{margin:0;font-size:clamp(20px,5.8vw,28px);color:#ff7a3d}
.card p{margin:0}
.q{font-size:clamp(17px,4.8vw,22px);font-weight:700;line-height:1.3}
.opts{display:flex;flex-direction:column;gap:clamp(8px,1.4vh,12px)}
.opts .big{min-height:50px}
.opts .big.no{background:#cbbbd9;box-shadow:0 5px 0 #9b88ad}
.msg{font-size:16px;font-weight:700;color:#d2462b;min-height:0}
.hintbtn{min-height:48px;border-radius:999px;border:3px solid #ff7a3d;background:#ffd64f;font-size:17px;font-weight:700;padding:4px 12px}
.hint{background:#fff1b8;border-radius:16px;padding:8px 10px;font-size:16px;line-height:1.35;animation:pop .35s}
.custom{font-size:12px;font-weight:700;color:#7c5cff}
.winbig{font-size:clamp(40px,10vh,64px);line-height:1}
.menu{display:flex;flex-direction:column;gap:10px}
.conf{position:absolute;inset:0;pointer-events:none;z-index:20;overflow:hidden}
.conf i{position:absolute;top:-20px;font-style:normal;font-size:22px;animation:fall linear forwards}
@keyframes fall{to{transform:translateY(110vh) rotate(540deg)}}
/* editor */
#ed .card{width:min(100%,460px);text-align:start;gap:8px}
.tabs{display:flex;gap:6px;flex-wrap:wrap}
.tabs button{flex:1;min-height:44px;min-width:44px;border-radius:14px;border:2px solid #7c5cff;background:#fff;font-weight:700;font-size:15px;padding:2px 6px}
.tabs button.sel{background:#7c5cff;color:#fff}
#ed textarea,#ed input[type=text]{width:100%;font-family:inherit;font-size:16px;border:2px solid #ffb38f;border-radius:12px;padding:8px;color:#4a2c6b;background:#fff;user-select:text;-webkit-user-select:text}
#ed textarea{resize:none;height:64px}
@media (max-height:660px){#edIntro{display:none}}
@media (max-height:700px){#ed .card{gap:5px;padding:9px 12px}#ed .note{font-size:12px}#ed textarea{height:54px}.edrow .big{min-height:48px}}
.optrow{display:flex;align-items:center;gap:8px}
.optrow label{width:44px;height:44px;min-width:44px;display:flex;align-items:center;justify-content:center}
.optrow input[type=radio]{width:26px;height:26px;accent-color:#ff7a3d;margin:0}
.edrow{display:flex;gap:8px}
.edrow .big{font-size:17px}
.err{color:#d2462b;font-size:14px;font-weight:700}
.note{font-size:13px;opacity:.8}

/* desktop: keyboard hints, hover, wide layout */
.keyhint{display:none}
.hot::after{content:attr(data-key);display:none}
@media (min-width:700px){
.desk .keyhint{display:block;font-size:13px;font-weight:700;opacity:.7;text-align:center;margin-top:2px}
.desk .hot::after{display:block;position:absolute;top:3px;inset-inline-start:3px;min-width:20px;padding:0 5px;border-radius:6px;background:rgba(74,44,107,.8);color:#fff;font-size:13px;line-height:20px;font-weight:700}
.desk .opts .big::before{content:attr(data-n);display:inline-block;min-width:1.6em;margin-inline-end:10px;border-radius:8px;background:rgba(255,255,255,.3);font-size:.8em;padding:0 5px}
.desk .card{width:min(100%,520px)}
}
.desk .hot:hover{background:rgba(255,214,79,.35);border-color:#ffd64f;opacity:1;animation:none}
.desk .iconbtn:hover,.desk .tabs button:hover,.desk .langs button:hover{transform:translateY(-1px)}
.desk .big:hover{filter:brightness(1.08)}
@media (min-width:860px) and (min-height:520px) and (orientation:landscape){
#game{max-width:1280px}
#game.on{display:grid;grid-template-columns:minmax(0,1fr) minmax(330px,430px);grid-template-rows:auto 1fr auto;align-items:stretch;column-gap:16px;padding:0 16px}
#game>.stage{grid-column:1;grid-row:1/4}
#game>.top{grid-column:2;grid-row:1}
#game>.say{grid-column:2;grid-row:2;height:auto;flex-direction:column;align-items:center;justify-content:center;gap:14px}
#game>.say img{height:clamp(150px,30vh,300px);max-height:none}
#game>.say .bubble{flex:none;align-self:stretch;min-height:96px;font-size:clamp(18px,2.4vh,24px);padding:12px 16px}
#game>.keyhint{grid-column:2;grid-row:3;padding-bottom:8px}
}
/* short landscape phone: the picture takes the full height, the guide and the speech bubble sit beside it */
@media (orientation:landscape) and (max-height:519px) and (max-width:859px){
#game{max-width:none}
#game.on{display:grid;grid-template-columns:minmax(0,1fr) minmax(250px,46%);grid-template-rows:auto 1fr auto;align-items:stretch;column-gap:10px;padding:0 10px}
#game>.stage{grid-column:1;grid-row:1/4}
#game>.top{grid-column:2;grid-row:1}
#game>.say{grid-column:2;grid-row:2;height:auto;align-items:center;align-self:center}
#game>.say img{height:76px;max-height:none}
#game>.say .bubble{align-self:center;min-height:70px;font-size:16px}
#game>.keyhint{grid-column:2;grid-row:3}
}
/* expert + rush */
.xt{display:none;background:#fff;border-radius:999px;padding:6px 10px;font-size:18px;font-weight:700;white-space:nowrap;box-shadow:0 3px 0 rgba(74,44,107,.2);direction:ltr;font-variant-numeric:tabular-nums}
.xt.on{display:block}.xt.low{background:#ffd6cf;color:#c0341b;animation:pls .6s infinite}
@keyframes pls{50%{transform:scale(1.1)}}
.xfloat{position:fixed;z-index:80;pointer-events:none;font-weight:900;font-size:32px;color:#d2462b;text-shadow:0 2px 0 #fff;left:50%;top:38%;animation:xf 1s forwards}
@keyframes xf{from{transform:translate(-50%,0)}to{transform:translate(-50%,-70px);opacity:0}}
.stbtns{display:flex;gap:8px}.stbtns .big{min-height:46px;font-size:16px;padding:6px 8px}
#rush{max-width:640px}
.rbar{width:calc(100% - 20px);height:12px;border-radius:6px;background:rgba(255,255,255,.75);overflow:hidden;margin:0 10px;flex-shrink:0}
.rbar i{display:block;height:100%;width:100%;background:#ff7a3d}.rbar.low i{background:#d2462b}
.rbody{flex:1;min-height:0;width:100%;display:flex;flex-direction:column;justify-content:center;gap:clamp(8px,2vh,16px);padding:6px 14px 10px}
.rrow{display:flex;align-items:center;gap:10px;min-height:56px}
.rrow img{height:clamp(52px,9vh,84px);aspect-ratio:1;animation:wig 1.2s ease-in-out infinite}
.rfb{direction:ltr;text-align:center;flex:1;font-size:clamp(18px,5vw,24px);font-weight:800;color:#e8581c;min-height:30px}
.rfb.bad{color:#d2462b}
.rq{direction:ltr;text-align:center;background:#fffaf0;border:4px solid #ff7a3d;border-radius:24px;padding:clamp(10px,2.4vh,22px) 8px;font-size:clamp(34px,10.5vw,60px);font-weight:800;line-height:1.1;box-shadow:0 5px 0 rgba(74,44,107,.2)}
.ropts{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.ropts .big{min-height:clamp(62px,11vh,92px);font-size:clamp(24px,7vw,34px);direction:ltr}
.rbig{font-size:clamp(40px,9vh,60px);font-weight:900;color:#ff7a3d;line-height:1}
.tb{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px;text-align:start}
.tb li{display:flex;align-items:center;gap:8px;background:var(--an-card);border:1px solid var(--an-line);border-radius:12px;padding:4px 10px;font-weight:700;font-size:16px}
.tb li.me{background:var(--an-tint);border-color:var(--an-accent)}.tb li b{width:1.4em}.tb li span{flex:1;font-size:18px;direction:ltr;text-align:start}.tb li em{font-style:normal;font-size:13px;opacity:.75;direction:ltr}
/*landscape-fit*/@media (orientation:landscape) and (max-height:500px){#pause{overflow-y:auto!important;align-items:safe center!important;justify-content:safe center!important}#pause>*{max-height:none!important;margin:auto}}
