/* Cozy Campsite 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 { --pine:#2e7d4f; --pine-d:#1f5a37; --sun:#ffc94a; --ember:#ff8a3d; --cream:#fff6e0; --ink:#2b2a24; --bark:#6b4a2b; --red:#e5533d;
  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(#9fd8f5, #dff2e4); 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; 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, #stage #ui .panel, #stage #ui .screen, #stage #ui .req { 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 #loader { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: linear-gradient(#2e7d4f, #8fcf9a); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 2px 0 rgba(0,40,20,.4); 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: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.35); border-top-color: var(--sun); animation: ccspin .8s linear infinite; }
@keyframes ccspin { 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(20,40,30,.88); color: #fff; font-weight: 700; }

/* HUD */
#stage .hud { position: absolute; inset: 0; pointer-events: none; padding: max(8px, env(safe-area-inset-top)) 8px 0; }
#stage .hud-top, #stage .hud-2 { display: flex; gap: 6px; align-items: center; }
#stage .hud-2 { margin-top: 6px; }
#stage .pill { background: rgba(31,58,40,.72); color: #fff; border-radius: 14px; padding: 4px 10px; display: flex; align-items: center; gap: 5px; min-height: 34px; font-size: 14px; white-space: nowrap; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
#stage .pill b { font-variant-numeric: tabular-nums; }
#stage .pill.grow { flex: 1; min-width: 0; overflow: hidden; }
#stage .pill.small { min-height: 28px; padding: 2px 8px; font-size: 13px; }
#stage .pill.low b { color: #ffb4a8; }
#stage .dim { opacity: .75; }
#stage .clock { flex: 1; min-width: 20px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; margin-left: 2px; }
#stage .clock i, #stage .xp i { display: block; height: 100%; background: var(--sun); width: 0; }
#stage .xp { width: 28px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; }
#stage .goal { flex: 1; min-width: 0; position: relative; height: 28px; border-radius: 14px; background: rgba(31,58,40,.72); overflow: hidden; display: flex; align-items: center; }
#stage .gbar { position: absolute; inset: 0; } #stage .gbar i { display: block; height: 100%; background: linear-gradient(90deg, #3aa86a, #8fd66b); width: 0; transition: width .4s; }
#stage .goal span { position: relative; z-index: 1; padding: 0 10px; color: #fff; font-size: 13px; font-weight: 700; text-shadow: 0 1px 0 rgba(0,0,0,.4); }
#stage .ib { pointer-events: auto; width: 44px; height: 44px; border-radius: 14px; border: 0; background: rgba(31,58,40,.8); color: #fff; font-size: 20px; }
#stage .reqs { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; align-items: flex-start; }
#stage .req { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 3px 10px; border-radius: 12px; border: 2px solid var(--sun); background: var(--cream); font-size: 13px; font-weight: 700; color: var(--ink); max-width: 70%; }
#stage .req b { color: var(--pine-d); }
#stage .hint { position: absolute; left: 10px; right: 10px; bottom: 76px; background: #fff7d6; border: 2px solid var(--sun); color: var(--ink); border-radius: 14px; padding: 8px 12px; font-size: 14px; font-weight: 700; text-align: center; pointer-events: none; box-shadow: 0 3px 0 rgba(0,0,0,.18); animation: ccbob 1.6s ease-in-out infinite; }
@keyframes ccbob { 50% { transform: translateY(-3px); } }
#stage .toasts { position: absolute; left: 8px; right: 8px; top: 108px; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#stage .toast { background: rgba(31,58,40,.9); color: #fff; border-radius: 12px; padding: 6px 12px; font-size: 13px; font-weight: 700; animation: cctoast 3.2s ease forwards; max-width: 100%; text-align: center; }
#stage .toast.good { background: #1f7a45; } #stage .toast.bad { background: #a8372a; }
@keyframes cctoast { 0% { opacity: 0; transform: translateY(-8px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#stage #floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#stage .fl { position: absolute; transform: translate(-50%, -50%); font-weight: 800; font-size: 15px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.55); animation: ccfloat 1.2s ease-out forwards; white-space: nowrap; }
#stage .fl.coin { color: #ffe27a; } #stage .fl.rep { color: #c9f7c0; }
@keyframes ccfloat { to { transform: translate(-50%, -64px); opacity: 0; } }
#stage .flash { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle, rgba(255,236,150,.55), rgba(255,236,150,0) 70%); animation: ccflash .7s ease-out forwards; z-index: 20; }
@keyframes ccflash { to { opacity: 0; } }

/* bottom bar */
#stage .bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 6px; padding: 6px 8px max(8px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(20,40,28,0), rgba(20,40,28,.55)); }
#stage .tb { pointer-events: auto; flex: 1; min-height: 52px; border: 0; border-radius: 14px; background: var(--cream); color: var(--ink); font-weight: 800; font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; box-shadow: 0 3px 0 rgba(0,0,0,.22); }
#stage .tb.main { flex: 1.5; background: var(--sun); font-size: 14px; flex-direction: row; gap: 6px; }
#stage .tb .ic { font-size: 20px; }
#stage .tb:active, #stage .btn:active, #stage .card:active { transform: translateY(2px); box-shadow: none; }
#stage .panel { background: var(--cream); border-radius: 16px; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
#stage .sheet { position: absolute; left: 6px; right: 6px; bottom: 70px; max-height: 52%; display: flex; flex-direction: column; overflow: hidden; }
#stage .tabs { display: flex; gap: 4px; padding: 6px; overflow-x: auto; flex: none; touch-action: pan-x; }
#stage .tab { flex: none; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 2px solid #e3d5ac; background: #fff; font-weight: 800; font-size: 13px; }
#stage .tab.on { background: var(--pine); color: #fff; border-color: var(--pine-d); }
#stage .tab.x { margin-left: auto; min-width: 44px; }
#stage .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; padding: 0 6px 8px; overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#stage .card { position: relative; display: grid; grid-template-columns: 38px 1fr; grid-template-rows: auto auto auto; column-gap: 6px; text-align: left; padding: 8px; min-height: 64px; border-radius: 12px; border: 2px solid #e3d5ac; background: #fff; }
#stage .card .ci { grid-row: 1 / 3; font-size: 28px; align-self: center; text-align: center; }
#stage .card b { font-size: 13px; } #stage .card .cc { font-size: 12px; font-weight: 800; color: var(--pine-d); }
#stage .card small { grid-column: 1 / 3; font-size: 11px; opacity: .75; margin-top: 2px; }
#stage .card.locked { opacity: .5; } #stage .card.poor .cc { color: var(--red); }
#stage .toolstrip { position: absolute; left: 8px; right: 8px; bottom: 70px; display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
#stage .toolstrip .ci { font-size: 26px; } #stage .toolstrip .tt { flex: 1; display: flex; flex-direction: column; font-size: 14px; } #stage .toolstrip small { font-size: 12px; opacity: .75; }
#stage .sel { position: absolute; left: 8px; right: 8px; bottom: 70px; padding: 8px 10px; }
#stage .sel .sh { display: flex; align-items: center; gap: 8px; } #stage .sel .sh .ci { font-size: 24px; } #stage .sel .lv { margin-left: auto; font-size: 12px; font-weight: 800; background: #fff; border-radius: 8px; padding: 2px 8px; }
#stage .sel .x { min-width: 44px; min-height: 44px; border: 0; background: transparent; font-size: 18px; margin-left: 4px; }
#stage .sel p { font-size: 13px; margin: 4px 0 6px; }
#stage .sel .row { display: flex; gap: 6px; }
#stage .nb { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 6px; font-size: 12px; margin: 2px 0; }
#stage .bar2 { height: 9px; background: #e8dcb8; border-radius: 5px; overflow: hidden; } #stage .bar2 i { display: block; height: 100%; } #stage .bar2 .g { background: #3aa86a; } #stage .bar2 .y { background: #f0b429; } #stage .bar2 .r { background: var(--red); }
#stage .btn { min-height: 44px; padding: 0 14px; border-radius: 12px; border: 0; background: #fff; color: var(--ink); font-weight: 800; font-size: 14px; box-shadow: 0 3px 0 rgba(0,0,0,.2); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
#stage .btn.go { background: var(--pine); color: #fff; } #stage .btn.warn { background: #f7d9d2; color: #7a1f12; } #stage .btn.ghost { background: transparent; box-shadow: none; text-decoration: underline; }
#stage .btn[aria-disabled="true"], #stage .btn:disabled { opacity: .5; }
#stage .sel .btn { flex: 1; }

/* screens */
#stage .screen { position: absolute; inset: 0; z-index: 30; overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; background: rgba(245,236,205,.97); padding: max(12px, env(safe-area-inset-top)) 14px 18px; }
#stage .screen.menu-screen { background: linear-gradient(rgba(20,50,35,.28), rgba(20,50,35,.72)); }
#stage .screen.pause-screen, #stage .screen.results-screen { background: rgba(20,40,30,.78); }
#stage .sc-in { max-width: 380px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
#stage .menu .sc-in, #stage .sc-in.menu { padding-top: 6px; }
#stage .sc-in.menu { color: #fff; } #stage .sc-in.menu .btn { color: var(--ink); } #stage .sc-in.menu .btn.go { color: #fff; } #stage .sc-in.menu .btn.ghost { color: #fff; }
#stage .sc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; } #stage .sc-head h2 { font-size: 22px; }
#stage .acorns { background: #fff; color: var(--ink); border-radius: 12px; padding: 4px 10px; font-weight: 800; font-size: 14px; }
#stage .acorns.big { text-align: center; background: rgba(255,255,255,.9); }
#stage .logo { text-align: center; margin: 8px 0; } #stage .logo .ic { font-size: 54px; display: block; } #stage .logo h2 { font-size: 30px; letter-spacing: 1px; text-shadow: 0 3px 0 rgba(0,0,0,.35); } #stage .logo p { font-size: 14px; margin-top: 4px; text-shadow: 0 1px 0 rgba(0,0,0,.4); }
#stage .wide { width: 100%; } #stage .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .c { text-align: center; } #stage .big { font-size: 22px; }
#stage .list { display: flex; flex-direction: column; gap: 8px; }
#stage .lvl { text-align: left; padding: 10px 12px; border-radius: 14px; border: 2px solid #d9c98f; background: #fff; display: block; width: 100%; }
#stage .lvl .ln { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; } #stage .lvl p { font-size: 13px; margin: 3px 0; } #stage .lvl small { font-size: 12px; opacity: .75; }
#stage .lvl.locked { opacity: .55; } #stage .stars { color: #e0a100; letter-spacing: 2px; } #stage .stars.big { text-align: center; font-size: 34px; }
#stage .row2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border-radius: 12px; padding: 8px 10px; } #stage .row2 p { font-size: 12px; opacity: .8; } #stage .row2.done { background: #e4f4d8; } #stage .pips { color: var(--pine); letter-spacing: 2px; }
#stage .jgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; } #stage .jc { background: #efe6c6; border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 2px; min-height: 84px; } #stage .jc.on { background: #fff; } #stage .jc .ci { font-size: 28px; } #stage .jc b { font-size: 13px; } #stage .jc small { font-size: 11px; opacity: .75; }
#stage h3 { font-size: 15px; margin-top: 6px; }
#stage .how { padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
#stage .sw { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 0; background: #fff; font-weight: 800; font-size: 15px; }
#stage .sw i { width: 44px; height: 26px; border-radius: 13px; background: #c9c3a8; position: relative; transition: background .2s; } #stage .sw i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; }
#stage .sw.on i { background: var(--pine); } #stage .sw.on i::after { left: 21px; }
#stage .seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; } #stage .seg button { min-height: 44px; border: 0; border-radius: 12px; background: #fff; font-weight: 800; } #stage .seg button.on { background: var(--pine); color: #fff; }
#stage .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; } #stage .stats div { background: rgba(255,255,255,.92); color: var(--ink); border-radius: 12px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; } #stage .stats b { font-size: 18px; } #stage .stats span { font-size: 11px; }
#stage .newach { list-style: none; background: rgba(255,255,255,.92); color: var(--ink); border-radius: 12px; padding: 8px 12px; font-size: 14px; font-weight: 700; }
#stage .goalline { font-size: 14px; }

/* page chrome around the stage */
.cc-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.cc-bar .btn { min-height: 44px; min-width: 44px; }
.cc-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.cc-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.cc-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.cc-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.cc-guide p { margin-bottom: .5rem; font-size: .95rem; }
@media (prefers-reduced-motion: reduce) { #stage .hint, #stage .toast, #stage .fl, #stage .flash { animation-duration: .01s; } }
#stage .nextgoal { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); border-radius: 12px; padding: 8px 12px; font-size: 13px; line-height: 1.35; text-align: center; color: #fff; }
#stage .results-screen .stats div, #stage .results-screen .stars.big { animation: ccPop .45s cubic-bezier(.2,1.4,.4,1) both; }
#stage .results-screen .stats div:nth-child(2) { animation-delay: .08s; } #stage .results-screen .stats div:nth-child(3) { animation-delay: .16s; } #stage .results-screen .stats div:nth-child(4) { animation-delay: .24s; }
@keyframes ccPop { from { opacity: 0; transform: translateY(10px) scale(.92); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #stage .results-screen .stats div, #stage .results-screen .stars.big { animation: none; } }

/* Full screen (shell native + immersive + own overlay): the stage fills everything under the dock, nothing else takes space. */
html.pip-immersive .game-wrap, html.pip-native .game-wrap, .game-wrap:fullscreen { display: flex !important; flex-direction: column; padding: 0 !important; margin: 0 !important; overflow: hidden; }
html.pip-immersive .game-wrap #stage, html.pip-native .game-wrap #stage, .game-wrap:fullscreen #stage {
  flex: 1 1 0; min-height: 0; width: 100% !important; max-width: none !important; height: auto; aspect-ratio: auto !important; border-radius: 0; margin: 0; }
html.pip-immersive .cc-bar, html.pip-immersive .cc-keys, html.pip-immersive .cc-guide, html.pip-immersive .ad-well, html.pip-immersive .game-header,
html.pip-native .cc-bar, html.pip-native .cc-keys, .game-wrap:fullscreen .cc-bar, .game-wrap:fullscreen .cc-keys { display: none !important; }
html.pip-immersive #stage .hud, html.pip-native #stage .hud, #stage.is-big .hud { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
html.pip-immersive #stage .bar, html.pip-native #stage .bar, #stage.is-big .bar { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .pill, html.pip-native #stage .pill { min-height: 30px; font-size: 13px; }
  html.pip-immersive #stage .bar, html.pip-native #stage .bar { padding-top: 4px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
}
/* Soft vignette over the 3D view: no per-frame cost. */
#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(10,30,20,.28) 100%); }
