/* Moonlit Heist 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 { --ink:#e8ecff; --mute:#9aa6d0; --bg:#12172b; --card:#1d2440; --card2:#262f52; --line:#3a4672; --gold:#ffc94a; --acc:#8b7bff; --good:#4ad46a; --bad:#ff5a4a;
  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: #12172b; 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; }
.game-wrap.pip-stage #stage { width: min(100%, calc((100vh - 64px) * 0.5625)); width: min(100%, calc((100svh - 64px) * 0.5625)); }
#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; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; color: inherit; }
#stage button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#stage [hidden] { display: none !important; }

#stage #loader { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: #12172b; }
#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; }
#stage .load-in span { font-size: 14px; opacity: .85; }
#stage .spinner { width: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.2); border-top-color: var(--gold); animation: shspin .8s linear infinite; }
@keyframes shspin { to { transform: rotate(360deg); } }
#stage #ctxlost, #stage #nogl { position: absolute; inset: 0; z-index: 55; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(14,18,40,.92); color: #fff; font-weight: 700; }

/* ---- play surface ---- */
#stage .zone { position: absolute; left: 0; right: 0; top: 56px; bottom: 0; touch-action: none; }
#stage .stick-base { position: absolute; width: 108px; height: 108px; margin: -54px 0 0 -54px; border-radius: 50%; background: rgba(255,255,255,.09); border: 2px solid rgba(255,255,255,.35); pointer-events: none; z-index: 3; }
#stage .stick-ring { position: absolute; inset: 15px; border-radius: 50%; border: 2px dashed rgba(255,201,74,.7); }
#stage .stick-knob { position: absolute; left: 31px; top: 31px; width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.7); box-shadow: 0 2px 8px rgba(0,0,0,.4); }
#stage .hud { position: absolute; left: 0; right: 0; top: 0; z-index: 4; pointer-events: none; padding: 6px 8px 0; }
#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 var(--line); background: rgba(20,26,52,.85); font-weight: 800; font-size: 16px; }
#stage .hud-mid { flex: 1; min-width: 0; text-align: center; text-shadow: 0 2px 4px rgba(0,0,0,.7); }
#stage .hud-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage .hud-time { font-size: 12px; color: var(--mute); }
#stage .hud-gems { min-width: 58px; text-align: center; padding: 8px 10px; border-radius: 12px; background: rgba(20,26,52,.85); border: 2px solid var(--line); color: #6ae7ff; font-weight: 800; font-size: 14px; }
#stage .alert-bar { margin: 6px 8px 0; height: 8px; border-radius: 6px; background: rgba(0,0,0,.45); overflow: hidden; }
#stage .alert-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffd84a, #ff7a2a); transition: width .1s linear; }
#stage .alert-bar.hot .alert-fill { background: #ff3b30; }
#stage .btns { position: absolute; right: 10px; bottom: 12px; z-index: 5; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
#stage .btns.left { right: auto; left: 10px; align-items: flex-start; }
#stage .act-btn { width: 84px; height: 84px; border-radius: 50%; border: 3px solid #fff; background: rgba(139,123,255,.9); font-size: 17px; font-weight: 900; display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; box-shadow: 0 4px 10px rgba(0,0,0,.4); }
#stage .act-btn.ready { background: #ffb02e; color: #2a1c00; animation: shpulse .9s ease-in-out infinite; }
#stage .act-btn.down, #stage .gad-btn.down { transform: scale(.94); filter: brightness(1.15); }
#stage .act-sub { font-size: 9px; font-weight: 700; line-height: 1.05; max-width: 70px; text-align: center; }
#stage .gad-btn { position: relative; width: 62px; height: 62px; border-radius: 50%; border: 2px solid #fff; background: rgba(40,50,90,.9); font-size: 10px; font-weight: 800; touch-action: none; }
#stage .gad-btn:disabled { opacity: .35; }
#stage .badge { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--gold); color: #1a1200; font-style: normal; font-size: 12px; font-weight: 900; line-height: 22px; text-align: center; }
@keyframes shpulse { 50% { transform: scale(1.06); } }
#stage .pick-bar { width: 84px; height: 10px; border-radius: 6px; background: rgba(0,0,0,.55); overflow: hidden; border: 1px solid #fff; }
#stage .pick-fill { height: 100%; width: 0; background: #ffb02e; }
#stage .hint { position: absolute; left: 12px; right: 12px; top: 74px; z-index: 6; padding: 10px 12px; border-radius: 12px; background: rgba(20,26,52,.92); border: 2px solid var(--gold); font-size: 13px; font-weight: 700; text-align: center; pointer-events: none; }
#stage .feed { position: absolute; left: 12px; top: 118px; z-index: 6; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
#stage .feed-item { padding: 4px 10px; border-radius: 10px; background: rgba(20,26,52,.85); font-size: 12px; font-weight: 700; animation: shfade 2.3s forwards; }
#stage .feed-item.gem { color: #6ae7ff; } #stage .feed-item.warn { color: #ffb02e; }
@keyframes shfade { 0%,80% { opacity: 1; } 100% { opacity: 0; } }
#stage .banner { position: absolute; left: 0; right: 0; top: 34%; z-index: 7; text-align: center; pointer-events: none; text-shadow: 0 3px 6px rgba(0,0,0,.8); display: flex; flex-direction: column; gap: 2px; }
#stage .banner b { font-size: 28px; letter-spacing: 1px; } #stage .banner span { font-size: 13px; }
#stage .flash { position: absolute; inset: 0; z-index: 8; pointer-events: none; }

/* ---- screens ---- */
#stage .screens { position: absolute; inset: 0; z-index: 20; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; -webkit-overflow-scrolling: touch; background: rgba(10,13,30,.82); padding: 12px; display: flex; }
#stage .panel { margin: auto; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 16px; background: rgba(29,36,64,.96); border: 2px solid var(--line); }
#stage .panel h2 { font-size: 20px; text-align: center; letter-spacing: 1px; }
#stage .title-panel { background: rgba(18,23,43,.92); text-align: center; }
#stage .logo { display: flex; flex-direction: column; align-items: center; line-height: 1; padding-top: 6px; }
#stage .logo b { font-size: clamp(30px, 10vw, 44px); letter-spacing: 4px; color: #fff; text-shadow: 0 3px 0 #4a3fb0; }
#stage .logo b.sub { font-size: clamp(16px, 5vw, 22px); letter-spacing: 8px; color: var(--gold); text-shadow: none; margin-top: 4px; }
#stage .moon { width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff7d6, #ffd36a); box-shadow: 0 0 22px rgba(255,211,106,.7); margin-bottom: 6px; }
#stage .tag { font-size: 12px; color: var(--mute); }
#stage .wallet { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#stage .chip { display: inline-block; padding: 5px 10px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); font-size: 12px; font-weight: 700; }
#stage .chip.coin { color: var(--gold); }
#stage .rankbar { height: 6px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; }
#stage .rankbar div { height: 100%; background: var(--acc); }
#stage .btn { min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card2); font-size: 15px; font-weight: 800; text-align: center; }
#stage .btn.primary { background: var(--acc); border-color: #c4baff; color: #12092f; }
#stage .btn.lg { min-height: 54px; font-size: 17px; }
#stage .btn.ghost { background: transparent; }
#stage .btn.locked { opacity: .5; }
#stage .btn:disabled { opacity: .4; }
#stage .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#stage .row3 .btn { font-size: 13px; padding: 10px 4px; }
#stage .fine { font-size: 12px; color: var(--mute); text-align: center; }
#stage .big { font-size: 17px; font-weight: 800; text-align: center; }
#stage .help { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
#stage .district { display: flex; flex-direction: column; gap: 6px; }
#stage .district h3 { font-size: 15px; color: var(--dc); display: flex; flex-direction: column; }
#stage .district h3 small { font-size: 11px; color: var(--mute); font-weight: 400; }
#stage .lvgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .lvcard { min-height: 66px; padding: 6px; border-radius: 12px; border: 2px solid var(--line); background: var(--card2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 12px; }
#stage .lvcard b { font-size: 14px; color: var(--gold); } #stage .lvcard .nm { font-size: 12px; }
#stage .lvcard.shut, #stage .district.shut .lvcard { opacity: .45; }
#stage .lvcard .lock { font-size: 11px; color: var(--mute); }
#stage .stars { letter-spacing: 2px; color: #55618f; font-size: 15px; }
#stage .stars i { font-style: normal; } #stage .stars i.on { color: var(--gold); }
#stage .stars.huge { font-size: 40px; text-align: center; letter-spacing: 8px; }
#stage .goals { list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
#stage .goals li { display: flex; gap: 8px; align-items: center; } #stage .goals li i { font-style: normal; color: #55618f; } #stage .goals li.done i { color: var(--gold); }
#stage .tip { font-size: 13px; padding: 8px 10px; background: rgba(255,201,74,.1); border-left: 3px solid var(--gold); border-radius: 6px; }
#stage .kv { display: flex; flex-direction: column; gap: 4px; font-size: 14px; } #stage .kv div { display: flex; justify-content: space-between; }
#stage .rewards { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#stage .bannerline { text-align: center; font-size: 13px; font-weight: 800; color: var(--gold); }
#stage .goal { text-align: center; font-size: 13px; color: #b8c4ff; }
#stage .shoprow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border-radius: 12px; background: var(--card2); }
#stage .shoprow .info { display: flex; flex-direction: column; gap: 2px; min-width: 0; } #stage .shoprow .info .fine { text-align: left; }
#stage .pips { display: flex; gap: 4px; } #stage .pips i { width: 14px; height: 6px; border-radius: 3px; background: #3a4672; } #stage .pips i.on { background: var(--gold); }
#stage .buy { white-space: nowrap; min-width: 84px; font-size: 13px; }
#stage .outfits { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .outfit { min-height: 84px; border-radius: 12px; border: 2px solid var(--line); background: var(--card2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px; }
#stage .outfit.equipped { border-color: var(--gold); } #stage .outfit.locked { opacity: .45; } #stage .outfit small { font-size: 11px; color: var(--mute); }
#stage .swatch { width: 30px; height: 30px; border-radius: 50%; border: 4px solid; }
#stage .ach { list-style: none; display: flex; flex-direction: column; gap: 6px; }
#stage .ach li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; background: var(--card2); font-size: 12px; }
#stage .ach li div { flex: 1; display: flex; flex-direction: column; } #stage .ach li span { color: var(--mute); } #stage .ach li i { font-style: normal; font-size: 16px; color: #55618f; } #stage .ach li.done i { color: var(--good); } #stage .ach li em { font-style: normal; color: var(--gold); font-weight: 800; }
#stage .setrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 700; }
#stage .seg { display: flex; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
#stage .seg button { min-height: 44px; min-width: 52px; padding: 0 10px; border: 0; background: var(--card2); font-size: 13px; font-weight: 700; } #stage .seg button.on { background: var(--acc); color: #12092f; }

@media (max-height: 560px) { #stage .btns { gap: 6px; } #stage .act-btn { width: 72px; height: 72px; } #stage .gad-btn { width: 54px; height: 54px; } }
#stage.is-big .panel { max-width: 460px; }
@media (prefers-reduced-motion: reduce) { #stage .act-btn.ready, #stage .feed-item { animation: none; } }

.sh-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.sh-bar .btn { min-height: 44px; min-width: 44px; }
.sh-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.sh-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.sh-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.sh-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.sh-guide p { margin-bottom: .5rem; font-size: .95rem; }
#stage .hud-time.late { color: #ffb347; }
#stage .hud { padding-top: max(6px, env(safe-area-inset-top)); padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
#stage .btns { bottom: max(12px, env(safe-area-inset-bottom)); }
#stage .screens { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
#stage .hud-time { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { #stage .flash { transition: none; } #stage .banner, #stage .hint { animation: none; } }

/* ---- shell full screen: fill the stage under the dock, no duplicate controls ---- */
html.pip-immersive .game-wrap { display: flex; flex-direction: column; align-items: stretch; max-width: none; padding: 0; margin: 0; }
html.pip-immersive .game-wrap #stage { flex: 1 1 auto; min-height: 0; width: 100%; height: auto; max-width: none; aspect-ratio: auto; border-radius: 0; margin: 0; }
html.pip-immersive .game-wrap > .sh-bar, html.pip-immersive .game-wrap > .sh-keys, html.pip-immersive .game-wrap > noscript, html.pip-immersive .game-wrap > .game-title { display: none; }
html.pip-immersive #stage .hud { padding-top: max(6px, env(safe-area-inset-top, 0px)); padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
html.pip-immersive #stage .btns { right: max(10px, env(safe-area-inset-right, 0px)); bottom: max(12px, env(safe-area-inset-bottom, 0px)); }
html.pip-immersive #stage .zone { top: calc(56px + env(safe-area-inset-top, 0px)); }
