/* Pinfall Alley 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:#f3effc; --bg:#14102a; --panel:rgba(20,16,42,.93); --orange:#ff9d2e; --teal:#37c8ff; --pink:#ff4fd8; --green:#53e08a; --dim:#a79fc4;
  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: linear-gradient(#14102a, #2a1d4a); 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; inset: 0; touch-action: none; }
#stage #app canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; color: inherit; }
#stage button:focus-visible, #stage input: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(#14102a, #2a1d4a); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 0 18px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 30px); letter-spacing: 2px; color: var(--orange); }
#stage .load-in span { font-size: 14px; color: var(--dim); }
#stage .spinner { width: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.2); border-top-color: var(--orange); animation: pfspin .8s linear infinite; }
@keyframes pfspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(20,16,42,.92); color: #fff; font-weight: 700; }

/* HUD */
#stage .hud { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: stretch; padding: max(6px, env(safe-area-inset-top)) 6px 6px; pointer-events: none; }
#stage .board { padding-right: 50px; display: flex; flex-direction: column; gap: 3px; }
#stage .brow { display: flex; align-items: stretch; gap: 2px; background: rgba(20,16,42,.78); border-radius: 8px; padding: 2px; border: 1px solid transparent; }
#stage .brow.active { border-color: var(--orange); }
#stage .bname { width: 34px; font-size: 9px; font-weight: 800; color: var(--dim); display: flex; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding-left: 2px; }
#stage .brow.you .bname { color: var(--teal); }
#stage .bcell { flex: 1 1 0; min-width: 0; background: rgba(255,255,255,.06); border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1px 0; height: 32px; }
#stage .bcell.last { flex: 1.45 1 0; }
#stage .bcell.cur { background: rgba(255,157,46,.35); }
#stage .bmarks { font-size: 9px; height: 11px; line-height: 11px; white-space: pre; color: #fff; font-weight: 700; }
#stage .bscore { font-size: 11px; height: 14px; line-height: 14px; font-variant-numeric: tabular-nums; }
#stage .btotal { width: 30px; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 13px; color: var(--orange); }
#stage .pause-btn { position: absolute; top: max(6px, env(safe-area-inset-top)); right: 6px; width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(20,16,42,.85); font-weight: 900; font-size: 16px; letter-spacing: 1px; pointer-events: auto; }
#stage .hud-info { display: flex; gap: 8px; align-items: baseline; margin: 6px 4px 0; text-shadow: 0 1px 2px #000; flex-wrap: wrap; }
#stage .hud-label { font-size: 13px; }
#stage .hud-sub { font-size: 11px; color: var(--dim); }
#stage .pins-left { margin: 2px 4px 0; font-size: 11px; color: var(--orange); font-weight: 800; text-shadow: 0 1px 2px #000; }
#stage .power { position: absolute; left: 12px; bottom: 22%; width: 12px; height: 34%; border-radius: 8px; background: rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.35); overflow: hidden; display: flex; align-items: flex-end; }
#stage .power i { display: block; width: 100%; background: linear-gradient(0deg, var(--green), var(--orange), #ff4a4a); }
#stage .banner { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font-weight: 900; font-size: clamp(28px, 9vw, 48px); letter-spacing: 2px; text-shadow: 0 3px 0 rgba(0,0,0,.55), 0 0 18px rgba(0,0,0,.6); pointer-events: none; }
#stage .banner.pop { animation: pfpop .45s ease-out; }
#stage .banner.strike { color: var(--orange); } #stage .banner.good { color: var(--green); } #stage .banner.bad { color: #ff6b6b; } #stage .banner.meh { color: #fff; font-size: clamp(22px, 6.5vw, 34px); }
@keyframes pfpop { 0% { transform: scale(.5); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
#stage .hint-bubble { position: absolute; left: 50%; bottom: 20%; transform: translateX(-50%); max-width: 86%; background: rgba(20,16,42,.9); border: 1px solid var(--orange); padding: 8px 12px; border-radius: 12px; font-size: 13px; text-align: center; pointer-events: none; }
#stage .hud.with-pad .hint-bubble { bottom: 34%; }
#stage .hud-actions { position: absolute; right: 10px; bottom: 12px; pointer-events: none; }
#stage .hud.with-pad .hud-actions { bottom: 40%; }
#stage .hud-actions .btn-mini { pointer-events: auto; }

/* slider pad */
#stage .pad { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr 96px; gap: 0 8px; padding: 6px 10px 8px; background: linear-gradient(0deg, rgba(20,16,42,.95), rgba(20,16,42,.7)); pointer-events: auto; touch-action: manipulation; }
#stage .pad.left { grid-template-columns: 96px 1fr; }
#stage .pad.left .btn-throw { grid-column: 1; grid-row: 1 / span 4; }
#stage .pad.left .pad-row { grid-column: 2; }
#stage .pad.disabled { opacity: .5; }
#stage .pad-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--dim); grid-column: 1; }
#stage .pad-row span { width: 54px; flex: none; }
#stage .pad-row { min-height: 44px; }
#stage .pad-row input { flex: 1; min-width: 0; height: 44px; accent-color: var(--orange); touch-action: pan-y; }
#stage .btn-throw { grid-column: 2; grid-row: 1 / span 4; font-size: 17px; letter-spacing: 1px; min-height: 90px; align-self: stretch; }

/* buttons */
#stage .btn, #stage .btn-big { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 8px 18px; border: 0; border-radius: 14px; background: linear-gradient(#ffb347, #ff8a1f); color: #2a1500; font-weight: 800; font-size: 15px; box-shadow: 0 3px 0 #a64f00; text-decoration: none; }
#stage .btn-big { min-height: 54px; font-size: 18px; width: 100%; }
#stage .btn.btn-alt { background: linear-gradient(#5fd9ff, #1fa8e0); box-shadow: 0 3px 0 #0b6a91; color: #04222f; }
#stage .btn.off, #stage .btn-mini.off, #stage .btn:disabled { opacity: .45; box-shadow: none; }
#stage .btn-ghost, #stage .btn-back { min-height: 44px; min-width: 44px; padding: 6px 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.07); font-weight: 700; font-size: 14px; }
#stage .btn-mini { min-height: 44px; min-width: 66px; padding: 4px 12px; border-radius: 12px; border: 0; background: linear-gradient(#ffb347, #ff8a1f); color: #2a1500; font-weight: 800; font-size: 13px; }
#stage .btn-mini.danger { background: #ff4a4a; color: #fff; }
#stage .icon-btn { font-weight: 900; }

/* screens */
#stage .screen-host { position: absolute; inset: 0; pointer-events: none; }
#stage .screen { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; pointer-events: auto;
  padding: max(12px, env(safe-area-inset-top)) 14px 18px; background: linear-gradient(rgba(20,16,42,.93), rgba(30,20,60,.96)); }
#stage .screen h2 { font-size: 22px; margin: 4px 0 8px; }
#stage .screen h3 { font-size: 14px; margin: 14px 0 6px; color: var(--orange); letter-spacing: .5px; text-transform: uppercase; }
#stage .screen h3.locked { color: var(--dim); }
#stage .sc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
#stage .sc-head h2 { margin: 0; }
#stage .blurb { font-size: 13px; color: #d7d1ea; margin: 4px 0 8px; }
#stage .blurb.strong { color: #fff; font-weight: 800; }
#stage .logo { font-size: clamp(30px, 10vw, 44px); margin: 6px 0 0; color: var(--orange); letter-spacing: 1px; text-shadow: 0 3px 0 #7a3a00; line-height: 1; }
#stage .tag { color: var(--dim); font-size: 13px; margin: 4px 0 10px; }
#stage .chips { display: flex; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
#stage .chip { background: rgba(255,255,255,.1); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 800; }
#stage .chip.coin { color: #ffd23f; } #stage .chip.lvl { color: var(--teal); }
#stage .bar { height: 10px; background: rgba(255,255,255,.12); border-radius: 6px; overflow: hidden; }
#stage .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--green)); }
#stage .xp small { display: block; color: var(--dim); font-size: 11px; margin-top: 3px; }
#stage .goal { margin: 10px 0; padding: 10px 12px; border-radius: 12px; background: rgba(55,200,255,.12); border: 1px solid rgba(55,200,255,.35); display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
#stage .goal b { color: var(--teal); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
#stage .menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }
#stage .menu-btn { text-align: left; min-height: 74px; padding: 10px 12px; border-radius: 14px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.07); display: flex; flex-direction: column; gap: 3px; justify-content: center; }
#stage .menu-btn b { font-size: 16px; } #stage .menu-btn small { font-size: 11px; color: var(--dim); }
#stage .menu-btn.primary { background: linear-gradient(#ffb347, #ff8a1f); color: #2a1500; border-color: transparent; box-shadow: 0 3px 0 #a64f00; }
#stage .menu-btn.primary small { color: #5a2d00; }
#stage .menu-btn.hot { border-color: var(--orange); box-shadow: 0 0 0 2px rgba(255,157,46,.35); }
#stage .foot-row, #stage .btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
#stage .btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
#stage .opts { display: flex; flex-wrap: wrap; gap: 8px; }
#stage .opt { min-height: 44px; padding: 6px 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.07); font-size: 13px; font-weight: 700; }
#stage .opt.sel { background: var(--orange); color: #2a1500; border-color: transparent; }
#stage .opt.locked { opacity: .5; }
#stage .opp { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; margin: 6px 0; border-radius: 12px; background: rgba(255,255,255,.06); }
#stage .opp.next { border: 1px solid var(--orange); background: rgba(255,157,46,.12); }
#stage .opp.locked { opacity: .55; }
#stage .opp-info { display: flex; flex-direction: column; min-width: 0; } #stage .opp-info small { color: var(--dim); font-size: 11px; }
#stage .opp-r { display: flex; align-items: center; gap: 8px; flex: none; } #stage .tick { color: var(--green); font-size: 12px; font-weight: 800; }
#stage .tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
#stage .tier { padding: 8px; border-radius: 12px; background: rgba(255,255,255,.07); display: flex; flex-direction: column; text-align: center; font-size: 12px; }
#stage .tier.got { background: rgba(83,224,138,.2); border: 1px solid var(--green); }
#stage .tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .tile { min-height: 74px; padding: 8px 10px; border-radius: 12px; text-align: left; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.07); display: flex; flex-direction: column; gap: 2px; }
#stage .tile b { font-size: 13px; } #stage .tile small { font-size: 10px; color: var(--dim); } #stage .tile .stars { color: #ffd23f; letter-spacing: 2px; font-size: 14px; }
#stage .tile.locked { opacity: .5; } #stage .tile.done { border-color: var(--green); }
#stage .ball-list { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; touch-action: pan-x; }
#stage .ball-chip { flex: none; width: 74px; min-height: 76px; border-radius: 12px; border: 2px solid transparent; background: rgba(255,255,255,.07); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px; }
#stage .ball-chip.sel { border-color: var(--orange); } #stage .ball-chip.unowned { opacity: .65; } #stage .ball-chip small { font-size: 10px; text-align: center; }
#stage .ball-dot { width: 34px; height: 34px; border-radius: 50%; display: block; box-shadow: inset -4px -4px 8px rgba(0,0,0,.4); }
#stage .ball-card { background: rgba(255,255,255,.06); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; }
#stage .ball-card h3 { margin-top: 2px; }
#stage .stat-row { display: grid; grid-template-columns: 80px 1fr; gap: 8px; align-items: center; font-size: 12px; margin: 5px 0; }
#stage .upg, #stage .mission, #stage .set-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
#stage .set-row { flex-direction: column; align-items: flex-start; }
#stage .upg-i, #stage .m-i { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; } #stage .upg-i small, #stage .m-i small { color: var(--dim); font-size: 11px; }
#stage .mission.claimed { opacity: .5; }
#stage .ach { padding: 6px 0; display: flex; flex-direction: column; opacity: .5; border-bottom: 1px solid rgba(255,255,255,.06); } #stage .ach small { color: var(--dim); font-size: 11px; }
#stage .ach.got { opacity: 1; } #stage .ach.got b { color: #ffd23f; }
#stage .rewards { margin: 10px 0; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.07); display: flex; flex-direction: column; gap: 4px; }
#stage .rw { font-weight: 800; color: #ffd23f; } #stage .lvlup { color: var(--teal); font-weight: 800; } #stage .trophy { color: var(--green); font-size: 13px; }
#stage .bigstars { font-size: 44px; color: #ffd23f; letter-spacing: 6px; text-align: center; margin: 6px 0; }
#stage .score-table { margin: 6px 0; } #stage .srow { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,.06); margin: 4px 0; font-size: 16px; }
#stage .srow.you { background: rgba(55,200,255,.16); } #stage .srow b { font-size: 20px; color: var(--orange); }
#stage .next { font-size: 13px; color: var(--teal); margin: 8px 0; }
#stage .toast { position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%); background: rgba(0,0,0,.85); padding: 9px 14px; border-radius: 12px; font-size: 13px; max-width: 88%; text-align: center; pointer-events: none; z-index: 5; }

.bw-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.bw-bar .btn { min-height: 44px; min-width: 44px; }
.bw-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.bw-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.bw-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.bw-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.bw-guide p { margin-bottom: .5rem; font-size: .95rem; }
@media (prefers-reduced-motion: reduce) { #stage .banner.pop, #stage .spinner, #stage .pb-badge { animation: none; } }
#stage .pb-badge { margin: 8px 0; padding: 10px 12px; border-radius: 12px; text-align: center; font-weight: 900; color: #2a1500; background: linear-gradient(#ffd23f, #ff8a1f); box-shadow: 0 0 0 2px rgba(255,255,255,.35); animation: pfpop .45s ease-out; }
#stage .statline { margin: 4px 0 2px; font-size: 12px; color: #cfc8e8; white-space: pre-wrap; text-align: center; }

/* Full screen under the shared shell (immersive on iPhone, native elsewhere): the alley fills the stage below the dock,
   the page extras and the duplicate Play big button step aside, and #stage stays inside the shell's frame. */
html.pip-immersive .game-wrap.pip-stage, html.pip-native .game-wrap { display: flex; flex-direction: column; padding: 0; margin: 0; max-width: none; overflow: hidden; }
html.pip-immersive .bw-bar, html.pip-immersive .bw-keys, html.pip-native .bw-bar, html.pip-native .bw-keys,
html.pip-immersive .game-header, html.pip-immersive .ad-well, html.pip-immersive .bw-guide { display: none; }
html.pip-immersive #stage, html.pip-immersive #stage.is-big, html.pip-native #stage, html.pip-native #stage.is-big {
  position: relative; inset: auto; flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; height: auto; aspect-ratio: auto; border-radius: 0; z-index: auto; }
html.pip-immersive #stage .pause-btn, html.pip-native #stage .pause-btn { right: max(6px, env(safe-area-inset-right)); }
