/* Bug Hunt 3D - stage, HUD and screens. Everything is scoped under #stage so site styles never leak in. */
html.pip-big, html.pip-big body { overflow: hidden; }
#stage { --g1:#3e8e2f; --g2:#2a6a20; --sun:#ffd84a; --org:#ff8a3c; --ink:#22301f; --cream:#fff6dc; --red:#ff4a5a;
  position: relative; width: min(100%, calc(78vh * 0.5625)); width: min(100%, calc(78svh * 0.5625)); aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden;
  border-radius: 14px; background: linear-gradient(#1d3b18, #4f9a3a); color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", Verdana, system-ui, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; line-height: 1.25; }
#stage.is-big { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; z-index: 99999; }
#stage.is-fs { position: absolute; inset: 0; width: auto; height: auto; max-width: none; aspect-ratio: auto; border-radius: 0; }
#stage *, #stage *::before, #stage *::after { box-sizing: border-box; }
#stage #app { position: absolute; inset: 0; }
#stage #app canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
#stage button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#stage [hidden] { display: none !important; }
#stage #loader { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: linear-gradient(#1d3b18, #4f9a3a); color: #fff; }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
#stage .load-in b { font-size: clamp(22px, 7vw, 34px); letter-spacing: 3px; }
#stage .spinner { width: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.3); border-top-color: var(--sun); animation: bhspin .8s linear infinite; }
@keyframes bhspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(15,30,15,.9); color: #fff; font-weight: 700; }

/* touch layer and floating sticks */
#stage .touch { position: absolute; inset: 0; pointer-events: none; touch-action: none; z-index: 1; }
#stage .stick { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
#stage .sbase { position: absolute; left: 0; top: 0; width: 108px; height: 108px; border-radius: 50%; border: 3px solid rgba(255,255,255,.55); background: rgba(255,255,255,.14); }
#stage .sbase.aim { border-color: rgba(255,200,80,.7); background: rgba(255,200,80,.12); }
#stage .sknob { position: absolute; left: 0; top: 0; width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.75); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
#stage .sknob.aim { background: rgba(255,214,90,.9); }
#stage .vig { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity .2s; box-shadow: inset 0 0 70px 16px rgba(255,40,50,.65); }

/* HUD */
#stage .hud { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
#stage .top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: max(8px, env(safe-area-inset-top)) 8px 4px; }
#stage .hpwrap { position: relative; flex: 0 0 30%; height: 26px; }
#stage .hpbar { height: 100%; border-radius: 13px; background: rgba(20,30,15,.6); overflow: hidden; border: 2px solid rgba(255,255,255,.8); }
#stage .hpbar i { display: block; height: 100%; width: 100%; background: linear-gradient(#7dff6a, #3fcf3a); transition: width .12s; }
#stage .hpbar.low i { background: linear-gradient(#ff7a7a, #ff3a4a); }
#stage .hpwrap span { position: absolute; left: 0; right: 0; top: 0; line-height: 26px; text-align: center; color: #fff; font-weight: 800; font-size: 13px; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
#stage .obj { flex: 1; min-width: 0; background: rgba(20,30,15,.55); border-radius: 10px; padding: 3px 8px 5px; color: #fff; font-weight: 800; font-size: 12px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
#stage .obj span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage .obar { height: 4px; margin-top: 3px; border-radius: 2px; background: rgba(255,255,255,.25); overflow: hidden; }
#stage .obar i { display: block; height: 100%; width: 0; background: var(--sun); }
#stage .pill { display: inline-flex; align-items: center; gap: 4px; background: rgba(20,30,15,.6); color: #ffe27a; border-radius: 99px; padding: 3px 9px 3px 6px; font-weight: 800; font-size: 13px; }
#stage .coin { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2a0, #ffb400); display: inline-block; flex: none; }
#stage .pausebtn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(20,30,15,.65); color: #fff; font-weight: 900; font-size: 16px; letter-spacing: 1px; pointer-events: auto; flex: none; }
#stage .bossbar { position: absolute; left: 14px; right: 14px; top: calc(max(8px, env(safe-area-inset-top)) + 46px); text-align: center; color: #fff; font-weight: 800; font-size: 12px; text-shadow: 0 1px 2px #000; }
#stage .bossbar .bar { height: 12px; margin-top: 2px; border-radius: 6px; background: rgba(0,0,0,.5); border: 2px solid #fff; overflow: hidden; }
#stage .bossbar .bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#ff7ad0, #b04aff); }
#stage .hint { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); width: max-content; max-width: 84%; background: rgba(255,255,255,.95); color: var(--ink); font-weight: 800; font-size: 15px; text-align: center; padding: 9px 15px; border-radius: 16px; box-shadow: 0 4px 0 rgba(0,0,0,.25); animation: bhfloat 1.2s ease-in-out infinite alternate; }
@keyframes bhfloat { from { transform: translateX(-50%) translateY(0); } to { transform: translateX(-50%) translateY(-5px); } }
#stage .feed { position: absolute; left: 0; right: 0; top: 17%; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#stage .feed .f { background: rgba(255,255,255,.92); color: var(--ink); font-weight: 800; font-size: 13px; padding: 3px 11px; border-radius: 99px; animation: bhfeed 1.9s ease-out forwards; }
#stage .feed .f.good { background: #d8ffd0; } #stage .feed .f.bad { background: #ffd8d8; }
@keyframes bhfeed { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
#stage .banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; color: #fff; font-size: clamp(26px, 9vw, 40px); font-weight: 900; letter-spacing: 2px; text-shadow: 0 3px 0 rgba(0,0,0,.5); opacity: 0; transform: scale(.8); transition: opacity .25s, transform .25s; }
#stage .banner.on { opacity: 1; transform: none; }
#stage .arrow { position: absolute; left: 0; top: 0; width: 36px; height: 36px; pointer-events: none; }
#stage .arrow::before { content: ""; position: absolute; left: 4px; top: 4px; border-left: 28px solid var(--sun); border-top: 14px solid transparent; border-bottom: 14px solid transparent; filter: drop-shadow(0 2px 0 rgba(0,0,0,.4)); }
#stage .btns { position: absolute; right: 10px; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
#stage .hud.lefty .btns { right: auto; left: 10px; align-items: flex-start; }
#stage .gbtn { position: relative; overflow: hidden; width: 62px; height: 62px; border-radius: 50%; border: 3px solid rgba(255,255,255,.85); background: rgba(30,50,25,.62); color: #fff; font-weight: 900; font-size: 11px; letter-spacing: 1px; pointer-events: auto; touch-action: none; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
#stage .gbtn.big { width: 76px; height: 76px; background: rgba(255,120,40,.8); font-size: 12px; }
#stage .gbtn.big b { font-size: 22px; }
#stage .gbtn small { font-size: 9px; letter-spacing: 0; font-weight: 700; opacity: .9; max-width: 54px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage .gbtn .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0,0,0,.5); }
#stage .gbtn .lab { position: relative; }
#stage .gbtn.down { transform: scale(.92); background: rgba(255,255,255,.4); }

/* screens */
#stage .screen { position: absolute; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; padding: 10px; overflow-y: auto; touch-action: pan-y; pointer-events: auto; background: rgba(10,25,10,.35); -webkit-overflow-scrolling: touch; }
#stage .panel { width: 100%; margin: auto 0 0; background: rgba(255,248,224,.97); border-radius: 20px; padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 9px; box-shadow: 0 6px 0 rgba(0,0,0,.3); text-align: center; touch-action: pan-y; }
#stage .panel.small { max-width: 320px; margin: auto; }
#stage .panel h2 { margin: 0; font-size: 22px; color: var(--g2); letter-spacing: 1px; }
#stage .phead { display: flex; align-items: center; gap: 8px; } #stage .phead h2 { flex: 1; text-align: center; padding-right: 60px; }
#stage .logo { display: flex; flex-direction: column; align-items: center; line-height: 1; }
#stage .logo span { font-size: 16px; letter-spacing: 7px; color: var(--g1); font-weight: 800; }
#stage .logo b { font-size: clamp(44px, 15vw, 66px); color: var(--org); letter-spacing: 3px; text-shadow: 0 3px 0 rgba(120,50,0,.3); }
#stage .rankbar { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; }
#stage .rankbar .bar { flex: 1; height: 10px; background: rgba(0,0,0,.14); border-radius: 6px; overflow: hidden; } #stage .rankbar .bar i { display: block; height: 100%; background: var(--g1); }
#stage .rankbar .pill { background: #fff; color: #6a4a00; }
#stage .btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 48px; padding: 8px 14px; border: 0; border-radius: 14px; background: var(--g1); color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 4px 0 var(--g2); text-decoration: none; pointer-events: auto; }
#stage .btn small { font-size: 11px; font-weight: 700; opacity: .9; }
#stage .btn.big { min-height: 58px; font-size: 20px; letter-spacing: 1px; background: var(--org); box-shadow: 0 5px 0 #b85a00; }
#stage .btn.small { min-height: 44px; font-size: 13px; padding: 6px 12px; }
#stage .btn.ghost { background: #fff; color: var(--g2); box-shadow: 0 3px 0 rgba(0,0,0,.18); }
#stage .btn.danger { background: #d83a4a; box-shadow: 0 4px 0 #8a1a28; }
#stage .btn.dim { background: #9aa39a; box-shadow: 0 4px 0 #6f776f; }
#stage .btn.locked { background: #b9c1b6; box-shadow: 0 4px 0 #8f978c; color: #fff; }
#stage .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } #stage .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#stage .blurb { font-size: 14px; margin: 0; } #stage .sub { font-weight: 800; font-size: 13px; margin: 0; text-align: left; }
#stage .tip { font-size: 12px; color: #4a5a46; margin: 0; text-align: left; }
#stage .facts { display: flex; flex-direction: column; gap: 5px; text-align: left; }
#stage .facts div { background: #fff; border-radius: 10px; padding: 6px 9px; font-size: 13px; } #stage .facts b { display: block; font-size: 11px; color: var(--g1); letter-spacing: 1px; text-transform: uppercase; }
#stage .chips { display: flex; gap: 6px; flex-wrap: wrap; }
#stage .chip { flex: 1; min-height: 44px; padding: 6px 8px; border-radius: 12px; border: 2px solid #cfd8c8; background: #fff; color: var(--ink); font-weight: 800; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#stage .chip.on { border-color: var(--g1); background: #e4f6dc; color: var(--g2); } #stage .chip.off { opacity: .55; } #stage .chip small { font-size: 10px; }
#stage .mlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
#stage .mlist li.sec { font-weight: 800; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--g1); padding-top: 4px; }
#stage .mrow { width: 100%; min-height: 54px; display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid #e1e8da; border-radius: 12px; padding: 6px 10px; text-align: left; color: var(--ink); }
#stage .mrow b { width: 26px; height: 26px; border-radius: 50%; background: var(--g1); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
#stage .mrow.locked { opacity: .55; } #stage .mrow.locked b { background: #9aa39a; }
#stage .mn { flex: 1; font-weight: 800; font-size: 14px; display: flex; flex-direction: column; } #stage .mn small { font-weight: 600; font-size: 11px; color: #5a6a56; }
#stage .stars { color: #ffb400; font-size: 18px; letter-spacing: 1px; } #stage .lock { font-size: 11px; font-weight: 800; color: #6a7a66; }
#stage .tabs { display: flex; gap: 6px; } #stage .tabs button { flex: 1; min-height: 44px; border: 2px solid #cfd8c8; background: #fff; border-radius: 12px; font-weight: 800; font-size: 13px; color: var(--ink); }
#stage .tabs button.on { border-color: var(--g1); background: #e4f6dc; color: var(--g2); }
#stage .items { display: flex; flex-direction: column; gap: 6px; }
#stage .item { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 8px; text-align: left; }
#stage .item .info { flex: 1; display: flex; flex-direction: column; min-width: 0; } #stage .item small { font-size: 11px; color: #5a6a56; }
#stage .swatch { width: 40px; height: 40px; border-radius: 12px; flex: none; border: 2px solid rgba(0,0,0,.1); }
#stage .pips { display: flex; gap: 3px; margin-top: 3px; } #stage .pips i { width: 12px; height: 6px; border-radius: 3px; background: #d5dcce; } #stage .pips i.on { background: var(--g1); }
#stage .maxed { font-weight: 800; font-size: 12px; color: var(--g1); padding: 0 6px; }
#stage .ach { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 10px; padding: 7px 10px; } #stage .ach.done { background: #e4f6dc; } #stage .rew { font-weight: 800; font-size: 12px; color: #8a6a00; }
#stage .srows { display: flex; flex-direction: column; gap: 6px; } #stage .srow { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #fff; border-radius: 12px; padding: 6px 10px; font-weight: 800; font-size: 14px; }
#stage .seg { display: flex; gap: 4px; } #stage .seg button { min-height: 44px; min-width: 50px; border: 2px solid #cfd8c8; background: #fff; border-radius: 10px; font-weight: 800; font-size: 13px; color: var(--ink); }
#stage .seg button.on { background: var(--g1); border-color: var(--g1); color: #fff; }
#stage .warn { background: #ffe7e7; border-radius: 12px; padding: 8px; } #stage .warn p { margin: 0 0 6px; font-weight: 800; font-size: 13px; }
#stage .tips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 13px; } #stage .tips li { background: #fff; border-radius: 10px; padding: 7px 10px; } #stage .tips b { color: var(--g1); margin-right: 4px; }
#stage .results h2.win { color: var(--g1); font-size: 28px; } #stage .results h2.lose { color: #c8333f; font-size: 28px; }
#stage .bigstars .stars { font-size: 36px; } #stage .tag { margin: 0; font-weight: 800; font-size: 13px; color: #8a6a00; }
#stage .grid, #stage .rewards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
#stage .grid div, #stage .rewards div { background: #fff; border-radius: 10px; padding: 5px; display: flex; flex-direction: column; font-size: 11px; color: #4a5a46; } #stage .grid b, #stage .rewards b { font-size: 17px; color: var(--ink); }
#stage .goal { margin: 0; font-weight: 800; font-size: 13px; color: var(--g2); background: #e4f6dc; border-radius: 10px; padding: 7px 9px; }
#stage .toast { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); z-index: 30; max-width: 86%; background: rgba(20,30,15,.92); color: #fff; font-weight: 800; font-size: 13px; padding: 8px 14px; border-radius: 12px; text-align: center; pointer-events: none; }

/* page chrome under the game */
.bh-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.bh-bar .btn { min-height: 44px; min-width: 44px; }
.bh-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.bh-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.bh-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.bh-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.bh-guide p { margin-bottom: .5rem; font-size: .95rem; }
@media (prefers-reduced-motion: reduce) { #stage .hint, #stage .feed .f, #stage .spinner { animation-duration: 3s; } }
#stage .bigexit { position: absolute; left: 50%; bottom: max(8px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; min-height: 44px; min-width: 44px; padding: 8px 14px; border: 2px solid rgba(255,255,255,.85); border-radius: 12px; background: rgba(20,30,15,.7); color: #fff; font-weight: 800; font-size: 13px; }

#stage .combo { position: absolute; left: 50%; top: 11%; transform: translateX(-50%); background: #ffe27a; color: #3a2a00; font-weight: 900; font-size: 15px; padding: 3px 12px; border-radius: 99px; pointer-events: none; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
#stage .combo[hidden] { display: none; }
#stage .combo.pop { animation: bhcombo .22s ease-out; }
@keyframes bhcombo { 0% { transform: translateX(-50%) scale(1.35); } 100% { transform: translateX(-50%) scale(1); } }
#stage .starlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 700; text-align: left; }
#stage .starlist li { padding: 3px 9px; border-radius: 8px; }
#stage .starlist li.ok { background: #d8ffd0; color: #1f5a14; }
#stage .starlist li.no { background: #eef0ec; color: #6a746a; }
#stage .totals { text-align: center; margin: 0; }
@media (prefers-reduced-motion: reduce) { #stage .combo.pop { animation: none; } }

/* Full screen on phones: the shell supplies the dock and stage; the game fills what is left, with no copy or duplicate buttons. */
html.pip-immersive .bh-bar, html.pip-immersive .bh-keys, html.pip-immersive #bigbtn, html.pip-immersive #stage .bigexit { display: none !important; }
html.pip-immersive .game-wrap.pip-stage { overflow: hidden; padding-bottom: 0 !important; }
html.pip-immersive #stage, html.pip-immersive #stage.is-fs, html.pip-immersive #stage.is-big {
  position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: auto; max-width: none; max-height: none; aspect-ratio: auto; margin: 0; border-radius: 0;
  top: calc(var(--pip-dock-h, 52px) + env(safe-area-inset-top, 0px));
}
html.pip-immersive #stage .top { padding-top: 6px; }
html.pip-immersive #stage #app canvas { width: 100% !important; height: 100% !important; }
@media (orientation: landscape) and (max-height: 500px) {
  html.pip-immersive #stage { top: 0; }
  html.pip-immersive #stage .top { padding-top: max(6px, env(safe-area-inset-top, 0px)); }
}
/* soft scrim so the HUD reads over any ground colour */
#stage .hud::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 84px; background: linear-gradient(rgba(10,24,8,.45), rgba(10,24,8,0)); pointer-events: none; }
