/* Wallspin 3D - stage + in-game UI. Everything is scoped under #stage so site styles never leak in. */
html.pip-big, html.pip-big body { overflow: hidden; }
#stage { --cy:#36e0ff; --pk:#ff4f8b; --ink:#e8f2ff; --dim:#9db3d8; --bg:#070b24; --pan:rgba(8,14,42,.86); --gold:#ffe45c; --ok:#59f0b0;
  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: #070b24; 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 *, #stage *::before, #stage *::after { box-sizing: border-box; }
#stage [hidden] { display: none !important; }
#stage #app { position: absolute; inset: 0; }
#stage #app canvas { display: block; width: 100%; height: 100%; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
#stage button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

#stage #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: #070b24; }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-align: center; padding: 0 18px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 30px); letter-spacing: 3px; color: var(--cy); }
#stage .load-in span { font-size: 14px; opacity: .9; }
#stage .spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid rgba(255,255,255,.2); border-top-color: var(--cy); animation: trspin 0.9s linear infinite; }
@keyframes trspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; background: rgba(7,11,36,.92); font-size: 15px; }

/* HUD */
#stage .hud { position: absolute; left: 0; right: 0; top: 0; padding: 8px 10px; pointer-events: none; }
#stage .hud-top { display: flex; align-items: center; gap: 8px; }
#stage .hud-btn { pointer-events: auto; width: 44px; height: 44px; border-radius: 12px; border: 2px solid rgba(255,255,255,.5); background: rgba(8,14,42,.6); color: #fff; font-weight: 800; font-size: 16px; letter-spacing: 1px; }
#stage .hud-mid { flex: 1; min-width: 0; }
#stage .hud-dist { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 800; text-align: center; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
#stage .hud-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.2); overflow: hidden; margin-top: 3px; }
#stage .hud-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cy), var(--gold)); }
#stage .hud-bar.endless i { opacity: .35; }
#stage .hud-right { text-align: right; font-weight: 700; font-size: 13px; text-shadow: 0 2px 0 rgba(0,0,0,.5); min-width: 62px; }
#stage .hud-shards { color: var(--gold); font-size: 15px; }
#stage .hud-tier { color: var(--cy); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
#stage .hud-sub { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding-left: 52px; min-height: 24px; }
#stage .heart { color: #ff4d6d; font-size: 20px; margin-right: 2px; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
#stage .heart:not(.on) { color: rgba(255,255,255,.4); }
#stage .heart.sh { color: #7fc8ff; font-size: 17px; }
#stage .hud-mult { background: var(--pk); color: #fff; font-weight: 800; font-size: 13px; padding: 2px 8px; border-radius: 10px; }
#stage .hud-pow { font-size: 12px; font-weight: 700; color: #bfffd0; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
#stage .zone { position: absolute; bottom: 0; height: 34%; width: 50%; display: flex; align-items: center; justify-content: center; font-size: 46px; font-weight: 800; color: rgba(255,255,255,.35); background: rgba(255,255,255,.05); pointer-events: none; }
#stage .zone.zl { left: 0; border-right: 1px solid rgba(255,255,255,.15); }
#stage .zone.zr { right: 0; }
#stage .zone.held { background: rgba(54,224,255,.2); color: #fff; }

#stage .hint { position: absolute; left: 12px; right: 12px; bottom: 38%; text-align: center; font-size: 16px; font-weight: 700; padding: 10px 12px; border-radius: 12px; background: rgba(8,14,42,.75); border: 1px solid rgba(54,224,255,.5); pointer-events: none; }
#stage .banner { position: absolute; left: 0; right: 0; top: 24%; text-align: center; pointer-events: none; display: flex; flex-direction: column; gap: 2px; text-shadow: 0 3px 0 rgba(0,0,0,.55); }
#stage .banner b { font-size: clamp(24px, 8vw, 38px); letter-spacing: 1px; color: #fff; }
#stage .banner span { font-size: 15px; color: var(--cy); }
#stage .banner.pop, #stage .countdown.pop { animation: trpop .35s ease-out; }
@keyframes trpop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
#stage .countdown { position: absolute; left: 0; right: 0; top: 38%; text-align: center; font-size: 72px; font-weight: 900; color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,.5), 0 0 24px var(--cy); pointer-events: none; }
#stage .feed { position: absolute; left: 12px; top: 112px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
#stage .feed-i { font-size: 13px; font-weight: 700; background: rgba(8,14,42,.7); padding: 3px 10px; border-radius: 10px; animation: trpop .25s ease-out; width: fit-content; }
#stage .flash { position: absolute; inset: 0; pointer-events: none; }
#stage .toast { position: absolute; left: 14px; right: 14px; bottom: 14px; text-align: center; font-size: 14px; font-weight: 700; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.95); color: #12204a; z-index: 30; pointer-events: none; }

/* screens */
#stage .screen-host { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 10px; pointer-events: none; z-index: 20; }
#stage .panel { pointer-events: auto; touch-action: pan-y; width: 100%; max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: var(--pan); border: 1px solid rgba(54,224,255,.35); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
#stage .logo { text-align: center; font-size: clamp(30px, 10vw, 46px); font-weight: 900; letter-spacing: 4px; color: #fff; text-shadow: 0 0 20px var(--cy), 0 4px 0 rgba(0,0,0,.5); }
#stage .logo span { margin-left: 8px; color: var(--pk); font-size: .6em; letter-spacing: 1px; }
#stage .tag, #stage .fine { text-align: center; color: var(--dim); font-size: 13px; }
#stage .fine { font-size: 12px; }
#stage .statrow { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
#stage .chip { display: inline-block; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.1); font-size: 13px; font-weight: 700; color: #fff; }
#stage .chip.ok { background: rgba(89,240,176,.2); color: var(--ok); }
#stage .xpbar, #stage .meter { height: 8px; border-radius: 4px; background: rgba(255,255,255,.15); overflow: hidden; }
#stage .xpbar i, #stage .meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--cy), var(--ok)); }
#stage .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; min-width: 46px; padding: 8px 14px; border-radius: 12px; border: 2px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.1); color: #fff; font-size: 15px; font-weight: 800; text-decoration: none; }
#stage .btn:active { transform: scale(.97); }
#stage .btn.wide { width: 100%; flex-direction: column; gap: 0; }
#stage .btn small { font-size: 12px; font-weight: 600; color: var(--dim); }
#stage .btn.primary { background: linear-gradient(#1fc8f0, #0b8fbf); border-color: #8be9ff; font-size: 18px; }
#stage .btn.primary small { color: #dff8ff; }
#stage .btn.ghost { background: transparent; }
#stage .btn.locked { opacity: .55; }
#stage .btn.danger { border-color: #ff6b6b; color: #ffb4b4; }
#stage .btn.buy { background: rgba(255,228,92,.16); border-color: var(--gold); color: var(--gold); }
#stage .btn.buy.poor { opacity: .55; }
#stage .btn.ok { border-color: var(--ok); color: var(--ok); }
#stage .btn em { font-style: normal; color: var(--gold); }
#stage .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .grid2 .btn { flex-direction: column; gap: 0; }
#stage .ptitle h2 { font-size: 22px; } #stage .ptitle p { color: var(--dim); font-size: 13px; }
#stage h3 { font-size: 15px; margin-top: 4px; }
#stage .tabs { display: flex; gap: 6px; flex-wrap: wrap; }
#stage .tab { flex: 1; min-width: 72px; font-size: 12px; padding: 6px 4px; }
#stage .tab.on { background: var(--cy); color: #04202c; border-color: var(--cy); }
#stage .tab.locked { opacity: .5; }
#stage .worldbar { border-left: 4px solid; padding: 4px 10px; font-size: 13px; color: var(--dim); }
#stage .lvlgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#stage .lvl { min-height: 96px; border-radius: 12px; border: 2px solid rgba(255,255,255,.28); background: rgba(255,255,255,.08); color: #fff; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
#stage .lvl b { font-size: 22px; } #stage .lvl span { font-size: 12px; font-weight: 700; } #stage .lvl small { font-size: 11px; color: var(--dim); }
#stage .lvl.locked { opacity: .45; }
#stage .stars i { font-style: normal; color: rgba(255,255,255,.3); font-size: 18px; } #stage .stars i.on { color: var(--gold); }
#stage .list { display: flex; flex-direction: column; gap: 8px; }
#stage .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: rgba(255,255,255,.07); border-radius: 12px; padding: 8px 10px; min-height: 52px; }
#stage .row.got { background: rgba(89,240,176,.12); }
#stage .rowtxt { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
#stage .rowtxt small { color: var(--dim); font-size: 12px; }
#stage .pips { display: flex; gap: 4px; } #stage .pips i { width: 14px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.2); } #stage .pips i.on { background: var(--cy); }
#stage .swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid; flex: none; }
#stage .seg { display: flex; gap: 4px; align-items: center; } #stage .btn.seg { min-height: 44px; padding: 4px 10px; font-size: 13px; }
#stage .btn.seg.on, #stage .btn.tog.on { background: var(--cy); color: #04202c; border-color: var(--cy); }
#stage .val { min-width: 48px; text-align: center; font-weight: 700; font-size: 13px; }
#stage .results h2 { text-align: center; font-size: 26px; } #stage .results h2.win { color: var(--ok); } #stage .results h2.lose { color: #ff8a7a; }
#stage .results .stars { text-align: center; } #stage .results .stars i { font-size: 34px; }
#stage .newbest { text-align: center; color: var(--gold); font-weight: 800; }
#stage .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#stage .stats div { background: rgba(255,255,255,.07); border-radius: 10px; padding: 6px; text-align: center; display: flex; flex-direction: column; }
#stage .stats small { color: var(--dim); font-size: 11px; } #stage .stats b { font-size: 15px; }
#stage .earn { display: flex; justify-content: space-between; font-weight: 800; font-size: 14px; }
#stage .earn span:first-child { color: var(--gold); }
#stage .bonus { list-style: none; font-size: 13px; color: var(--ok); display: flex; flex-direction: column; gap: 2px; }
#stage .goal { font-size: 14px; background: rgba(54,224,255,.1); border-radius: 10px; padding: 8px 10px; }

@media (max-height: 560px) { #stage .logo { font-size: 28px; } #stage .panel { padding: 10px; gap: 7px; } }
@media (prefers-reduced-motion: reduce) { #stage * { animation: none !important; transition: none !important; } }

/* page chrome under the game */
.tr-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.tr-bar .btn { min-height: 44px; min-width: 44px; }
.tr-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.tr-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.tr-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.tr-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.tr-guide p { margin-bottom: .5rem; font-size: .95rem; }

/* Full screen (shell immersive on iPhone, native Fullscreen API on Android): the stage fills the game-wrap below the dock. */
html.pip-immersive .game-wrap.pip-stage, html.pip-native .game-wrap.pip-stage, .game-wrap.pip-stage:fullscreen {
  display: flex; flex-direction: column; align-items: stretch; padding: 0; margin: 0; overflow: hidden; max-width: none; background: #070b24; }
html.pip-immersive .game-wrap.pip-stage > #stage, html.pip-native .game-wrap.pip-stage > #stage, .game-wrap.pip-stage:fullscreen > #stage {
  flex: 1 1 0; min-height: 0; width: 100%; max-width: none; height: auto; aspect-ratio: auto; border-radius: 0; margin: 0; }
html.pip-immersive .tr-bar, html.pip-immersive .tr-keys, html.pip-immersive .tr-guide,
html.pip-native .tr-bar, html.pip-native .tr-keys, html.pip-native .tr-guide,
.game-wrap.pip-stage:fullscreen .tr-bar, .game-wrap.pip-stage:fullscreen .tr-keys { display: none; }
html.pip-immersive #stage .hud, html.pip-native #stage .hud { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .hud, html.pip-native #stage .hud { padding-top: 4px; padding-bottom: 0; }
}
/* Full screen landscape: keep panel buttons on screen without scrolling. */
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .screen-host, html.pip-native #stage .screen-host { padding: 4px max(10px, env(safe-area-inset-right)) 4px max(10px, env(safe-area-inset-left)); }
  html.pip-immersive #stage .panel, html.pip-native #stage .panel { max-width: 640px; padding: 8px 12px; gap: 5px; }
  html.pip-immersive #stage .panel.menu .tag, html.pip-native #stage .panel.menu .tag,
  html.pip-immersive #stage .panel.menu .fine, html.pip-native #stage .panel.menu .fine,
  html.pip-immersive #stage .panel.menu .xpbar, html.pip-native #stage .panel.menu .xpbar,
  html.pip-immersive #stage .results .bonus, html.pip-native #stage .results .bonus,
  html.pip-immersive #stage .results .goal, html.pip-native #stage .results .goal,
  html.pip-immersive #stage .results .xpbar, html.pip-native #stage .results .xpbar,
  html.pip-immersive #stage .results .fine, html.pip-native #stage .results .fine { display: none; }
  html.pip-immersive #stage .panel.menu .logo, html.pip-native #stage .panel.menu .logo { font-size: 24px; }
  html.pip-immersive #stage .panel.menu .grid2, html.pip-native #stage .panel.menu .grid2 { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  html.pip-immersive #stage .results h2, html.pip-native #stage .results h2 { font-size: 20px; }
  html.pip-immersive #stage .results .stars i, html.pip-native #stage .results .stars i { font-size: 24px; }
  html.pip-immersive #stage .results .btn, html.pip-native #stage .results .btn { min-height: 46px; }
}
