/* Beaver Bridge. System fonts only, no inline styles. */
[hidden]{display:none!important}
*{box-sizing:border-box}
html,body{margin:0;padding:0;height:100%;width:100%;overflow:hidden;overscroll-behavior:none;touch-action:none;
  -webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent}
body{position:fixed;inset:0;height:100dvh;background:#8fd0f2;color:#2b3a4a;
  font-family:ui-rounded,"SF Pro Rounded","Nunito","Segoe UI Rounded","Trebuchet MS",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
#bbw{position:fixed;inset:0;height:100dvh;width:100vw;overflow:hidden;overscroll-behavior:none;touch-action:none}
#world{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;outline:none}
#world:focus-visible{box-shadow:inset 0 0 0 4px #ffffffaa}
button,a{touch-action:manipulation;font:inherit;color:inherit}
button{cursor:pointer}
svg{display:block}
.nojs{position:absolute;inset:40% 10% auto;text-align:center;font-weight:800;background:#fff;padding:16px;border-radius:16px}
:focus-visible{outline:4px solid #5a49d6;outline-offset:2px}

/* ---------- HUD ---------- */
.hud{position:absolute;left:0;right:0;top:0;display:flex;align-items:center;gap:6px;z-index:7;pointer-events:none;
  padding:calc(env(safe-area-inset-top,0px) + 6px) calc(env(safe-area-inset-right,0px) + 8px) 6px calc(env(safe-area-inset-left,0px) + 8px)}
.hud > *{pointer-events:auto}
.hbtn{flex:0 0 auto;width:46px;height:46px;border-radius:16px;border:0;display:grid;place-items:center;padding:0;text-decoration:none;
  background:linear-gradient(#ffffff,#e4f1fb);box-shadow:0 3px 0 #8db5d3,0 6px 14px #1d4f7a33,inset 0 1px 0 #fff;color:#2f5b86}
.hbtn svg{width:28px;height:28px}
.hbtn:active,.tbtn:active,.pill.coins:active{transform:translateY(2px)}
.hbtn.kav-off,.hbtn.off{color:#8a97a5}
.lvl{flex:1 1 auto;min-width:0;height:46px;display:flex;align-items:center;gap:8px;padding:0 6px 0 4px;border-radius:23px;
  background:linear-gradient(#ffffff,#eef7ff);box-shadow:0 3px 0 #8db5d3,0 6px 14px #1d4f7a33}
.lvl-n{flex:0 0 auto;width:38px;height:38px;border-radius:50%;display:grid;place-items:center;font-weight:900;font-size:19px;color:#fff;
  background:radial-gradient(circle at 35% 30%,#7cc4ff,#2f7fd0);box-shadow:inset 0 -3px 0 #1f5f9f}
.lvl-t{flex:1 1 auto;min-width:0;font-weight:900;font-size:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#24486c}
.goal{flex:0 0 auto;height:36px;width:64px;background:center/contain no-repeat}
.pill{flex:0 0 auto;height:42px;padding:0 10px 0 6px;border-radius:21px;display:flex;align-items:center;gap:4px;border:0;
  background:#fffffff0;box-shadow:0 3px 0 #8db5d3,0 6px 14px #1d4f7a22;font-weight:900;font-size:19px;color:#a8660b}
.pill small{font-size:13px;color:#a98a5a;font-weight:800}
.coin-ic{width:28px;height:28px;border-radius:50%;background:radial-gradient(circle at 35% 30%,#fff3b0,#ffcf3a 45%,#e09b12 80%);
  box-shadow:inset 0 0 0 3px #f7b524,inset 0 0 0 5px #ffe48a,0 2px 0 #b8770b}
.pill.coins.low{animation:wig .8s ease-in-out 2}
.pill.coins.pop{animation:pop .5s}
.stars{gap:1px;padding:0 8px}
.star{width:24px;height:24px}
.star path{fill:#e3e7ee;stroke:#b9c2cf;stroke-width:1.5}
.star.on path{fill:#ffcf3a;stroke:#d99a0b}
@keyframes pop{40%{transform:scale(1.25)}}
@keyframes wig{20%{transform:rotate(-8deg)}40%{transform:rotate(7deg)}60%{transform:rotate(-4deg)}}
@media (max-width:560px){.hbtn{width:42px;height:42px}.hbtn svg{width:25px;height:25px}.lvl{height:42px}.lvl-n{width:34px;height:34px;font-size:17px}
  .lvl-t{font-size:15px}.goal{display:none}.stars{display:none}.pill{height:38px;font-size:17px}.coin-ic{width:24px;height:24px}}
@media (max-width:380px){.pill small{display:none}#btnSound{display:none}}

/* ---------- tool bar ---------- */
.tools{position:absolute;left:0;right:0;bottom:0;z-index:6;display:flex;align-items:flex-end;justify-content:center;gap:10px;flex-wrap:wrap;pointer-events:none;
  padding:6px calc(env(safe-area-inset-right,0px) + 8px) calc(env(safe-area-inset-bottom,0px) + 8px) calc(env(safe-area-inset-left,0px) + 8px)}
.tools > *{pointer-events:auto}
.mats,.shapes,.acts{display:flex;gap:8px;align-items:flex-end}
.mat,.shape{position:relative;width:78px;height:72px;border-radius:18px;border:0;padding:4px 2px 2px;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;gap:2px;
  background:linear-gradient(#ffffff,#e9f2fa);box-shadow:0 4px 0 #8db5d3,0 8px 16px #1d4f7a33;font-weight:900;font-size:14px;color:#2f4a66}
.mat canvas,.shape canvas{width:62px;height:34px}
.mat .cost{position:absolute;top:-7px;right:-5px;min-width:26px;height:26px;border-radius:13px;padding:0 4px;display:flex;align-items:center;justify-content:center;gap:1px;
  background:radial-gradient(circle at 35% 30%,#fff3b0,#ffcf3a 50%,#e09b12);box-shadow:0 2px 0 #b8770b;color:#6b3f00;font-size:14px}
.mat[aria-checked="true"],.shape[aria-checked="true"]{background:linear-gradient(#fff9df,#ffe38a);box-shadow:0 4px 0 #d39b1e,0 0 0 4px #ffcf3a,0 8px 16px #1d4f7a33;transform:translateY(-4px)}
.tbtn{width:64px;height:64px;border-radius:18px;border:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;padding:0;
  background:linear-gradient(#ffffff,#e9f2fa);box-shadow:0 4px 0 #8db5d3,0 8px 16px #1d4f7a33;font-weight:900;font-size:13px;color:#2f4a66}
.tbtn .ic svg{width:30px;height:30px}
.tbtn[aria-pressed="true"]{background:linear-gradient(#fff9df,#ffe38a);box-shadow:0 4px 0 #d39b1e,0 0 0 3px #ffcf3a}
.tbtn:disabled{opacity:.45}
.test{height:76px;min-width:124px;border-radius:24px;border:0;display:flex;align-items:center;justify-content:center;gap:6px;padding:0 18px;
  background:linear-gradient(#7fe08a,#2fb24e);box-shadow:0 5px 0 #1e7f36,0 10px 22px #1d4f7a44,inset 0 2px 0 #c9ffd0;color:#fff;font-weight:900;font-size:24px;
  text-shadow:0 2px 0 #1e7f3699}
.test .ic svg{width:34px;height:34px}
.test.stop{background:linear-gradient(#ffb36b,#f07c2a);box-shadow:0 5px 0 #b4551a,0 10px 22px #1d4f7a44,inset 0 2px 0 #ffe0c2;text-shadow:0 2px 0 #b4551a99}
.test.glow{animation:glow 1.2s ease-in-out infinite}
@keyframes glow{50%{box-shadow:0 5px 0 #1e7f36,0 0 0 8px #7fe08a77,0 10px 22px #1d4f7a44}}
.test:active{transform:translateY(3px)}
@media (max-width:560px){.mat,.shape{width:66px;height:62px;font-size:12px}.mat canvas,.shape canvas{width:52px;height:28px}
  .tbtn{width:56px;height:58px;font-size:12px}.test{height:66px;min-width:104px;font-size:21px}.tools{gap:8px}.mats,.shapes,.acts{gap:6px}}
/* short landscape phones: tools become a column on the right */
@media (max-height:520px) and (orientation:landscape){
  .tools{left:auto;top:calc(env(safe-area-inset-top,0px) + 58px);bottom:0;width:calc(env(safe-area-inset-right,0px) + 160px);flex-direction:column;align-items:flex-end;justify-content:flex-end;flex-wrap:nowrap;gap:6px;
    padding:4px calc(env(safe-area-inset-right,0px) + 8px) calc(env(safe-area-inset-bottom,0px) + 6px) 4px}
  .mats,.shapes{flex-wrap:wrap;justify-content:flex-end;width:150px;gap:6px}
  .acts{flex-wrap:wrap;justify-content:flex-end;width:150px;gap:6px}
  .mat,.shape{width:70px;height:54px;font-size:12px}.mat canvas,.shape canvas{width:50px;height:24px}
  .tbtn{width:70px;height:48px;font-size:12px}.tbtn .ic svg{width:24px;height:24px}
  .test{height:56px;min-width:146px;font-size:20px}
  .hbtn{width:40px;height:40px}.lvl,.pill{height:40px}.lvl-n{width:32px;height:32px}
}

/* ---------- Chip the beaver + speech bubble ---------- */
.beaver{position:absolute;left:calc(env(safe-area-inset-left,0px) + 4px);bottom:var(--beaver-b,96px);width:86px;height:124px;z-index:5;pointer-events:none;transform-origin:50% 100%}
.beaver-img{display:block;width:100%;height:100%;background:url(assets/beaver.png) center bottom/contain no-repeat}
.beaver.talk{animation:beaverTalk .6s ease-in-out 2}
.beaver.cheer{animation:beaverCheer .5s ease-in-out 4}
@keyframes beaverTalk{50%{transform:translateY(-6px) rotate(-3deg)}}
@keyframes beaverCheer{50%{transform:translateY(-18px) scale(1.06)}}
.bubble{position:absolute;left:calc(env(safe-area-inset-left,0px) + 92px);bottom:calc(var(--beaver-b,96px) + 40px);max-width:min(440px,calc(100vw - 110px));z-index:8;
  background:#fffef8;border-radius:20px;padding:10px 14px;box-shadow:0 4px 0 #c9b98f,0 10px 24px #1d4f7a44;font-weight:800;font-size:17px;line-height:1.3;color:#3a2f1f;
  animation:bubIn .35s cubic-bezier(.2,1.6,.4,1)}
.bubble::before{content:"";position:absolute;left:-10px;bottom:16px;border:10px solid transparent;border-right-color:#fffef8;border-left:0}
.bubble p{margin:0}
.bubble-row{display:flex;gap:8px;margin-top:8px;flex-wrap:wrap}
.bubble-row:empty{display:none}
.bubble-row button{border:0;border-radius:14px;padding:10px 16px;font-weight:900;font-size:16px;color:#fff;background:linear-gradient(#ffb36b,#f07c2a);box-shadow:0 3px 0 #b4551a}
.bubble-row button.alt{background:linear-gradient(#fff,#e9f2fa);color:#2f4a66;box-shadow:0 3px 0 #8db5d3}
@keyframes bubIn{from{opacity:0;transform:scale(.8) translateY(8px)}}
@media (max-width:560px){.beaver{width:64px;height:92px}.bubble{left:calc(env(safe-area-inset-left,0px) + 66px);font-size:15px;bottom:calc(var(--beaver-b,96px) + 30px);max-width:calc(100vw - 76px)}}
@media (max-height:520px) and (orientation:landscape){.beaver{width:58px;height:84px}.bubble{left:66px;font-size:15px;max-width:calc(100vw - 250px);bottom:calc(var(--beaver-b,6px) + 30px)}}

/* ---------- weigh station ---------- */
.weigh{position:absolute;right:calc(env(safe-area-inset-right,0px) + 8px);top:calc(env(safe-area-inset-top,0px) + 62px);z-index:6;width:236px;
  background:#fffdf6f2;border-radius:18px;padding:8px 10px;box-shadow:0 4px 0 #c9b98f,0 10px 24px #1d4f7a33;pointer-events:none}
.weigh-top{display:flex;align-items:center;gap:8px}
.weigh-pic{flex:0 0 auto;width:72px;height:44px;background:center/contain no-repeat}
.weigh b{display:block;font-size:17px;font-weight:900;color:#3a2f1f}
.weigh span{display:block;font-size:16px;font-weight:900;color:#b35a12}
.blocks{display:flex;flex-wrap:wrap;gap:3px;margin-top:6px;align-items:flex-end;min-height:18px}
.blk{width:14px;height:14px;border-radius:3px;background:linear-gradient(#9aa7b8,#66768c);box-shadow:inset 0 -2px 0 #4c5a6e,inset 0 1px 0 #c9d3e0}
.blk.tiny{width:14px;height:4px}
.blk.ten{width:44px;height:18px;background:linear-gradient(90deg,#66768c 0 2px,transparent 2px) 0 0/4.4px 100%,linear-gradient(#9aa7b8,#66768c)}
.blocks small{font-size:12px;font-weight:800;color:#6a5a3f;margin-left:4px}
.lineup{display:flex;gap:3px;margin-top:6px;flex-wrap:wrap}
.lu{width:24px;height:18px;border-radius:5px;background:#eef2f6 center/contain no-repeat;position:relative;opacity:.55}
.lu.now{opacity:1;box-shadow:0 0 0 2px #ffcf3a}
.lu.ok{opacity:1}
.lu.ok::after{content:"";position:absolute;right:-3px;bottom:-3px;width:11px;height:11px;border-radius:50%;background:#2fae4e;box-shadow:0 0 0 2px #fff}
.lu.no::after{content:"";position:absolute;right:-3px;bottom:-3px;width:11px;height:11px;border-radius:50%;background:#f07c2a;box-shadow:0 0 0 2px #fff}
@media (max-width:560px){.weigh{width:200px;top:calc(env(safe-area-inset-top,0px) + 56px);padding:6px 8px}.weigh-pic{width:56px;height:36px}.weigh b{font-size:15px}.weigh span{font-size:14px}.blk{width:11px;height:11px}.blk.ten{width:36px;height:14px}}
@media (max-height:520px) and (orientation:landscape){.weigh{right:auto;left:calc(env(safe-area-inset-left,0px) + 8px);top:54px;width:200px;padding:5px 8px}.weigh-pic{width:50px;height:32px}.lineup{display:none}}

/* ---------- title ---------- */
.title-card{position:absolute;inset:0;z-index:10;display:flex;align-items:flex-start;justify-content:center;background:#8fd0f2}
.title-art{position:absolute;inset:0;background:url(assets/title.jpg) center 70%/cover no-repeat}
.title-box{position:relative;margin-top:calc(env(safe-area-inset-top,0px) + 5vh);text-align:center;padding:16px 22px 20px;border-radius:28px;max-width:min(92vw,560px);
  background:#ffffffd9;box-shadow:0 8px 0 #8db5d388,0 18px 40px #1d4f7a44;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}
.title-box h1{margin:0;font-size:clamp(30px,7vw,52px);font-weight:900;color:#7a3f12;letter-spacing:.5px;text-shadow:0 3px 0 #ffd77a}
.lead{margin:6px 0 14px;font-weight:800;font-size:clamp(16px,2.6vw,20px);color:#3a4a5a}
.go{border:0;border-radius:26px;padding:16px 34px;font-weight:900;font-size:24px;color:#fff;background:linear-gradient(#7fe08a,#2fb24e);
  box-shadow:0 5px 0 #1e7f36,0 12px 24px #1d4f7a44;text-shadow:0 2px 0 #1e7f3699}
.go:active{transform:translateY(3px)}
@media (orientation:landscape){
  .title-card{align-items:center;justify-content:flex-end;padding:0 4vw 0 0}
  .title-art{background-position:8% 40%}
  .title-box{margin-top:0;max-width:min(46vw,520px)}
}
@media (orientation:landscape) and (max-height:520px){
  .title-box{padding:10px 18px 14px;max-width:min(52vw,480px)}
  .title-box h1{font-size:34px}
  .lead{margin:4px 0 10px}
}

/* ---------- menu (fits the screen; the panel itself does not scroll) ---------- */
.menu{position:absolute;inset:0;z-index:9;overflow:hidden;background:linear-gradient(#bfe6fb,#e9f7ff 60%,#d5f0c9)}
.menu-in{position:absolute;inset:0;display:flex;flex-direction:column;overflow:hidden;overscroll-behavior:none;touch-action:none;
  padding:calc(env(safe-area-inset-top,0px) + 8px) calc(env(safe-area-inset-right,0px) + 12px) calc(env(safe-area-inset-bottom,0px) + 8px) calc(env(safe-area-inset-left,0px) + 12px)}
.menu-head{display:flex;align-items:center;gap:8px;max-width:980px;width:100%;margin:0 auto;flex:0 0 auto}
.menu-head h2{flex:1;margin:0;font-size:clamp(20px,3.6vh,28px);font-weight:900;color:#24486c}
.menu h3{max-width:980px;width:100%;margin:clamp(4px,1.2vh,14px) auto clamp(4px,.8vh,8px);font-size:clamp(14px,2.2vh,18px);font-weight:900;color:#2f5b86;flex:0 0 auto}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:clamp(6px,1.2vh,12px);max-width:980px;width:100%;margin:0 auto;flex:1 1 auto;min-height:0;align-content:start}
.grid.towers{flex:0 1 auto}
.lv{position:relative;border:0;border-radius:16px;padding:0 0 4px;overflow:hidden;text-align:left;background:#fff;box-shadow:0 3px 0 #8db5d3,0 8px 16px #1d4f7a26;color:#24486c;min-height:0;display:flex;flex-direction:column}
.lv canvas{display:block;width:100%;height:clamp(36px,8.5vh,84px);flex:0 0 auto}
.lv b{display:block;padding:3px 8px 0;font-size:clamp(13px,1.9vh,16px);font-weight:900;line-height:1.15}
.lv .meta{display:flex;align-items:center;gap:6px;padding:1px 8px 0;font-size:clamp(11px,1.5vh,13px);font-weight:800;color:#5a6f86;line-height:1.15}
.lv .num{position:absolute;left:6px;top:6px;width:26px;height:26px;border-radius:50%;display:grid;place-items:center;font-weight:900;font-size:13px;color:#fff;background:#2f7fd0;box-shadow:0 2px 0 #1f5f9f}
.lv .gimg{position:absolute;right:4px;top:clamp(22px,5vh,44px);width:clamp(44px,7vh,62px);height:clamp(24px,4vh,36px);background:center/contain no-repeat}
.lv .st{display:flex;gap:1px;padding:1px 6px 0;margin-top:auto}
.lv .star{width:clamp(14px,2.2vh,20px);height:clamp(14px,2.2vh,20px)}
.lv.next{box-shadow:0 3px 0 #d39b1e,0 0 0 3px #ffcf3a,0 8px 16px #1d4f7a26}
.lv:active{transform:translateY(2px)}
.menu-note{max-width:980px;width:100%;margin:clamp(4px,1.2vh,12px) auto 0;font-size:clamp(11px,1.6vh,13px);font-weight:700;color:#5a6f86;flex:0 0 auto}
.menu-note a{color:#2f5b86}
@media (max-width:420px){.grid{grid-template-columns:repeat(2,1fr)}.lv .num{width:24px;height:24px;font-size:12px}}
@media (max-height:520px) and (orientation:landscape){
  .grid{grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:6px}
  .lv .meta{display:none}
  .menu-note{display:none}
}
@media (max-height:600px) and (max-width:420px){
  .lv .meta{display:none}
  .menu-note{display:none}
}

/* ---------- result ---------- */
.result{position:absolute;inset:0;z-index:9;display:grid;place-items:center;background:#1d4f7a55;padding:12px}
.res-in{width:min(440px,94vw);max-height:calc(100dvh - 24px);overflow:hidden;text-align:center;background:linear-gradient(#fffef8,#fff3d2);border-radius:28px;padding:14px 18px 18px;
  box-shadow:0 8px 0 #d6b46a,0 20px 50px #1d4f7a66;animation:bubIn .45s cubic-bezier(.2,1.6,.4,1)}
.res-stars{display:flex;justify-content:center;gap:6px}
.res-stars .star{width:58px;height:58px}
.res-stars .star.on{animation:starIn .5s cubic-bezier(.2,1.8,.4,1) both}
.res-stars .star:nth-child(2){animation-delay:.25s}.res-stars .star:nth-child(3){animation-delay:.5s}
@keyframes starIn{from{transform:scale(0) rotate(-90deg)}}
.res-in h2{margin:6px 0 2px;font-size:26px;font-weight:900;color:#7a3f12}
.res-in p{margin:0 0 6px;font-weight:800;color:#4a4030}
.res-list{list-style:none;margin:0 0 10px;padding:0;text-align:left;font-weight:800;font-size:15px;color:#4a4030}
.res-list li{display:flex;align-items:center;gap:8px;padding:3px 0}
.res-list li .star{width:22px;height:22px;flex:0 0 auto}
.res-row{display:flex;justify-content:center;gap:12px;align-items:center}
.res-row .tbtn{width:auto;padding:0 14px;flex-direction:row;gap:6px;height:60px;font-size:15px}
@media (max-height:520px){.res-stars .star{width:40px;height:40px}.res-in h2{font-size:21px}.res-list{font-size:13px;margin-bottom:6px}.res-list li{padding:1px 0}.go{padding:12px 26px;font-size:20px}.res-row .tbtn{height:50px}}

.toast{position:absolute;left:50%;top:30%;transform:translate(-50%,-50%);z-index:9;pointer-events:none;padding:12px 22px;border-radius:24px;
  background:#fffef8;box-shadow:0 5px 0 #c9b98f,0 14px 30px #1d4f7a44;font-weight:900;font-size:22px;color:#7a3f12;animation:bubIn .4s cubic-bezier(.2,1.6,.4,1)}

/* screens */
body.scr-tower .weigh{display:none}
#starRow{display:flex;gap:1px}
