/* Pawprint Haven - 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 { --o:#e8743b; --od:#b8501f; --cream:#fff7ea; --sand:#ffe3bf; --ink:#3b2a20; --green:#3ccf7a; --blue:#2f9bff; --red:#e24b4b; --gold:#ffc21a;
  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: #fbe3c4; 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; font-size: 14px; }
#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; font-size: inherit; color: inherit; cursor: pointer; touch-action: manipulation; border: 0; }
#stage button:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
#stage button:disabled { opacity: .45; cursor: default; }
/* inside the site shell (native or immersive full screen) keep the 9:16 stage fitting the viewport */
.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; left: 0; right: 0; top: 0; bottom: 42%; touch-action: none; }
#stage #app canvas { display: block; width: 100%; height: 100%; }
#stage.wide #app { right: 38%; bottom: 0; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage #ui > * { pointer-events: none; }
#stage #ui button, #stage #ui .card, #stage #ui .dock, #stage #ui .screen, #stage #ui .care, #stage #ui .modal { pointer-events: auto; }

#stage #loader { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: linear-gradient(#ffd9a8, #ffb77a); }
#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 .spinner { width: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.4); border-top-color: #fff; animation: psspin .8s linear infinite; }
@keyframes psspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; inset: 0; z-index: 55; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(60,30,10,.88); color: #fff; font-weight: 700; }

/* HUD */
#stage .hud { position: absolute; left: 0; right: 0; top: 0; padding: max(6px, env(safe-area-inset-top)) 8px 0; display: flex; flex-direction: column; gap: 4px; }
#stage .hud-row { display: flex; align-items: center; gap: 5px; }
#stage .pill { background: rgba(59,42,32,.78); color: #fff; border-radius: 12px; padding: 5px 9px; font-weight: 700; font-size: 13px; white-space: nowrap; }
#stage .pill.coin { color: var(--gold); }
#stage .timebar { flex: 1; min-width: 20px; height: 10px; border-radius: 6px; background: rgba(59,42,32,.35); overflow: hidden; }
#stage .timebar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd24a, #ff9a3a); }
#stage .ibtn { width: 44px; height: 44px; border-radius: 12px; background: rgba(59,42,32,.78); color: #fff; font-weight: 800; pointer-events: auto; }
#stage .hud-row2 { display: flex; align-items: center; gap: 8px; }
#stage .repbar { position: relative; flex: 0 1 190px; height: 18px; border-radius: 9px; background: rgba(59,42,32,.4); overflow: hidden; }
#stage .repbar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--green); width: 0; }
#stage .repbar i.mid { background: #f5b82e; } #stage .repbar i.low { background: var(--red); }
#stage .repbar span { position: relative; display: block; text-align: center; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
#stage .evt { background: var(--o); color: #fff; font-size: 11px; font-weight: 800; border-radius: 9px; padding: 2px 8px; }
#stage .evt:empty { display: none; }
#stage .badges { position: absolute; inset: 0; pointer-events: none; }
#stage .badge { position: absolute; left: 0; top: 0; min-width: 44px; text-align: center; font-weight: 800; font-size: 13px; border-radius: 10px; padding: 3px 6px; color: #fff; border: 2px solid #fff; }
#stage .badge.yes { background: var(--green); } #stage .badge.wait { background: #f5a02e; } #stage .badge.no { background: #8b8b99; }
#stage .hint { position: absolute; left: 10px; right: 10px; top: 76px; background: #fff; border: 3px solid var(--o); border-radius: 14px; padding: 8px 12px; font-weight: 700; text-align: center; box-shadow: 0 4px 0 rgba(0,0,0,.15); animation: pspop .3s; }
@keyframes pspop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
#stage .toasts { position: absolute; left: 8px; right: 8px; top: 108px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#stage .toast { background: rgba(59,42,32,.92); color: #fff; padding: 6px 12px; border-radius: 12px; font-weight: 700; font-size: 13px; text-align: center; animation: pspop .2s; }
#stage .toast.good { background: #1f8f55; } #stage .toast.bad { background: #b13a3a; }
#stage .banner { position: absolute; left: 14px; right: 14px; top: 28%; background: #fff; border: 4px solid var(--o); border-radius: 18px; padding: 12px; text-align: center; box-shadow: 0 6px 0 rgba(0,0,0,.18); animation: pspop .3s; z-index: 15; }
#stage .banner b { display: block; font-size: 20px; color: var(--od); } #stage .banner span { font-size: 14px; }

/* dock */
#stage .dock { position: absolute; left: 0; right: 0; bottom: 0; height: 42%; background: var(--cream); border-top: 3px solid #f0c9a0; padding: 6px 8px max(6px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; overflow-y: auto; touch-action: pan-y; }
#stage.wide .dock { left: auto; top: 0; width: 38%; height: auto; border-top: 0; border-left: 3px solid #f0c9a0; }
#stage .adopters { display: flex; gap: 6px; overflow-x: auto; touch-action: pan-x; flex: 0 0 auto; min-height: 50px; }
#stage .empty { padding: 10px; color: #8a6a54; font-size: 13px; text-align: center; width: 100%; }
#stage .chip { flex: 0 0 auto; min-width: 118px; min-height: 48px; background: #fff; border: 3px solid #f0c9a0; border-radius: 12px; padding: 3px 8px 6px; text-align: left; position: relative; overflow: hidden; }
#stage .chip.on { border-color: var(--green); background: #e9fff1; }
#stage .chip b { display: block; font-size: 13px; } #stage .chip span { display: block; font-size: 11px; color: #7a5a44; }
#stage .chip i { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--green); } #stage .chip i.low { background: var(--red); }
#stage .petcard { flex: 1 0 auto; background: #fff; border-radius: 14px; padding: 8px; display: flex; flex-direction: column; gap: 5px; min-height: 100px; }
#stage .pc-top b { font-size: 16px; margin-right: 6px; } #stage .pc-top span { font-size: 12px; color: #7a5a44; }
#stage .bars { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; }
#stage .bar { display: flex; align-items: center; gap: 5px; font-size: 11px; } #stage .bar em { font-style: normal; width: 42px; color: #7a5a44; }
#stage .bar span { flex: 1; height: 9px; border-radius: 5px; background: #f0e2d0; overflow: hidden; } #stage .bar i { display: block; height: 100%; background: var(--green); }
#stage .bar i.mid { background: #f5b82e; } #stage .bar i.low { background: var(--red); }
#stage .status { font-size: 12px; font-weight: 700; color: #7a5a44; min-height: 16px; } #stage .status.good { color: #1f8f55; } #stage .status.bad { color: var(--red); }
#stage .acts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
#stage .acts button { min-height: 46px; border-radius: 12px; background: var(--o); color: #fff; font-weight: 800; box-shadow: 0 3px 0 var(--od); }
#stage .acts button.alert { background: var(--red); box-shadow: 0 3px 0 #9a2d2d; animation: pspulse 1s infinite; }
#stage .match { font-size: 12px; font-weight: 700; color: #1f6f4a; }
#stage .go { min-height: 46px; border-radius: 12px; background: #8b8b99; color: #fff; font-weight: 800; } #stage .go.ready { background: var(--green); box-shadow: 0 3px 0 #1f8f55; }
#stage .supply { display: flex; gap: 6px; flex: 0 0 auto; }
#stage .sp { flex: 1; min-height: 44px; border-radius: 12px; background: #fff; border: 3px solid #f0c9a0; font-weight: 800; font-size: 13px; } #stage .sp small { font-weight: 600; color: #7a5a44; }
#stage .sp.pulse { border-color: var(--o); animation: pspulse 1.2s infinite; }
@keyframes pspulse { 50% { transform: scale(1.04); } }

/* minigames */
#stage .care { position: absolute; inset: 0; z-index: 18; background: rgba(59,42,32,.55); display: flex; align-items: center; justify-content: center; padding: 10px; touch-action: none; }
#stage .mg { background: var(--cream); border: 4px solid var(--o); border-radius: 18px; padding: 12px; width: 100%; max-width: 340px; text-align: center; }
#stage .mg h3 { font-size: 18px; } #stage .mg-sub { font-size: 13px; color: #7a5a44; margin: 4px 0 8px; }
#stage .timer { height: 10px; border-radius: 6px; background: #f0e2d0; overflow: hidden; margin-bottom: 8px; } #stage .timer i { display: block; height: 100%; width: 100%; background: var(--blue); }
#stage .pet-art { position: relative; height: 200px; }
#stage .pet-art .blob { position: absolute; left: 15%; right: 15%; top: 8%; bottom: 8%; border-radius: 46% 46% 42% 42%; background: var(--pc, #d9a066); box-shadow: inset -10px -12px 0 rgba(0,0,0,.1); }
#stage .spot { position: absolute; width: 54px; height: 54px; border-radius: 50%; transform: translate(-50%, -50%); background: radial-gradient(#8a5a35, #5a3a22); border: 3px dashed #fff; touch-action: none; }
#stage .spot.gone { pointer-events: none; visibility: hidden; }
#stage .track { position: relative; height: 40px; border-radius: 20px; background: #f0e2d0; margin: 14px 4px; overflow: hidden; }
#stage .zone { position: absolute; left: 38%; width: 24%; top: 0; bottom: 0; background: rgba(60,207,122,.55); }
#stage .ball { position: absolute; top: 5px; width: 30px; height: 30px; margin-left: -15px; border-radius: 50%; background: var(--red); border: 3px solid #fff; left: 50%; }
#stage .pips { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; } #stage .pips b { width: 16px; height: 16px; border-radius: 50%; background: #e3d3c0; } #stage .pips b.g { background: var(--green); } #stage .pips b.y { background: #f5b82e; } #stage .pips b.r { background: var(--red); }
#stage .throw { width: 100%; min-height: 64px; border-radius: 16px; background: var(--o); color: #fff; font-size: 20px; font-weight: 800; box-shadow: 0 4px 0 var(--od); touch-action: none; }
#stage .remedies { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
#stage .rem { min-height: 56px; border-radius: 14px; background: #fff; border: 3px solid #f0c9a0; font-weight: 800; } #stage .rem.right { background: #d9ffe8; border-color: var(--green); } #stage .rem.wrong { background: #ffe0e0; border-color: var(--red); }
#stage .book { background: #fff; border-radius: 10px; padding: 6px; font-size: 12px; text-align: left; margin-bottom: 6px; } #stage .book b, #stage .book span { display: block; }
#stage .mg-msg { min-height: 20px; font-weight: 800; color: var(--od); margin: 4px 0; }
#stage .ghost { background: transparent; color: var(--od); font-weight: 700; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 2px solid #f0c9a0; }

/* modal + screens */
#stage .modal { position: absolute; inset: 0; z-index: 30; background: rgba(59,42,32,.6); display: flex; align-items: center; justify-content: center; padding: 12px; overflow-y: auto; touch-action: pan-y; }
#stage .card { background: var(--cream); border: 4px solid var(--o); border-radius: 18px; padding: 14px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 8px; max-height: 100%; overflow-y: auto; }
#stage h2 { font-size: 20px; text-align: center; color: var(--od); } #stage h3 { font-size: 15px; margin-top: 6px; color: var(--od); }
#stage .note { font-size: 13px; color: #7a5a44; text-align: center; } #stage .note.warn { color: var(--red); font-weight: 700; }
#stage .big { min-height: 52px; border-radius: 14px; background: var(--o); color: #fff; font-weight: 800; font-size: 16px; box-shadow: 0 4px 0 var(--od); padding: 0 14px; width: 100%; }
#stage .big.alt { background: #4a8fe0; box-shadow: 0 4px 0 #2f6bb5; } #stage .big.ghost { background: #fff; color: var(--od); box-shadow: 0 4px 0 #f0c9a0; }
#stage .big small { font-weight: 600; opacity: .85; font-size: 12px; margin-left: 6px; }
#stage .sum { list-style: none; display: flex; flex-direction: column; gap: 4px; } #stage .sum li { display: flex; justify-content: space-between; background: #fff; border-radius: 10px; padding: 6px 10px; font-size: 14px; }
#stage .van-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #fff; border-radius: 12px; padding: 8px; }
#stage .van-row span, #stage .van-row em { display: block; font-size: 12px; color: #7a5a44; font-style: normal; } #stage .vb { display: flex; flex-direction: column; gap: 4px; }
#stage .vb button { min-height: 44px; min-width: 76px; border-radius: 10px; font-weight: 800; } #stage .vb .ok { background: var(--green); color: #fff; }
#stage .screen { position: absolute; inset: 0; z-index: 25; background: linear-gradient(#ffe9cf, #ffd3a8); overflow-y: auto; padding: max(10px, env(safe-area-inset-top)) 12px 16px; display: flex; flex-direction: column; gap: 8px; touch-action: pan-y; }
#stage .sc-head { display: flex; align-items: center; gap: 8px; } #stage .sc-head h2 { flex: 1; text-align: left; }
#stage .back { width: 44px; height: 44px; border-radius: 12px; background: #fff; font-weight: 800; font-size: 18px; } #stage .hearts { background: #fff; border-radius: 12px; padding: 6px 10px; font-weight: 800; color: #d6406e; }
#stage .menu { display: flex; flex-direction: column; gap: 10px; min-height: 100%; justify-content: center; }
#stage .logo { text-align: center; } #stage .logo h1 { font-size: 30px; color: var(--od); text-shadow: 0 2px 0 #fff; } #stage .logo p { color: #7a5a44; } #stage .paw { font-size: 40px; color: #ff5d8f; }
#stage .rankline { display: flex; align-items: center; gap: 8px; font-weight: 800; } #stage .xp { flex: 1; height: 10px; border-radius: 6px; background: #fff; overflow: hidden; } #stage .xp i { display: block; height: 100%; background: var(--blue); }
#stage .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } #stage .grid2 button, #stage .wide { min-height: 48px; border-radius: 12px; background: #fff; font-weight: 800; box-shadow: 0 3px 0 #f0c9a0; }
#stage .lv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .lv { min-height: 92px; border-radius: 14px; background: #fff; text-align: left; padding: 8px 10px; position: relative; box-shadow: 0 3px 0 #f0c9a0; }
#stage .lv b { font-size: 22px; color: var(--o); } #stage .lv span { display: block; font-weight: 800; font-size: 13px; } #stage .lv em { display: block; font-style: normal; font-size: 11px; color: #7a5a44; } #stage .lv i { font-style: normal; color: var(--gold); font-size: 15px; } #stage .lv i s { color: #d8c8b8; text-decoration: none; }
#stage .shop-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #fff; border-radius: 12px; padding: 8px 10px; }
#stage .shop-row span { display: block; font-size: 12px; color: #7a5a44; } #stage .shop-row button { min-width: 84px; min-height: 44px; border-radius: 10px; background: var(--o); color: #fff; font-weight: 800; } #stage .shop-row button.poor { background: #b9a898; } #stage .shop-row button.maxed { background: #8bd6a8; color: #124; }
#stage .pips2 i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #e3d3c0; margin-left: 3px; } #stage .pips2 i.on { background: var(--o); }
#stage .dx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } #stage .dx { background: #fff; border-radius: 12px; padding: 8px; } #stage .dx em { display: block; font-style: normal; font-size: 11px; color: #7a5a44; }
#stage .sw { display: inline-block; width: 26px; height: 26px; border-radius: 50%; margin: 4px 4px 4px 0; border: 2px solid #fff; box-shadow: 0 0 0 1px #d8c8b8; } #stage .sw.q { background: #e7ddd2; color: #a89888; text-align: center; line-height: 22px; font-weight: 800; }
#stage .tr { list-style: none; display: flex; flex-direction: column; gap: 6px; } #stage .tr li { background: #fff; border-radius: 12px; padding: 8px 10px; opacity: .55; } #stage .tr li.on { opacity: 1; border-left: 6px solid var(--green); } #stage .tr b, #stage .tr span { display: block; } #stage .tr span { font-size: 12px; color: #7a5a44; }
#stage .set-row { display: flex; justify-content: space-between; align-items: center; background: #fff; border-radius: 12px; padding: 8px 10px; gap: 8px; font-weight: 700; }
#stage .set-row button { min-width: 64px; min-height: 44px; border-radius: 10px; background: #f0e2d0; font-weight: 800; padding: 0 10px; } #stage .seg { display: flex; gap: 4px; } #stage .seg button.on { background: var(--o); color: #fff; } #stage .set-row .danger { background: var(--red); color: #fff; }
#stage .help p { background: #fff; border-radius: 12px; padding: 10px; margin-bottom: 8px; font-size: 14px; }
#stage .res { display: flex; flex-direction: column; gap: 10px; min-height: 100%; justify-content: center; }
#stage .stars { text-align: center; font-size: 44px; letter-spacing: 6px; } #stage .stars b { color: #d8c8b8; } #stage .stars b.on { color: var(--gold); text-shadow: 0 3px 0 #b9801a; }
#stage .gain { text-align: center; font-weight: 800; color: #1f8f55; } #stage .ach { list-style: none; text-align: center; font-weight: 700; } #stage .next { text-align: center; font-weight: 800; color: var(--od); }

.ps-bar { display: flex; justify-content: center; margin-top: .75rem; }
.ps-keys { text-align: center; font-size: .8rem; color: #64748b; margin-top: .5rem; }
.ps-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 16px; line-height: 1.65; }
.ps-guide h2 { font-size: 1.35rem; margin-bottom: .6rem; } .ps-guide h3 { font-size: 1.05rem; margin: 1rem 0 .3rem; } .ps-guide p { color: #334155; font-size: .95rem; }
@media (prefers-reduced-motion: reduce) { #stage * { animation: none !important; } }

/* Full screen (native and immersive): the stage fills the shell's frame; landscape flips to the side dock via .wide */
html.pip-immersive .game-wrap.pip-stage #stage { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; margin: 0; border-radius: 0; }
html.pip-immersive .game-wrap.pip-stage > .ps-bar, html.pip-immersive .game-wrap.pip-stage > .ps-keys, html.pip-immersive .ps-bar, html.pip-immersive .ps-keys { display: none; }
#stage #app::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 58%, rgba(60,30,10,.22) 100%); }
html.pip-native .game-wrap.pip-stage #stage { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; margin: 0; border-radius: 0; }
html.pip-native .game-wrap.pip-stage > .ps-bar, html.pip-native .game-wrap.pip-stage > .ps-keys, html.pip-native .ps-bar, html.pip-native .ps-keys { display: none; }
/* Full screen, portrait: a slimmer care dock so the shelter view gets about two thirds of the height */
html.pip-immersive #stage:not(.wide) #app, html.pip-native #stage:not(.wide) #app { bottom: 35%; }
html.pip-immersive #stage:not(.wide) .dock, html.pip-native #stage:not(.wide) .dock { height: 35%; padding: 4px 8px max(4px, env(safe-area-inset-bottom)); gap: 4px; }
html.pip-immersive #stage:not(.wide) .adopters, html.pip-native #stage:not(.wide) .adopters { min-height: 46px; }
html.pip-immersive #stage:not(.wide) .chip, html.pip-native #stage:not(.wide) .chip { min-height: 46px; }
html.pip-immersive #stage:not(.wide) .petcard, html.pip-native #stage:not(.wide) .petcard { padding: 5px 8px; gap: 3px; min-height: 0; }
html.pip-immersive #stage:not(.wide) .bars, html.pip-native #stage:not(.wide) .bars { gap: 1px 10px; }
html.pip-immersive #stage:not(.wide) .acts button, html.pip-native #stage:not(.wide) .acts button,
html.pip-immersive #stage:not(.wide) .go, html.pip-native #stage:not(.wide) .go { min-height: 44px; }
html.pip-immersive #stage:not(.wide) .sp, html.pip-native #stage:not(.wide) .sp { min-height: 44px; }
/* Full screen, landscape: the Career level list fits without scrolling */
html.pip-immersive #stage.wide .lv-grid, html.pip-native #stage.wide .lv-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
html.pip-immersive #stage.wide .lv, html.pip-native #stage.wide .lv { min-height: 76px; padding: 5px 8px; }
html.pip-immersive #stage.wide .lv b, html.pip-native #stage.wide .lv b { font-size: 18px; }
html.pip-immersive #stage.wide .screen, html.pip-native #stage.wide .screen { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 8px; gap: 5px; }
html.pip-immersive #stage.wide .menu, html.pip-native #stage.wide .menu { display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: row dense; gap: 6px 12px; align-content: center; min-height: 100%; }
html.pip-immersive #stage.wide .menu .logo, html.pip-native #stage.wide .menu .logo, html.pip-immersive #stage.wide .menu .rankline, html.pip-native #stage.wide .menu .rankline, html.pip-immersive #stage.wide .menu .grid2, html.pip-native #stage.wide .menu .grid2 { grid-column: 1; }
html.pip-immersive #stage.wide .menu .big, html.pip-native #stage.wide .menu .big, html.pip-immersive #stage.wide .menu .ghost, html.pip-native #stage.wide .menu .ghost { grid-column: 2; min-height: 44px; }
