/* Pocket Isles 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 { --teal:#1aa6a6; --deep:#0f5a73; --sun:#ffc21a; --coral:#ff6f59; --cream:#fff7e2; --ink:#1f3b4d; --leaf:#4cb85a;
  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(#8fd6f2, #bfe6ff); 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; }
.game-wrap.pip-stage #stage { width: min(100%, calc((100vh - 64px) * 0.5625)); width: min(100%, calc((100svh - 64px) * 0.5625)); }
#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 #ui button { pointer-events: auto; 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 #ctxlost { position: absolute; left: 12px; right: 12px; top: 40%; z-index: 40; background: var(--cream); padding: 14px; border-radius: 14px; text-align: center; font-size: 14px; box-shadow: 0 4px 0 rgba(15,90,115,.35); }
#stage #loader { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: linear-gradient(#1aa6a6, #8fd6f2); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(15,90,115,.5); text-align: center; padding: 0 18px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 30px); letter-spacing: 3px; }
#stage .spinner { width: 34px; height: 34px; border-radius: 50%; border: 5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: pispin .9s linear infinite; }
@keyframes pispin { to { transform: rotate(360deg); } }

/* HUD */
#stage .hud { position: absolute; inset: 0; pointer-events: none; }
#stage .top { position: absolute; left: 6px; right: 6px; top: 6px; display: flex; gap: 6px; align-items: flex-start; }
#stage .pop { flex: none; min-width: 58px; min-height: 44px; padding: 3px 8px; border: 0; border-radius: 14px; background: var(--cream); color: var(--ink); box-shadow: 0 3px 0 rgba(15,90,115,.35); display: flex; flex-direction: column; align-items: center; justify-content: center; }
#stage .pop b { font-size: 16px; }
#stage .pop small { font-size: 10px; opacity: .75; }
#stage .res { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; pointer-events: none; }
#stage .chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px 0 5px; border-radius: 99px; background: rgba(255,247,226,.95); font-size: 12px; font-weight: 800; box-shadow: 0 2px 0 rgba(15,90,115,.3); }
#stage .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); flex: none; }
#stage .goalbar { position: absolute; left: 6px; right: 6px; top: 54px; min-height: 44px; padding: 5px 10px 10px; border: 0; border-radius: 12px; background: rgba(15,90,115,.88); color: #fff; font-size: 12px; font-weight: 700; text-align: left; overflow: hidden; }
#stage .goalbar .gbar { position: absolute; left: 10px; right: 10px; bottom: 4px; height: 4px; border-radius: 3px; background: rgba(255,255,255,.25); }
#stage .goalbar .gbar u { display: block; height: 100%; width: 0; background: var(--sun); border-radius: 3px; text-decoration: none; transition: width .3s; }
#stage .tip { position: absolute; left: 14px; right: 14px; top: 108px; padding: 9px 12px; border-radius: 12px; background: var(--sun); color: #3a2a00; font-size: 13px; font-weight: 800; text-align: center; box-shadow: 0 3px 0 rgba(120,80,0,.4); pointer-events: none; }
#stage .toast { position: absolute; left: 20px; right: 20px; bottom: 132px; padding: 8px 12px; border-radius: 12px; background: rgba(31,59,77,.93); color: #fff; font-size: 13px; text-align: center; pointer-events: none; z-index: 15; }
#stage .floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#stage .fl { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 15px; text-shadow: 0 2px 0 rgba(0,0,0,.55); opacity: 0; white-space: nowrap; }
#stage .fl.go { animation: pifloat 1s ease-out forwards; }
@keyframes pifloat { 0% { opacity: 0; transform: translate(-50%, -30%); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -190%); } }
#stage .bar { position: absolute; left: 6px; right: 6px; bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
#stage .bar .b { flex: 1; min-width: 44px; min-height: 48px; padding: 2px; border-radius: 14px; font-size: 12px; }
#stage .place { position: absolute; left: 6px; right: 6px; bottom: 62px; display: flex; gap: 6px; align-items: center; padding: 8px; border-radius: 14px; background: var(--cream); box-shadow: 0 3px 0 rgba(15,90,115,.35); pointer-events: auto; z-index: 11; }
#stage .place .pl { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 12px; min-width: 0; }
#stage .place .pl b { font-size: 14px; }
#stage .why { font-size: 11px; color: #b3321f; font-weight: 800; }
#stage .why.ok { color: #1b7a34; }
#stage .place .b { min-width: 64px; min-height: 44px; }

/* buttons and cards */
#stage .b { border: 0; border-radius: 12px; min-height: 44px; padding: 8px 12px; background: #fff; color: var(--ink); font-weight: 800; font-size: 14px; box-shadow: 0 3px 0 rgba(15,90,115,.3); }
#stage .b:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(15,90,115,.3); }
#stage .b.pri { background: var(--teal); color: #fff; }
#stage .b.danger { background: #fde4df; color: #a32a17; }
#stage .b.dis { opacity: .5; }
#stage .b.big { padding: 10px 14px; font-size: 17px; }
#stage .b small { display: block; font-size: 11px; font-weight: 700; opacity: .85; }
#stage .costs { display: inline-flex; flex-wrap: wrap; gap: 3px; }
#stage .cost { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 800; background: rgba(0,0,0,.07); padding: 1px 6px 1px 4px; border-radius: 99px; }
#stage .cost.no { color: #b3321f; background: #fde4df; }
#stage .sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 72%; z-index: 12; pointer-events: auto; display: flex; }
#stage .sheet .sh { background: var(--cream); border-radius: 18px 18px 0 0; padding: 10px 10px 12px; box-shadow: 0 -4px 0 rgba(15,90,115,.3); width: 100%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; display: flex; flex-direction: column; gap: 8px; }
#stage .shh { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
#stage .shh .mini { flex: 1; text-align: left; }
#stage .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
#stage .tile { min-height: 76px; padding: 6px 8px; border: 2px solid #d3dfe3; border-radius: 12px; background: #fff; color: var(--ink); text-align: left; display: flex; flex-direction: column; gap: 3px; }
#stage .tile b { font-size: 13px; }
#stage .tile small { font-size: 10px; opacity: .75; line-height: 1.15; }
#stage .tile.sel { border-color: var(--teal); background: #e3f6f5; }
#stage .tile.poor { opacity: .72; }
#stage .tile.lock { opacity: .45; }
#stage .screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 10px; z-index: 20; background: rgba(15,90,115,.35); pointer-events: auto; overflow-y: auto; touch-action: pan-y; }
#stage .screen.title { background: linear-gradient(rgba(15,90,115,.1), rgba(15,90,115,.5)); }
#stage .panel { pointer-events: auto; width: 100%; max-height: 100%; background: var(--cream); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 6px 0 rgba(15,90,115,.4); text-align: center; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
#stage .panel h2 { margin: 0; font-size: 22px; color: var(--deep); }
#stage .logo { display: flex; flex-direction: column; line-height: 1; margin-bottom: 2px; }
#stage .logo span { font-size: 15px; letter-spacing: 8px; color: var(--teal); font-weight: 800; }
#stage .logo b { font-size: clamp(34px, 12vw, 50px); color: var(--coral); letter-spacing: 3px; text-shadow: 0 3px 0 rgba(120,40,20,.25); }
#stage .tag { margin: 0; font-size: 13px; color: #48606f; }
#stage .mini { font-size: 11px; color: #5b7482; margin: 0; }
#stage .row2 { display: flex; gap: 8px; }
#stage .row2 > * { flex: 1; }
#stage .row3 { display: flex; gap: 6px; }
#stage .row3 > * { flex: 1; padding: 8px 4px; font-size: 13px; }
#stage .card { background: #fff; border-radius: 14px; padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 5px; border: 2px solid #e1ebee; }
#stage .card.lock { opacity: .55; }
#stage .card.got { border-color: var(--leaf); background: #eefaf0; }
#stage .card p { margin: 0; font-size: 12px; }
#stage .ctop { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 14px; }
#stage .goals { margin: 0; padding-left: 18px; font-size: 12px; text-align: left; display: flex; flex-direction: column; gap: 3px; }
#stage .goals li.done { text-decoration: line-through; opacity: .6; }
#stage .st { color: #cfd8dc; font-size: 18px; }
#stage .st.on { color: var(--sun); text-shadow: 0 1px 0 rgba(120,80,0,.4); }
#stage .bigstars .st { font-size: 40px; }
#stage .gain { color: #1b7a34; font-weight: 800; margin: 0; }
#stage .news { color: var(--deep); font-weight: 800; margin: 0; font-size: 12px; }
#stage .next { background: #e3f6f5; border-radius: 10px; padding: 7px 9px; font-size: 12px; margin: 0; }
#stage .hintline { background: #fff3c4; border-radius: 10px; padding: 7px 9px; font-size: 12px; margin: 0; }
#stage .pip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #d3dfe3; margin-left: 3px; }
#stage .pip.on { background: var(--teal); }
#stage .srow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 14px; }
#stage .seg { display: flex; gap: 5px; }
#stage .flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 30; }
#stage .banner { position: absolute; left: 0; right: 0; top: 24%; text-align: center; pointer-events: none; opacity: 0; transform: scale(.85); transition: opacity .3s, transform .3s; color: #fff; text-shadow: 0 3px 0 rgba(15,90,115,.7); z-index: 25; padding: 0 12px; }
#stage .banner.show { opacity: 1; transform: scale(1); }
#stage .b-main { font-size: clamp(24px, 8vw, 36px); font-weight: 900; letter-spacing: 1px; }
#stage .b-sub { font-size: 14px; font-weight: 800; }
.er-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.er-bar .btn { min-height: 44px; min-width: 44px; }
.er-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.er-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.er-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.er-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.er-guide p { margin-bottom: .5rem; font-size: .95rem; }
@media (prefers-reduced-motion: reduce) { #stage .banner, #stage .goalbar .gbar u { transition: none; } #stage .fl.go { animation-duration: .01s; } }
/* safe areas, larger readout, motion */
#stage .top { left: max(6px, env(safe-area-inset-left)); right: max(6px, env(safe-area-inset-right)); top: max(6px, env(safe-area-inset-top)); }
#stage .bar { bottom: max(6px, env(safe-area-inset-bottom)); }
#stage .chip { height: 24px; font-size: 13px; }
@media (prefers-reduced-motion: reduce) { #stage .spinner { animation-duration: 3s; } #stage * { scroll-behavior: auto; } }

/* full screen (shell adds html.pip-immersive in both native and immersive modes): the game fills the stage under the dock */
html.ibr-shell .er-bar { display: none; }
html.pip-immersive .game-wrap.pip-stage { display: flex; flex-direction: column; overflow: hidden; }
html.pip-immersive .game-wrap.pip-stage > #stage { flex: 1 1 auto; width: 100% !important; max-width: none; height: auto; min-height: 0; aspect-ratio: auto; border-radius: 0; }
html.pip-immersive .game-wrap.pip-stage > .er-bar, html.pip-immersive .game-wrap.pip-stage > .er-keys, html.pip-immersive .game-wrap.pip-stage > noscript { display: none; }
html.pip-immersive #stage #bigbtn { display: none; }
@media (orientation: landscape) and (max-height: 480px) {
  html.pip-immersive #stage .goalbar { top: 50px; right: 52%; }
  html.pip-immersive #stage .tip { top: 100px; right: 52%; }
  html.pip-immersive #stage .toast { bottom: 70px; }
  html.pip-immersive #stage .sheet { left: auto; width: min(52%, 420px); max-height: 100%; }
  html.pip-immersive #stage .place { left: auto; width: min(52%, 420px); }
  html.pip-immersive #stage .screen { align-items: flex-start; }
  html.pip-immersive #stage .panel { max-width: 460px; margin: 0 auto; }
}
/* finish: soft depth on the HUD and title */
#stage .pop, #stage .chip, #stage .goalbar { backdrop-filter: none; }
#stage .panel { box-shadow: 0 6px 0 rgba(15,90,115,.4), 0 14px 28px rgba(15,60,80,.25); }
#stage .b { transition: transform .08s, box-shadow .08s, filter .15s; }
#stage .b.pri { background: linear-gradient(#25bdbd, #1aa6a6); }
#stage .b:not(.dis):hover { filter: brightness(1.05); }
#stage .screen.title { background: radial-gradient(120% 80% at 50% 0%, rgba(255,230,160,.25), transparent 60%), linear-gradient(rgba(15,90,115,.1), rgba(15,90,115,.5)); }
/* full screen: the Back or Close button of a long menu stays pinned at the bottom of its scroll area */
html.pip-immersive #stage .panel.scroll > .b:last-child, html.pip-native #stage .panel.scroll > .b:last-child { position: sticky; bottom: 0; z-index: 2; min-height: 48px; flex: none; }
html.pip-immersive #stage .panel, html.pip-native #stage .panel { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
