/* Jetpack Canyon 3D - stage and in-game UI. Everything is scoped under #stage so site styles never leak in. Sizes use em; main.js sets the stage font size from its width. */
html.pip-big, html.pip-big body { overflow: hidden; }
#stage { --accent:#e8743b; --accent-d:#a8501f; --gold:#ffc83a; --green:#4aff7a; --ink:#2a1a14; --panel:rgba(32,18,14,.88); --line:rgba(255,255,255,.14);
  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; font-size: 15px;
  border-radius: 14px; background: linear-gradient(#ffd9a0, #ff8f5a); color: #fff; 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 #ui button, #stage #ui .screen:not([hidden]) { 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: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#ffd9a0, #ff8f5a); }
#stage #loader[hidden] { display: none; }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: .7em; color: #fff; text-shadow: 0 2px 0 rgba(90,30,10,.5); text-align: center; padding: 0 1.2em; }
#stage .load-in b { font-size: 1.7em; letter-spacing: 2px; }
#stage .spinner { width: 2.6em; height: 2.6em; border-radius: 50%; border: .4em solid rgba(255,255,255,.4); border-top-color: var(--gold); animation: jcspin .8s linear infinite; }
@keyframes jcspin { 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: 1.6em; background: rgba(30,14,10,.9); color: #fff; font-weight: 700; }

/* screens */
#stage .screen { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; overflow: hidden; }
#stage .screen.dim { background: rgba(20,8,6,.62); align-items: center; justify-content: center; padding: 1em; overflow-y: auto; touch-action: pan-y; }
#stage .home { flex: 1; display: flex; flex-direction: column; justify-content: space-between; padding: max(.7em, env(safe-area-inset-top)) .9em .9em; background: linear-gradient(rgba(30,10,4,.55), rgba(30,10,4,0) 34%, rgba(30,10,4,0) 52%, rgba(30,10,4,.72)); }
#stage .toprow { display: flex; justify-content: space-between; align-items: center; gap: .5em; }
#stage .rank, #stage .coinchip { background: rgba(0,0,0,.45); border-radius: 999px; padding: .3em .8em; font-size: .85em; display: inline-flex; align-items: center; gap: .4em; }
#stage .xpbar { display: inline-block; width: 4.5em; height: .45em; background: rgba(255,255,255,.25); border-radius: 9px; overflow: hidden; }
#stage .xpbar i { display: block; height: 100%; background: var(--gold); }
#stage .coinchip b { color: var(--gold); }
#stage .logo { text-align: center; margin-top: .6em; text-shadow: 0 3px 0 rgba(90,30,10,.7); }
#stage .logo small { letter-spacing: .5em; font-size: .75em; color: #ffe2b0; }
#stage .logo h1 { font-size: 2.5em; line-height: .98; letter-spacing: 1px; color: #fff; text-transform: uppercase; }
#stage .menu { display: flex; flex-direction: column; gap: .6em; }
#stage .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5em; }
#stage .tip { text-align: center; font-size: .8em; opacity: .9; margin-top: .6em; text-shadow: 0 1px 2px #000; }
#stage .btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; min-height: max(44px, 2.9em); min-width: 44px; padding: .5em .8em; border: 0; border-radius: .9em; background: var(--accent); color: #fff; font-weight: 800; font-size: 1em; box-shadow: 0 .28em 0 var(--accent-d); text-decoration: none; }
#stage .btn:active { transform: translateY(.2em); box-shadow: 0 .08em 0 var(--accent-d); }
#stage .btn:disabled { background: #7a6a64; box-shadow: 0 .28em 0 #54463f; cursor: default; color: #d8c8c0; }
#stage .btn.big { min-height: 3.6em; font-size: 1.4em; letter-spacing: .2em; flex-direction: column; background: #f2a21f; box-shadow: 0 .22em 0 #a86a0a; color: #3a2200; gap: 0; }
#stage .btn.big small { font-size: .5em; letter-spacing: .05em; font-weight: 700; opacity: .85; }
#stage .btn.alt { background: #4a6a8a; box-shadow: 0 .28em 0 #2e445c; }
#stage .btn.ghost { background: rgba(255,255,255,.14); box-shadow: none; min-height: 44px; }
#stage .btn.danger { background: #d94a4a; box-shadow: 0 .28em 0 #962b2b; }
#stage .dot { font-style: normal; background: #ff4a4a; border-radius: 999px; padding: 0 .45em; font-size: .8em; }

#stage .panel { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; padding: max(.6em, env(safe-area-inset-top)) .8em 1em; background: var(--panel); }
#stage .phead { display: flex; align-items: center; gap: .5em; margin-bottom: .6em; position: sticky; top: 0; z-index: 2; padding: .3em 0; background: var(--panel); }
#stage .phead h2 { flex: 1; font-size: 1.25em; }
#stage .sub { font-size: .82em; opacity: .85; margin: .2em 0 .7em; }
#stage h3 { font-size: 1em; margin: 1em 0 .4em; color: #ffd9a0; }
#stage .list { display: flex; flex-direction: column; gap: .5em; }
#stage .card { display: flex; align-items: center; gap: .7em; padding: .6em .7em; min-height: 3.2em; background: rgba(255,255,255,.09); border: 1px solid var(--line); border-radius: .8em; text-align: left; width: 100%; }
#stage button.card:active { background: rgba(255,255,255,.2); }
#stage .card.locked { opacity: .5; }
#stage .card.done { border-color: #6aff8a; }
#stage .card .nm { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#stage .card .nm small { opacity: .75; font-size: .78em; }
#stage .num { flex: none; width: 2.1em; height: 2.1em; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-size: 1em; color: #fff; }
#stage .stars i { font-style: normal; color: #6a5a54; font-size: 1.1em; }
#stage .stars i.on { color: var(--gold); text-shadow: 0 0 6px rgba(255,200,58,.6); }
#stage .lock { font-size: .75em; opacity: .7; }
#stage .pips { display: flex; gap: .25em; margin-top: .3em; }
#stage .pips i { width: 1.1em; height: .45em; border-radius: 3px; background: rgba(255,255,255,.2); }
#stage .pips i.on { background: var(--gold); }
#stage .card.mis { flex-wrap: wrap; } #stage .card.mis .bar { flex: 1 1 100%; }
#stage .bar { display: block; height: .45em; border-radius: 9px; background: rgba(255,255,255,.2); overflow: hidden; }
#stage .bar i { display: block; height: 100%; background: var(--green); }
#stage .rw { font-size: .8em; color: var(--gold); white-space: nowrap; }
#stage .swatches { display: flex; flex-wrap: wrap; gap: .5em; }
#stage .swatch { display: flex; flex-direction: column; align-items: center; gap: .2em; min-width: 4.2em; min-height: 44px; padding: .4em; border-radius: .7em; background: rgba(255,255,255,.09); border: 2px solid transparent; font-size: .8em; }
#stage .swatch i { width: 2em; height: 2em; border-radius: 50%; border: 2px solid #fff; }
#stage .swatch.sel { border-color: var(--gold); } #stage .swatch.locked { opacity: .45; }
#stage .seg { display: flex; border-radius: .7em; overflow: hidden; border: 1px solid var(--line); }
#stage .seg button { min-height: 44px; min-width: 44px; padding: .3em .7em; background: rgba(255,255,255,.08); border: 0; font-size: .85em; font-weight: 700; }
#stage .seg button.on { background: var(--accent); }
#stage .box { background: rgba(255,255,255,.09); border: 1px solid var(--line); border-radius: .9em; padding: 1em; display: flex; flex-direction: column; gap: .7em; }
#stage .box h3 { margin: 0; font-size: 1.15em; }
#stage .big2 b { color: var(--gold); }

#stage .modal { width: 100%; max-width: 20em; background: var(--panel); border: 1px solid var(--line); border-radius: 1em; padding: 1em; display: flex; flex-direction: column; gap: .6em; text-align: center; touch-action: pan-y; }
#stage .modal h2 { font-size: 1.5em; }
#stage .modal table { width: 100%; font-size: .9em; border-collapse: collapse; }
#stage .modal td { padding: .2em .1em; border-bottom: 1px solid var(--line); text-align: left; }
#stage .modal td + td { text-align: right; font-weight: 700; }
#stage .bigstars .stars i { font-size: 2.2em; }
#stage .gain { color: var(--gold); font-weight: 800; font-size: 1.2em; }
#stage .notes { list-style: none; font-size: .82em; display: flex; flex-direction: column; gap: .2em; }
#stage .notes .gold { color: var(--gold); }
#stage .goal { font-size: .88em; background: rgba(255,255,255,.1); padding: .5em; border-radius: .6em; }
#stage .btns { display: flex; flex-direction: column; gap: .5em; }

/* HUD */
#stage .hud { position: absolute; inset: 0; z-index: 5; pointer-events: none; padding: max(.5em, env(safe-area-inset-top)) .6em .6em; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
#stage .hud-top { display: flex; align-items: center; gap: .5em; }
#stage .pausebtn { pointer-events: auto; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,.4); font-size: .85em; letter-spacing: -2px; flex: none; }
#stage .dist { flex: 1; text-align: center; }
#stage .dist b { font-size: 1.7em; font-variant-numeric: tabular-nums; }
#stage .pbar { display: block; height: .35em; margin: .1em auto 0; width: 70%; background: rgba(0,0,0,.35); border-radius: 9px; overflow: hidden; }
#stage .pbar i { display: block; height: 100%; width: 0; background: var(--gold); }
#stage .coinhud { display: flex; align-items: center; gap: .3em; background: rgba(0,0,0,.4); border-radius: 999px; padding: .25em .7em; min-width: 4em; justify-content: center; }
#stage .cdot { width: .9em; height: .9em; border-radius: 50%; background: var(--gold); display: inline-block; }
#stage .hearts { display: flex; gap: .25em; margin: .5em 0 0 .2em; }
#stage .hearts i { width: 1.1em; height: 1.1em; border-radius: 40% 40% 50% 50%; background: rgba(0,0,0,.4); border: 2px solid #fff; transform: rotate(45deg) scale(.8); }
#stage .hearts i.on { background: #ff4a6a; }
#stage .combo { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-weight: 800; font-size: 1.1em; color: var(--gold); }
#stage .fuel { position: absolute; left: .6em; bottom: 4.5em; width: 1.3em; height: 38%; background: rgba(0,0,0,.45); border: 2px solid #fff; border-radius: .7em; overflow: hidden; display: flex; align-items: flex-end; }
#stage .fuel small { position: absolute; left: 50%; bottom: -1.6em; transform: translateX(-50%); font-size: .6em; letter-spacing: 1px; }
#stage .fuel-fill { display: block; width: 100%; height: 100%; background: linear-gradient(#7aff9a, #2ad45a); transition: height .08s linear; }
#stage .fuel.low { animation: jcblink .5s steps(2) infinite; } #stage .fuel.low .fuel-fill { background: #ff5a4a; }
@keyframes jcblink { 50% { border-color: #ff5a4a; } }
#stage .hint { position: absolute; left: 50%; bottom: 16%; transform: translateX(-50%); width: 80%; text-align: center; background: rgba(0,0,0,.6); border-radius: .9em; padding: .6em .8em; font-weight: 700; }
#stage .banner { position: absolute; left: 50%; top: 32%; transform: translateX(-50%); width: 90%; text-align: center; font-size: 1.5em; font-weight: 800; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.6); }
#stage .wind { position: absolute; right: .6em; top: 18%; font-size: .75em; background: rgba(0,0,0,.45); padding: .3em .6em; border-radius: .7em; }
#stage .toast { position: absolute; left: 50%; bottom: 3.2em; transform: translateX(-50%); z-index: 20; width: 86%; text-align: center; background: rgba(0,0,0,.75); border-radius: .8em; padding: .6em .8em; font-size: .85em; pointer-events: none; }

/* page chrome around the stage */
.jc-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.jc-bar .btn { min-height: 44px; min-width: 44px; background: #E8743B; }
.jc-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.jc-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.jc-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.jc-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.jc-guide p { margin-bottom: .5rem; font-size: .95rem; }
#stage .bestline { position: absolute; left: 50%; top: 4.2em; transform: translateX(-50%); font-size: .75em; font-weight: 700; background: rgba(0,0,0,.4); padding: .2em .7em; border-radius: 999px; white-space: nowrap; }
#stage .bestline[hidden] { display: none; }
#stage .bestline.beaten { background: var(--gold); color: #1a1208; text-shadow: none; }
#stage .flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 5em 1.2em rgba(255,40,40,.75); }
#stage .flash.on { animation: jcflash .45s ease-out; }
@keyframes jcflash { from { opacity: 1; } to { opacity: 0; } }
#stage .checks { list-style: none; margin: .2em 0 .5em; font-size: .85em; text-align: left; display: inline-block; }
#stage .checks li { padding: .15em 0 .15em 1.6em; position: relative; opacity: .75; }
#stage .checks li::before { content: ""; position: absolute; left: .2em; top: .3em; width: .9em; height: .9em; border-radius: 50%; border: 2px solid #fff; }
#stage .checks li.ok { opacity: 1; font-weight: 700; } #stage .checks li.ok::before { background: var(--gold); border-color: var(--gold); }
@media (prefers-reduced-motion: reduce) { #stage .spinner, #stage .fuel.low { animation: none; } #stage .flash.on { animation-duration: .01s; } }

/* Depth: a static vignette over the canvas (painted once, 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) 55%, rgba(30,10,4,.32) 100%); }

/* Full screen (shell native + immersive): the stage fills the area under the dock, the page chrome steps aside. */
html.pip-immersive .game-wrap.pip-stage { display: flex; flex-direction: column; align-items: stretch; justify-content: stretch; overflow: hidden; padding-left: 0; padding-right: 0; padding-bottom: 0; }
html.pip-immersive .game-wrap.pip-stage #stage { flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; height: auto; aspect-ratio: auto; border-radius: 0; margin: 0; }
html.pip-immersive .game-wrap.pip-stage > .jc-bar,
html.pip-immersive .game-wrap.pip-stage > .jc-keys,
html.pip-immersive .game-wrap.pip-stage > .game-title { display: none; }
