/* Sandbar Smash 3D - stage and in-game UI. Everything is scoped under #stage so site styles never leak in. */
html.pip-big, html.pip-big body { overflow: hidden; }
#stage { --coral:#ff6b3d; --coral-d:#c8461f; --teal:#1fb5a5; --sun:#ffd23f; --ink:#16324f; --cream:#fff3d6; --glass:rgba(16,40,70,.72);
  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(#5ec8ff 0%, #d7f3ff 55%, #f1d9a0 100%); 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; }
/* inside the site's own game shell (native or immersive full screen) keep the 9:16 stage fitting the viewport */
.game-wrap.pip-stage #stage { width: min(100%, calc((100vh - 64px) * 0.5625)); width: min(100%, calc((100svh - 64px) * 0.5625)); }
#stage.is-big { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; z-index: 99999; }
#stage *, #stage *::before, #stage *::after { box-sizing: border-box; }
#stage #app { position: absolute; inset: 0; }
#stage #app canvas { display: block; width: 100%; height: 100%; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage #ui button, #stage #ui .panel, #stage #ui .screen, #stage #stickzone { pointer-events: auto; }
#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: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#5ec8ff 0%, #d7f3ff 60%, #f1d9a0 100%); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(20,60,100,.45); text-align: center; padding: 0 18px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 32px); letter-spacing: 2px; }
#stage .load-in span { font-size: 14px; }
#stage .spinner { width: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.4); border-top-color: var(--sun); animation: bvspin .8s linear infinite; }
@keyframes bvspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(16,40,70,.88); color: #fff; font-weight: 700; }

/* HUD */
#stage .hud { position: absolute; inset: 0; pointer-events: none; }
#stage .score { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 56px; right: 56px; display: flex; justify-content: center; align-items: stretch; gap: 6px; }
#stage .team { background: var(--glass); color: #fff; border-radius: 12px; padding: 4px 10px; display: flex; align-items: center; gap: 6px; min-width: 76px; justify-content: center; }
#stage .team.me { border-bottom: 3px solid var(--sun); } #stage .team.them { border-bottom: 3px solid #ff6b8a; }
#stage .team b { font-size: 26px; font-variant-numeric: tabular-nums; line-height: 1; }
#stage .team .lbl { font-size: 10px; letter-spacing: 1px; opacity: .85; }
#stage .srv { width: 9px; height: 9px; border-radius: 50%; background: var(--sun); display: inline-block; opacity: 0; box-shadow: 0 0 6px var(--sun); }
#stage .mid { display: flex; flex-direction: column; justify-content: center; align-items: center; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); font-size: 10px; min-width: 52px; }
#stage .fever { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 52px); left: 50%; width: 150px; margin-left: -75px; height: 14px; border-radius: 7px; background: rgba(16,40,70,.6); overflow: hidden; }
#stage .fever i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #ffd23f, #ff6b3d); transition: width .2s; }
#stage .fever span { position: relative; z-index: 1; display: block; text-align: center; font-size: 9px; letter-spacing: 1px; color: #fff; line-height: 14px; }
#stage .fever.armed { animation: bvpulse .5s infinite alternate; }
@keyframes bvpulse { to { box-shadow: 0 0 12px 2px #ffd23f; } }
#stage .wind { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 72px); left: 50%; transform: translateX(-50%); font-size: 11px; color: #fff; background: var(--glass); padding: 1px 8px; border-radius: 8px; }
#stage .pausebtn, #stage .quitbtn { position: absolute; top: max(8px, env(safe-area-inset-top)); width: 46px; height: 46px; border-radius: 12px; border: 0; background: var(--glass); color: #fff; font-weight: 800; letter-spacing: 1px; }
#stage .pausebtn { right: 6px; font-size: 16px; } #stage .quitbtn { left: 6px; font-size: 10px; }
#stage .hint-bubble { position: absolute; left: 12px; right: 12px; top: 36%; background: rgba(255,255,255,.95); color: var(--ink); border-radius: 14px; padding: 10px 14px; font-weight: 700; font-size: 14px; text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,.25); }

#stage #stickzone { position: absolute; left: 0; bottom: 0; width: 56%; height: 50%; }
#stage.x #stickzone { }
#stage #ui.lefty #stickzone { left: auto; right: 0; }
#stage #stickbase, #stage #stickknob { position: absolute; left: 0; top: 0; display: none; pointer-events: none; border-radius: 50%; }
#stage #stickbase { width: 100px; height: 100px; margin: -50px 0 0 -50px; border: 3px solid rgba(255,255,255,.7); background: rgba(255,255,255,.18); }
#stage #stickknob { width: 46px; height: 46px; margin: -23px 0 0 -23px; background: rgba(255,255,255,.85); box-shadow: 0 2px 6px rgba(0,0,0,.35); }

#stage .abtns { position: absolute; right: 8px; bottom: max(10px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: 74px 74px; gap: 8px; }
#stage #ui.lefty .abtns { right: auto; left: 8px; }
#stage .ab { width: 74px; height: 74px; border-radius: 50%; border: 3px solid rgba(255,255,255,.85); color: #fff; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; box-shadow: 0 4px 0 rgba(0,0,0,.28); }
#stage .ab b { font-size: 14px; letter-spacing: .5px; } #stage .ab small { font-size: 9px; opacity: .85; }
#stage .ab.bump { background: #2f8cff; } #stage .ab.set { background: #1fb5a5; } #stage .ab.spike { background: #ff6b3d; } #stage .ab.block { background: #8b5cd6; }
#stage .ab.down { transform: translateY(3px) scale(.95); box-shadow: 0 1px 0 rgba(0,0,0,.28); filter: brightness(1.2); }
#stage .ab.smart { display: none; }
#stage #ui.smart .ab { display: none; } #stage #ui.smart .ab.smart { display: flex; grid-column: 1 / 3; width: 110px; height: 110px; justify-self: end; background: #ff6b3d; }
#stage #ui.smart .ab.smart b { font-size: 20px; }
#stage #ui.smart .abtns { grid-template-columns: 110px; }
#stage #ui.smart .ab.smart { grid-column: auto; }

#stage #feed { position: absolute; left: 0; right: 0; top: 24%; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#stage .ft { font-weight: 900; font-size: 22px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.45), 0 0 8px rgba(0,0,0,.3); animation: bvft 1.3s ease-out forwards; letter-spacing: 1px; }
#stage .ft.big { font-size: 28px; color: var(--sun); } #stage .ft.gold { color: var(--sun); font-size: 18px; } #stage .ft.good { color: #fff; } #stage .ft.bad { color: #ffb4b4; }
@keyframes bvft { 0% { opacity: 0; transform: translateY(8px) scale(.7); } 15% { opacity: 1; transform: scale(1.1); } 100% { opacity: 0; transform: translateY(-26px); } }
#stage #banner { position: absolute; left: 0; right: 0; top: 42%; text-align: center; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.4); pointer-events: none; animation: bvban .3s ease-out; }
#stage #banner b { display: block; font-size: 32px; letter-spacing: 1px; } #stage #banner span { font-size: 15px; }
@keyframes bvban { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
#stage #toast { position: absolute; left: 16px; right: 16px; bottom: 120px; margin: 0 auto; width: fit-content; max-width: 90%; background: rgba(16,40,70,.92); color: #fff; padding: 8px 14px; border-radius: 12px; font-size: 13px; text-align: center; pointer-events: none; z-index: 30; }
#stage #flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 20; }
#stage #flash.go { animation: bvflash .35s ease-out; }
@keyframes bvflash { 0% { opacity: .8; } 100% { opacity: 0; } }

/* menus */
#stage #screens { position: absolute; inset: 0; z-index: 10; }
#stage .screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(rgba(10,30,60,.25), rgba(10,30,60,.65)); padding: 10px; }
#stage .panel { width: 100%; max-width: 420px; max-height: 100%; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain;
  background: var(--cream); border-radius: 18px; padding: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 10px; }
#stage .panel h1 { font-size: 34px; line-height: 1; color: var(--coral-d); letter-spacing: 1px; }
#stage .panel h2 { font-size: 20px; flex: 1; } #stage .panel h3 { font-size: 13px; letter-spacing: 1px; text-transform: uppercase; color: #6a7f95; margin-top: 4px; }
#stage .logo { text-align: center; } #stage .logo small { letter-spacing: 3px; color: var(--teal); font-weight: 800; font-size: 11px; }
#stage .top { display: flex; align-items: center; gap: 8px; } #stage .chips { display: flex; gap: 6px; }
#stage .chip { background: var(--ink); color: #fff; border-radius: 12px; padding: 3px 9px; font-size: 12px; font-weight: 800; white-space: nowrap; }
#stage .chip.coin::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--sun); margin-right: 5px; }
#stage .chip.rank { background: var(--teal); }
#stage .b { min-height: 46px; min-width: 46px; border: 0; border-radius: 14px; background: #fff; color: var(--ink); font-weight: 800; font-size: 15px; padding: 8px 14px; box-shadow: 0 3px 0 rgba(22,50,79,.25); }
#stage .b.primary { background: var(--coral); color: #fff; box-shadow: 0 3px 0 var(--coral-d); } #stage .b.accent { background: var(--teal); color: #fff; box-shadow: 0 3px 0 #0f7f73; }
#stage .b.big { min-height: 58px; font-size: 20px; } #stage .b.sm { min-height: 44px; font-size: 13px; padding: 6px 10px; }
#stage .b.on { background: var(--ink); color: #fff; } #stage .b.back { background: transparent; box-shadow: none; padding: 4px 8px; min-width: 44px; }
#stage .b.warn { background: #d63a3a; color: #fff; } #stage .b[disabled] { opacity: .4; } #stage .b[data-short] { opacity: .65; }
#stage .b:active { transform: translateY(2px); }
#stage .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #ff3b3b; margin-left: 4px; vertical-align: middle; }
#stage .rankrow { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; }
#stage .bar { flex: 1; height: 10px; border-radius: 5px; background: rgba(22,50,79,.15); overflow: hidden; min-width: 40px; } #stage .bar i { display: block; height: 100%; background: var(--teal); border-radius: 5px; } #stage .bar.xp i { background: var(--sun); }
#stage .goal { font-size: 13px; background: #fff; border-radius: 10px; padding: 8px 10px; border-left: 4px solid var(--coral); }
#stage .small, #stage small { font-size: 12px; color: #4b6075; display: block; }
#stage .tiers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
#stage .tier { min-height: 52px; border: 2px solid transparent; border-radius: 10px; background: #fff; color: var(--ink); padding: 4px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; }
#stage .tier.sel { border-color: var(--coral); background: #ffe9df; } #stage .tier.locked { opacity: .45; } #stage .tier small { font-size: 9px; }
#stage .card { background: #fff; border-radius: 12px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; } #stage .card.locked { opacity: .6; } #stage .card.done { background: #e6f6ea; }
#stage .card b { font-size: 14px; display: block; } #stage .grow { flex: 1; min-width: 0; } #stage .acts { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
#stage .lock { font-size: 11px; font-weight: 800; color: #6a7f95; text-align: center; max-width: 92px; }
#stage .swatch { width: 28px; height: 28px; border-radius: 50%; border: 4px solid #fff; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.15); } #stage .swatch.sq { border-radius: 8px; }
#stage .sb { display: flex; align-items: center; gap: 6px; font-size: 9px; font-weight: 800; color: #4b6075; } #stage .sb span { width: 26px; } #stage .sb .bar { height: 6px; }
#stage .pips { display: flex; gap: 4px; margin-top: 4px; } #stage .pip { width: 16px; height: 8px; border-radius: 3px; background: rgba(22,50,79,.18); } #stage .pip.on { background: var(--coral); }
#stage .row { 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 .row.danger { background: #ffe9e9; }
#stage .seg { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
#stage .res { text-align: center; } #stage .res small { letter-spacing: 3px; font-weight: 900; } #stage .res.win small { color: var(--teal); } #stage .res.loss small { color: #c0392b; } #stage .res h1 { font-size: 46px; }
#stage .stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; } #stage .stats span { background: #fff; border-radius: 10px; padding: 5px 4px; text-align: center; font-size: 11px; } #stage .stats b { display: block; font-size: 18px; }
#stage .gain { display: flex; gap: 8px; justify-content: center; }
#stage .lines { list-style: none; display: flex; flex-direction: column; gap: 4px; } #stage .lines li { font-size: 13px; background: #fff; border-radius: 8px; padding: 5px 8px; font-weight: 700; } #stage .lines li.good { border-left: 4px solid var(--teal); }

.bv-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.bv-bar .btn { min-height: 44px; min-width: 44px; }
.bv-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.bv-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.bv-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.bv-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.bv-guide p { margin-bottom: .5rem; font-size: .95rem; }

@media (max-height: 520px) and (orientation: landscape) {
  #stage .panel { max-width: 520px; } #stage .ab { width: 62px; height: 62px; } #stage .abtns { grid-template-columns: 62px 62px; }
}
@media (prefers-reduced-motion: reduce) { #stage .ft, #stage #banner, #stage #flash.go, #stage .fever.armed { animation: none; } }
#stage .team b.pop { animation: bvpop .45s ease-out; }
@keyframes bvpop { 0% { transform: scale(1); } 35% { transform: scale(1.45); color: #ffd23f; } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { #stage .team b.pop { animation: none; } }

/* ---- shell full screen (native and immersive): the stage fills the area under the dock, nothing scrolls ---- */
html.pip-immersive .game-wrap.pip-stage { display: flex; flex-direction: column; overflow: hidden; }
html.pip-immersive .game-wrap.pip-stage > .bv-bar,
html.pip-immersive .game-wrap.pip-stage > .bv-keys,
html.pip-immersive .game-wrap.pip-stage > noscript { display: none; }
html.pip-immersive .game-wrap.pip-stage #stage,
html.pip-immersive .game-wrap.pip-stage #stage.is-big {
  position: relative; inset: auto; flex: 1 1 0; min-height: 0; width: 100%; max-width: none; height: auto;
  aspect-ratio: auto; border-radius: 0; z-index: auto; margin: 0;
}
/* soft sun-and-shade finish over the 3D view; clicks pass through */
#stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(120% 90% at 50% 38%, rgba(255,246,214,0) 55%, rgba(20,50,80,.22) 100%),
              linear-gradient(rgba(255,236,170,.07), rgba(255,236,170,0) 35%); }
#stage #ui { z-index: 2; }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive .game-wrap.pip-stage #stage .score { top: 4px; }
}
