:root{
  --blue:#3d7fe6;--blue-d:#2559b0;--red:#e8493f;--red-d:#a92c25;--ink:#2b2a3a;--paper:#fff8ea;--wood:#c98b4f;--wood-d:#8f5a2c;
  --gold:#ffc93c;--green:#5fbf4a;
  font-size:clamp(11px, calc(min(2.1vh, 1.5vw) + 4px), 24px);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
[hidden]{display:none!important}
html,body{margin:0;height:100%;overflow:hidden;background:#7a4d28;font-family:"Trebuchet MS","Segoe UI",Roboto,system-ui,sans-serif;color:var(--ink);user-select:none;-webkit-user-select:none}
button{font:inherit;color:inherit;cursor:pointer;border:0}
#app{position:fixed;inset:0;display:flex;flex-direction:column;
  background:radial-gradient(ellipse at 50% 40%,#d9a066 0%,#b97a42 55%,#8f5a2c 100%)}
#app::before{content:"";position:absolute;inset:0;pointer-events:none;opacity:.25;
  background:repeating-linear-gradient(92deg,transparent 0 22px,rgba(90,50,20,.35) 22px 24px,transparent 24px 61px)}
/* HUD */
#hud{position:relative;z-index:3;display:flex;align-items:center;gap:.45rem;padding:.3rem .5rem;height:2.9rem;flex:none;
  background:linear-gradient(#fff8ea,#f2e3c4);border-bottom:3px solid var(--wood-d);box-shadow:0 2px 0 rgba(0,0,0,.15)}
#side{display:flex;align-items:center;gap:.35rem;font-weight:800;min-width:0}
#side .dot{width:1.1rem;height:1.1rem;border-radius:50%;background:var(--blue);border:2px solid var(--ink);flex:none}
#side.red .dot{background:var(--red)}
.sup{display:flex;align-items:center;gap:.2rem;background:#fff;border:2px solid var(--ink);border-radius:1rem;padding:.05rem .5rem .05rem .3rem}
.sup small{color:#2f8a2a;font-weight:700}
.crate{display:inline-block;width:1rem;height:1rem;border-radius:3px;background:linear-gradient(45deg,transparent 42%,#8f5a2c 42% 58%,transparent 58%),#e0a45e;border:2px solid #6b3f19;vertical-align:-.15rem}
#dayBox{flex:1;display:flex;flex-direction:column;align-items:center;line-height:1.05;min-width:0}
#dayBox b{font-size:1.05rem}#dayBox small{opacity:.75;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.hb{background:var(--gold);border:2px solid var(--ink);border-radius:.7rem;padding:.3rem .7rem;font-weight:800;box-shadow:0 3px 0 var(--ink);white-space:nowrap}
.hb:active{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
.hb[disabled]{opacity:.45;filter:grayscale(1)}
kbd{display:inline-block;min-width:1.3em;padding:0 .25em;border:1.5px solid var(--ink);border-bottom-width:3px;border-radius:.3em;background:#fff;font:700 .8em/1.4 inherit;text-align:center;margin:0 .08em}
.hb kbd{font-size:.7em;vertical-align:.1em}
.ib{width:2.2rem;height:2.2rem;flex:none;border-radius:50%;background:#fff;border:2px solid var(--ink);display:grid;place-items:center;font-weight:900;font-size:1.1rem;box-shadow:0 2px 0 var(--ink)}
.ib svg{width:1.25rem;height:1.25rem;fill:var(--ink);stroke:var(--ink);stroke-width:2;stroke-linecap:round}
#bMusic svg{fill:none}#bMusic svg circle{fill:var(--ink)}
#bSound .w{fill:none}#bSound .x{display:none}
.ib.off{opacity:.55}#bSound.off .w{display:none}#bSound.off .x{display:block}#bMusic.off{opacity:.4}
/* stage */
#stage{position:relative;flex:1;min-height:0}
#cv{position:absolute;inset:0;width:100%;height:100%;touch-action:none;display:block}
#tip{position:absolute;left:50%;bottom:.35rem;transform:translateX(-50%);max-width:calc(100% - 1rem);background:rgba(43,42,58,.82);color:#fff;
  padding:.22rem .75rem;border-radius:1rem;font-size:.82rem;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none}
#info{position:absolute;left:.4rem;top:.4rem;background:var(--paper);border:2px solid var(--ink);border-radius:.7rem;padding:.3rem .55rem;font-size:.8rem;
  box-shadow:0 3px 0 rgba(0,0,0,.25);max-width:15rem;pointer-events:none;line-height:1.3}
#info b{font-size:.9rem}#info .pv{display:flex;gap:.6rem;margin-top:.15rem;font-weight:800}
#info .pv .d{color:#c0392b}#info .pv .c{color:#2559b0}
#act{position:absolute;z-index:4;display:flex;flex-direction:column;gap:.3rem;background:var(--paper);border:2px solid var(--ink);border-radius:.8rem;padding:.35rem;box-shadow:0 4px 0 rgba(0,0,0,.25)}
#act button{background:#fff;border:2px solid var(--ink);border-radius:.55rem;padding:.35rem .75rem;font-weight:800;text-align:left;white-space:nowrap;min-height:2.3rem}
#act button.go{background:var(--gold)}#act button.atk{background:#ff8a7a}
#act button kbd{margin-right:.35rem}
#act .pvl{font-size:.8rem;font-weight:700;padding:0 .2rem}
#banner{position:absolute;left:50%;top:40%;transform:translate(-50%,-50%) scale(.6);opacity:0;pointer-events:none;z-index:2;
  font-size:2rem;font-weight:900;color:#fff;padding:.4rem 1.4rem;border-radius:1rem;border:3px solid var(--ink);background:var(--blue);white-space:nowrap;
  box-shadow:0 5px 0 rgba(0,0,0,.3);transition:transform .25s,opacity .25s}
#banner.red{background:var(--red)}#banner.show{opacity:1;transform:translate(-50%,-50%) scale(1)}
/* overlays */
.ov{position:absolute;inset:0;z-index:10;display:none;align-items:center;justify-content:center;padding:.6rem;background:rgba(60,35,15,.45)}
.ov.show{display:flex}
#menu{background:url(img/menu.webp) center/cover,#b97a42}
#menu::before{content:"";position:absolute;inset:0;background:rgba(40,25,10,.28)}
.card{position:relative;background:var(--paper);border:3px solid var(--ink);border-radius:1.2rem;box-shadow:0 6px 0 rgba(0,0,0,.3);padding:1rem;max-height:100%;display:flex;flex-direction:column;gap:.55rem;width:min(28rem,100%)}
.card.wide{width:min(46rem,100%);height:min(32rem,100%)}
.card.mid{width:min(34rem,100%);max-height:100%}
.card.small{width:min(24rem,100%);align-items:stretch;text-align:center}
.card.start{width:min(48rem,100%);flex-direction:row;gap:1.1rem;align-items:center}
.card.start .col{display:flex;flex-direction:column;gap:.5rem;min-width:0}
.card.start .col.a{flex:1.25}.card.start .col.b{flex:1}
h1{margin:0;font-size:2.4rem;line-height:1;color:var(--blue-d);text-shadow:2px 2px 0 #fff,4px 4px 0 rgba(0,0,0,.15);font-weight:900}
h2{margin:0;font-size:1.35rem;font-weight:900}
.sub{margin:0;font-weight:900;color:var(--red-d);font-size:1.15rem}
.intro{margin:0;font-size:.92rem;line-height:1.35}
.keys{display:flex;flex-wrap:wrap;gap:.3rem .7rem;font-size:.78rem;opacity:.9}
.keys .touch{flex-basis:100%;font-weight:700;color:var(--blue-d)}
.big{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.05rem;background:#fff;border:2.5px solid var(--ink);border-radius:.9rem;padding:.5rem .8rem;font-weight:900;font-size:1.05rem;box-shadow:0 4px 0 var(--ink);min-height:2.9rem}
.big small{font-weight:700;font-size:.72rem;opacity:.75}
.big.go{background:var(--gold)}.big.alt{background:#d8ecff}
.big:active{transform:translateY(3px);box-shadow:0 1px 0 var(--ink)}
.big[disabled]{opacity:.45;filter:grayscale(1)}
.chead{display:flex;align-items:center;gap:.6rem;flex:none}
.chead h2{flex:1}
.stars{font-weight:900;color:#b07a00}
.sm{background:#fff;border:2px solid var(--ink);border-radius:.6rem;padding:.25rem .7rem;font-weight:800;box-shadow:0 2px 0 var(--ink);min-height:2.1rem}
.sm.x{background:#ffe0dc}
.row{display:flex;gap:.6rem;flex:none}
.tog{background:#fff;border:2px solid var(--ink);border-radius:.6rem;padding:.25rem .7rem;font-weight:800;min-height:2.1rem}
.tog.on{background:#9fd36a}
.scroll{overflow-y:auto;min-height:0;flex:1;-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
#mapGrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(8.2rem,1fr));gap:.45rem;align-content:start;padding:.15rem}
.mapc{position:relative;background:#fff;border:2px solid var(--ink);border-radius:.7rem;padding:.35rem .45rem;text-align:left;box-shadow:0 3px 0 var(--ink);min-height:3.4rem;display:flex;flex-direction:column;gap:.1rem}
.mapc b{font-size:.75rem;color:var(--blue-d)}.mapc span{font-size:.8rem;font-weight:800;line-height:1.1}
.mapc i{font-style:normal;color:#e0a000;font-size:.8rem;letter-spacing:.05em}
.mapc.lock{opacity:.45}.mapc.cur{background:#fff3c4}
.mapc .tags{font-size:.62rem;opacity:.7;font-weight:700}
.lvls{display:grid;grid-template-columns:repeat(3,1fr);gap:.6rem}
.rules{font-size:.86rem;line-height:1.4}
.rules h3{margin:.5rem 0 .2rem;font-size:1rem}
.rules table{border-collapse:collapse;width:100%;font-size:.8rem}
.rules td,.rules th{border:1px solid #c9b98f;padding:.18rem .3rem;text-align:center}
.rules th{background:#f2e3c4}
.rules td:first-child,.rules th:first-child{text-align:left}
.rules .g{background:#c9f0b4}.rules .b{background:#ffd2cc}
#buildList{display:grid;grid-template-columns:repeat(auto-fill,minmax(14rem,1fr));gap:.45rem;align-content:start}
.bu{display:flex;align-items:center;gap:.5rem;background:#fff;border:2px solid var(--ink);border-radius:.7rem;padding:.3rem .5rem;box-shadow:0 3px 0 var(--ink);text-align:left;min-height:3.4rem}
.bu canvas{width:2.8rem;height:2.8rem;flex:none}
.bu div{display:flex;flex-direction:column;line-height:1.15;min-width:0}
.bu b{font-size:.95rem}.bu small{font-size:.7rem;opacity:.8}
.bu .cost{margin-left:auto;font-weight:900;display:flex;align-items:center;gap:.2rem;flex:none}
.bu[disabled]{opacity:.45}
.bigstars{font-size:2.4rem;color:#e0a000;letter-spacing:.1em;line-height:1}
.bigstars .off{color:#d6ccb5}
.rbtns{display:flex;flex-direction:column;gap:.45rem}
/* short windows */
@media (max-height:560px){
  #hud{height:2.5rem;padding:.2rem .4rem}
  .ib{width:1.95rem;height:1.95rem}
  .hb{padding:.12rem .55rem;box-shadow:0 2px 0 var(--ink)}
  h1{font-size:2rem}
  .card{padding:.7rem;gap:.4rem}
  .big{min-height:2.5rem;padding:.35rem .6rem}
  .card.start .col.b{gap:.4rem}
}
@media (max-height:420px){
  :root{font-size:12px}
  h1{font-size:1.75rem}
  .intro{font-size:.85rem}
  .rbtns{flex-direction:row}.rbtns .big{flex:1}
  .card.small h2{font-size:1.15rem}
  .bigstars{font-size:1.8rem}
}
@media (max-width:620px){
  .card.start{flex-direction:column;align-items:stretch;gap:.6rem}
  .card.start .col.a{flex:none}
  .hb{padding:.25rem .45rem}.hb kbd{display:none}
  #dayBox small{display:none}
  #side .sup small{display:none}
  .lvls{grid-template-columns:1fr}
  #mapGrid{grid-template-columns:repeat(auto-fill,minmax(7.4rem,1fr))}
  .keys span:not(.touch){display:none}
}
@media (max-width:420px){ #sideName{display:none} }
