@font-face{font-family:Fred;src:url(font/fredoka-latin-500-normal.woff2) format("woff2");font-weight:500;font-display:swap}
@font-face{font-family:Fred;src:url(font/fredoka-latin-600-normal.woff2) format("woff2");font-weight:600;font-display:swap}
@font-face{font-family:Fred;src:url(font/fredoka-latin-700-normal.woff2) format("woff2");font-weight:700;font-display:swap}
@font-face{font-family:Cond;src:url(font/barlow-condensed-latin-600-normal.woff2) format("woff2");font-weight:600;font-display:swap}
@font-face{font-family:Cond;src:url(font/barlow-condensed-latin-700-normal.woff2) format("woff2");font-weight:700;font-display:swap}
:root{--ink:#24364f;--ink2:#566a86;--teal:#1f8a80;--teal2:#16675f;--terra:#e0663f;--sun:#ffc845;--cream:#fff9ee;--paper:#fffdf8;--line:#e6dccb;--green:#3aa564;--red:#d8443a;
  font-size:clamp(11px, min(2.3vh, 1.55vw) + 4.5px, 26px)}
body.big{--bigk:1}
:root:has(body.big){font-size:clamp(13px, min(2.7vh, 1.85vw) + 5px, 29px)}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden;background:#d99a62;color:var(--ink);font-family:Fred,"Trebuchet MS",Arial,sans-serif;touch-action:manipulation;user-select:none;-webkit-user-select:none}
button{font-family:inherit;color:inherit;cursor:pointer;border:0;background:none;padding:0}
.hidden{display:none!important}
#bg{position:fixed;inset:0;background:url(img/mesa.webp) center/cover no-repeat}
#bg::after{content:"";position:absolute;inset:0;background:radial-gradient(ellipse at center,rgba(255,249,238,.55),rgba(255,249,238,.2) 70%)}
#app{position:fixed;inset:0;display:flex;flex-direction:column;padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)}
#top{display:flex;align-items:center;gap:.4rem;padding:.35rem .5rem;background:var(--teal);color:#fff;z-index:2;box-shadow:0 3px 0 var(--teal2);flex:none}
.ib{width:2.45rem;height:2.45rem;border-radius:.8rem;display:grid;place-items:center;background:rgba(255,255,255,.16);flex:none}
.ib svg{width:1.4rem;height:1.4rem}
.ib.txt{font-weight:700;font-size:1.05rem}
body.big #bBig{background:var(--sun);color:var(--ink)}
.ib.dark{background:#efe6d6;color:var(--ink)}
#bSound .x{display:none}#bSound.off .x{display:block}#bSound.off .w{display:none}
#bMusic.off{opacity:.45}
#bBack{visibility:hidden}
body.playing #bBack{visibility:visible}
#ttl{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.1}
#ttl b{font-weight:700;font-size:1.12rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#ttl span{font-size:.78rem;opacity:.85;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pill{background:#fff;color:var(--ink);border-radius:999px;padding:.28rem .65rem;font-weight:700;font-size:.95rem;min-width:3.3rem;text-align:center;flex:none}
#pts i{font-style:normal;color:var(--terra);margin-right:3px}
#timer{display:none}body.playing #timer{display:block}

/* ---------- hub ---------- */
#hub{flex:1;min-height:0;display:flex;gap:.8rem;padding:.7rem;align-items:stretch}
#hubIntro{flex:0 0 34%;max-width:22rem;display:flex;flex-direction:column;align-items:center;justify-content:center;background:rgba(255,253,248,.94);border-radius:1.1rem;padding:.6rem .8rem;box-shadow:0 .3rem 0 rgba(36,54,79,.18);min-height:0}
#hubIntro .mascot{height:min(9rem,22vh);width:auto;flex:none;margin-bottom:-.2rem}
.introText{display:flex;flex-direction:column;align-items:center;text-align:center;gap:.4rem;min-height:0}
h1{margin:0;font-size:1.65rem;line-height:1;color:var(--teal2)}
h1 small{display:block;font-size:.8rem;color:var(--ink2);font-weight:500;margin-top:.25rem}
.intro{margin:0;font-size:.86rem;line-height:1.25;color:var(--ink2)}
button.big{background:var(--terra);color:#fff;font-weight:700;font-size:1.15rem;border-radius:.9rem;padding:.55rem 1.2rem;box-shadow:0 .25rem 0 #a8442a;width:100%;line-height:1.15}
button.big span{display:block;font-size:.72rem;font-weight:500;opacity:.92}
button.big:active{transform:translateY(2px);box-shadow:0 .1rem 0 #a8442a}
.hubStats{display:flex;gap:.35rem;width:100%}
.st{flex:1;background:#f3ecdf;border-radius:.7rem;padding:.3rem .2rem;display:flex;flex-direction:column;align-items:center;line-height:1.05}
.st b{font-size:1.15rem;color:var(--teal2);display:flex;align-items:center;justify-content:center;min-height:1.3rem}
.st span{font-size:.66rem;color:var(--ink2)}
.st.cal{background:#e3f1ee;color:var(--teal2)}
#hubRight{flex:1;min-width:0;display:flex;flex-direction:column;gap:.55rem;min-height:0}
#days{display:flex;gap:.3rem;flex:none}
.day{flex:1;min-width:0;background:rgba(255,253,248,.85);border-radius:.7rem;padding:.25rem .1rem;line-height:1.05;display:flex;flex-direction:column;align-items:center;border:2px solid transparent}
.day b{font-size:.8rem}.day span{font-size:.66rem;color:var(--ink2)}
.day i{font-style:normal;font-size:.62rem;color:var(--teal2);font-weight:700;min-height:.7rem}
.day.on{border-color:var(--terra);background:#fff}
.day.today b{color:var(--terra)}
#cards{flex:1;min-height:0;display:grid;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(2,1fr);gap:.55rem}
.card{position:relative;background:var(--paper);border-radius:1rem;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.25rem;padding:.4rem;box-shadow:0 .3rem 0 var(--cc,#999);border:2px solid transparent;min-height:0;overflow:hidden;text-align:center}
.card svg{width:auto;height:min(5rem,45%);flex:none}
.card b{font-size:1rem;line-height:1.05}
.card span{font-size:.72rem;color:var(--ink2);line-height:1.1}
.card.focus,.card:focus-visible{border-color:var(--cc);outline:none}
.card.done{background:#f1f8ef}
.card.done::after{content:"✓";position:absolute;top:.3rem;right:.4rem;width:1.5rem;height:1.5rem;border-radius:50%;background:var(--green);color:#fff;font-weight:700;display:grid;place-items:center;font-size:.9rem}
.card.prog::after{content:"";position:absolute;top:.5rem;right:.5rem;width:.7rem;height:.7rem;border-radius:50%;background:var(--sun);box-shadow:0 0 0 3px #fff3cf}
.card:active{transform:translateY(2px)}
#hubTip{margin:0;font-size:.68rem;color:var(--ink);text-align:center;background:rgba(255,253,248,.7);border-radius:.5rem;padding:.15rem .4rem;flex:none}

/* ---------- play ---------- */
#play{flex:1;min-height:0;display:flex;gap:.6rem;padding:.55rem}
#stage{flex:1;min-width:0;min-height:0;display:flex;align-items:center;justify-content:center;position:relative}
#side{flex:0 0 40%;max-width:27rem;min-width:0;display:flex;flex-direction:column;gap:.45rem;justify-content:center;min-height:0}
#help{display:flex;align-items:center;gap:.4rem;background:rgba(255,253,248,.95);border-radius:.8rem;padding:.3rem .5rem;flex:none;box-shadow:0 .2rem 0 rgba(36,54,79,.15)}
#help img{height:2.4rem;width:auto;flex:none}
#help p{margin:0;font-size:.86rem;line-height:1.2}
#help img.hop{animation:hop .45s}
@keyframes hop{30%{transform:translateY(-6px) rotate(-6deg)}60%{transform:translateY(0) rotate(3deg)}}
#ctl{display:flex;flex-direction:column;gap:.4rem;min-height:0}
.paper{background:var(--paper);border-radius:.8rem;padding:.45rem;box-shadow:0 .3rem 0 rgba(36,54,79,.22),0 .6rem 1.2rem rgba(36,54,79,.15);line-height:0}
canvas.board{display:block;touch-action:none}
.pad{display:grid;gap:.35rem}
.k{background:#fff;border-radius:.6rem;font-weight:700;font-size:1.35rem;min-height:2.6rem;box-shadow:0 .2rem 0 #c9bca6;color:var(--ink);display:grid;place-items:center;padding:0 .2rem}
.k.on,.k:active{background:var(--sun);transform:translateY(2px);box-shadow:0 0 0 #c9bca6}
.k.alt{background:#e3f1ee;color:var(--teal2);font-size:.9rem}
.k.warm{background:var(--terra);color:#fff;box-shadow:0 .2rem 0 #a8442a;font-size:.95rem}
.k.sel{background:var(--teal);color:#fff;box-shadow:0 .2rem 0 var(--teal2)}
.k small{display:block;font-size:.62rem;font-weight:500;opacity:.8}
.kb{display:flex;flex-direction:column;gap:.28rem}
.kr{display:flex;gap:.22rem;justify-content:center}
.kr .k{flex:1;min-width:0;font-size:1rem;min-height:2.35rem;border-radius:.45rem;padding:0}
.kr .k.wide{flex:1.7;font-size:.78rem}
.k.g{background:#5fb57a;color:#fff}.k.y{background:#f2c14e;color:#3b2c00}.k.x{background:#b9b2a6;color:#fff}
.tools{display:flex;gap:.35rem}
.tools .k{flex:1;font-size:.85rem;min-height:2.3rem}
.tools .k em{font-style:normal;color:var(--terra);font-size:.75rem;margin-left:.2rem}
.clue{display:flex;align-items:stretch;background:#fff3cf;border-radius:.7rem;min-height:3.1rem;overflow:hidden;box-shadow:0 .2rem 0 #d6b45a}
.clue button{width:2.3rem;font-size:1.6rem;font-weight:700;color:#fff;background:#c0392b;flex:none}
.clue div{flex:1;display:flex;flex-direction:column;justify-content:center;padding:.2rem .6rem;min-width:0;cursor:pointer}
.clue small{font-size:.7rem;color:var(--ink2)}
.clue b{font-size:1.05rem;line-height:1.15}
.words{display:flex;flex-wrap:wrap;gap:.25rem .35rem;background:var(--paper);border-radius:.7rem;padding:.45rem;box-shadow:0 .2rem 0 rgba(36,54,79,.18)}
.words span{font-size:.92rem;font-weight:600;padding:.05rem .45rem;border-radius:.4rem;background:#f3ecdf}
.words span.f{text-decoration:line-through;opacity:.55;background:#dff0e3}
.words .th{width:100%;font-size:.72rem;color:var(--ink2);background:none;padding:0}
/* palabra oculta tiles */
.po{display:grid;grid-template-rows:repeat(6,1fr);gap:.3rem}
.po .row{display:grid;grid-template-columns:repeat(5,1fr);gap:.3rem}
.po .t{display:grid;place-items:center;font-weight:700;background:#fff;border:2px solid #d9cfbd;border-radius:.45rem;color:var(--ink);text-transform:uppercase}
.po .t.f{border-color:var(--ink2)}
.po .t.g{background:#5fb57a;border-color:#4c9a65;color:#fff}
.po .t.y{background:#f2c14e;border-color:#d9a935;color:#3b2c00}
.po .t.x{background:#b9b2a6;border-color:#a39b8e;color:#fff}
.po .t.flip{animation:flip .45s both}
.po .row.shake{animation:shake .4s}
@keyframes flip{0%{transform:scaleY(1)}50%{transform:scaleY(.05)}100%{transform:scaleY(1)}}
@keyframes shake{20%,60%{transform:translateX(-7px)}40%,80%{transform:translateX(7px)}}
/* cálculo */
.calc{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.6rem;background:var(--paper);border-radius:1rem;padding:1rem 1.4rem;box-shadow:0 .3rem 0 rgba(36,54,79,.22);min-width:min(100%,19rem)}
.calc .q{font-size:2.6rem;font-weight:700;white-space:nowrap;color:var(--ink)}
.calc .a{min-width:6rem;font-size:2.4rem;font-weight:700;border-bottom:4px solid var(--teal);text-align:center;min-height:3rem;color:var(--teal2)}
.calc .a.bad{color:var(--red);border-color:var(--red)}
.calc .a.ok{color:var(--green);border-color:var(--green)}
.dots{display:flex;gap:.3rem;flex-wrap:wrap;justify-content:center}
.dots i{width:.8rem;height:.8rem;border-radius:50%;background:#e6dccb}
.dots i.ok{background:var(--green)}.dots i.bad{background:var(--red)}.dots i.cur{background:var(--sun);box-shadow:0 0 0 2px #fff,0 0 0 4px var(--sun)}
.calc .note{font-size:.85rem;color:var(--ink2);min-height:1.1rem}
.modeBtns{display:flex;gap:.35rem}
.modeBtns .k{flex:1;font-size:.95rem}

/* ---------- overlays ---------- */
.ov{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(36,54,79,.45);z-index:10;padding:.6rem}
.sheet{background:var(--cream);border-radius:1.2rem;box-shadow:0 .5rem 0 rgba(0,0,0,.15),0 1rem 2.5rem rgba(0,0,0,.3);padding:.9rem 1.1rem;max-height:100%;width:min(32rem,100%);display:flex;flex-direction:column;min-height:0;animation:pop .3s}
@keyframes pop{from{transform:scale(.9);opacity:0}}
.doneSheet{flex-direction:row;align-items:center;gap:.8rem;width:min(36rem,100%)}
.doneSheet .mascot{height:min(11rem,38vh);width:auto;flex:none}
.doneBody{flex:1;display:flex;flex-direction:column;gap:.45rem;align-items:center;text-align:center;min-width:0}
.doneBody h2{margin:0;font-size:1.6rem;color:var(--teal2);line-height:1.05}
.doneBody p{margin:0;font-size:.95rem;color:var(--ink2);line-height:1.25}
.doneStats{display:flex;gap:.4rem;width:100%}
.doneStats div{flex:1;background:#f3ecdf;border-radius:.7rem;padding:.3rem;line-height:1.1}
.doneStats b{display:block;font-size:1.25rem;color:var(--terra)}
.doneStats span{font-size:.7rem;color:var(--ink2)}
.doneBtns{width:100%;display:flex;flex-direction:column;gap:.4rem}
.row2{display:flex;gap:.4rem}
.sec{flex:1;background:#e3f1ee;color:var(--teal2);font-weight:700;border-radius:.8rem;padding:.45rem .4rem;font-size:.88rem}
.calSheet{gap:.5rem;width:min(26rem,100%)}
.calHead{display:flex;align-items:center;gap:.5rem}
.calHead h2{flex:1;margin:0;text-align:center;font-size:1.3rem;color:var(--teal2)}
.calScroll{overflow:auto;min-height:0;flex:1}
#calGrid{display:grid;grid-template-columns:repeat(7,1fr);gap:.22rem}
#calGrid .h{font-size:.68rem;text-align:center;color:var(--ink2);font-weight:600}
#calGrid .d{aspect-ratio:1.25;border-radius:.45rem;background:#fff;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:.8rem;line-height:1;position:relative}
#calGrid .d i{font-style:normal;font-size:.6rem;color:var(--teal2);font-weight:700}
#calGrid .d.l1{background:#d9efe9}#calGrid .d.l2{background:#a8dccf}#calGrid .d.l3{background:#53b3a2;color:#fff}#calGrid .d.l3 i{color:#fff}
#calGrid .d.all::after{content:"★";position:absolute;top:1px;right:3px;font-size:.6rem;color:var(--sun)}
#calGrid .d.today{outline:2px solid var(--terra)}
#calGrid .d.fut{opacity:.4}
#calGrid .d.e{background:none}
#calStats{display:flex;gap:.35rem;margin-top:.5rem}
#calStats div{flex:1;background:#f3ecdf;border-radius:.6rem;text-align:center;padding:.25rem;line-height:1.1}
#calStats b{display:block;font-size:1.1rem;color:var(--terra)}#calStats span{font-size:.66rem;color:var(--ink2)}
.calNote{font-size:.72rem;color:var(--ink2);margin:.4rem 0 0;text-align:center}
#toast{position:fixed;left:50%;top:3.6rem;transform:translate(-50%,-150%);opacity:0;visibility:hidden;transition:transform .25s,opacity .25s,visibility .25s;background:var(--ink);color:#fff;padding:.45rem 1rem;border-radius:999px;font-size:.92rem;transition:transform .25s;z-index:20;pointer-events:none;max-width:92vw;text-align:center}
#toast.show{transform:translate(-50%,0);opacity:1;visibility:visible}
#fx{position:fixed;inset:0;width:100%;height:100%;pointer-events:none;z-index:30}

/* ---------- portrait ---------- */
@media (max-aspect-ratio:1/1){
  :root{font-size:clamp(12px, 1.4vh + 3.6px, 19px)}
  :root:has(body.big){font-size:clamp(14px, 1.65vh + 4.6px, 22px)}
  #hub{flex-direction:column;overflow:auto}
  #hubIntro{flex:none;max-width:none;flex-direction:row;gap:.6rem;padding:.5rem .6rem}
  #hubIntro .mascot{height:7.5rem}
  .introText{align-items:stretch;text-align:left}
  #hubRight{flex:1}
  #cards{grid-template-columns:repeat(2,1fr);grid-template-rows:repeat(3,1fr);min-height:18rem}
  #play{flex-direction:column}
  #side{flex:none;max-width:none;justify-content:flex-start}
  #help img{height:2rem}
  .doneSheet{flex-direction:column}
  .doneSheet .mascot{height:min(8rem,22vh)}
}
/* ---------- short frames ---------- */
@media (max-height:520px) and (min-aspect-ratio:1/1){
  #hubIntro .mascot{height:min(6.5rem,20vh)}
  .intro{font-size:.78rem}
  #hubTip{display:none}
  #help img{height:1.9rem}
  #help p{font-size:.8rem}
  .doneSheet .mascot{height:min(9rem,40vh)}
}
@media (max-height:400px) and (min-aspect-ratio:1/1){
  #hubIntro .mascot{display:none}
  #help img{display:none}
  .card svg{height:min(2.6rem,40%)}
}
