/* Idle Bakery 3D - 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 { --ink:#4a2f1d; --cream:#fff6e4; --crust:#d9822b; --crust-d:#a65d17; --berry:#c83e5e; --mint:#4fb07a; --card:#fffaf0; --line:#ecd9b8;
  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: #bfe3f5; 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; }
#stage *, #stage *::before, #stage *::after { box-sizing: border-box; }
#stage #app { position: absolute; left: 0; right: 0; top: 0; height: 46%; }
#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 .scr, #stage #ui input { 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 [hidden] { display: none !important; }
#stage .fatal { position: absolute; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; background: var(--cream); font-weight: 700; }

#stage #loader { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: linear-gradient(#ffe7bd, #f6b86b); pointer-events: none; }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .06em; }
#stage .load-in span { font-weight: 600; font-size: .85rem; letter-spacing: 0; }
#stage .spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid #fff9; border-top-color: var(--crust-d); animation: ibspin .8s linear infinite; }
@keyframes ibspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; left: 12px; right: 12px; top: 56px; z-index: 55; background: #fff; border-radius: 10px; padding: 10px 12px; font-size: .85rem; box-shadow: 0 4px 14px #0003; }

/* scene layer (top 46%) */
#stage .sl { position: absolute; left: 0; right: 0; top: 0; height: 46%; pointer-events: none; }
#stage .nogl { position: absolute; left: 10px; right: 10px; top: 56px; padding: 10px; background: #fffc; border-radius: 10px; font-size: .85rem; text-align: center; pointer-events: none; }
#stage.no3d #app { background: linear-gradient(#bfe3f5, #f3e6c8); }
#stage.no3d .chips { display: none; }
#stage .hud { position: absolute; left: 6px; right: 6px; top: 6px; display: flex; gap: 6px; align-items: flex-start; pointer-events: none; }
#stage .hl { flex: 1 1 auto; min-width: 0; } #stage .hm { display: flex; flex-direction: column; gap: 3px; } #stage .hr { display: flex; gap: 4px; }
#stage .pill { display: flex; align-items: baseline; gap: 5px; background: #fffd; border-radius: 12px; padding: 3px 9px; font-size: .78rem; box-shadow: 0 1px 4px #0002; white-space: nowrap; }
#stage .pill .k { opacity: .65; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; }
#stage .pill .v { font-size: 1.05rem; } #stage .pill.coin .v { font-size: 1.25rem; color: var(--crust-d); } #stage .pill .s { font-size: .72rem; color: var(--mint); font-weight: 700; }
#stage .btn2 { font-weight: 800; border: 0; border-radius: 12px; min-height: 44px; padding: 8px 12px; background: #fff; box-shadow: 0 2px 0 #0002; font-size: .86rem; }
#stage .btn2:disabled { opacity: .5; box-shadow: none; }
#stage .btn2.ico { min-width: 44px; padding: 0; font-size: 1.05rem; background: #fffe; }
#stage .btn2.buy { background: var(--crust); color: #fff; min-width: 96px; }
#stage .btn2.hire { background: var(--berry); color: #fff; }
#stage .btn2.go { background: var(--mint); color: #fff; min-height: 38px; padding: 4px 12px; }
#stage .btn2.mini { min-height: 32px; padding: 2px 10px; font-size: .75rem; background: #fff3; color: #fff; box-shadow: none; }
#stage .btn2.seg { min-height: 40px; padding: 6px 10px; background: #fff; border: 2px solid var(--line); box-shadow: none; }
#stage .btn2.seg.on { background: var(--crust); color: #fff; border-color: var(--crust-d); }
#stage .btn2.wide { width: 100%; margin-top: 8px; }
#stage .btn2.danger { color: #a01c2c; border-color: #e7b3b9; }
#stage .btn2.rush { width: 100%; background: #ffe2b8; border: 2px solid var(--crust); }
#stage .btn2.rush.hot { background: var(--crust); color: #fff; }
#stage .fab { position: absolute; right: 8px; bottom: 8px; width: 58px; height: 58px; min-height: 58px; border-radius: 50%; padding: 0; background: #e8d7bd; font-size: .8rem; pointer-events: auto; }
#stage .fab.ready { background: var(--berry); color: #fff; animation: ibpulse 1.4s ease-in-out infinite; }
#stage .fab.hot { background: var(--crust); color: #fff; }
@keyframes ibpulse { 50% { transform: scale(1.08); } }
#stage .chips { position: absolute; inset: 0; pointer-events: none; }
#stage .chip { position: absolute; transform: translate(-50%, -50%); min-width: 56px; min-height: 46px; padding: 3px 7px 5px; border: 2px solid #fff; border-radius: 12px; background: #4a2f1dd9; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 1px; pointer-events: auto; touch-action: manipulation; line-height: 1.05; }
#stage .chip .cn { font-weight: 800; font-size: .78rem; } #stage .chip .cl { font-size: .68rem; opacity: .9; }
#stage .chip .cb { width: 100%; height: 4px; border-radius: 3px; background: #fff3; overflow: hidden; }
#stage .chip .cb i { display: block; height: 100%; width: 0; background: #ffd66b; }
#stage .chip.off { background: #fff9; color: var(--ink); border-style: dashed; }
#stage .chip.auto { border-color: #8be28b; }
#stage .chip.hot { border-color: #ffb02e; box-shadow: 0 0 0 3px #ffb02e66; }
#stage .bobar { position: absolute; left: 6px; right: 76px; top: 44px; background: #fffe; border-radius: 10px; padding: 4px 8px; font-size: .74rem; pointer-events: none; }
#stage .bobar .bl { display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
#stage .bar { position: relative; height: 8px; border-radius: 5px; background: #0001; overflow: hidden; margin-top: 4px; }
#stage .bar.big { height: 12px; overflow: visible; }
#stage .bar i { display: block; height: 100%; width: 0; background: var(--mint); border-radius: 5px; }
#stage .bar u { position: absolute; top: -2px; bottom: -2px; width: 3px; background: #4a2f1d88; text-decoration: none; }
#stage .bar u.got { background: #ffb02e; }
#stage .hint { position: absolute; left: 8px; right: 76px; bottom: 8px; background: #4a2f1def; color: #fff; padding: 7px 10px; border-radius: 12px; font-size: .8rem; display: flex; gap: 8px; align-items: center; justify-content: space-between; pointer-events: auto; }
#stage .feed { position: absolute; left: 8px; right: 76px; top: 44px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; pointer-events: none; }
#stage .m-bo .feed { top: 84px; }
#stage .toast { background: #fffe; padding: 4px 10px; border-radius: 10px; font-size: .76rem; font-weight: 700; animation: ibin .2s ease-out; }
#stage .toast.good { background: #d9f6df; } #stage .toast.warn { background: #ffe0d6; }
@keyframes ibin { from { opacity: 0; transform: translateY(-6px); } }

/* bottom sheet */
#stage .sheet { position: absolute; left: 0; right: 0; bottom: 0; height: 54%; display: flex; flex-direction: column; background: var(--cream); border-radius: 16px 16px 0 0; box-shadow: 0 -3px 12px #0003; z-index: 5; }
#stage .tabs { display: flex; gap: 2px; padding: 6px 6px 0; flex: 0 0 auto; }
#stage .tab { flex: 1 1 0; min-height: 44px; min-width: 0; border: 0; border-radius: 10px 10px 0 0; background: #f0e0c2; font-weight: 800; font-size: .74rem; position: relative; padding: 0 2px; }
#stage .tab.on { background: var(--card); box-shadow: inset 0 3px 0 var(--crust); }
#stage .tab .dot { position: absolute; top: 5px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--berry); }
#stage .tbody { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; -webkit-overflow-scrolling: touch; background: var(--card); overscroll-behavior: contain; }
#stage .pane { padding: 8px 10px 18px; display: flex; flex-direction: column; gap: 6px; }
#stage h4 { font-size: .85rem; margin: 8px 0 0; text-transform: uppercase; letter-spacing: .05em; color: var(--crust-d); }
#stage .card { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; }
#stage .bestbuy { display: flex; gap: 8px; align-items: center; font-size: .8rem; }
#stage .bestbuy .bb-t { flex: 1 1 auto; min-width: 0; }
#stage .segs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; } #stage .lbl { font-size: .78rem; font-weight: 700; margin-right: 4px; }
#stage .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 6px 8px; }
#stage .rl { display: flex; gap: 8px; align-items: center; min-width: 0; flex: 1 1 auto; } #stage .rm { min-width: 0; flex: 1 1 auto; }
#stage .rb { display: flex; flex-direction: column; gap: 4px; align-items: stretch; flex: 0 0 auto; }
#stage .r1 { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; font-size: .86rem; } #stage .r2 { font-size: .72rem; color: #7a6048; display: block; }
#stage .lv { font-size: .74rem; color: var(--crust-d); font-weight: 700; }
#stage .tag { font-size: .62rem; background: #ffb02e; color: #4a2f1d; border-radius: 6px; padding: 1px 5px; font-weight: 800; }
#stage .mgr { font-size: .7rem; color: var(--mint); font-weight: 800; text-align: center; }
#stage .sw { width: 22px; height: 22px; border-radius: 6px; flex: 0 0 22px; border: 2px solid #0002; } #stage .sw.round { border-radius: 50%; }
#stage .stars { color: #e8a40f; letter-spacing: 1px; font-size: .8rem; }
#stage .row.od .bar { margin-top: 3px; }
#stage .note { font-size: .74rem; color: #7a6048; } #stage .big { font-size: 1.15rem; font-weight: 800; }
#stage .row.ac { opacity: .55; } #stage .row.ac.done { opacity: 1; background: #f1fbe9; }

/* full screen panels */
#stage .scr { position: absolute; inset: 0; z-index: 30; background: #2a190ccc; display: flex; align-items: center; justify-content: center; padding: 14px; }
#stage .scr .box { width: 100%; max-width: 330px; max-height: 100%; overflow-y: auto; touch-action: pan-y; background: var(--cream); border-radius: 18px; padding: 16px; text-align: center; box-shadow: 0 8px 28px #0006; }
#stage .scr .box.tall { text-align: left; }
#stage .scr h3 { font-size: 1.25rem; margin-bottom: 6px; text-align: center; }
#stage .scr .goal { margin: 8px 0; font-weight: 700; font-size: .86rem; }
#stage .rs { font-size: 2rem; letter-spacing: 6px; color: #cdb892; } #stage .rs .on { color: #f2b01e; text-shadow: 0 1px 0 #a66d00; }
#stage .srow { display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 700; margin: 4px 0; }
#stage .srow span:first-child { flex: 0 0 64px; } #stage .srow input { flex: 1 1 auto; min-height: 44px; touch-action: pan-x; } #stage .sv { flex: 0 0 38px; text-align: right; font-size: .75rem; }

.ib-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.ib-bar .btn { min-height: 44px; min-width: 44px; }
.ib-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.ib-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.ib-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.ib-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.ib-guide p { margin-bottom: .5rem; font-size: .95rem; }

/* streak badge, first-tap nudge, safe areas, reduced motion */
#stage .streak { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); z-index: 6; padding: 4px 14px; border-radius: 999px; background: #c83e5ee6; color: #fff; font-weight: 800; font-size: 1rem; letter-spacing: .02em; pointer-events: none; box-shadow: 0 2px 0 #7d1f37; }
#stage .streak[hidden] { display: none; }
#stage .streak.pop { animation: ibpop .25s ease-out; }
@keyframes ibpop { 0% { transform: translateX(-50%) scale(1.35); } 100% { transform: translateX(-50%) scale(1); } }
#stage .chip.nudge { animation: ibnudge 1.1s ease-in-out infinite; border-color: #ffd66b; }
@keyframes ibnudge { 0%, 100% { box-shadow: 0 0 0 0 #ffd66bcc; } 50% { box-shadow: 0 0 0 10px #ffd66b00; } }
#stage .hud { padding-top: max(0px, env(safe-area-inset-top)); }
#stage.is-big .sheet { padding-bottom: env(safe-area-inset-bottom); }
#stage .hint { bottom: max(8px, env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) {
  #stage .streak.pop, #stage .chip.nudge, #stage .spinner { animation: none; }
  #stage * { transition-duration: 0s !important; }
}

/* ---- pass 3: full screen fit, landscape split, finish ---- */
.ib-bar { display: none; }
html.pip-immersive .ib-keys, html.pip-immersive .game-header, html.pip-immersive .ad-well, html.pip-immersive .ib-guide, html.pip-immersive #similar-games, html.pip-immersive footer { display: none !important; }
html.pip-immersive .game-wrap { display: flex; flex-direction: column; }
html.pip-immersive #stage { flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; height: auto; aspect-ratio: auto; border-radius: 0; margin: 0; }
html.pip-immersive #stage .sheet { padding-bottom: env(safe-area-inset-bottom); }
#stage #app::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 40%, transparent 55%, #4a2f1d38 100%), linear-gradient(#fff4d838, transparent 35%); }
#stage .sheet { box-shadow: 0 -6px 18px #4a2f1d40, 0 -1px 0 #fff8 inset; }
#stage .btn2:active:not(:disabled) { transform: translateY(1px) scale(.98); box-shadow: 0 1px 0 #0002; }
#stage .btn2, #stage .tab { transition: transform .12s ease, background-color .15s ease; }
@media (orientation: landscape) and (max-height: 560px) {
  html.pip-immersive #stage #app, html.pip-immersive #stage .sl { width: 50%; height: 100%; right: auto; }
  html.pip-immersive #stage .sheet { left: 50%; height: 100%; border-radius: 16px 0 0 16px; box-shadow: -4px 0 14px #4a2f1d40; }
  html.pip-immersive #stage .hud { right: calc(50% + 6px); }
  html.pip-immersive #stage .bobar, html.pip-immersive #stage .feed, html.pip-immersive #stage .hint { right: calc(50% + 6px); }
  html.pip-immersive #stage .fab { right: calc(50% + 8px); }
  html.pip-immersive #stage .streak { left: 25%; }
}
