/* Orbit Foundry - 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: #0b1226; --panel: #131c38; --panel2: #1a2547; --line: #2a3866; --ink: #e8eefc; --dim: #93a3cf; --acc: #4fc3f7; --gold: #ffd54f; --good: #66d17a; --bad: #ff6b6b; --violet: #b388ff;
  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: "Plus Jakarta Sans", "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; font-size: 14px; }
html.pip-immersive #stage, html.pip-native #stage { position: absolute; inset: 0; width: auto; height: auto; max-width: none; aspect-ratio: auto; border-radius: 0; }
#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; left: 0; top: 0; right: 0; height: 40%; }
#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 .modal { pointer-events: auto; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; color: inherit; }
#stage button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

#stage #loader { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: linear-gradient(#0b1226, #1b2a5a); }
#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: 2px; }
#stage .load-in span { font-size: 14px; opacity: .9; }
#stage .spinner { width: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.25); border-top-color: var(--gold); animation: ofspin .8s linear infinite; }
@keyframes ofspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; left: 0; right: 0; top: 0; height: 40%; z-index: 30; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(11,18,38,.88); color: #fff; font-weight: 600; pointer-events: none; }
#stage #ctxlost.soft { font-size: 12px; font-weight: 500; }

/* HUD over the 3D view */
#stage .hud { position: absolute; left: 0; right: 0; top: 0; padding: 8px 10px 0; pointer-events: none; }
#stage .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
#stage .money { display: flex; flex-direction: column; text-shadow: 0 2px 6px rgba(0,0,0,.7); }
#stage .money .cr { font-size: 26px; font-weight: 800; color: var(--gold); line-height: 1; }
#stage .money .cps { font-size: 12px; color: #cfe6ff; margin-top: 2px; }
#stage .hbtns { display: flex; gap: 6px; }
#stage .btn.ico { min-width: 44px; min-height: 44px; padding: 0 10px; font-size: 12px; font-weight: 700; border-radius: 12px; border: 1px solid var(--line); background: rgba(19,28,56,.85); }
#stage .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
#stage .chip { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: rgba(19,28,56,.8); border: 1px solid var(--line); color: #cfe6ff; }
#stage .chip.warn { color: #fff; background: #b3412f; border-color: #ff8a6b; }
#stage .chbox { margin-top: 5px; padding: 4px 8px; border-radius: 10px; background: rgba(19,28,56,.9); border: 1px solid var(--line); font-size: 11px; font-weight: 700; }
#stage .gbox { margin-top: 5px; padding: 4px 8px; border-radius: 10px; background: rgba(19,28,56,.85); border: 1px solid var(--line); font-size: 11px; font-weight: 700; color: #cfe6ff; max-width: 78%; }
#stage .gbox[hidden] { display: none; }
#stage .gbox .bar { margin-top: 3px; }
#stage .gbox.ready { border-color: var(--gold); color: var(--gold); animation: ofpulse 1.2s ease-in-out infinite; }
#stage .boost.hot { box-shadow: 0 0 0 4px rgba(255,213,79,.45), 0 0 26px 8px rgba(255,180,40,.7); }
#stage .bar { height: 6px; border-radius: 4px; background: #0a1020; overflow: hidden; margin-top: 4px; }
#stage .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--acc), var(--good)); }

#stage .badges { position: absolute; left: 0; top: 0; width: 100%; height: 40%; pointer-events: none; overflow: hidden; }
#stage .badge { position: absolute; left: 0; top: 0; font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 8px; background: rgba(11,18,38,.82); border: 1px solid var(--line); color: #fff; white-space: nowrap; will-change: transform; }
#stage .badge.plus { background: var(--acc); color: #06142a; font-size: 14px; padding: 0 8px; }
#stage .badge.lock { color: var(--dim); }

#stage .evbtn { position: absolute; left: 10px; right: 104px; top: calc(40% - 118px); min-height: 48px; padding: 6px 12px; border-radius: 12px; border: 2px solid var(--gold); background: rgba(38,52,98,.95); font-weight: 800; font-size: 14px; text-align: center; animation: ofpulse 1s ease-in-out infinite; }
#stage .evbtn.bad { border-color: #ff8a6b; }
#stage .evbtn .bar { margin-top: 4px; }
@keyframes ofpulse { 50% { transform: scale(1.02); } }
#stage .boost { position: absolute; right: 10px; top: calc(40% - 118px); width: 84px; height: 84px; border-radius: 50%; border: 3px solid #fff3b0; background: radial-gradient(circle at 35% 30%, #ffe27a, #f0a21a 70%); color: #3a2400; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.5); font-weight: 900; line-height: 1.05; }
#stage .boost b { font-size: 14px; letter-spacing: 1px; }
#stage .boost .bv { font-size: 12px; font-weight: 800; }
#stage .boost:active { transform: scale(.94); }
#stage .floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#stage .float { position: absolute; transform: translateX(-50%); font-weight: 800; font-size: 15px; color: var(--gold); text-shadow: 0 2px 4px #000; animation: offloat .9s ease-out forwards; white-space: nowrap; }
@keyframes offloat { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -38px); } }
#stage .flash { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
#stage .flash.flare { background: radial-gradient(circle, rgba(255,160,60,.0), rgba(255,120,30,.45)); animation: offade .7s ease-out forwards; }
@keyframes offade { from { opacity: 1; } to { opacity: 0; } }
#stage .toasts { position: absolute; left: 10px; right: 10px; top: calc(40% - 36px); display: flex; flex-direction: column; gap: 4px; pointer-events: none; z-index: 12; }
#stage .toast { align-self: center; max-width: 100%; padding: 5px 12px; border-radius: 999px; background: rgba(19,28,56,.94); border: 1px solid var(--line); font-size: 12px; font-weight: 700; text-align: center; }
#stage .toast.good { border-color: var(--good); } #stage .toast.bad { border-color: var(--bad); } #stage .toast.warn { border-color: var(--gold); }

/* Bottom sheet */
#stage .sheet { position: absolute; left: 0; right: 0; bottom: 0; top: 40%; display: flex; flex-direction: column; background: var(--panel); border-top: 2px solid var(--line); border-radius: 16px 16px 0 0; z-index: 5; }
#stage .tut { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; background: #26407a; color: #fff; font-size: 13px; font-weight: 700; border-radius: 14px 14px 0 0; }
#stage .tutx { min-width: 44px; min-height: 44px; border: 1px solid #6f8fd8; background: transparent; border-radius: 8px; font-size: 11px; }
#stage .tabs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 4px 4px 0; }
#stage .tab { position: relative; min-height: 46px; border: 0; border-radius: 10px 10px 0 0; background: #0f1730; font-size: 12px; font-weight: 800; color: var(--dim); }
#stage .tab.on { background: var(--panel2); color: #fff; box-shadow: inset 0 -3px 0 var(--acc); }
#stage .tab.nudge { animation: ofpulse 1s ease-in-out infinite; color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold); }
#stage .pip { position: absolute; right: 8px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); }
#stage .sheetbody { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; -webkit-overflow-scrolling: touch; background: var(--panel2); padding: 8px; overscroll-behavior: contain; }
#stage .tabpane { display: flex; flex-direction: column; gap: 6px; padding-bottom: 12px; }
#stage .hd { font-size: 12px; font-weight: 800; color: var(--acc); text-transform: uppercase; letter-spacing: .06em; margin: 6px 2px 0; }
#stage .card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
#stage .card.sel { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
#stage .card.done { opacity: .55; }
#stage .card.ach { opacity: .45; padding: 6px 10px; } #stage .card.ach.got { opacity: 1; border-color: var(--good); }
#stage .row { display: flex; align-items: center; gap: 8px; }
#stage .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
#stage .ct { font-size: 14px; font-weight: 800; }
#stage .crate { margin-left: auto; font-size: 12px; color: var(--acc); font-weight: 700; }
#stage .csub { font-size: 12px; color: var(--dim); margin: 2px 0 4px; }
#stage .csub.warn { color: #ffb36b; }
#stage .note { font-size: 12px; color: var(--dim); padding: 4px 2px; }
#stage .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #1f2d5c; font-size: 13px; font-weight: 800; text-decoration: none; }
#stage .btn.act { width: 100%; background: linear-gradient(#2e6fd6, #2257b3); border-color: #5b95f0; color: #fff; }
#stage .btn.act.alt { background: #2a3866; border-color: var(--line); }
#stage .btn.act.go, #stage .btn.go { background: linear-gradient(#34c37a, #1f9a5c); border-color: #7ee2ad; color: #05261a; }
#stage .btn.cant { opacity: .45; filter: grayscale(.5); }
#stage .btn.danger { background: #7a2430; border-color: #ff6b6b; }
#stage .btnrow { display: flex; gap: 6px; flex-wrap: wrap; } #stage .btnrow .btn { flex: 1 1 120px; }
#stage .chips { }
#stage .slotcard .chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#stage .btn.chip { flex-direction: column; gap: 0; padding: 6px 8px; font-size: 12px; background: #1f2d5c; border-radius: 10px; border: 1px solid var(--line); border-width: 1px; font-weight: 700; justify-content: center; }
#stage .btn.chip em { font-style: normal; color: var(--gold); font-size: 11px; }
#stage .crewrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#stage .stepper { display: flex; align-items: center; gap: 8px; }
#stage .btn.step { min-width: 48px; padding: 0; font-size: 20px; }
#stage .cnt { min-width: 36px; text-align: center; font-weight: 800; }

/* Modal */
#stage .modal { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5,9,22,.8); }
#stage .mcard { width: 100%; max-width: 340px; max-height: 92%; overflow-y: auto; background: var(--panel); border: 2px solid var(--acc); border-radius: 16px; padding: 14px; touch-action: pan-y; }
#stage .mcard h2 { font-size: 18px; margin-bottom: 8px; }
#stage .mbody { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
#stage .mbody p { margin: 0; } #stage .mbody .lead { font-size: 18px; font-weight: 800; color: var(--gold); }
#stage .mbtns { margin-top: 12px; }
#stage .btn.tog { background: #1f2d5c; } #stage .btn.tog[aria-pressed="true"], #stage .btn.tog.on { background: #24607a; border-color: var(--acc); }

/* Landscape / wide stage: 3D on the left, sheet on the right */
#stage.wide #app { right: auto; width: 56%; height: 100%; }
#stage.wide #ctxlost, #stage.wide .badges { right: auto; width: 56%; height: 100%; }
#stage.wide .sheet { left: 56%; top: 0; border-radius: 0; border-top: 0; border-left: 2px solid var(--line); }
#stage.wide .boost { right: auto; left: calc(56% - 96px); top: auto; bottom: 12px; }
#stage.wide .evbtn { right: calc(44% + 10px); top: auto; bottom: 108px; }
#stage.wide .toasts { right: calc(44% + 10px); top: auto; bottom: 62px; }
#stage.wide .hud { right: 44%; }

.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; }
.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 .evbtn, #stage .tab.nudge { animation: none; } #stage .float { animation-duration: .01s; } }
#stage .sheet { padding-bottom: env(safe-area-inset-bottom, 0px); }
@media (prefers-reduced-motion: reduce) { #stage .gbox.ready { animation: none; } }

/* Full screen on phones: the shell already hides the title; drop the duplicate Play big bar, key hints and page chrome,
   and keep the HUD and tabs clear of the notch. */
html.pip-immersive .er-bar, html.pip-immersive .er-keys, html.pip-native .er-bar, html.pip-native .er-keys,
html.pip-immersive .ad-well, html.pip-immersive .er-guide, html.pip-immersive footer, html.pip-immersive #similar-games { display: none !important; }
html.pip-immersive #stage, html.pip-native #stage { overscroll-behavior: none; }
html.pip-immersive #stage #ui .hud, html.pip-native #stage #ui .hud { padding-top: max(0px, env(safe-area-inset-top, 0px)); }
html.pip-immersive #stage .sheet, html.pip-native #stage .sheet { padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
html.pip-native #stage { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
