/* PequeBloques — diseñado por David OZC */
:root{
  --fs:16px;
  --bar:#6A4DE0; --bar2:#8B5CF6; --bg:#E8F0FD; --ink:#2b2350; --ink2:#575e75;
  --panel:#fff; --line:#D6DFF0; --accent:#FFB300; --green:#3FBF67; --red:#E64040; --blue:#4C97FF;
  --radius:16px;
  --font:"Arial Rounded MT Bold","Nunito","Trebuchet MS","Segoe UI",system-ui,-apple-system,Roboto,Arial,sans-serif;
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{font-family:var(--font);color:var(--ink);background:var(--bg);display:flex;flex-direction:column;overflow:hidden;-webkit-tap-highlight-color:transparent}
button{font-family:inherit;cursor:pointer}
svg{flex:none}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
.skip{position:absolute;left:-999px;top:0;background:#fff;padding:8px 12px;z-index:9999}
.skip:focus{left:8px;top:8px}
:focus-visible{outline:3px solid #FFD43B;outline-offset:2px}

/* ---------- barra superior ---------- */
#menubar{flex:none;display:flex;align-items:center;gap:10px;padding:6px 12px;min-height:58px;color:#fff;
  background:linear-gradient(100deg,#6A4DE0 0%,#8B5CF6 55%,#C264E8 100%);box-shadow:0 3px 0 rgba(0,0,0,.12);position:relative;z-index:30;flex-wrap:wrap}
.brand{display:flex;align-items:center;gap:8px;margin-right:6px}
.logo{width:40px;height:40px;filter:drop-shadow(0 2px 0 rgba(0,0,0,.18))}
.bname{font-size:25px;letter-spacing:.3px;font-weight:900;white-space:nowrap;text-shadow:0 2px 0 rgba(0,0,0,.2)}
.bname i,.bname b{font-style:normal;display:inline-block;animation:hop 4.5s ease-in-out infinite;animation-delay:calc(var(--i)*.07s)}
.bname i{color:#fff}.bname b{color:#FFE066}
@keyframes hop{0%,88%,100%{transform:none}93%{transform:translateY(-5px)}}
.menu{display:flex;gap:6px;flex-wrap:wrap}
.menuright{display:flex;gap:6px;margin-left:auto;align-items:center;flex-wrap:wrap}
.mbtn{display:inline-flex;align-items:center;gap:7px;border:0;border-radius:12px;padding:8px 13px;font-size:15px;font-weight:700;color:#fff;background:rgba(255,255,255,.17);min-height:42px;transition:transform .12s,background .15s}
.mbtn:hover{background:rgba(255,255,255,.3);transform:translateY(-1px)}
.mbtn:active{transform:translateY(1px)}
.mbtn svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.mbtn.hot{background:linear-gradient(#FFD43B,#FFB300);color:#4a2f00;box-shadow:0 3px 0 #c98700}
.mbtn.hot:hover{background:linear-gradient(#FFE066,#FFB300)}
.mbtn.save{background:linear-gradient(#59D98E,#2FB37D);box-shadow:0 3px 0 #1d8059}
.mbtn.sq{padding:8px;min-width:42px;justify-content:center}
.mbtn.tgl[aria-pressed="true"]{background:#fff;color:#5b3bd0}
.titlebox input{border:0;border-radius:12px;padding:9px 12px;font:700 15px var(--font);min-height:42px;width:min(210px,30vw);background:rgba(255,255,255,.95);color:var(--ink)}
.credit{font-size:13px;line-height:1.1;background:rgba(0,0,0,.18);padding:6px 11px;border-radius:12px;white-space:nowrap}
.credit span{display:block;opacity:.85;font-size:12px}
.credit b{font-size:16px;color:#FFE066;letter-spacing:.2px}

/* ---------- distribución ---------- */
#app{flex:1;min-height:0;display:grid;grid-template-columns:minmax(0,1fr) clamp(340px,40vw,540px);gap:10px;padding:10px}
#left,#right{min-height:0;min-width:0;display:flex;flex-direction:column}
#left{background:var(--panel);border-radius:var(--radius);box-shadow:0 2px 0 var(--line),0 6px 18px rgba(60,80,150,.1);overflow:hidden;position:relative}
#right{gap:8px;overflow:auto}
#tabs{display:flex;gap:4px;padding:6px 8px 0;background:#EEF3FC;border-bottom:3px solid #C9D6F2}
.tab{display:inline-flex;align-items:center;gap:7px;border:0;border-radius:12px 12px 0 0;padding:9px 16px;font-size:15px;font-weight:800;color:#5b6794;background:transparent;min-height:42px}
.tab svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.tab:hover{background:#dfe8fb}
.tab.on{background:#fff;color:#5b3bd0;box-shadow:0 -2px 0 #8B5CF6 inset}
.pane{flex:1;min-height:0;display:flex}
.pane[hidden]{display:none}
#pane-code{position:relative}

/* ---------- categorías y paleta ---------- */
#cats{width:78px;flex:none;display:flex;flex-direction:column;gap:2px;padding:6px 4px;background:#F4F7FD;border-right:2px solid #E1E8F6;overflow-y:auto}
.cat{border:0;background:transparent;border-radius:12px;padding:7px 2px;display:flex;flex-direction:column;align-items:center;gap:3px;font-size:11.5px;font-weight:800;color:#575e75;min-height:58px}
.cat .dot{width:30px;height:30px;border-radius:50%;background:var(--cc);border:3px solid rgba(0,0,0,.14);display:block}
.cat:hover{background:#E6EDFB}
.cat.on{background:#fff;box-shadow:0 1px 0 #cfd9f0,0 0 0 2px var(--cc)}
#pal{width:calc(var(--fs) * 20);min-width:210px;max-width:46%;flex:none;overflow-y:auto;overflow-x:hidden;padding:4px 10px 60px 8px;background:#fff;border-right:2px solid #E1E8F6;position:relative;transition:background .15s}
#pal.trash{background:#FFE9E9;outline:3px dashed var(--red);outline-offset:-5px}
.palh{margin:16px 2px 6px;font-size:14px;color:#6b739a;text-transform:uppercase;letter-spacing:.8px}
.palitem{margin:9px 0 9px 4px;display:block}
.palitem .block{display:inline-flex}

#wscol{flex:1;min-width:0;position:relative;display:flex;flex-direction:column}
#ws{flex:1;min-height:0;overflow:auto;position:relative;background-color:#F6F9FF;
  background-image:radial-gradient(#c7d3ee 1.6px,transparent 1.7px);background-size:26px 26px}
#wsin{position:relative;width:3200px;height:2400px}
.script{position:absolute;isolation:isolate;border-radius:10px}
/* programa en marcha: halo dibujado una sola vez (box-shadow en un pseudo-elemento) y animado solo con la opacidad */
.script.running::after{content:'';position:absolute;inset:-5px;border-radius:14px;z-index:-1;pointer-events:none;
  box-shadow:0 0 0 3px #FFD43B,0 0 12px 5px rgba(255,224,102,.75);animation:runhalo .9s ease-in-out infinite alternate;will-change:opacity}
@keyframes runhalo{from{opacity:.45}to{opacity:1}}
#wshint{position:absolute;left:30px;top:24px;pointer-events:none;color:#8a98c4;font-size:20px;font-weight:800;display:flex;align-items:center;gap:6px;flex-direction:column;opacity:.95}
#wshint[hidden]{display:none}
#wshint svg{width:200px;height:120px}
#wshint p{margin:-4px 0 0}
#wstools{position:absolute;right:16px;bottom:12px;display:flex;gap:8px;z-index:6}
.rb{width:46px;height:46px;border-radius:50%;border:0;background:#fff;color:#5b3bd0;box-shadow:0 3px 0 #cfd8ee,0 4px 10px rgba(50,70,140,.18);display:flex;align-items:center;justify-content:center}
.rb:hover{background:#F0EBFF}.rb:active{transform:translateY(2px)}
.rb svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}

/* ---------- bloques ---------- */
.stack{display:flex;flex-direction:column;align-items:flex-start}
.block{position:relative;font-size:var(--fs);color:#fff;font-weight:800;line-height:1.1;touch-action:none;user-select:none;-webkit-user-select:none;cursor:grab;white-space:nowrap;display:flex;flex-direction:column;align-items:stretch}
.block:active{cursor:grabbing}
.block .t{display:inline-block;text-shadow:0 1px 0 rgba(0,0,0,.18)}
.icow{display:inline-flex;align-items:center;justify-content:center;width:1.55em;height:1.55em;flex:none}
.icow .ico{width:1.5em;height:1.5em}
.flagw .ico{width:1.7em;height:1.7em}
.row{position:relative;display:flex;align-items:center;gap:.5em;min-height:2.65em;padding:.3em .85em;background:var(--c);border:1.5px solid var(--b)}
.stack>.block+.block{margin-top:-1.5px}
.sub>.stack>.block:first-child{margin-top:-1.5px}
/* esquinas redondeadas solo arriba del primero y abajo del último */
.row{border-radius:0}
.block.sfirst>.row.head{border-top-left-radius:.42em;border-top-right-radius:.42em}
.block.slast.k-stack>.row,.block.slast.k-cap>.row,.block.slast.k-c>.row.foot,.block.k-c.slast>.row.foot{border-bottom-left-radius:.42em;border-bottom-right-radius:.42em}
.k-hat>.row.head{border-radius:2.1em 2.1em .42em .42em / 1.5em 1.5em .42em .42em;padding-top:1em;min-height:3.35em}
.k-hat.slast>.row{border-bottom-left-radius:.42em;border-bottom-right-radius:.42em}
/* muesca superior */
.row.head::before{content:"";position:absolute;left:1.15em;top:-1.5px;width:2.5em;height:.5em;background:var(--b);clip-path:polygon(0 0,100% 0,84% 100%,16% 100%)}
.k-hat>.row.head::before{display:none}
.sub>.stack>.block:not(.sfirst)>.row.head::before,.stack>.block:not(.sfirst)>.row.head::before{display:block}
/* pestaña inferior */
.row.bump::after{content:"";position:absolute;left:1.15em;bottom:calc(-.5em - 1.5px);width:2.5em;height:calc(.5em + 3px);background:var(--c);clip-path:polygon(0 0,100% 0,84% 100%,16% 100%);z-index:3}
.row.cbump::after{content:"";position:absolute;left:calc(1.15em + 1.25em);bottom:calc(-.5em - 1.5px);width:2.5em;height:calc(.5em + 3px);background:var(--c);clip-path:polygon(0 0,100% 0,84% 100%,16% 100%);z-index:3}
.row.mid.cbump::after{left:calc(1.15em + 1.25em)}
/* bloques en C */
.k-c>.row.head{border-bottom-left-radius:0}
.cwrap{display:flex;align-items:stretch;margin-top:-1.5px}
.arm{width:1.25em;flex:none;background:var(--c);border-left:1.5px solid var(--b);margin-top:0}
.sub{flex:1;min-width:3.6em;min-height:1.9em;position:relative;display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start}
.sub>.stack{min-height:1.9em;padding-bottom:0}
.sub>.stack:empty{min-height:1.9em}
.row.mid{margin-top:-1.5px}
.row.foot{min-height:1.7em;margin-top:-1.5px;padding-top:.1em;padding-bottom:.1em}
/* condiciones (hexágonos) */
.block.k-bool{display:inline-flex;vertical-align:middle}
.block.k-bool{--h:.9em;background:var(--b);clip-path:polygon(var(--h) 0,calc(100% - var(--h)) 0,100% 50%,calc(100% - var(--h)) 100%,var(--h) 100%,0 50%);padding:1.5px 1.5px}
.k-bool>.in{display:flex;align-items:center;gap:.45em;min-height:2.1em;padding:.2em 1.3em;background:var(--c);clip-path:polygon(calc(var(--h) - 1px) 0,calc(100% - var(--h) + 1px) 0,100% 50%,calc(100% - var(--h) + 1px) 100%,calc(var(--h) - 1px) 100%,0 50%)}
.condslot{display:inline-flex;align-items:center;min-width:3.2em}
.hexempty{display:inline-block;width:3.2em;height:1.85em;background:rgba(0,0,0,.24);clip-path:polygon(.9em 0,calc(100% - .9em) 0,100% 50%,calc(100% - .9em) 100%,.9em 100%,0 50%)}
.condslot.hl .hexempty,.condslot.hl.filled{filter:drop-shadow(0 0 4px #fff) brightness(1.5)}
.condslot.filled .block{cursor:grab}
/* campos */
.fld{background:#fff;color:#4d5470;border:1.5px solid var(--b);border-radius:999px;min-width:2.3em;height:1.85em;padding:0 .7em;text-align:center;font:800 1em var(--font);display:inline-flex;align-items:center;justify-content:center;cursor:text;box-shadow:inset 0 1px 0 rgba(0,0,0,.06)}
.fld.num{cursor:pointer}
.fld.num:hover,.fld.txt:hover{background:#FFF9D6}
input.fld{outline:0;width:5em;text-align:center}
input.fld:focus{background:#FFF9D6;box-shadow:0 0 0 3px rgba(255,255,255,.7)}
.sel{appearance:none;-webkit-appearance:none;font:800 .95em var(--font);color:#fff;background:var(--b) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right .5em center/.7em;border:0;border-radius:.5em;height:1.85em;padding:0 1.6em 0 .65em;max-width:11em;cursor:pointer}
.sel option{color:#333;background:#fff;font-weight:600}
.block.pulse{animation:pulse 1s ease-in-out infinite;z-index:5}
@keyframes pulse{0%,100%{filter:drop-shadow(0 0 0 #fff)}50%{filter:drop-shadow(0 0 9px #fff) drop-shadow(0 0 5px #FFD43B)}}
.block.clicked{filter:brightness(1.25)}
.dragstack{position:fixed;z-index:2000;pointer-events:none;filter:drop-shadow(0 8px 10px rgba(0,0,0,.28));transform:rotate(-1.2deg)}
.snapline{position:fixed;z-index:1999;height:10px;border-radius:6px;background:#FFD43B;box-shadow:0 0 0 3px #fff,0 0 0 5px rgba(60,40,140,.55),0 0 14px 5px rgba(255,212,59,.8);pointer-events:none;animation:snappulse .7s ease-in-out infinite alternate}
.snapline::before{content:'';position:absolute;left:-13px;top:50%;margin-top:-9px;border:9px solid transparent;border-left-color:#FFD43B;filter:drop-shadow(0 0 2px rgba(60,40,140,.7))}
@keyframes snappulse{from{opacity:.75}to{opacity:1}}
.block.snapped{animation:snapbounce .3s cubic-bezier(.3,1.6,.5,1)}
@keyframes snapbounce{0%{transform:translateY(-7px) scale(1.04)}55%{transform:translateY(2px) scale(.985)}100%{transform:none}}
body.dragging{cursor:grabbing}
body.dragging *{cursor:grabbing!important}

.keypad{position:fixed;z-index:3000;width:236px;background:#fff;border-radius:18px;padding:10px;box-shadow:0 10px 30px rgba(20,20,60,.35);border:3px solid #8B5CF6}
.kdisp{background:#F1F4FC;border-radius:12px;font-size:30px;font-weight:900;text-align:right;padding:6px 14px;min-height:50px;margin-bottom:8px;overflow:hidden;color:#2b2350}
.kgrid{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
.kb{height:50px;border:0;border-radius:12px;font-size:24px;font-weight:900;background:#EEF1FB;color:#3b3170;box-shadow:0 3px 0 #cfd6ee}
.kb:hover{background:#E1E7FA}.kb:active{transform:translateY(2px);box-shadow:none}
.kb.kok{background:#59D98E;color:#fff;box-shadow:0 3px 0 #2fa56c;grid-column:span 2}
.ctxmenu{position:fixed;z-index:3100;background:#fff;border-radius:12px;box-shadow:0 8px 24px rgba(0,0,0,.3);padding:5px;display:flex;flex-direction:column;min-width:170px}
.ctxmenu button{border:0;background:transparent;text-align:left;padding:10px 14px;border-radius:8px;font:700 15px var(--font);color:var(--ink)}
.ctxmenu button:hover{background:#EFEAFF}

/* ---------- escenario ---------- */
#stagebox{background:#fff;border-radius:var(--radius);padding:8px;box-shadow:0 2px 0 var(--line),0 6px 18px rgba(60,80,150,.1)}
#stagebar{display:flex;align-items:center;gap:6px;margin-bottom:8px}
.sp{flex:1}
.sbtn{width:46px;height:46px;border-radius:14px;border:0;background:#EEF1FB;color:#4a3fa0;display:flex;align-items:center;justify-content:center;transition:transform .1s}
.sbtn:hover{background:#E1E7FA}.sbtn:active{transform:scale(.94)}
.sbtn svg{width:26px;height:26px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.sbtn.flag{background:#E5F8EA;width:56px;box-shadow:0 3px 0 #b5e3c2}
.sbtn.flag.running{background:#B8F0C8;box-shadow:0 0 0 3px #3FBF67}
.sbtn.flag svg{width:34px;height:34px}
.sbtn.stop{background:#FDE7E7;box-shadow:0 3px 0 #f1bcbc}
.sbtn[aria-pressed="true"]{background:#5b3bd0;color:#fff}
#stagewrap{width:min(100%,max(250px,calc((100vh - 500px) * 1.333)));margin:0 auto;position:relative;border-radius:12px;overflow:hidden;border:3px solid #cdd8f2;background:#fff;aspect-ratio:4/3;touch-action:none}
#stage{display:block;width:100%;height:100%;cursor:default}
#right.small #stagewrap{width:72%;margin:0 auto}
#stagebox:fullscreen{background:#111;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:0}
#stagebox:fullscreen #stagewrap{height:calc(100vh - 70px);width:auto;border:0;border-radius:0;max-width:100vw}
#stagebox:fullscreen #stagebar{width:100%;padding:8px;margin:0}
#spriteinfo{display:flex;flex-wrap:wrap;gap:6px 10px;background:#fff;border-radius:var(--radius);padding:8px 10px;align-items:flex-end;box-shadow:0 2px 0 var(--line)}
#spriteinfo .f{display:flex;flex-direction:column;gap:2px;font-size:12px;font-weight:800;color:#6b739a}
#spriteinfo .f.nm{flex:1 1 120px}
#spriteinfo input{font:800 15px var(--font);border:2px solid #D6DFF0;border-radius:10px;padding:5px 8px;width:68px;color:var(--ink);background:#F8FAFF;min-height:36px}
#spriteinfo .nm input{width:100%}
#spriteinfo .vis{flex-direction:column}
#spriteinfo .vis>div,#spriteinfo .vis{}
#spriteinfo .vis button{width:38px;height:36px;border:2px solid #D6DFF0;background:#F8FAFF;border-radius:10px;color:#4a3fa0;padding:0;display:inline-flex;align-items:center;justify-content:center}
#spriteinfo .vis{flex-direction:row;align-items:center}
#spriteinfo .vis span{margin-right:3px}
#spriteinfo .vis button svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round}
#spriteinfo .vis button.on{background:#5b3bd0;color:#fff;border-color:#5b3bd0}
#lower{display:flex;gap:8px;min-height:0;flex:1}
#spritepanel{flex:1;min-width:0;background:#fff;border-radius:var(--radius);padding:8px;display:flex;gap:8px;box-shadow:0 2px 0 var(--line);min-height:128px;overflow:hidden}
#spritelist{flex:1;display:flex;flex-wrap:wrap;gap:8px;align-content:flex-start;overflow-y:auto;min-width:0;padding:2px}
.stile{position:relative;width:88px;height:98px;border-radius:14px;border:3px solid #E1E8F6;background:#F6F9FF;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:4px;cursor:pointer;font-size:12px;font-weight:800;color:#575e75}
.stile img{width:58px;height:58px;object-fit:contain;pointer-events:none}
.stile .nm{max-width:78px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:2px}
.stile:hover{border-color:#B9A6F8}
.stile.on{border-color:#8B5CF6;background:#F1EBFF;box-shadow:0 0 0 2px #fff inset}
.stile .x,.stile .dup{position:absolute;top:-8px;width:26px;height:26px;border-radius:50%;border:0;background:#E64040;color:#fff;display:none;align-items:center;justify-content:center;padding:0;box-shadow:0 2px 4px rgba(0,0,0,.25)}
.stile .x{right:-8px}
.stile .dup{left:-8px;background:#5b3bd0}
.stile.on .x,.stile.on .dup{display:flex}
.stile .x svg,.stile .dup svg{width:15px;height:15px;fill:none;stroke:#fff;stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round}
.addwrap{display:flex;align-items:flex-end}
.addbtn{width:54px;height:54px;border-radius:50%;border:0;background:linear-gradient(#9B72FF,#6A4DE0);color:#fff;box-shadow:0 4px 0 #4a34a8;display:flex;align-items:center;justify-content:center}
.addbtn:hover{filter:brightness(1.1)}.addbtn:active{transform:translateY(3px);box-shadow:0 1px 0 #4a34a8}
.addbtn svg{width:28px;height:28px;fill:none;stroke:#fff;stroke-width:3;stroke-linecap:round}
.addbtn.small{width:42px;height:42px}
#stagepanel{width:112px;flex:none;background:#fff;border-radius:var(--radius);padding:8px;display:flex;flex-direction:column;align-items:center;gap:6px;box-shadow:0 2px 0 var(--line)}
#stagepanel .lbl{font-size:12px;font-weight:800;color:#6b739a}
.tile{width:92px;height:70px;border-radius:12px;border:3px solid #E1E8F6;background:#F6F9FF center/cover no-repeat;padding:0}
.tile.on{border-color:#8B5CF6;box-shadow:0 0 0 2px #fff inset}

/* ---------- pestañas disfraces / sonidos ---------- */
.listcol{width:min(250px,42%);flex:none;overflow-y:auto;padding:10px;background:#F4F7FD;border-right:2px solid #E1E8F6;display:flex;flex-direction:column;gap:8px}
.item{position:relative;display:flex;align-items:center;gap:8px;background:#fff;border:3px solid #E1E8F6;border-radius:14px;padding:6px 8px;cursor:pointer;min-height:70px}
.item.on{border-color:#8B5CF6;background:#F1EBFF}
.item .num{position:absolute;left:6px;top:4px;font-size:11px;font-weight:900;color:#8b93b3}
.item img{width:56px;height:56px;object-fit:contain;flex:none;background:repeating-conic-gradient(#f1f4fb 0 25%,#fff 0 50%) 0 0/12px 12px;border-radius:8px}
.item .nm{font-size:13px;font-weight:800;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}
.item .del{position:absolute;right:-7px;top:-7px;width:26px;height:26px;border-radius:50%;border:0;background:#E64040;color:#fff;display:none;align-items:center;justify-content:center;padding:0}
.item.on .del{display:flex}
.item .del svg{width:15px;height:15px;fill:none;stroke:#fff;stroke-width:2.6;stroke-linecap:round}
.editcol{flex:1;min-width:0;overflow:auto;padding:16px 18px;display:flex;flex-direction:column;gap:14px}
.editcol h2{margin:0;font-size:19px;color:#4a3fa0}
.bigprev{align-self:flex-start;background:repeating-conic-gradient(#eef2fb 0 25%,#fff 0 50%) 0 0/16px 16px;border:3px solid #D6DFF0;border-radius:14px;padding:10px;max-width:100%}
.bigprev img{display:block;max-width:100%;max-height:230px;width:auto;height:auto;min-width:80px;min-height:80px;object-fit:contain}
.row2{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.rname{font:800 16px var(--font);border:2px solid #D6DFF0;border-radius:12px;padding:8px 12px;min-height:42px;width:min(260px,100%)}
.btn{display:inline-flex;align-items:center;gap:8px;border:0;border-radius:14px;padding:10px 16px;font:800 15px var(--font);min-height:46px;background:#EEF1FB;color:#3b3170;box-shadow:0 3px 0 #cfd6ee}
.btn:hover{background:#E1E7FA}.btn:active{transform:translateY(2px);box-shadow:none}
.btn svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.btn.pri{background:linear-gradient(#9B72FF,#6A4DE0);color:#fff;box-shadow:0 3px 0 #4a34a8}
.btn.ok{background:linear-gradient(#59D98E,#2FB37D);color:#fff;box-shadow:0 3px 0 #1d8059}
.btn.red{background:#FDE7E7;color:#a52a2a;box-shadow:0 3px 0 #f1bcbc}
.btn.yel{background:linear-gradient(#FFD43B,#FFB300);color:#4a2f00;box-shadow:0 3px 0 #c98700}
.hint{color:#6b739a;font-size:14px;margin:0}

/* ---------- ventanas ---------- */
.modal-back{position:fixed;inset:0;z-index:4000;background:rgba(32,22,80,.55);display:flex;align-items:center;justify-content:center;padding:14px;animation:fade .18s}
@keyframes fade{from{opacity:0}}
.modal{background:#fff;border-radius:22px;max-width:min(980px,100%);max-height:calc(100vh - 28px);display:flex;flex-direction:column;overflow:hidden;box-shadow:0 20px 60px rgba(0,0,0,.45);width:100%;animation:pop .22s cubic-bezier(.2,1.3,.4,1)}
@keyframes pop{from{transform:scale(.92);opacity:0}}
.modal.sm{max-width:480px}
.modal.md{max-width:720px}
.mh{display:flex;align-items:center;gap:10px;padding:14px 18px;background:linear-gradient(100deg,#6A4DE0,#9B72FF);color:#fff}
.mh h2{margin:0;font-size:21px;flex:1}
.mh .close{border:0;background:rgba(255,255,255,.22);color:#fff;border-radius:50%;width:40px;height:40px;display:flex;align-items:center;justify-content:center;padding:0}
.mh .close:hover{background:rgba(255,255,255,.4)}
.mh .close svg{width:22px;height:22px;fill:none;stroke:#fff;stroke-width:2.6;stroke-linecap:round}
.mb{padding:16px 18px;overflow:auto;flex:1;min-height:0}
.mf{display:flex;gap:10px;justify-content:flex-end;padding:12px 18px;background:#F4F7FD;flex-wrap:wrap}
.mb p{margin:0 0 10px;line-height:1.45;font-size:16px}
.mb input.big{width:100%;font:800 18px var(--font);border:3px solid #D6DFF0;border-radius:14px;padding:10px 14px;min-height:50px}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(132px,1fr));gap:12px}
.card{border:3px solid #E1E8F6;border-radius:16px;background:#F6F9FF;padding:10px 8px;display:flex;flex-direction:column;align-items:center;gap:6px;font:800 14px var(--font);color:#3b3170;cursor:pointer;min-height:140px;justify-content:center;transition:transform .12s,border-color .12s}
.card:hover{border-color:#8B5CF6;transform:translateY(-3px);background:#F1EBFF}
.card img{width:96px;height:96px;object-fit:contain}
.card.bd img{width:100%;height:auto;aspect-ratio:4/3;border-radius:8px}
.card .snd{width:64px;height:64px;border-radius:50%;background:#CF63CF;display:flex;align-items:center;justify-content:center}
.card .snd svg{width:34px;height:34px;fill:none;stroke:#fff;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.stories{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:14px}
.story{border:0;border-radius:20px;color:#fff;text-align:left;padding:0;overflow:hidden;display:flex;flex-direction:column;background:#fff;box-shadow:0 4px 0 rgba(0,0,0,.12),0 8px 18px rgba(40,50,120,.18);transition:transform .14s;font-family:var(--font)}
.nivel{grid-column:1/-1;display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin:10px 0 0;padding:10px 16px;border-radius:16px;background:var(--nv);color:#fff}
.nivel:first-child{margin-top:0}
.nivel b{font-size:19px}.nivel span{font-size:14px;font-weight:800;background:rgba(255,255,255,.25);padding:2px 10px;border-radius:999px}
.nivel em{flex-basis:100%;font-style:normal;font-size:14px;opacity:.95}
.story:hover{transform:translateY(-4px) rotate(-.6deg)}
.story .pic{height:128px;background-size:cover;background-position:center;position:relative}
.story .kind{position:absolute;left:10px;top:10px;font-size:12px;font-weight:900;padding:4px 10px;border-radius:999px;background:#fff;color:#5b3bd0}
.story .kind.reto{color:#c25a00}.story .kind.tut{color:#12805b}
.story .body{padding:10px 14px 14px;color:var(--ink);background:#fff;flex:1}
.story h3{margin:0 0 4px;font-size:18px}
.story p{margin:0;font-size:14px;line-height:1.35;color:#575e75}
.stars{color:#FFB300;font-size:17px;letter-spacing:2px;margin-top:6px}
.section-t{margin:6px 0 10px;font-size:18px;color:#4a3fa0}
.tabsm{display:flex;gap:6px;margin-bottom:12px;flex-wrap:wrap}
.tabsm button{border:0;border-radius:999px;padding:8px 16px;font:800 14px var(--font);background:#EEF1FB;color:#4a3fa0}
.tabsm button.on{background:#6A4DE0;color:#fff}
.about h3{margin:14px 0 6px;color:#4a3fa0}
.about ul{margin:0 0 8px;padding-left:20px;line-height:1.5}
.about .by{background:linear-gradient(100deg,#F1EBFF,#FFF4CC);border-radius:16px;padding:12px 16px;font-size:17px;margin-bottom:10px}
.about small{color:#6b739a;display:block;margin-top:10px;line-height:1.4}
kbd{background:#EEF1FB;border-radius:6px;padding:1px 6px;border:1px solid #cfd6ee;font:700 .9em var(--font)}

/* ---------- pintar ---------- */
.paint{display:flex;gap:14px;flex-wrap:wrap;justify-content:center}
.pcanvaswrap{background:repeating-conic-gradient(#eef2fb 0 25%,#fff 0 50%) 0 0/16px 16px;border:3px solid #cdd8f2;border-radius:14px;touch-action:none;line-height:0}
#paintCv{width:min(330px,80vw);height:min(330px,80vw);cursor:crosshair;touch-action:none}
.ptools{display:flex;flex-direction:column;gap:10px;min-width:210px;flex:1}
.pcolors{display:grid;grid-template-columns:repeat(6,1fr);gap:6px}
.pcol{aspect-ratio:1;border-radius:50%;border:3px solid rgba(0,0,0,.15);padding:0;min-height:36px}
.pcol.on{outline:3px solid #6A4DE0;outline-offset:2px}
.psizes{display:flex;gap:8px}
.psz{flex:1;height:46px;border-radius:12px;border:2px solid #D6DFF0;background:#F8FAFF;display:flex;align-items:center;justify-content:center;padding:0}
.psz.on{border-color:#6A4DE0;background:#F1EBFF}
.psz i{display:block;background:#333;border-radius:50%}
.ptb{display:flex;gap:6px;flex-wrap:wrap}
.ptb .btn{padding:8px 12px;min-height:44px}
.ptb .btn.on{background:#6A4DE0;color:#fff;box-shadow:0 3px 0 #4a34a8}
.vu{height:16px;border-radius:8px;background:#EEF1FB;overflow:hidden;margin:8px 0}
.vu i{display:block;height:100%;width:0;background:linear-gradient(90deg,#59D98E,#FFD43B,#E64040);transition:width .08s}

/* ---------- guía, aviso, avisos emergentes ---------- */
#banner{background:linear-gradient(100deg,#FFF4CC,#FFE9A8);border-bottom:3px solid #FFC933;padding:9px 14px;display:flex;align-items:center;gap:10px;font-weight:800;font-size:16px;color:#5a3d00}
#banner[hidden]{display:none}
#banner .bi{width:34px;height:34px;border-radius:50%;background:#FFB300;display:flex;align-items:center;justify-content:center;flex:none}
#banner .bi svg{width:20px;height:20px;fill:none;stroke:#fff;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round}
#banner{flex-wrap:wrap}
#banner .bt{flex:1 1 150px;min-width:150px;line-height:1.3}
#banner button{border:0;background:rgba(0,0,0,.1);border-radius:50%;width:34px;height:34px;color:#5a3d00;font-size:18px;font-weight:900;padding:0}
#guide{position:absolute;left:12px;bottom:12px;width:min(540px,calc(100% - 24px));background:#fff;border:4px solid #8B5CF6;border-radius:22px;box-shadow:0 10px 30px rgba(40,30,120,.3);padding:10px 12px;display:flex;gap:10px;align-items:flex-start;z-index:7;animation:pop .25s cubic-bezier(.2,1.3,.4,1)}
#guide[hidden]{display:none}
#guide .mascot{width:76px;height:76px;flex:none;animation:bob 2.6s ease-in-out infinite}
@keyframes bob{50%{transform:translateY(-4px)}}
#guide .gt{flex:1;min-width:0}
#guide .gs{font-size:12px;font-weight:900;color:#8b5cf6;text-transform:uppercase;letter-spacing:.8px}
#guide p{margin:2px 0 8px;font-size:17px;line-height:1.35;font-weight:700;color:var(--ink)}
#guide .gb{display:flex;gap:6px;flex-wrap:wrap}
#guide .gb .btn{min-height:40px;padding:7px 12px;font-size:14px}
#guide.done{border-color:#3FBF67}
.progress{display:flex;gap:4px;margin:2px 0 4px}
.progress i{width:18px;height:7px;border-radius:4px;background:#E1E8F6}
.progress i.on{background:#8B5CF6}.progress i.ok{background:#3FBF67}
#toasts{position:fixed;left:50%;bottom:46px;transform:translateX(-50%);display:flex;flex-direction:column;gap:8px;z-index:5000;align-items:center;pointer-events:none;width:min(560px,94vw)}
.toast{background:#2b2350;color:#fff;border-radius:16px;padding:12px 18px;font-weight:700;box-shadow:0 8px 24px rgba(0,0,0,.35);pointer-events:auto;display:flex;gap:12px;align-items:center;animation:pop .25s;font-size:15px;line-height:1.3}
.toast.good{background:#1d8059}
.toast .btn{min-height:36px;padding:6px 12px;font-size:14px}
#dropveil{position:fixed;inset:0;z-index:6000;background:rgba(106,77,224,.82);display:flex;align-items:center;justify-content:center;color:#fff;font-size:34px;font-weight:900;text-align:center;border:8px dashed #fff}
#dropveil[hidden]{display:none}
.confetti{position:fixed;top:-20px;width:10px;height:14px;z-index:7000;pointer-events:none;animation:fall linear forwards}
@keyframes fall{to{transform:translate3d(var(--dx),110vh,0) rotate(var(--rot));opacity:.9}}

/* ---------- pantallas pequeñas ---------- */
@media (max-width:1060px){
  .credit span{display:none}
  .mbtn span{display:none}
  .mbtn.hot span,.mbtn.save span{display:inline}
  #btnLevel span,#btnVoice span{display:none}
}
@media (max-width:860px){
  body{overflow:auto;height:auto;min-height:100vh}
  .menuright{margin-left:0}
  .titlebox input{width:min(210px,40vw)}
  #app{display:flex;flex-direction:column;grid-template-columns:none;height:auto;min-height:0;flex:none}
  #right{order:-1;overflow:visible}
  #left{min-height:560px}
  #stagewrap{max-height:42vh;aspect-ratio:4/3;margin:0 auto}
  #cats{width:62px}
  .cat .cn{font-size:11px}
  #pal{min-width:170px}
}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation:none!important;transition:none!important}
}
/* «modo tranquilo» (Ajustes): lo mismo que pide el sistema con «reducir movimiento», pero elegido en la aplicación */
.calm *,.calm *::before,.calm *::after{animation:none!important;transition:none!important}

/* ---------- reporteros, huecos, variables ---------- */
.block.k-rep{display:inline-flex;vertical-align:middle;background:var(--b);border-radius:999px;padding:1.5px}
.k-rep>.in{display:flex;align-items:center;gap:.45em;min-height:2.1em;padding:.2em 1em;background:var(--c);border-radius:999px}
.islot{display:inline-flex;align-items:center;border-radius:999px}
.islot.hl{outline:3px solid #fff;box-shadow:0 0 12px 4px rgba(255,255,255,.9)}
.islot.filled>.block{cursor:grab}
.fld.clr{width:2.1em;min-width:2.1em;padding:0;border:2px solid #fff;cursor:pointer}
.clrpop{position:fixed;z-index:3100;background:#fff;border-radius:14px;padding:8px;width:206px;display:grid;grid-template-columns:repeat(6,1fr);gap:6px;box-shadow:0 8px 24px rgba(20,20,60,.35);border:3px solid #8B5CF6}
.clrpop .pcol{width:100%;aspect-ratio:1;border-radius:50%;border:3px solid #fff;box-shadow:0 0 0 2px #cfd8ee}
.valbubble{position:fixed;z-index:3200;background:#fff;color:#333;font:800 20px var(--font);padding:6px 14px;border-radius:14px;border:2.5px solid #B9C0CF;box-shadow:0 6px 16px rgba(20,20,60,.25);pointer-events:none;animation:pop .2s}
.mkvar{display:flex;align-items:center;gap:8px;margin:6px 0 8px;padding:9px 14px;border:0;border-radius:999px;background:#FF8C1A;color:#fff;font:800 15px var(--font);box-shadow:0 3px 0 #DB6E00}
.mkvar span{font-size:22px;line-height:1}
#cats{overflow-y:auto}

/* ---------- ayuda de Pipo ---------- */
.sbtn.help{width:auto;padding:0 14px 0 8px;gap:8px;background:linear-gradient(#B79BFF,#8B5CF6);color:#fff;font:800 16px var(--font);box-shadow:0 3px 0 #5B3BD0}
.sbtn.help svg{width:34px;height:34px;fill:none;stroke:none}
.sbtn.help:hover{background:linear-gradient(#C4ADFF,#9a6dff)}
.sbtn.help.wiggle{animation:wig 1.1s ease-in-out infinite}
@keyframes wig{0%,100%{transform:rotate(0)}15%{transform:rotate(-7deg) scale(1.06)}30%{transform:rotate(7deg) scale(1.06)}45%{transform:rotate(-5deg)}60%{transform:rotate(4deg)}}
.pulse-ui{animation:pulseui .9s ease-in-out infinite;position:relative;z-index:8}
@keyframes pulseui{0%,100%{box-shadow:0 0 0 0 rgba(255,191,0,.0)}50%{box-shadow:0 0 0 7px rgba(255,191,0,.85)}}
#guide.help{border-color:#FFBF00}
#guide .btn.big{min-height:46px;padding:7px 14px;font-size:15px;gap:7px}
#guide .btn.big svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round}
#guide .btn.ghost{background:#F1F4FC;color:#4a3fa0;box-shadow:none}
#guide .gw{margin-top:8px;font-size:12px;font-weight:700;color:#a35a00;background:#FFF3D6;border-radius:10px;padding:5px 9px}
.ghostblock{opacity:.92}
.ghosthand svg{filter:drop-shadow(0 3px 4px rgba(0,0,0,.35))}
#banner .bsp{flex:none;width:44px;height:44px;border-radius:50%;border:0;background:#fff;color:#5b3bd0;display:flex;align-items:center;justify-content:center;box-shadow:0 2px 0 #e3c04a}
#banner .bsp svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round}

/* ---- mando en pantalla (flechas y espacio) ---- */
#pad{position:absolute;left:0;right:0;bottom:0;padding:8px;display:flex;justify-content:space-between;align-items:flex-end;pointer-events:none;z-index:6}
#pad[hidden]{display:none}
#pad .dp{display:grid;grid-template-columns:repeat(3,clamp(36px,8.5vw,52px));grid-template-rows:repeat(2,clamp(36px,8.5vw,52px));gap:4px;grid-template-areas:". up ." "left down right"}
#pad .pk{pointer-events:auto;touch-action:none;border:3px solid #5b3bd0;background:rgba(255,255,255,.82);color:#4a3fa0;border-radius:14px;display:flex;align-items:center;justify-content:center;font:800 14px/1 inherit;padding:0;box-shadow:0 3px 0 rgba(91,59,208,.45);-webkit-user-select:none;user-select:none}
#pad .pk svg{width:60%;height:60%;fill:none;stroke:currentColor;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
#pad .pk.on{background:#5b3bd0;color:#fff;transform:translateY(2px);box-shadow:none}
#pad .up{grid-area:up}#pad .left{grid-area:left}#pad .down{grid-area:down}#pad .right{grid-area:right}
/* solo izquierda y derecha (¡Penalti!) */
#pad.lr .dp{grid-template-columns:repeat(2,clamp(36px,8.5vw,52px));grid-template-rows:clamp(36px,8.5vw,52px);grid-template-areas:"left right"}
#pad.lr .up,#pad.lr .down{display:none}
#pad .space{width:clamp(84px,22vw,130px);height:clamp(36px,8.5vw,52px);letter-spacing:.06em}
.block.sel{outline:4px solid #FFD91A;outline-offset:2px;border-radius:10px}

.story .kind.juego{color:#c2185b}
.story .kind.pc{background:#6D4AFF;color:#fff}

/* aviso de derechos */
#legal{flex:none;display:flex;align-items:center;justify-content:center;gap:10px;flex-wrap:wrap;padding:3px 12px 5px;font-size:12px;line-height:1.25;color:var(--ink);background:rgba(255,255,255,.65);border-top:1px solid rgba(58,44,79,.15);text-align:center}
#legal .ccl{display:inline-flex}
#legal .ccb{height:26px;width:auto;display:block}
#legal .lg{opacity:.85;max-width:62em}
@media (max-height:820px),(max-width:700px){#legal .lg{display:none}}
.tile{flex:none}
@media (min-width:701px) and (max-width:1180px){
  #app{grid-template-columns:minmax(0,1fr) clamp(320px,34vw,400px)}
  #cats{width:64px}
  #pal{width:calc(var(--fs) * 16.5);min-width:200px;padding-right:6px}
  #btnGrid,#btnStageSize{display:none}
}
@media (pointer:coarse){.stile .x,.stile .dup{width:32px;height:32px;top:-10px}.stile .x{right:-10px}.stile .dup{left:-10px}}
@media (max-height:800px) and (min-height:451px){#spriteinfo{display:none}}
@media (max-height:700px) and (min-height:451px){#btnGrid,#btnStageSize{display:none}#spritepanel{min-height:96px}.stile{width:78px}}

/* ---------- tabletas y móviles: pantalla completa y siempre en horizontal ---------- */
body{padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right)}
@supports (height:100dvh){html,body{height:100dvh}}
@media (orientation:landscape) and (max-height:600px){
  body{overflow:hidden;height:100%;min-height:0}
  @supports (height:100dvh){body{height:100dvh}}
  #menubar{padding:3px 8px;gap:6px;min-height:0}
  #menubar .bname{font-size:19px}
  #menubar .logo{width:30px;height:30px}
  .mbtn{min-height:34px;padding:0 9px}
  .titlebox input{min-height:34px;padding:4px 10px;font-size:14px;width:min(150px,20vw)}
  .credit{padding:2px 8px}.credit b{font-size:13px}
  #app{display:grid;grid-template-columns:minmax(0,1fr) clamp(210px,34vw,420px);flex:1;min-height:0;height:auto;padding:4px;gap:6px}
  #right{order:0;overflow:auto;gap:4px}
  #left{min-height:0}
  #stagewrap{max-height:none;width:min(100%,calc((100dvh - 150px) * 1.333))}
  #cats{width:54px}
  #pal{min-width:150px}
  #legal{padding:1px 8px;font-size:10.5px}
  #legal .lg{display:none}
  #legal .ccb{height:22px}
  .mbtn.save span{display:none}
  .titlebox input{width:min(120px,16vw)}
  #guide{left:6px;bottom:6px;width:calc(100% - 12px);padding:6px 8px;border-width:3px;gap:8px;border-radius:16px}
  #guide .mascot{width:40px;height:40px}
  #guide p{font-size:13.5px;margin:0 0 4px;line-height:1.25}
  #guide .gs{font-size:10px}
  #guide .gb .btn,#guide .btn.big{min-height:32px;font-size:13px;padding:4px 10px}
  #banner{padding:5px 8px;max-height:92px;overflow:auto;gap:6px}
  #banner,#banner p,#banner span{font-size:12.5px;line-height:1.25}
}
@media (orientation:landscape) and (max-height:600px) and (max-width:760px){.credit{display:none}}
@media (orientation:landscape) and (max-height:600px) and (max-width:700px){#menubar .bname{display:none}}

/* ---------- iPhone y móviles similares (horizontal, pantalla baja) ---------- */
body{touch-action:manipulation;overscroll-behavior:none;-webkit-text-size-adjust:100%;-webkit-touch-callout:none}
#pal,#ws,#cats,#tabs,#stagewrap,.stile,.block{-webkit-user-select:none;user-select:none}
@media (pointer:coarse){.titlebox input,#spriteinfo input{font-size:16px}}
@media (orientation:landscape) and (max-height:450px){
  #menubar{padding:2px 8px;gap:5px}
  .mbtn{min-height:32px}
  .titlebox input{min-height:32px;width:min(118px,15vw)}
  #app{grid-template-columns:minmax(0,1fr) min(46vw,calc((100dvh - 188px) * 1.333 + 22px));padding:3px;gap:5px}
  #right{overflow:hidden;gap:4px}
  #stagebox{padding:4px}
  #stagebar{gap:4px;margin-bottom:4px}
  .sbtn{width:38px;height:38px;border-radius:11px}
  .sbtn svg{width:22px;height:22px}
  .sbtn.flag{width:46px}.sbtn.flag svg{width:28px;height:28px}
  .sbtn.help{font-size:0;padding:0 6px;gap:0}.sbtn.help svg{width:30px;height:30px}
  #btnGrid,#btnStageSize{display:none}
  #stagewrap{width:min(100%,calc((100dvh - 188px) * 1.333));border-width:2px}
  #spriteinfo{display:none}
  #lower{flex:none;gap:4px;height:56px}
  #spritepanel{min-height:0;height:100%;padding:3px 4px;gap:4px;border-radius:12px}
  #spritelist{flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;align-content:center;align-items:center;gap:6px;padding:4px 2px 0}
  .stile{flex:none;width:48px;height:48px;padding:2px;border-width:2px;border-radius:11px}
  .stile img{width:34px;height:34px}.stile .nm{display:none}
  .addbtn{width:38px;height:38px;box-shadow:0 3px 0 #4a34a8}.addbtn svg{width:22px;height:22px}
  .addwrap{align-items:center}
  #stagepanel{padding:3px 4px;border-radius:12px;gap:4px;min-height:0;height:100%;align-items:center}
  #stagepanel .lbl,#btnAddBackdrop{display:none}
  #stagepanel{flex:none}
  #pad{padding:4px}
  #pad .dp{grid-template-columns:repeat(3,34px);grid-template-rows:repeat(2,34px);gap:3px}
  #pad .space{width:64px;height:34px;font-size:11px}
  #pad.lr .dp{grid-template-columns:repeat(2,34px);grid-template-rows:34px}
  #pad .pk{border-width:2px;border-radius:10px}
  #stagepanel .tile{width:44px;height:36px}
  #pal{width:calc(var(--fs) * 15);min-width:150px;padding:4px 6px 40px 6px}
  #cats{width:50px;padding:4px 2px}
  #banner{padding:3px 6px;gap:6px}
  #banner .bi{display:none}
  #banner .bsp{width:30px;height:30px}.bsp svg{width:18px;height:18px}
  #banner button{width:26px;height:26px;font-size:15px}
  #banner .bt{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;font-size:11.5px;line-height:1.2}
  #legal{flex-wrap:nowrap;white-space:nowrap;overflow:hidden;gap:6px;padding:0 8px max(1px,env(safe-area-inset-bottom));font-size:10px}
  #legal .ccb{height:17px}
}
@media (orientation:landscape) and (max-height:450px) and (max-width:800px){#btnZoomOut,#btnZoomIn{display:none}}
/* paleta: deslizar en vertical con el dedo hace scroll; arrastrar hacia el lado coge el bloque */
#pal .block{touch-action:pan-y}

/* escenario ampliado a toda la ventana (iPhone y navegadores sin pantalla completa de elementos) */
#stagebox.pfull{position:fixed;inset:0;z-index:9000;border-radius:0;box-shadow:none;background:#111;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:max(6px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}
#stagebox.pfull #stagebar{width:100%;margin-bottom:6px;flex:none}
#stagebox.pfull #stagewrap{width:min(100%,calc((100dvh - 66px) * 1.333));max-height:none;margin:0 auto;border:0;border-radius:6px}
#stagebox.pfull #btnGrid,#stagebox.pfull #btnStageSize{display:none}

/* navegadores algo antiguos (iPadOS 14): sin la propiedad «inset» */
.modal-back,#dropveil,#stagebox.pfull{top:0;left:0;right:0;bottom:0}

/* aviso de inicio de los cuentos con voz */
#starthint{position:fixed;inset:0;pointer-events:none;z-index:900}
#starthint .hint{position:absolute;max-width:230px;padding:9px 12px;border-radius:14px;background:#FFD43B;color:#3a2a00;font-weight:800;font-size:16px;line-height:1.15;text-align:center;box-shadow:0 4px 14px rgba(0,0,0,.28);animation:hintblink 1s ease-in-out infinite}
#starthint .hint[hidden]{display:none}
#starthint .hint .ar{position:absolute;top:-8px;width:16px;height:16px;background:#FFD43B;transform:rotate(45deg);border-radius:3px}
@keyframes hintblink{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.6;transform:scale(1.08)}}
.sbtn.blink{animation:btnblink 1s ease-in-out infinite;outline:4px solid #FFD43B;outline-offset:2px}
@keyframes btnblink{0%,100%{box-shadow:0 0 0 0 rgba(255,212,59,.95)}50%{box-shadow:0 0 0 10px rgba(255,212,59,0)}}
@media (prefers-reduced-motion:reduce){#starthint .hint,.sbtn.blink{animation:none}}

/* icono «leer» (pensamiento computacional) */
#readbtn{position:absolute;top:3px;right:3px;width:10%;max-width:48px;min-width:32px;aspect-ratio:1;padding:0;border:0;border-radius:50%;background:#7C5CFF;box-shadow:0 2px 8px rgba(0,0,0,.35);z-index:5;cursor:pointer;display:flex;align-items:center;justify-content:center}
#readbtn svg{width:72%;height:72%}
#readbtn.on{background:#34C26B}
#readpanel{position:absolute;left:4%;right:4%;top:14%;max-height:70%;overflow:auto;z-index:6;background:rgba(255,255,255,.97);border:4px solid #7C5CFF;border-radius:16px;padding:12px 56px 12px 14px;box-shadow:0 6px 24px rgba(0,0,0,.4)}
#readpanel[hidden]{display:none}
#readpanel .rtxt{font-size:clamp(13px,2.2vw,21px);line-height:1.3;font-weight:800;color:#2b2150;cursor:pointer}
#readpanel .rear{position:absolute;top:8px;right:8px;width:40px;height:40px;padding:6px;border:0;border-radius:50%;background:#34C26B;cursor:pointer}

#readbtn:not(.on){animation:readpulse 1.4s ease-in-out 4}
@keyframes readpulse{0%,100%{box-shadow:0 2px 8px rgba(0,0,0,.35)}50%{box-shadow:0 0 0 9px rgba(255,212,59,.9)}}
@media (prefers-reduced-motion:reduce){#readbtn{animation:none!important}}

/* ---- ajustes de voz ---- */
.modal.lg{max-width:640px}
.vset{display:flex;flex-direction:column;gap:14px;font-size:16px}
.vstate{background:#F3F0FF;border-radius:14px;padding:10px 14px;font-size:14px;line-height:1.45;color:#3b3170}
.vrow{display:flex;flex-direction:column;gap:6px}
.vrow>label{font-weight:800;color:#3b3170}
.vseg{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.vseg select{font:inherit;padding:9px 10px;border-radius:12px;border:2px solid #cfd6f5;min-height:46px;max-width:100%}
.vseg .btn[aria-pressed="true"]{outline:3px solid #3b3170}
.vrange{display:flex;align-items:center;gap:12px}
.vrange input{flex:1;min-width:0;height:34px;accent-color:#8B5CF6}
.vrange output{min-width:9.5em;text-align:right;font-weight:700;color:#3b3170}
.vnote{margin:0;font-size:13.5px;color:#5f5a86;line-height:1.4}
/* biblioteca de sonidos: categorías y elegido */
.chips{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 10px}
.chip{min-height:44px;padding:6px 14px;font-weight:800}
.card.sel{border-color:#8B5CF6;background:#EADFFF;box-shadow:0 0 0 3px #CBB4FF}
.sndadd{display:block;width:100%;margin-top:10px;min-height:52px;font-size:17px}
.sndadd:disabled{opacity:.5}

/* ---------- globo de Pipo (avisos amables) ---------- */
#pipo{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);width:min(520px,calc(100vw - 24px));background:#fff;border:4px solid #8B5CF6;border-radius:22px;box-shadow:0 10px 30px rgba(40,30,120,.35);padding:10px 12px;display:flex;gap:10px;align-items:center;z-index:60;animation:pipoin .22s cubic-bezier(.2,1.3,.4,1)}
#pipo.warn{border-color:#FF8A4D}
#pipo.out{opacity:0;transition:opacity .16s}
#pipo .mascot{width:64px;height:64px;flex:none}
#pipo .pt{flex:1;min-width:0}
#pipo p{margin:0 0 8px;font-size:16px;line-height:1.35;font-weight:700;color:var(--ink)}
#pipo .btn{min-height:44px;padding:7px 16px;font-size:15px}
@keyframes pipoin{from{opacity:0;transform:translateX(-50%) translateY(14px) scale(.94)}to{opacity:1;transform:translateX(-50%)}}
.block.failed{outline:3px dashed #E5484D;outline-offset:2px;border-radius:6px}

/* ---------- celebración ---------- */
#pipo.win{border-color:#3FBF67}
#pipo .mascot.cheer,#guide .mascot.cheer{animation:cheer 1.1s cubic-bezier(.3,1.5,.5,1) 2;transform-origin:50% 90%}
@keyframes cheer{0%{transform:none}25%{transform:translateY(-16px) rotate(-10deg) scale(1.08)}50%{transform:translateY(0) rotate(0) scale(.96,1.04)}75%{transform:translateY(-12px) rotate(10deg) scale(1.08)}100%{transform:none}}
#banner.done{background:#DDF7E6;border-color:#3FBF67}

/* ---------- interruptores de Ajustes ---------- */
.vsw{display:flex;flex-direction:column;gap:8px}
.vswitch{display:flex;align-items:center;gap:12px;text-align:left;border:2px solid #cfd6f5;background:#fff;border-radius:16px;padding:8px 12px;min-height:56px;font:inherit;color:var(--ink);cursor:pointer}
.vswitch .knob{flex:none;width:52px;height:30px;border-radius:15px;background:#C5CBE0;position:relative;transition:background .15s}
.vswitch .knob::after{content:'';position:absolute;left:3px;top:3px;width:24px;height:24px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.3);transition:transform .15s}
.vswitch[aria-checked="true"] .knob{background:#3FBF67}
.vswitch[aria-checked="true"] .knob::after{transform:translateX(22px)}
.vswitch .st{display:flex;flex-direction:column;gap:1px}
.vswitch .st b{font-size:15.5px}
.vswitch .st small{font-size:13px;color:#5f5a86;line-height:1.3}
.vswitch:focus-visible{outline:3px solid #3b3170;outline-offset:2px}

/* ---------- objetivos táctiles de 56 px (dedos pequeños, tabletas y pizarras digitales) ----------
 * Solo con puntero grueso y con sitio suficiente; en móviles apaisados se mantiene el diseño compacto. */
@media (pointer:coarse) and (min-width:700px) and (min-height:600px){
  .mbtn,.mbtn.sq{min-height:56px;min-width:56px;justify-content:center}
  .mbtn{padding:8px 14px}
  .tab{min-height:56px}
  .sbtn{width:56px;height:56px}
  .sbtn.flag{width:64px}
  .sbtn.help{height:56px}
  #stagebar{flex-wrap:wrap}
  #wstools button{width:56px;height:56px}
  .addbtn,.addbtn.small{width:56px;height:56px;flex:none}
  #btnShow,#btnHide{min-width:56px;min-height:56px}
  .cat{min-height:60px}
  .mkvar{min-height:56px}
  /* paleta: el bloque se ve igual, pero su zona de toque mide 56 px de alto y no se pisa con la del vecino */
  #pal .palitem{margin:18px 0 18px 4px}
  #pal .palitem>.block::before{content:'';position:absolute;left:-4px;right:-4px;top:-9px;bottom:-9px}
  #pal .palitem>.block{min-height:38px}
}

.vstate .vnow{font-size:15px;margin-bottom:4px}

/* ---------- área de programación con teclado ---------- */
#ws.kbnav{outline:4px solid #5b3bd0;outline-offset:-4px}
#ws:focus-visible{outline:4px solid #5b3bd0;outline-offset:-4px}
#wslive{position:absolute;left:12px;right:216px;bottom:12px;z-index:6;pointer-events:none;background:#2b2350;color:#fff;border-radius:14px;padding:9px 14px;font-size:15px;font-weight:700;line-height:1.3;box-shadow:0 6px 18px rgba(0,0,0,.3);
  clip-path:inset(50%);width:1px;height:1px;overflow:hidden;white-space:nowrap}
#ws.kbnav ~ #wslive:not(:empty){clip-path:none;width:auto;height:auto;overflow:visible;white-space:normal}
.block.kbgrab{outline:4px dashed #E5484D;outline-offset:3px;border-radius:10px}

/* ---- Vertical (móvil y tableta en posición vertical): el programa funciona sin girar la pantalla ----
   La página se desplaza: arriba el escenario y los personajes; debajo, el editor ocupa casi toda la pantalla. */
@media (orientation:portrait) and (max-width:860px){
  #stagebar{flex-wrap:wrap}
  #left{height:calc(100dvh - 84px);min-height:460px}
  #cats{width:56px;padding:4px 2px}
  #cats .cn{font-size:10px}
}
@media (orientation:portrait) and (max-width:520px){
  #pal{width:148px;min-width:148px;max-width:148px;padding:4px 6px 60px 6px}
  #cats{width:50px}
}

/* ---- Música: número de nota con su nombre y teclado para elegirla ---- */
.fld.note small{font-size:.72em;font-weight:800;margin-left:.3em;opacity:.75}
.notepop{position:fixed;z-index:3100;background:#fff;border-radius:16px;padding:8px 8px 10px;box-shadow:0 8px 24px rgba(20,20,60,.35);border:2px solid #E64980}
.notepop .nphead{display:flex;align-items:center;gap:6px;margin-bottom:6px}
.notepop .nplbl{flex:1;text-align:center;font-weight:800;font-size:13px;color:#5a4a72}
.notepop .npoct{min-width:40px;height:36px;border-radius:10px;border:0;background:#FCE4EE;color:#C2255C;font-weight:900;font-size:15px;cursor:pointer}
.notepop .npkeys{position:relative;display:flex;height:132px}
.notepop .npw{flex:1;margin:0 1px;border:2px solid #cfd8ee;border-radius:0 0 9px 9px;background:linear-gradient(#fff 70%,hsl(var(--hue),85%,92%));display:flex;flex-direction:column;justify-content:flex-end;align-items:center;padding:0 0 6px;cursor:pointer;color:#3a2c4f;font-family:inherit}
.notepop .npw b{font-size:13px}.notepop .npw i{font-style:normal;font-size:10px;opacity:.6}
.notepop .npb{position:absolute;top:0;width:7.6%;height:58%;background:#2d2540;border:0;border-radius:0 0 6px 6px;cursor:pointer;z-index:2}
.notepop .on{outline:3px solid #E64980;outline-offset:-3px}.notepop .npb.on{background:#E64980}
/* móvil en vertical: la explicación del tutorial ocupa todo el ancho, abajo (el área de bloques es estrecha) */
@media (orientation:portrait) and (max-width:520px){
  #guide{position:fixed;left:6px;right:6px;bottom:6px;width:auto;max-height:44vh;overflow:auto;padding:8px 10px;gap:8px;border-radius:16px;border-width:3px}
  #guide .mascot{width:44px;height:44px}
  #guide p{font-size:15px;line-height:1.3;margin:2px 0 6px}
}

/* tutoriales: repasar pasos anteriores */
#guide.review{border-color:#5CB1D6}
#guide.review .gs{color:#2E8EB8}
#guide .btn.gnext:disabled{opacity:.45;cursor:not-allowed;filter:grayscale(.6)}
