/* Idle Pizza Shop 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 { --tom: #d9452c; --tom-d: #a8301d; --crust: #f2b84b; --crust-d: #c98a1c; --cream: #fff4dc; --ink: #3a2418; --basil: #3f9d4a; --mute: #7a604f;
  position: relative; width: min(100%, calc(82vh * 0.5625)); width: min(100%, calc(82svh * 0.5625)); aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden;
  border-radius: 14px; background: var(--cream); 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; }
#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 button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
#stage button:focus-visible { outline: 3px solid #1a73e8; outline-offset: 2px; }

#stage #app { position: absolute; left: 0; top: 0; right: 0; height: 45%; background: #9fd4ff; }
#stage #app canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage .viewfx { position: absolute; left: 0; top: 0; right: 0; height: 45%; pointer-events: none; overflow: hidden; }
#stage .dock { position: absolute; left: 0; right: 0; top: 45%; bottom: 0; display: flex; flex-direction: column; gap: 6px; padding: 6px; pointer-events: auto; background: var(--cream); border-top: 3px solid var(--tom); }
#stage.land #app, #stage.land .viewfx { right: auto; width: 58%; height: 100%; }
#stage.land .dock { left: 58%; top: 0; border-top: 0; border-left: 3px solid var(--tom); }

#stage #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#d9452c, #f2b84b); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(90,20,10,.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: #fff; animation: ipspin .8s linear infinite; }
@keyframes ipspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; left: 0; right: 0; top: 0; height: 45%; z-index: 40; display: flex; align-items: center; justify-content: center; text-align: center; padding: 18px; background: rgba(58,36,24,.88); color: #fff; font-weight: 700; font-size: 14px; pointer-events: none; }

/* HUD */
#stage .hud { position: absolute; left: 0; right: 0; top: 0; padding: 6px 8px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 4px; pointer-events: none; }
#stage .hud-l { display: flex; flex-direction: column; background: rgba(255,244,220,.9); border-radius: 12px; padding: 3px 10px; border: 2px solid var(--ink); }
#stage .cash { font-size: clamp(20px, 6.4vw, 28px); font-weight: 900; line-height: 1; color: var(--tom-d); }
#stage .rate { font-size: 11px; font-weight: 800; color: var(--basil); }
#stage .hud-r { display: flex; gap: 6px; pointer-events: auto; }
#stage .chips { position: absolute; left: 8px; bottom: 6px; right: 80px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
#stage .chip { background: rgba(58,36,24,.78); color: #fff; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 10px; }
#stage .chip:empty { display: none; }
#stage .rushbar { position: absolute; left: 8px; right: 78px; bottom: 6px; display: flex; align-items: center; gap: 8px; background: rgba(58,36,24,.82); color: #fff; padding: 4px 8px; border-radius: 12px; pointer-events: auto; }
#stage .timer { font-size: 22px; font-weight: 900; min-width: 52px; }
#stage .score { font-size: 16px; font-weight: 800; color: var(--crust); flex: 1; }
#stage .pips { font-size: 18px; color: var(--crust); letter-spacing: 2px; }
#stage .btn { min-height: 44px; min-width: 44px; border: 2px solid var(--ink); border-radius: 12px; background: #fff; color: var(--ink); font-weight: 800; font-size: 13px; padding: 4px 12px; box-shadow: 0 3px 0 var(--ink); }
#stage .btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
#stage .btn:disabled { opacity: .55; cursor: default; }
#stage .btn.ico { width: 44px; padding: 0; font-size: 16px; }
#stage .btn.exitfs { display: none; }
#stage.is-big .btn.exitfs { display: inline-block; }
#stage .btn.quit { width: auto; padding: 0 10px; font-size: 12px; }
#stage .btn.go { background: var(--tom); color: #fff; box-shadow: 0 3px 0 var(--tom-d); border-color: var(--tom-d); }
#stage .btn.go:disabled { background: #c9b8aa; box-shadow: 0 3px 0 #9d8a7b; border-color: #9d8a7b; }
#stage .btn.full { width: 100%; }
#stage .btn.danger { color: #a8301d; }
#stage .btn.buy { min-width: 84px; background: #efe3cc; font-size: 12px; box-shadow: 0 2px 0 var(--ink); }
#stage .btn.buy.can { background: var(--basil); color: #fff; }
#stage .btn.buy.done { background: #e4ddd0; color: var(--mute); box-shadow: none; }

#stage .boost { position: absolute; right: 8px; bottom: 8px; width: 62px; height: 62px; border-radius: 50%; border: 3px solid var(--ink); background: #c9b8aa; color: var(--ink); font-weight: 900; font-size: 12px; pointer-events: auto; box-shadow: 0 4px 0 var(--ink); touch-action: manipulation; }
#stage .boost.ready { background: var(--crust); animation: ipPulse 1s ease-in-out infinite; }
#stage .boost.live { background: var(--tom); color: #fff; }
@keyframes ipPulse { 50% { transform: scale(1.08); } }
#stage .hint { position: absolute; left: 8px; right: 80px; bottom: 40px; background: rgba(255,244,220,.95); border: 2px solid var(--ink); border-radius: 12px; padding: 6px 10px; font-size: 12px; font-weight: 800; }
#stage .toasts { position: absolute; left: 0; right: 0; top: 54px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#stage .toast { background: rgba(58,36,24,.92); color: #fff; padding: 5px 12px; border-radius: 12px; font-size: 12px; font-weight: 800; max-width: 92%; text-align: center; animation: ipIn .25s ease-out; }
#stage .toast.good { background: var(--basil); }
@keyframes ipIn { from { opacity: 0; transform: translateY(-6px); } }
#stage .pops { position: absolute; inset: 0; }
#stage .pop { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 16px; color: #fff; text-shadow: 0 2px 0 var(--tom-d), 0 0 6px rgba(0,0,0,.4); animation: ipFloat .9s ease-out forwards; white-space: nowrap; }
#stage .pop.ride { color: var(--crust); }
#stage .pop.gone { opacity: 0; animation: none; }
@keyframes ipFloat { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -38px; } }
#stage .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#stage .flash.on { animation: ipFlash .6s ease-out; }
@keyframes ipFlash { 0% { opacity: .75; } 100% { opacity: 0; } }

/* dock */
#stage .stations { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#stage .sbtn { min-height: 52px; border: 2px solid var(--ink); border-radius: 12px; background: #fff; box-shadow: 0 3px 0 var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px; touch-action: none; }
#stage .sbtn b { font-size: 12px; }
#stage .s-sub { font-size: 10px; white-space: nowrap; color: var(--mute); font-weight: 700; }
#stage .sbtn.hot { background: #ffe9a8; }
#stage .sbtn.auto { background: #dff1d6; }
#stage .sbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
#stage .tabs { display: flex; gap: 4px; }
#stage .tab { flex: 1; min-width: 0; padding: 4px 2px; box-shadow: none; font-size: 12px; background: #efe3cc; }
#stage .tab.on { background: var(--tom); color: #fff; border-color: var(--tom-d); }
#stage .panel { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#stage .panel .plist { display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; flex: none; background: none; }
#stage .rushinfo { padding: 8px; font-size: 12px; font-weight: 700; color: var(--mute); text-align: center; }
#stage .sec { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--tom-d); margin: 6px 2px 0; }
#stage .row { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 12px; padding: 6px 8px; border: 2px solid #ead9bb; }
#stage .row.locked { opacity: .55; }
#stage .r-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#stage .r-title { font-size: 13px; }
#stage .r-sub { font-size: 11px; color: var(--mute); font-weight: 600; }
#stage .chip { flex: none; }
#stage .row > .chip { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); padding: 0; }
#stage .tag { font-size: 11px; font-weight: 900; color: var(--mute); min-width: 70px; text-align: center; }
#stage .tag.ok { color: var(--basil); }
#stage .note { font-size: 12px; color: var(--mute); font-weight: 600; margin: 2px 2px; }
#stage .card { display: flex; flex-direction: column; gap: 6px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 8px 10px; text-align: left; }
#stage .bar { height: 12px; border-radius: 8px; background: #ead9bb; overflow: hidden; }
#stage .bar.thin { height: 6px; }
#stage .bar i { display: block; height: 100%; width: 0; background: var(--basil); }

/* modal */
#stage .modal { position: absolute; inset: 0; z-index: 30; background: rgba(58,36,24,.72); display: flex; align-items: center; justify-content: center; padding: 10px; pointer-events: auto; }
#stage .modal-box { width: 100%; max-width: 360px; max-height: 96%; overflow-y: auto; touch-action: pan-y; background: var(--cream); border: 3px solid var(--ink); border-radius: 18px; padding: 14px; box-shadow: 0 6px 0 var(--ink); text-align: center; }
#stage .modal-in { display: flex; flex-direction: column; gap: 8px; }
#stage .modal-in h2 { font-size: 22px; color: var(--tom-d); }
#stage .modal-in p { font-size: 13px; font-weight: 600; }
#stage .big { font-size: 32px !important; font-weight: 900 !important; color: var(--tom-d); line-height: 1.1; }
#stage .big.stars { color: var(--crust-d); letter-spacing: 4px; }
#stage .gain { color: var(--basil); font-weight: 900 !important; }
#stage .tip { background: #fff; border-radius: 10px; padding: 6px 8px; border: 2px dashed var(--crust-d); }
#stage .label { font-size: 12px; font-weight: 800; text-align: left; }
#stage .seg { display: flex; gap: 6px; } #stage .seg .btn { flex: 1; }
#stage .seg .btn.on { background: var(--tom); color: #fff; }
#stage .lvls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#stage .lvl { display: flex; flex-direction: column; align-items: center; padding: 2px; min-width: 0; }
#stage .lvl b { font-size: 16px; } #stage .lvl span { font-size: 9px; color: var(--crust-d); }
#stage .lvl.off { opacity: .5; }
#stage .tips { text-align: left; font-size: 13px; font-weight: 600; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
#stage .modal-in.roomy { gap: 6px; }

@media (prefers-reduced-motion: reduce) { #stage * { animation: none !important; transition: none !important; } }

/* inside the site's own game shell (native or immersive full screen) the stage fills the space left by the shell dock */
.game-wrap.pip-stage #stage { width: 100%; max-width: none; aspect-ratio: auto; height: calc(var(--pip-vvh, 100dvh) - var(--pip-dock-h, 56px) - 24px); min-height: 320px; }
html.pip-immersive .ip-bar, html.pip-immersive .ip-keys, html.pip-native .ip-bar, html.pip-native .ip-keys { display: none; }

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

/* next upgrade strip */
#stage .nextbuy { position: relative; flex: none; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 12px; border: 2px solid var(--ink); border-radius: 12px; background: #efe3cc; overflow: hidden; font-size: 13px; font-weight: 800; color: var(--ink); text-align: left; }
#stage .nextbuy i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #cfe6bd; transition: width .25s linear; }
#stage .nextbuy .nx-t, #stage .nextbuy .nx-c { position: relative; }
#stage .nextbuy .nx-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stage .nextbuy.can { background: var(--crust); box-shadow: 0 3px 0 var(--ink); animation: ipPulse 1.2s ease-in-out infinite; }
#stage .nextbuy.can i { background: transparent; }
#stage .nextbuy:disabled { opacity: .7; }
#stage .nextbuy[hidden] { display: none !important; }
#stage .dock { padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
#stage.is-big .hud { padding-top: calc(6px + env(safe-area-inset-top, 0px)); padding-left: calc(8px + env(safe-area-inset-left, 0px)); padding-right: calc(8px + env(safe-area-inset-right, 0px)); }

/* full screen on phones: the stage takes all the room under the dock, the page extras go away */
html.pip-immersive .game-wrap.pip-stage, html.pip-native .game-wrap.pip-stage { display: flex; flex-direction: column; overflow: hidden; }
html.pip-immersive .game-wrap.pip-stage #stage, html.pip-native .game-wrap.pip-stage #stage { flex: 1 1 auto; height: auto; min-height: 0; width: 100%; max-width: none; margin: 0; border-radius: 12px; }
html.pip-native .game-wrap.pip-stage #stage { border-radius: 0; }
html.pip-immersive .game-wrap #bigbtn, html.pip-native .game-wrap #bigbtn, #stage:fullscreen ~ .ip-bar { display: none; }
html.pip-immersive .game-header, html.pip-immersive .ad-well, html.pip-immersive .ip-guide, html.pip-immersive #similar-games, html.pip-immersive footer { display: none; }
@media (orientation: landscape) and (max-height: 520px) { #stage.land .dock { padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); } }

/* full screen on phones: the 3D shop gets most of the stage, the order dock is compact and its list scrolls on its own */
html.pip-immersive #stage, html.pip-native #stage { --vw: 70%; }
html.pip-immersive #stage #app, html.pip-native #stage #app, html.pip-immersive #stage .viewfx, html.pip-native #stage .viewfx, html.pip-immersive #stage #ctxlost, html.pip-native #stage #ctxlost { height: var(--vw); }
html.pip-immersive #stage .dock, html.pip-native #stage .dock { top: var(--vw); gap: 4px; padding-top: 4px; }
html.pip-immersive #stage .sbtn, html.pip-native #stage .sbtn { min-height: 48px; }
html.pip-immersive #stage .tab, html.pip-native #stage .tab { min-height: 44px; }
html.pip-immersive #stage .panel, html.pip-native #stage .panel { min-height: 44px; }
html.pip-immersive #stage .rushinfo, html.pip-native #stage .rushinfo { padding: 2px; }
html.pip-immersive #stage.land #app, html.pip-native #stage.land #app, html.pip-immersive #stage.land .viewfx, html.pip-native #stage.land .viewfx, html.pip-immersive #stage.land #ctxlost, html.pip-native #stage.land #ctxlost { width: 64%; height: 100%; right: auto; }
html.pip-immersive #stage.land .dock, html.pip-native #stage.land .dock { left: 64%; top: 0; }
@media (orientation: landscape) and (max-height: 520px) { html.pip-immersive #stage.land .sbtn, html.pip-native #stage.land .sbtn { min-height: 44px; } html.pip-immersive #stage.land .tab, html.pip-native #stage.land .tab { min-height: 44px; } }
