/* Iron Lane Gym 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 { --org:#ff7a45; --org-d:#c2410c; --gold:#ffc21a; --ink:#1f2740; --paper:#fffaf0; --green:#2fae6b; --navy:#1c2236;
  position: relative; width: min(100%, calc(88vh * 0.5625)); width: min(100%, calc(88svh * 0.5625)); aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden;
  border-radius: 14px; background: #9ec9ef; 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; left: 0; right: 0; top: 0; height: 52%; touch-action: none; }
#stage #app canvas { display: block; width: 100%; height: 100%; }
#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; }
#stage button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#stage [hidden] { display: none !important; }

#stage #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#ff9a6b, #ffd9b8); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(120,50,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: 40px; height: 40px; border-radius: 50%; border: 6px solid rgba(255,255,255,.4); border-top-color: var(--gold); animation: igspin .8s linear infinite; }
@keyframes igspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; left: 10px; right: 10px; top: 30%; z-index: 40; background: rgba(28,34,54,.92); color: #fff; padding: 14px; border-radius: 12px; text-align: center; font-size: 14px; }

/* HUD */
#stage .hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: max(8px, env(safe-area-inset-top)) 8px 0 8px; pointer-events: none; }
#stage .hleft { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
#stage .cashbox { display: flex; align-items: baseline; gap: 8px; background: rgba(28,34,54,.78); color: #fff; padding: 4px 12px; border-radius: 12px; align-self: flex-start; }
#stage .cash { font-size: clamp(20px, 6.2vw, 28px); color: var(--gold); text-shadow: 0 2px 0 rgba(0,0,0,.35); }
#stage .rate { font-size: 12px; opacity: .9; white-space: nowrap; }
#stage .chiprow { display: flex; flex-wrap: wrap; gap: 4px; }
#stage .pill { background: rgba(255,255,255,.88); color: var(--ink); font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; }
#stage .pill.loc { background: rgba(255,122,69,.92); color: #fff; }
#stage .pausebtn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(28,34,54,.78); color: #fff; font-weight: 800; font-size: 16px; letter-spacing: 1px; pointer-events: auto; flex: none; }
#stage .chal { position: absolute; left: 8px; right: 8px; top: 74px; display: flex; align-items: center; gap: 8px; background: rgba(28,34,54,.82); color: #fff; padding: 6px 10px; border-radius: 12px; font-size: 12px; pointer-events: none; }
#stage .chal .ct { font-size: 18px; min-width: 42px; }
#stage .cbar { flex: 1; height: 10px; background: rgba(255,255,255,.2); border-radius: 6px; overflow: hidden; }
#stage .cbar i { display: block; height: 100%; width: 0; background: var(--gold); }
#stage .cs { color: var(--gold); font-weight: 800; letter-spacing: 2px; }
#stage .hint-bubble { position: absolute; left: 50%; top: 26%; transform: translateX(-50%); width: 88%; background: rgba(255,255,255,.96); color: var(--ink); font-weight: 700; font-size: 13px; text-align: center; padding: 8px 12px; border-radius: 14px; box-shadow: 0 4px 0 rgba(28,34,54,.3); pointer-events: none; }

/* floating buttons above the sheet */
#stage .fab { position: absolute; bottom: calc(48% + 8px); min-width: 96px; height: 48px; padding: 0 14px; border: 0; border-radius: 24px; font-weight: 800; font-size: 14px; color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.28); background: #7c8396; }
#stage .fab.pump { left: 8px; }
#stage .fab.collect { right: 8px; }
#stage .fab.pump.rdy { background: var(--org); animation: igpulse 1.2s ease-in-out infinite; }
#stage .fab.pump.on { background: #e04b6a; }
#stage .fab.collect.rdy { background: var(--green); animation: igpulse 1.4s ease-in-out infinite; }
@keyframes igpulse { 50% { transform: scale(1.05); } }

/* bottom sheet */
#stage .sheet { position: absolute; left: 0; right: 0; bottom: 0; height: 48%; display: flex; flex-direction: column; background: var(--paper); border-radius: 18px 18px 0 0; box-shadow: 0 -4px 14px rgba(0,0,0,.25); }
#stage .tabs { display: flex; gap: 4px; padding: 6px 6px 0; flex: none; }
#stage .tab { flex: 1; min-height: 44px; border: 0; border-radius: 12px 12px 0 0; background: #f0e3cf; color: #6b5a44; font-weight: 800; font-size: 13px; padding: 0 2px; }
#stage .tab.on { background: var(--org); color: #fff; }
#stage .sbody { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
#stage .panel { display: flex; flex-direction: column; gap: 6px; }
#stage .chips { display: flex; gap: 6px; overflow-x: auto; touch-action: pan-x; padding-bottom: 4px; flex: none; }
#stage .chip { flex: none; min-height: 44px; padding: 0 12px; border-radius: 22px; border: 2px solid #e5d3b8; background: #fff; color: var(--ink); font-weight: 700; font-size: 12px; white-space: nowrap; }
#stage .chip.sel { border-color: var(--org); background: #fff0e6; }
#stage .chip.lock { color: #8a8f9c; }
#stage .row { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid #efe2cb; border-radius: 12px; padding: 6px 8px; }
#stage .row.gone { display: none; }
#stage .info { flex: 1; min-width: 0; }
#stage .rt { font-weight: 800; font-size: 13px; }
#stage .rd { font-size: 11.5px; color: #5b6277; }
#stage .rbar { height: 6px; border-radius: 4px; background: #eadcc3; margin-top: 4px; overflow: hidden; }
#stage .rbar i { display: block; height: 100%; width: 0; background: var(--green); }
#stage .buy { flex: none; min-width: 84px; min-height: 44px; padding: 0 10px; border: 0; border-radius: 12px; font-weight: 800; font-size: 12.5px; color: #fff; }
#stage .buy.can { background: var(--green); box-shadow: 0 3px 0 #1d7a4a; }
#stage .buy.off { background: #aab0be; box-shadow: 0 3px 0 #8a90a0; }
#stage .sec { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
#stage .sec b { font-size: 14px; }
#stage .sec span { font-size: 11px; color: #6b7185; }
#stage .note { font-size: 11.5px; color: #5b6277; }

/* toasts + floaters */
#stage .toasts { position: absolute; left: 0; right: 0; top: 42%; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#stage .toast { background: rgba(28,34,54,.9); color: #fff; font-weight: 700; font-size: 12.5px; padding: 6px 12px; border-radius: 99px; max-width: 92%; text-align: center; animation: igtoast 2.6s ease-out forwards; }
#stage .toast.good { background: rgba(31,138,84,.95); }
#stage .toast.bad { background: rgba(190,60,70,.95); }
@keyframes igtoast { 0% { opacity: 0; transform: translateY(8px); } 10% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }
#stage .floats { position: absolute; left: 0; top: 0; width: 100%; height: 52%; pointer-events: none; overflow: hidden; }
#stage .fl { position: absolute; transform: translate(-50%, 0); color: var(--gold); font-weight: 900; font-size: 15px; text-shadow: 0 2px 0 rgba(0,0,0,.55); animation: igfloat 1.2s ease-out forwards; white-space: nowrap; }
#stage .fl.auto { color: #bfe9ff; font-size: 12px; }
@keyframes igfloat { 0% { opacity: 0; transform: translate(-50%, 6px); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -34px); } }

/* modal */
#stage .modal { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 14px; background: rgba(20,24,40,.6); }
#stage .mbox { width: 100%; max-width: 330px; max-height: 92%; overflow-y: auto; background: var(--paper); border-radius: 18px; padding: 16px; text-align: center; touch-action: pan-y; box-shadow: 0 8px 0 rgba(0,0,0,.25); }
#stage .mbox h2 { font-size: 20px; margin-bottom: 8px; }
#stage .mbox p { font-size: 13.5px; margin-bottom: 8px; color: #3b4258; }
#stage .mbtns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
#stage .mbtn { min-height: 46px; min-width: 100px; padding: 0 14px; border: 0; border-radius: 14px; background: #d9dce6; color: var(--ink); font-weight: 800; font-size: 14px; }
#stage .mbtn.go { background: var(--org); color: #fff; box-shadow: 0 3px 0 var(--org-d); }
#stage .stars { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; }
#stage .st { font-size: 40px; line-height: 1; color: #cfd3de; }
#stage .st.on { color: var(--gold); text-shadow: 0 2px 0 rgba(0,0,0,.25); }

@media (orientation: landscape) and (max-height: 520px) { #stage.is-big #app { height: 100%; width: 50%; right: auto; } #stage.is-big .sheet { left: 50%; height: 100%; border-radius: 0; } #stage.is-big .fab { bottom: 12px; } #stage.is-big .fab.collect { right: calc(50% + 8px); } #stage.is-big .floats { width: 50%; height: 100%; } }
@media (prefers-reduced-motion: reduce) { #stage * { animation: none !important; transition: none !important; } }

/* page chrome under the game */
.ig-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.ig-bar .btn { min-height: 44px; min-width: 44px; }
.ig-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.ig-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.ig-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.ig-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.ig-guide p { margin-bottom: .5rem; font-size: .95rem; }
#stage .goalbox { align-self: flex-start; max-width: 62vw; background: rgba(28,34,54,.78); color: #fff; font-size: 11px; font-weight: 700; padding: 4px 10px 6px; border-radius: 10px; }
#stage .goalbox[hidden] { display: none; }
#stage .goalbox .gt { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage .goalbox .gbar { height: 5px; margin-top: 3px; background: rgba(255,255,255,.25); border-radius: 3px; overflow: hidden; }
#stage .goalbox .gbar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .25s; }
#stage .goalbox.rdy .gbar i { background: #6fe39a; }
#stage .goalbox.rdy { box-shadow: 0 0 0 2px #6fe39a; }
#stage .tab.nudge { animation: nudgepulse 1s ease-in-out infinite; box-shadow: inset 0 0 0 2px var(--org); }
@keyframes nudgepulse { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* Full screen on phones (shell immersive + native): the stage fills the area below the dock, nothing scrolls. */
html.pip-immersive .game-wrap.pip-stage { overflow: hidden; padding: 0; }
html.pip-immersive .game-wrap.pip-stage .ig-bar, html.pip-immersive .game-wrap.pip-stage .ig-keys { display: none; }
html.pip-immersive .game-wrap.pip-stage #stage { width: 100%; max-width: none; height: calc(var(--pip-vvh, 100dvh) - var(--pip-dock-h, 52px)); aspect-ratio: auto; border-radius: 0; margin: 0; }
html.pip-immersive .game-wrap.pip-stage #stage .fab { min-height: 48px; }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive .game-wrap.pip-stage #stage #app { height: 100%; width: 50%; right: auto; }
  html.pip-immersive .game-wrap.pip-stage #stage .sheet { left: 50%; height: 100%; border-radius: 0; }
  html.pip-immersive .game-wrap.pip-stage #stage .fab { bottom: 12px; }
  html.pip-immersive .game-wrap.pip-stage #stage .fab.collect { right: calc(50% + 8px); }
  html.pip-immersive .game-wrap.pip-stage #stage .floats { width: 50%; height: 100%; }
}

/* Full screen v2: 3D view takes 70% (portrait) / 55% (landscape); the sheet keeps its own scroll area; the stage never scrolls. */
html.pip-immersive .game-wrap.pip-stage .game-title, html.pip-native .game-wrap.pip-stage .game-title { display: none; }
html.pip-immersive .game-wrap.pip-stage, html.pip-native .game-wrap.pip-stage { overflow: hidden; }
html.pip-immersive .game-wrap.pip-stage #stage #app { height: 70%; }
html.pip-immersive .game-wrap.pip-stage #stage .floats { height: 70%; }
html.pip-immersive .game-wrap.pip-stage #stage .sheet { height: 30%; }
html.pip-immersive .game-wrap.pip-stage #stage .fab { bottom: calc(30% + 8px); }
html.pip-immersive .game-wrap.pip-stage #stage .tabs { padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive .game-wrap.pip-stage #stage { height: var(--pip-vvh, 100dvh); }
  html.pip-immersive .game-wrap.pip-stage #stage #app { height: 100%; width: 55%; right: auto; }
  html.pip-immersive .game-wrap.pip-stage #stage .sheet { left: 55%; height: 100%; border-radius: 0; padding-right: env(safe-area-inset-right); }
  html.pip-immersive .game-wrap.pip-stage #stage .fab { bottom: calc(12px + env(safe-area-inset-bottom)); }
  html.pip-immersive .game-wrap.pip-stage #stage .fab.collect { right: calc(45% + 8px); }
  html.pip-immersive .game-wrap.pip-stage #stage .floats { width: 55%; height: 100%; }
}
