/* Rhythm Rush 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 { --bg:#150f2b; --panel:rgba(22,14,44,.94); --ink:#f6efff; --dim:#b9aad8; --pink:#ff4f8b; --pink-d:#b32a5e; --amber:#ffc233; --mint:#4fdc9a; --sky:#4ab8ff; --line:rgba(255,255,255,.14);
  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: var(--bg); color: var(--ink); font-family: "Trebuchet MS", "Segoe UI", Verdana, system-ui, sans-serif; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent; line-height: 1.25; touch-action: manipulation; }
#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%; touch-action: none; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; color: inherit; }
#stage button:focus-visible, #stage input: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: var(--bg); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 0 18px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 30px); letter-spacing: 3px; color: var(--pink); }
#stage .load-in span { font-size: 14px; color: var(--dim); }
#stage .spinner { width: 40px; height: 40px; border-radius: 50%; border: 5px solid rgba(255,255,255,.2); border-top-color: var(--amber); animation: rrspin .8s linear infinite; }
@keyframes rrspin { 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(15,10,30,.9); color: #fff; font-weight: 700; }

/* play surface and HUD */
#stage .pad { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }
#stage .hud { position: absolute; inset: 0; pointer-events: none; }
#stage .hud-top { position: absolute; left: 10px; right: 10px; top: max(8px, env(safe-area-inset-top)); display: flex; justify-content: space-between; align-items: flex-start; }
#stage .hud-score { display: flex; flex-direction: column; text-shadow: 0 2px 0 rgba(0,0,0,.45); }
#stage .hud-score b { font-size: clamp(22px, 7vw, 30px); letter-spacing: 1px; font-variant-numeric: tabular-nums; }
#stage .hud-score small { font-size: 12px; color: var(--dim); font-weight: 700; }
#stage .pausebtn { pointer-events: auto; width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--line); background: rgba(20,12,40,.7); font-weight: 900; font-size: 16px; letter-spacing: 2px; }
#stage .hud-bars { position: absolute; left: 10px; right: 66px; top: calc(max(8px, env(safe-area-inset-top)) + 52px); display: flex; flex-direction: column; gap: 4px; }
#stage .hbar, #stage .pbar { height: 8px; border-radius: 5px; background: rgba(255,255,255,.14); overflow: hidden; }
#stage .pbar { height: 4px; }
#stage .hbar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--mint), #b6ff8f); transform-origin: left; transform: scaleX(.7); }
#stage .hbar.low i { background: linear-gradient(90deg, #ff4a4a, #ff9a4a); animation: rrblink .4s infinite alternate; }
#stage .pbar i { display: block; height: 100%; width: 100%; background: var(--sky); transform-origin: left; transform: scaleX(0); }
@keyframes rrblink { to { opacity: .45; } }
#stage .hud-mid { position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none; }
#stage .combo { min-height: 52px; font-weight: 900; text-shadow: 0 3px 0 rgba(0,0,0,.45); }
#stage .combo b { display: block; font-size: clamp(34px, 11vw, 52px); line-height: 1; color: var(--amber); font-variant-numeric: tabular-nums; }
#stage .combo small { font-size: 11px; letter-spacing: 4px; color: var(--dim); }
#stage .combo.pop { animation: rrpop .25s ease-out; }
@keyframes rrpop { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
#stage .judge { min-height: 30px; margin-top: 6px; font-weight: 900; font-size: clamp(18px, 6vw, 26px); letter-spacing: 2px; opacity: 0; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
#stage .judge.show { animation: rrjudge .7s ease-out forwards; }
#stage .judge small { display: block; font-size: 11px; letter-spacing: 3px; opacity: .85; }
#stage .j-perfect { color: #fff4a8; } #stage .j-great { color: #8ff0ff; } #stage .j-good { color: #b5f5a0; } #stage .j-miss { color: #ff6b6b; }
@keyframes rrjudge { 0% { opacity: 0; transform: scale(.7); } 15% { opacity: 1; transform: scale(1.12); } 30% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
#stage .hud-keys { position: absolute; left: 3%; right: 3%; top: 80%; transform: translateY(-50%); display: grid; grid-template-columns: repeat(4, 1fr); pointer-events: none; }
#stage .hud-keys span { text-align: center; font-weight: 900; font-size: 15px; color: var(--lc); opacity: .75; text-shadow: 0 1px 0 rgba(0,0,0,.6); transition: transform .06s, opacity .06s; }
#stage .hud-keys span.down { transform: scale(1.3); opacity: 1; }
#stage .hud-badge { position: absolute; left: 10px; top: calc(max(8px, env(safe-area-inset-top)) + 80px); font-size: 11px; font-weight: 900; letter-spacing: 1px; padding: 3px 8px; border-radius: 8px; background: rgba(255,79,139,.25); color: #ffd0e2; }
#stage .hint-bubble { position: absolute; left: 50%; top: 52%; transform: translateX(-50%); max-width: 86%; background: rgba(255,255,255,.95); color: #2a1a4a; font-weight: 800; font-size: 14px; text-align: center; padding: 8px 14px; border-radius: 14px; animation: rrfloat 1.2s ease-in-out infinite alternate; }
@keyframes rrfloat { to { transform: translate(-50%, -6px); } }
#stage .flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
#stage .flash.go { animation: rrflash .45s ease-out forwards; }
@keyframes rrflash { 0% { opacity: 1; } 100% { opacity: 0; } }
#stage .count { position: absolute; left: 0; right: 0; top: 36%; text-align: center; pointer-events: none; font-size: clamp(34px, 12vw, 58px); font-weight: 900; letter-spacing: 3px; text-shadow: 0 4px 0 rgba(0,0,0,.45); }
#stage .count.go { animation: rrcount .65s ease-out forwards; }
@keyframes rrcount { 0% { opacity: 0; transform: scale(1.6); } 25% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
#stage .toasts { position: absolute; left: 0; right: 0; top: 9%; display: flex; flex-direction: column; align-items: center; gap: 5px; pointer-events: none; z-index: 5; }
#stage .toast { background: rgba(255,255,255,.95); color: #2a1a4a; font-weight: 800; font-size: 13px; padding: 5px 14px; border-radius: 99px; max-width: 92%; text-align: center; animation: rrtoast 2.6s ease-out forwards; }
#stage .toast.gold { background: var(--amber); }
@keyframes rrtoast { 0% { opacity: 0; transform: translateY(8px); } 10% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }

/* screens */
#stage .screens { position: absolute; inset: 0; pointer-events: none; }
#stage .screen { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 8px; pointer-events: none; }
#stage .screen .panel { pointer-events: auto; width: 100%; max-height: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
#stage .srow input[type=range] { touch-action: none; }
#stage .panel h2 { margin: 0; font-size: 20px; letter-spacing: 1px; flex: 1; }
#stage .panel p { margin: 0; }
#stage .phead { display: flex; align-items: center; gap: 8px; }
#stage .back { width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--line); background: rgba(255,255,255,.06); font-size: 26px; line-height: 1; font-weight: 900; }
#stage .logo { display: flex; flex-direction: column; line-height: 1; text-align: center; padding: 4px 0; }
#stage .logo span { font-size: 15px; letter-spacing: 8px; color: var(--amber); font-weight: 800; }
#stage .logo b { font-size: clamp(32px, 11vw, 46px); color: var(--pink); letter-spacing: 3px; text-shadow: 0 3px 0 rgba(0,0,0,.4); }
#stage .tag { font-size: 13px; color: var(--dim); }
#stage .tag.small { font-size: 12px; }
#stage .warn { color: #ffb0b0; }
#stage .goal { font-size: 13px; background: rgba(255,194,51,.1); border: 1px solid rgba(255,194,51,.3); border-radius: 12px; padding: 8px 10px; color: #ffe9b0; }
#stage .rankbar { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; }
#stage .bar { flex: 1; height: 9px; background: rgba(255,255,255,.14); border-radius: 6px; overflow: hidden; }
#stage .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--amber)); }
#stage .pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
#stage .pill { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.1); border-radius: 99px; padding: 4px 11px; font-weight: 800; font-size: 13px; color: #ffe9b0; }
#stage .btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 46px; min-width: 44px; padding: 8px 14px; border: 0; border-radius: 14px; background: var(--pink); color: #fff; font-weight: 900; font-size: 15px; box-shadow: 0 4px 0 var(--pink-d); }
#stage .btn small { font-size: 11px; font-weight: 700; opacity: .85; }
#stage .btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--pink-d); }
#stage .btn:disabled { background: #5a4d78; box-shadow: 0 4px 0 #3d3354; color: #cbbfe4; cursor: default; }
#stage .btn.big { min-height: 56px; font-size: 22px; letter-spacing: 3px; background: var(--amber); color: #3a2400; box-shadow: 0 5px 0 #b8841a; }
#stage .btn.alt { background: #6a4bd8; box-shadow: 0 4px 0 #46309a; }
#stage .btn.ghost { background: rgba(255,255,255,.08); box-shadow: 0 3px 0 rgba(0,0,0,.35); border: 1px solid var(--line); }
#stage .btn.danger { background: #d94a4a; box-shadow: 0 4px 0 #962b2b; }
#stage .btn.small { min-height: 44px; font-size: 14px; }
#stage .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
#stage .grid3 .btn { font-size: 13px; padding: 6px 4px; }
#stage .chips { display: flex; flex-wrap: wrap; gap: 6px; }
#stage .chip { min-height: 44px; min-width: 44px; padding: 5px 11px; border-radius: 12px; border: 2px solid var(--line); background: rgba(255,255,255,.07); font-weight: 800; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#stage .chip small { font-size: 10px; font-weight: 700; opacity: .75; }
#stage .chip.on { border-color: var(--dc, var(--amber)); background: rgba(255,194,51,.16); }
#stage .chip.locked { opacity: .5; }
#stage .songs { height: 100%; }
#stage .tracklist { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
#stage .trk { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "n s" "b b"; gap: 1px 8px; text-align: left; padding: 8px 11px; min-height: 52px; border-radius: 12px; border: 2px solid var(--line); background: rgba(255,255,255,.06); flex: none; }
#stage .trk.on { border-color: var(--tc, var(--amber)); background: rgba(255,255,255,.14); }
#stage .trk.locked { opacity: .6; }
#stage .trk .tn { grid-area: n; font-weight: 900; font-size: 15px; }
#stage .trk .tb { grid-area: b; font-size: 12px; color: var(--dim); }
#stage .trk .ts { grid-area: s; font-size: 12px; font-weight: 800; color: #ffe9b0; align-self: center; }
#stage .songbar { display: flex; flex-direction: column; gap: 7px; flex: none; }
#stage .dcard { display: flex; justify-content: space-between; font-size: 20px; font-weight: 900; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.08); }
#stage .dcard span { color: var(--amber); }
#stage .dmod { padding: 10px 12px; border-radius: 12px; border: 2px dashed rgba(255,79,139,.6); }
#stage .dmod b { color: var(--pink); }
#stage .dmod p { font-size: 13px; color: var(--dim); }

/* results */
#stage .rhead { text-align: center; font-weight: 900; letter-spacing: 4px; font-size: 18px; }
#stage .rhead.ok { color: var(--mint); } #stage .rhead.bad { color: #ff7a7a; }
#stage .rtop { display: flex; align-items: center; gap: 14px; justify-content: center; }
#stage .rletter { width: 84px; height: 84px; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 54px; font-weight: 900; background: rgba(255,255,255,.1); border: 3px solid var(--amber); color: var(--amber); }
#stage .L-S { color: #fff4a8; border-color: #fff4a8; box-shadow: 0 0 22px rgba(255,244,168,.5); } #stage .L-A { color: var(--mint); border-color: var(--mint); } #stage .L-D { color: #ff8a8a; border-color: #ff8a8a; }
#stage .rstars { font-size: 26px; color: var(--amber); letter-spacing: 3px; }
#stage .rscore { font-size: 28px; font-weight: 900; font-variant-numeric: tabular-nums; }
#stage .newbest { display: inline-block; font-size: 11px; font-weight: 900; letter-spacing: 2px; background: var(--pink); color: #fff; padding: 2px 8px; border-radius: 8px; }
#stage .rgrid { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 3px 10px; font-size: 13px; background: rgba(255,255,255,.06); border-radius: 12px; padding: 8px 10px; }
#stage .rgrid span { color: var(--dim); } #stage .rgrid b { text-align: right; font-variant-numeric: tabular-nums; }
#stage .rgrid .g0 { color: #fff4a8; } #stage .rgrid .g1 { color: #8ff0ff; } #stage .rgrid .g2 { color: #b5f5a0; } #stage .rgrid .g3 { color: #ff6b6b; }
#stage .rewards { margin: 0; padding: 0 0 0 18px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
#stage .rbtns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
#stage .rbtns .big { grid-column: 1 / -1; }
#stage .rbtns .btn { font-size: 14px; padding: 6px; }
#stage .rbtns .btn.big { font-size: 18px; }

/* skins, missions, settings, calibration */
#stage .skingrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .skin { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 6px; border-radius: 14px; border: 2px solid var(--line); background: rgba(255,255,255,.06); }
#stage .skin.on { border-color: var(--amber); background: rgba(255,194,51,.12); }
#stage .swatch { display: flex; gap: 5px; height: 26px; align-items: center; }
#stage .swatch i { display: block; width: 22px; height: 22px; border-radius: 50%; }
#stage .sh-gem i { border-radius: 3px; transform: rotate(45deg) scale(.8); }
#stage .sh-cube i { border-radius: 3px; }
#stage .sh-petal i { border-radius: 50%; width: 26px; height: 15px; }
#stage .sh-star i { border-radius: 4px; clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 82% 100%, 50% 76%, 18% 100%, 30% 60%, 0 38%, 38% 36%); }
#stage .sh-ring i { background: transparent !important; border: 5px solid; border-color: inherit; box-shadow: inset 0 0 0 2px rgba(255,255,255,.2); }
#stage .sname { font-weight: 800; font-size: 13px; text-align: center; }
#stage .state { font-size: 12px; font-weight: 800; color: var(--mint); } #stage .state.lock { color: var(--dim); }
#stage .mis, #stage .ach { padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.07); display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
#stage .mis.done, #stage .ach.done { background: rgba(79,220,154,.14); }
#stage .mt { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 14px; }
#stage .mis small, #stage .ach span, #stage .ach em { font-size: 12px; color: var(--dim); font-style: normal; }
#stage .stats { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; font-size: 14px; } #stage .stats span { color: var(--dim); } #stage .stats b { text-align: right; }
#stage .pbody { display: flex; flex-direction: column; }
#stage .srow { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 44px; font-weight: 800; font-size: 14px; }
#stage .srow input[type=range] { flex: 1; max-width: 60%; min-height: 44px; accent-color: var(--pink); }
#stage .sgroup { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 14px; }
#stage .stepper { display: flex; gap: 6px; }
#stage .calib { align-items: stretch; }
#stage .calring { align-self: center; width: 90px; height: 90px; border-radius: 50%; border: 6px solid var(--pink); opacity: .5; }
#stage .calring.ping { animation: rrping .5s ease-out; }
@keyframes rrping { 0% { transform: scale(1.3); opacity: 1; background: rgba(255,79,139,.5); } 100% { transform: scale(1); opacity: .5; } }
#stage .calpad { min-height: 140px; border-radius: 18px; border: 3px dashed var(--amber); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; font-size: 20px; touch-action: none; }
#stage .calpad small { font-size: 13px; color: var(--dim); }

/* the page around the stage */
.rr-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.rr-bar .btn { min-height: 44px; min-width: 44px; }
.rr-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.er-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.er-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.er-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.er-guide p { margin-bottom: .5rem; font-size: .95rem; }

/* inside the site's own game shell (native or immersive full screen) keep the 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)); }
@media (orientation: landscape) { .game-wrap.pip-stage #stage { aspect-ratio: auto; height: calc(100svh - 64px); width: min(100%, calc((100svh - 64px) * 1.78)); } }
@media (prefers-reduced-motion: reduce) { #stage .hint-bubble, #stage .hbar.low i { animation: none; } }

#stage .hud-score #hudBest{display:block;font-size:10px;font-weight:900;letter-spacing:1.5px;color:#ffe9b0;opacity:.85;margin-top:1px}
#stage .hud-score #hudBest[hidden]{display:none}
#stage .hud-score #hudBest.beat{color:#ffc233;opacity:1;animation:rrpop .35s ease-out}
#stage .chase{color:#ffe9b0}
@media (prefers-reduced-motion: reduce) { #stage .combo.pop, #stage #hudBest.beat, #stage .calring.ping, #stage .spinner { animation: none; } }

/* full screen (shell native or immersive): the stage fills the space beside the dock, the page extras go away */
.game-wrap.pip-stage { display: flex; flex-direction: column; align-items: stretch; justify-content: center; padding: 0; }
.game-wrap.pip-stage > .rr-bar, .game-wrap.pip-stage > .rr-keys, .game-wrap.pip-stage > .game-title { display: none !important; }
html.pip-immersive .hub-bar, html.pip-immersive .game-header, html.pip-immersive .ad-well, html.pip-immersive .playyard-ad, html.pip-immersive .below-content, html.pip-immersive .er-guide { display: none !important; }
.game-wrap.pip-stage #stage { flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; height: 100%; aspect-ratio: auto; border-radius: 0; margin: 0; }
.game-wrap.pip-stage #stage .pausebtn { width: 48px; height: 48px; }
.game-wrap.pip-stage #stage .hud-top { left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); }
@media (orientation: landscape) { .game-wrap.pip-stage #stage .hud-bars { right: 76px; } }
