:root{--ink:#22305c;--green:#2b8a4b;--mint:#8fdc4a;--red:#d9472b;--cream:#fff7e6;--gold:#f5b82e;--wood:#b4532a;--sky:#2bb5b0;--blue:#1f4e9c;--pink:#e8457a}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden;color:var(--ink);background:#e07b39;
  font-family:"Trebuchet MS","Segoe UI",system-ui,-apple-system,Roboto,Arial,sans-serif;touch-action:none;user-select:none;-webkit-user-select:none}
body{background:radial-gradient(ellipse at 50% 30%,#ffd27a 0,#f39a3d 45%,#c4532f 100%)}
body::before{content:"";position:fixed;inset:0;opacity:.18;background:repeating-linear-gradient(90deg,transparent 0 46px,rgba(255,255,255,.5) 46px 50px),repeating-linear-gradient(0deg,transparent 0 46px,rgba(255,255,255,.5) 46px 50px)}
#picado{position:absolute;left:0;right:0;top:0;height:26px;z-index:0;pointer-events:none;background:linear-gradient(var(--ink),var(--ink)) 0 3px/100% 2px no-repeat,linear-gradient(90deg,#e8457a 0 25%,#f5b82e 25% 50%,#2bb5b0 50% 75%,#7a5bd6 75%) 0 5px/160px 21px repeat-x;-webkit-mask:linear-gradient(#000,#000) 0 0/100% 5px no-repeat,conic-gradient(from -45deg at 50% 100%,transparent 0 90deg,#000 0) 0 5px/20px 21px repeat-x;mask:linear-gradient(#000,#000) 0 0/100% 5px no-repeat,conic-gradient(from -45deg at 50% 100%,transparent 0 90deg,#000 0) 0 5px/20px 21px repeat-x}
#app{position:fixed;inset:0;display:flex;flex-direction:column;align-items:center}
#hud{position:relative;width:100%;max-width:760px;display:flex;align-items:center;gap:6px;padding:14px 10px 4px;flex:0 0 auto;z-index:1}
.sp{flex:1}
.pill{background:var(--cream);border:3px solid var(--ink);border-radius:14px;padding:2px 8px;font-weight:800;line-height:1.1;box-shadow:0 3px 0 var(--ink);min-width:60px;text-align:center}
.pill small{display:block;font-size:10px;letter-spacing:.3px;opacity:.75;white-space:nowrap}
.pill b{font-size:19px;font-variant-numeric:tabular-nums}
.pill.wide{min-width:86px}
#pBest{background:#ffe9a8}
#pInfo.warn{background:#ffb3a3;animation:breathe .6s infinite}
#pScore{background:#dff3ff}
.btn{appearance:none;border:3px solid var(--ink);background:var(--cream);color:var(--ink);border-radius:14px;font:inherit;font-weight:800;
  box-shadow:0 3px 0 var(--ink);cursor:pointer;min-width:44px;min-height:44px;padding:4px 10px;font-size:15px}
.btn:active{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
.icon{width:44px;padding:0;display:flex;align-items:center;justify-content:center}
.icon svg{width:24px;height:24px;fill:var(--ink);stroke:var(--ink);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
#bMusic svg{fill:none}#bMusic svg circle{fill:var(--ink)}
#bSound .w,#bSound .x{fill:none}#bSound .x{display:none}
#bSound.off .w{display:none}#bSound.off .x{display:block}
#bMusic.off{opacity:.45}
#fx{position:absolute;left:0;right:0;top:2px;display:flex;flex-wrap:wrap;gap:4px 6px;justify-content:center;z-index:3;pointer-events:none;padding:0 6px}
#mid{position:relative}
.chip{background:var(--cream);border:2px solid var(--ink);border-radius:20px;padding:1px 9px 1px 4px;font-weight:800;font-size:13px;display:flex;align-items:center;gap:4px;white-space:nowrap}
.chip img{width:18px;height:18px}
#mid{flex:1 1 auto;min-height:0;width:100%;display:flex;flex-direction:column;align-items:center;justify-content:center}
#stage{position:relative;flex:1 1 auto;min-height:0;width:100%;overflow:hidden}
#stage canvas{position:absolute;left:0;top:0}
canvas{display:block;touch-action:none}
#hint{position:relative;color:#fff;font-weight:700;font-size:13px;text-align:center;padding:4px 10px;text-shadow:0 1px 0 var(--ink),0 0 6px rgba(0,0,0,.7);flex:0 0 auto}
#pad{position:relative;display:none;flex:0 0 auto;padding:2px 0 12px;gap:6px;grid-template-columns:70px 70px 70px;grid-template-rows:54px 54px}
#pad.on{display:grid}
#pad .btn{font-size:24px;padding:0;min-width:70px;background:#e3f6f5}
#pad .btn.hit{background:var(--gold)}
#pad .u{grid-column:2;grid-row:1}#pad .l{grid-column:1;grid-row:2}#pad .d{grid-column:2;grid-row:2}#pad .r{grid-column:3;grid-row:2}
.ov{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(34,48,92,.42);z-index:5}
.ov.show{display:flex}
.panel,.card{background:var(--cream);border:4px solid var(--ink);border-radius:22px;box-shadow:0 6px 0 var(--ink);text-align:center;animation:pop .3s cubic-bezier(.2,1.5,.4,1)}
.panel{width:min(500px,95vw);max-height:96%;overflow:auto;padding:10px 14px 14px;touch-action:pan-y;
  border-top:10px solid var(--blue);background-image:radial-gradient(circle at 14px 14px,rgba(31,78,156,.09) 0 4px,transparent 5px),radial-gradient(circle at 0 0,rgba(31,78,156,.06) 0 6px,transparent 7px);background-size:28px 28px}
@keyframes pop{from{transform:scale(.6);opacity:0}to{transform:scale(1);opacity:1}}
.head{display:flex;align-items:center;justify-content:center;gap:10px}
.head img{width:88px;height:auto;filter:drop-shadow(0 3px 0 rgba(29,42,74,.25))}
h1{margin:0;font-size:31px;line-height:1.02;color:var(--green);text-shadow:0 2px 0 #fff,0 3px 0 var(--ink);letter-spacing:.2px;text-align:left}
h2{margin:4px 0 0;font-size:17px;color:var(--red);text-align:left}
.intro{font-size:13px;line-height:1.45;margin:6px 2px 8px}
.modes{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
.mode{appearance:none;font:inherit;color:var(--ink);background:#fff;border:3px solid var(--ink);border-radius:12px;padding:5px 2px;cursor:pointer;display:flex;flex-direction:column;align-items:center;gap:2px;box-shadow:0 3px 0 var(--ink);min-width:0}
.mode b{font-size:12.5px;white-space:nowrap;letter-spacing:-.2px}
.mode.sel{background:var(--gold);transform:translateY(-2px)}
.mi{width:34px;height:28px;display:block;background:center/contain no-repeat}
.mi.m1{background-image:url(img/manzana.webp)}
.mi.m2{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 28'%3E%3Crect x='3' y='3' width='28' height='22' rx='4' fill='%23fbf4e4' stroke='%2322305c' stroke-width='2.5' stroke-dasharray='4 3'/%3E%3Cpath d='M2 14h30M26 9l6 5-6 5M8 9l-6 5 6 5' fill='none' stroke='%232bb5b0' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}
.mi.m3{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 28'%3E%3Crect x='2' y='2' width='30' height='24' rx='4' fill='%23fbf4e4' stroke='%2322305c' stroke-width='2.2'/%3E%3Cpath d='M8 2v14M16 26V12M24 2v14' stroke='%233aa35a' stroke-width='4' stroke-linecap='round'/%3E%3Ccircle cx='28' cy='22' r='2.6' fill='%23d9472b'/%3E%3C/svg%3E")}
.mi.m4{background-image:url(img/reloj.webp)}
.mdesc{font-size:12.5px;margin:6px 0 4px;min-height:34px;line-height:1.35}
.row{display:flex;align-items:center;justify-content:center;gap:8px;margin:5px 0;flex-wrap:wrap}
.lbl{font-weight:800;font-size:13.5px;min-width:70px;text-align:right}
.seg{display:flex;border:3px solid var(--ink);border-radius:12px;overflow:hidden}
.seg button{appearance:none;border:0;border-left:2px solid var(--ink);background:#fff;font:inherit;font-weight:800;font-size:13.5px;color:var(--ink);padding:6px 10px;min-height:36px;cursor:pointer}
.seg button:first-child{border-left:0}
.seg button.sel{background:var(--blue);color:#fff}
.stepper{display:flex;align-items:center;gap:8px}
.stepper button{appearance:none;border:3px solid var(--ink);border-radius:10px;background:#fff;font:inherit;font-weight:800;width:40px;height:36px;cursor:pointer;color:var(--ink)}
.stepper button:disabled{opacity:.35}
.stepper b{min-width:150px;font-size:14px}
.keys{font-size:12px;gap:4px}
.k{display:inline-flex;align-items:center;justify-content:center;min-width:24px;height:24px;border:2px solid var(--ink);border-bottom-width:4px;border-radius:6px;background:#fff;font-weight:800;font-size:13px}
.or{opacity:.8;margin:0 2px}
.bestline{font-weight:800;font-size:13px;margin-top:4px;color:var(--wood)}
.btn.big{display:block;width:100%;margin:8px 0 0;font-size:22px;min-height:54px;background:var(--red);color:#fff;text-shadow:0 2px 0 var(--ink);animation:breathe 1.6s ease-in-out infinite}
@keyframes breathe{50%{filter:brightness(1.1)}}
.card{width:min(330px,88vw);padding:12px 18px 16px;max-height:94%;overflow:auto}
.card img{width:80px;height:auto;margin:-46px auto 0;display:block}
.card h3{margin:4px 0;font-size:25px;color:var(--green)}
.card p{margin:4px 0 8px;font-size:14px}
.card .btn:not(.big){margin-top:8px;width:100%}
.two{display:flex;gap:8px}.two .btn{flex:1}
.nums{display:flex;justify-content:center;gap:24px}
.nums small{display:block;font-size:11px;opacity:.75}.nums b{font-size:28px}
.rec{display:none;margin:6px auto 0;background:var(--gold);border:2px solid var(--ink);border-radius:20px;padding:2px 12px;font-weight:800;width:max-content;animation:pop .4s}
.rec.show{display:block}
.card.share{width:min(560px,94vw);padding:10px 12px 12px}
#shareCv{width:auto;max-width:100%;height:auto;max-height:58vh;border:3px solid var(--ink);border-radius:12px;display:block;margin:0 auto;background:#fff}
#clear{align-items:flex-end;padding-bottom:6vh;background:rgba(29,42,74,.12)}
@media (max-width:420px){.pill b{font-size:17px}.pill{min-width:52px;padding:2px 6px}.pill.wide{min-width:74px}#hud{gap:4px;padding:6px 6px 2px}.btn.icon{width:40px;min-width:40px;min-height:40px}h1{font-size:29px}.lbl{min-width:0}.mode b{font-size:10.5px;letter-spacing:-.4px}.mi{width:28px;height:24px}}
@media (max-height:640px){#pad{grid-template-rows:46px 46px}.panel{padding:6px 10px 10px}.intro{font-size:12.5px}}
@media (orientation:landscape) and (max-height:560px){#hint{display:none}#pad{position:absolute;right:10px;bottom:8px;z-index:3;padding:0}#pad .btn{opacity:.92}#fx{position:absolute;left:8px;top:60px;flex-direction:column;height:auto;z-index:3}#hud{padding:4px 8px 2px}}

/* small store frame (794x447, 640x360): two-column menu, compact cards */
.pcol{display:contents}
@media (max-height:560px){
  #menu .panel{width:min(790px,96vw);max-height:96%;display:grid;grid-template-columns:minmax(0,1.05fr) minmax(0,1fr);column-gap:16px;align-items:center;padding:8px 14px 10px}
  #menu .pcol{display:block}
  .head img{width:60px}
  h1{font-size:28px}h2{font-size:15px;margin-top:2px}
  .intro{font-size:12px;margin:4px 2px 6px;line-height:1.4}
  .mode{padding:4px 1px}.mode b{font-size:11px}
  .mi{width:28px;height:22px}
  .mdesc{margin:5px 0 0;min-height:0;font-size:11.5px}
  .row{margin:4px 0}
  .seg button{min-height:32px;padding:4px 9px;font-size:13px}
  .stepper button{height:32px;width:36px}
  .lbl{font-size:12.5px}
  .btn.big{margin-top:6px;min-height:46px;font-size:20px}
  .card{padding:8px 16px 12px}
  .card img{width:58px;margin-top:-28px}
  .card h3{font-size:21px;margin:2px 0}
  .nums b{font-size:24px}
  .card .btn:not(.big){margin-top:6px;min-height:38px}
  #shareCv{max-height:52vh}
}
@media (max-height:420px){
  #menu .panel{padding:6px 12px 8px}
  .head img{width:44px}
  h1{font-size:24px}h2{font-size:13px}
  .intro{font-size:11px;line-height:1.35;margin:3px 2px 5px}
  .mdesc{font-size:11px}
  .keys{display:none}
  .row{margin:3px 0}
  .seg button{min-height:30px;padding:3px 8px}
  .stepper button{height:30px}
  .bestline{font-size:12px;margin-top:2px}
  .btn.big{min-height:40px;font-size:18px}
  .card img{display:none}
  .card p{margin:2px 0 4px;font-size:12.5px}
  .card h3{font-size:19px}
  .nums b{font-size:21px}
  .card .btn:not(.big){min-height:34px;margin-top:5px;padding:2px 8px}
  #shareCv{max-height:48vh;width:auto;margin:0 auto}
}
@media (max-height:560px) and (max-width:520px){#menu .panel{display:block}#menu .pcol{display:contents}}
@media (orientation:landscape) and (max-height:420px){#pad{grid-template-columns:56px 56px 56px;grid-template-rows:42px 42px;gap:5px}#pad .btn{min-width:56px;font-size:20px}}

/* big screens: scale DOM UI up so it is not tiny at 1376x774 / 1920x1080 */
@media (min-width:1300px) and (min-height:740px){#hud,.panel,.card,#hint{zoom:1.15}}
@media (min-width:1700px) and (min-height:950px){#hud,.panel,.card,#hint{zoom:1.4}#fx{zoom:1.3}}
