/* Skyline Hub - 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 { --navy:#10213d; --navy2:#1a3257; --gold:#fbbf24; --teal:#2dd4bf; --red:#ef4444; --ink:#e8f0ff; --mut:#9fb3d6;
  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(#9fd8ff, #dff2ff); 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; }
html.pip-immersive .pip-stage #stage, html.pip-native .pip-stage #stage { width: 100%; max-width: none; height: 100%; aspect-ratio: auto; border-radius: 0; }
#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%; touch-action: none; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage #ui button, #stage #ui .sheet, #stage #ui .screens, #stage #ui input { pointer-events: auto; }
#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 #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#2f6df0, #74b9ff 55%, #dff2ff); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(20,40,110,.45); text-align: center; padding: 0 18px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 30px); 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,.35); border-top-color: var(--gold); animation: iaspin .8s linear infinite; }
@keyframes iaspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; left: 0; right: 0; top: 46%; z-index: 40; text-align: center; padding: 14px 18px; background: rgba(16,33,61,.9); color: #fff; font-weight: 700; font-size: 14px; }

/* ---- HUD */
#stage .hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; min-height: 54px; background: linear-gradient(rgba(10,25,50,.78), rgba(10,25,50,0)); }
#stage .cashbox { display: flex; flex-direction: column; min-width: 0; }
#stage .cash { font-size: clamp(20px, 6.4vw, 28px); color: var(--gold); text-shadow: 0 2px 0 rgba(0,0,0,.45); line-height: 1.05; }
#stage .inc { font-size: 12px; color: #c9ffe9; text-shadow: 0 1px 0 rgba(0,0,0,.5); }
#stage .midbox { flex: 1; display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; text-shadow: 0 1px 0 rgba(0,0,0,.6); min-width: 0; }
#stage .tierl { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#stage .starl { color: var(--gold); }
#stage button.icon { min-width: 56px; min-height: 44px; border: 2px solid rgba(255,255,255,.5); border-radius: 12px; background: rgba(16,33,61,.8); font-weight: 800; font-size: 13px; }
#stage .flowrow { position: absolute; top: 54px; left: 6px; right: 6px; display: flex; gap: 4px; }
#stage .fchip { flex: 1; min-width: 0; text-align: center; font-size: 11px; font-weight: 700; padding: 3px 2px; border-radius: 8px; background: rgba(16,33,61,.78); border: 1px solid rgba(255,255,255,.18); white-space: nowrap; overflow: hidden; }
#stage .fchip.hot { background: #7f1d1d; border-color: #fca5a5; animation: iapulse 1.1s ease-in-out infinite; }
@keyframes iapulse { 50% { filter: brightness(1.35); } }
#stage .hbar { position: absolute; top: 84px; left: 8px; right: 8px; height: 20px; border-radius: 10px; background: rgba(16,33,61,.8); border: 1px solid rgba(255,255,255,.25); overflow: hidden; }
#stage .hbar i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #f59e0b, #fde047); transition: width .2s linear; }
#stage .hbar.active i { background: linear-gradient(90deg, #22d3ee, #a7f3d0); }
#stage .hbar .hl { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; text-shadow: 0 1px 0 rgba(0,0,0,.7); letter-spacing: .5px; }
#stage .sprintbar { position: absolute; top: 108px; left: 8px; right: 8px; text-align: center; font-size: 12px; font-weight: 800; padding: 4px 6px; border-radius: 8px; background: rgba(16,33,61,.85); }
#stage .events { position: absolute; left: 8px; right: 8px; bottom: calc(40% + 52px); display: flex; flex-direction: column; gap: 6px; align-items: center; }
#stage .evt { min-height: 46px; padding: 8px 14px; border-radius: 14px; border: 2px solid #fff; font-weight: 800; font-size: 14px; box-shadow: 0 4px 0 rgba(0,0,0,.35); }
#stage .evt.vip { background: linear-gradient(#fde047, #f59e0b); color: #3b2300; animation: iapulse .8s ease-in-out infinite; }
#stage .evt.storm { background: linear-gradient(#93c5fd, #3b82f6); color: #06204a; }
#stage .hint { position: absolute; left: 10px; right: 10px; bottom: calc(40% + 6px); padding: 8px 12px; border-radius: 12px; background: #fffbe6; color: #3b2a00; font-size: 13px; font-weight: 700; text-align: center; border: 2px solid var(--gold); box-shadow: 0 3px 0 rgba(0,0,0,.3); }
#stage .toasts { position: absolute; top: 134px; left: 8px; right: 8px; display: flex; flex-direction: column; gap: 4px; align-items: center; pointer-events: none; }
#stage .toast { padding: 6px 12px; border-radius: 10px; background: rgba(16,33,61,.92); font-size: 13px; font-weight: 700; text-align: center; border: 1px solid rgba(255,255,255,.3); animation: iafade 2.6s ease forwards; }
#stage .toast.gold { border-color: var(--gold); color: #fff3c4; }
@keyframes iafade { 0% { opacity: 0; transform: translateY(-6px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#stage .floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#stage .float { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 15px; color: #fff3a8; text-shadow: 0 2px 0 rgba(0,0,0,.6); animation: iarise 1.2s ease-out forwards; white-space: nowrap; }
#stage .float.tapfx { color: #fff; font-size: 20px; }
@keyframes iarise { 0% { opacity: 1; margin-top: 0; } 100% { opacity: 0; margin-top: -46px; } }
#stage .flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s; }
#stage .flash.on { opacity: .5; transition: none; }
#stage .pulse { animation: iapulse .5s ease-in-out 3; box-shadow: 0 0 0 3px var(--gold); }

/* ---- bottom sheet */
#stage .sheet { position: absolute; bottom: 0; left: 0; right: 0; margin: 0 auto; width: min(100%, 560px); height: 40%; min-height: 200px; display: flex; flex-direction: column; background: var(--navy); border-top: 3px solid #2f4f86; border-radius: 16px 16px 0 0; }
#stage .tabs { display: flex; flex: 0 0 auto; gap: 3px; padding: 4px 4px 0; }
#stage .tab { flex: 1; min-height: 44px; border: 0; border-radius: 10px 10px 0 0; background: #1d3866; font-weight: 800; font-size: 13px; color: var(--mut); }
#stage .tab.on { background: #2f5aa5; color: #fff; }
#stage .sheetbody { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; background: var(--navy2); padding: 6px 8px 10px; }
#stage .page { display: flex; flex-direction: column; gap: 6px; }
#stage .row { display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 6px 8px; border-radius: 12px; background: rgba(255,255,255,.07); }
#stage .row.small { min-height: 44px; }
#stage .row.done { opacity: .7; }
#stage .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
#stage .nm { font-size: 14px; }
#stage .sub { font-size: 12px; color: var(--mut); }
#stage .sub2 { font-size: 11px; color: #7f95bb; }
#stage .dot { width: 12px; height: 12px; border-radius: 50%; background: #3a4f78; flex: 0 0 auto; }
#stage .dot.hot { background: var(--red); box-shadow: 0 0 8px var(--red); }
#stage .dot.ok { background: #34d399; }
#stage .sw { width: 18px; height: 34px; border-radius: 6px; flex: 0 0 auto; border: 2px solid rgba(255,255,255,.5); }
#stage .buy { flex: 0 0 auto; min-width: 112px; min-height: 44px; padding: 6px 10px; border: 0; border-radius: 12px; font-weight: 900; font-size: 13px; color: #06311f; background: linear-gradient(#6ee7b7, #10b981); box-shadow: 0 3px 0 #047857; }
#stage .buy.off { background: #3a4f78; color: #9fb3d6; box-shadow: 0 3px 0 #27385a; }
#stage .buy.wide { width: 100%; margin-top: 6px; }
#stage .bulk { display: flex; align-items: center; gap: 6px; }
#stage .bulk-note { font-size: 11px; color: var(--mut); margin-left: auto; }
#stage .chip { min-width: 52px; min-height: 44px; border: 2px solid #3a5a96; border-radius: 12px; background: #1d3866; font-weight: 800; font-size: 13px; }
#stage .chip.on { background: #2f5aa5; border-color: #93c5fd; }
#stage .card { padding: 10px; border-radius: 12px; background: rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 4px; }
#stage .bar { height: 8px; border-radius: 6px; background: #0b1730; overflow: hidden; }
#stage .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #22d3ee, #34d399); }
#stage .starline { font-size: 13px; font-weight: 800; color: var(--gold); padding: 2px 4px; }
#stage .h { font-size: 13px; color: var(--gold); margin: 4px 2px 0; }
#stage .tag { font-size: 11px; color: var(--gold); font-weight: 800; }

/* ---- screens */
#stage .screens { position: absolute; inset: 0; z-index: 30; background: rgba(8,16,32,.9); overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; display: flex; }
#stage .modal { margin: auto; width: min(100%, 380px); padding: 16px 14px 20px; display: flex; flex-direction: column; gap: 8px; text-align: center; }
#stage .mt { font-size: 26px; letter-spacing: 1px; color: var(--gold); text-shadow: 0 3px 0 rgba(0,0,0,.5); }
#stage .mh { font-size: 14px; color: var(--teal); margin-top: 6px; text-align: left; }
#stage .ms { font-size: 14px; color: var(--ink); }
#stage .ms.left { text-align: left; font-size: 13px; }
#stage .bigscore { font-size: 34px; font-weight: 900; color: #c9ffe9; }
#stage .stars-big { font-size: 38px; color: var(--gold); letter-spacing: 6px; }
#stage .mrow { display: flex; gap: 8px; align-items: center; justify-content: center; }
#stage .modal button.big { width: 100%; min-height: 54px; padding: 8px 12px; border-radius: 14px; border: 2px solid rgba(255,255,255,.4); background: #1d3866; font-weight: 800; font-size: 15px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
#stage .modal button.big.primary { background: linear-gradient(#34d399, #059669); color: #052e1a; border-color: #a7f3d0; font-size: 17px; }
#stage .modal button.big.card { align-items: flex-start; text-align: left; background: #172c52; }
#stage .modal button.big.off { opacity: .55; }
#stage .modal button.small { flex: 1; min-height: 48px; padding: 6px 10px; border-radius: 12px; border: 2px solid rgba(255,255,255,.35); background: #1d3866; font-weight: 800; font-size: 14px; }
#stage .modal button.small.on { background: #2f5aa5; border-color: #93c5fd; }
#stage .modal button.small.danger { border-color: #f87171; color: #fecaca; }
#stage .modal .sub { font-size: 12px; color: var(--mut); font-weight: 600; }
#stage .range { flex: 1; min-height: 44px; accent-color: var(--gold); touch-action: pan-x; }

/* ---- page chrome below the stage */
.er-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.er-bar .btn { min-height: 44px; min-width: 44px; }
.er-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
html.pip-immersive .pip-stage > .er-bar, html.pip-immersive .pip-stage > .er-keys { display: none; }
.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; }
@media (prefers-reduced-motion: reduce) { #stage .fchip.hot, #stage .evt.vip, #stage .pulse { animation: none; } }

/* ---- full screen pass 3: stage fills the space under the dock, chrome out of the way */
html.pip-immersive .game-wrap.pip-stage, html.pip-native .game-wrap.pip-stage { display: flex; flex-direction: column; overflow: hidden; }
html.pip-immersive .pip-stage > .er-bar, html.pip-immersive .pip-stage > .er-keys, html.pip-immersive .pip-stage > noscript,
html.pip-native .pip-stage > .er-bar, html.pip-native .pip-stage > .er-keys, html.pip-native .pip-stage > .game-title, html.pip-native .pip-stage > noscript { display: none; }
html.pip-immersive .pip-stage #stage, html.pip-native .pip-stage #stage { flex: 1 1 0; min-height: 0; height: auto; width: 100%; aspect-ratio: auto; max-width: none; }
html.pip-immersive #stage .hud, html.pip-native #stage .hud { padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
html.pip-immersive #stage .sheet, html.pip-native #stage .sheet { padding-bottom: env(safe-area-inset-bottom, 0px); }
html.pip-immersive #stage .screens, html.pip-native #stage .screens { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
@media (orientation: landscape) and (max-height: 520px) {
  #stage .sheet { height: 46%; min-height: 150px; }
  #stage .modal { padding-top: 10px; padding-bottom: 12px; gap: 6px; }
}

/* ---- finish: panels, depth, press feedback */
#stage .modal { background: linear-gradient(#1b335c, #12244a); border: 2px solid #35568f; border-radius: 18px; box-shadow: 0 10px 28px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.14); animation: iapop .22s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes iapop { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
#stage .sheet { box-shadow: 0 -8px 22px rgba(0,0,0,.35); }
#stage button { transition: transform .08s ease-out, filter .12s ease-out; }
#stage button:active { transform: scale(.96); filter: brightness(1.12); }
#stage .modal button.big.primary { box-shadow: 0 4px 0 #047857, 0 8px 14px rgba(0,0,0,.3); }
@media (prefers-reduced-motion: reduce) { #stage .modal { animation: none; } #stage button { transition: none; } }
