/* Rampline BMX 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 { --k: clamp(44px, calc(min(100vw - 32px, 78vh * 0.5625) * 0.25 - 10px), 66px); --org:#ff7a1a; --org-d:#c24f00; --ink:#1f2937; --cream:#fff6e6; --gold:#ffd23a;
  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(#8fd0ff, #cfeaff); 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 { --k: 66px; 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; }
#stage #app canvas { display: block; width: 100%; height: 100%; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage #ui button, #stage #ui .panel, #stage #ui input { pointer-events: auto; }
#stage button { 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 #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#ff7a1a, #ffb066 60%, #ffe3c2); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(120,40,0,.45); 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,.4); border-top-color: #fff; animation: bxspin .8s linear infinite; }
@keyframes bxspin { 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,24,40,.88); color: #fff; font-weight: 700; }

/* HUD */
#stage .hud { position: absolute; inset: 0; padding: max(8px, env(safe-area-inset-top)) 10px 8px; pointer-events: none; }
#stage .hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; padding-right: 50px; }
#stage .stat { background: rgba(20,24,40,.6); color: #fff; border-radius: 12px; padding: 4px 9px; display: flex; align-items: baseline; gap: 4px; min-height: 30px; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
#stage .stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
#stage .stat.big b { font-size: 20px; }
#stage .stat .lbl { font-size: 10px; opacity: .8; letter-spacing: 1px; }
#stage .dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--gold); box-shadow: inset -2px -2px 0 rgba(140,90,0,.5); align-self: center; }
#stage .target { margin-top: 4px; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
#stage .chain { position: absolute; left: 10px; top: 76px; display: flex; align-items: baseline; gap: 6px; background: var(--org); color: #fff; border-radius: 12px; padding: 4px 10px; font-weight: 900; box-shadow: 0 3px 0 var(--org-d); }
#stage .chain .cx { font-size: 20px; }
#stage .chain .cv { font-size: 14px; font-variant-numeric: tabular-nums; }
#stage .meter { position: absolute; left: 10px; right: 60px; top: 62px; height: 8px; border-radius: 6px; background: rgba(20,24,40,.45); overflow: hidden; }
#stage .meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #38bdf8, #7dd3fc); }
#stage .meter.ready i { background: linear-gradient(90deg, #22d3ee, #fff); }
#stage .pausebtn { position: absolute; right: 10px; top: max(8px, env(safe-area-inset-top)); width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(20,24,40,.65); color: #fff; font-weight: 900; font-size: 16px; pointer-events: auto; }
#stage .hint-bubble { position: absolute; left: 14px; right: 14px; top: 26%; background: rgba(20,24,40,.82); color: #fff; padding: 10px 12px; border-radius: 14px; text-align: center; font-weight: 700; font-size: 14px; pointer-events: none; }
#stage .feed { position: absolute; left: 0; right: 0; top: 36%; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#stage .fl { padding: 3px 10px; border-radius: 10px; background: rgba(20,24,40,.6); color: #fff; font-weight: 800; font-size: 14px; animation: bxfeed 1.5s ease-out forwards; }
#stage .fl.trick { background: rgba(255,122,26,.9); }
#stage .fl.bank { background: rgba(34,160,90,.92); font-size: 16px; }
#stage .fl.chain { background: rgba(59,130,246,.9); }
#stage .fl.bad { background: rgba(200,50,40,.88); }
@keyframes bxfeed { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-12px); } }
#stage .banner { position: absolute; left: 0; right: 0; top: 18%; text-align: center; pointer-events: none; opacity: 0; transform: scale(.8); transition: opacity .25s, transform .25s; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.45); }
#stage .banner.show { opacity: 1; transform: scale(1); }
#stage .b-main { font-size: clamp(28px, 10vw, 44px); font-weight: 900; letter-spacing: 2px; }
#stage .b-sub { font-size: 14px; font-weight: 700; }
#stage .flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; background: #fff; transition: opacity .12s; }

/* touch controls */
#stage .pad { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 10px max(12px, env(safe-area-inset-bottom)); pointer-events: none; }
#stage .pad.lefty { flex-direction: row-reverse; }
#stage .steerpad, #stage .actpad { display: grid; gap: 8px; pointer-events: none; grid-template-columns: repeat(2, var(--k)); }
#stage .key { width: var(--k); height: var(--k); border-radius: 18px; border: 0; background: rgba(20,24,40,.62); color: #fff; font-weight: 900; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: auto; box-shadow: 0 4px 0 rgba(0,0,0,.35); }
#stage .key .kl { font-size: 15px; letter-spacing: .5px; }
#stage .key.steer .kl { font-size: 30px; }
#stage .key small { font-size: 10px; opacity: .8; min-height: 11px; }
#stage .key.act { background: rgba(255,122,26,.88); box-shadow: 0 4px 0 var(--org-d); }
#stage .key.act.air { background: rgba(59,130,246,.92); box-shadow: 0 4px 0 #1d4bb8; }
#stage .key.down { transform: translateY(3px); filter: brightness(1.2); }

/* screens */
#stage .screen { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 10px; pointer-events: none; overflow-y: auto; }
#stage .screen .panel { pointer-events: auto; width: 100%; max-height: 100%; background: rgba(255,246,230,.97); border-radius: 20px; padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 9px; box-shadow: 0 6px 0 rgba(120,50,0,.35); text-align: center; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
#stage .panel.tall { height: 100%; }
#stage .panel .scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; display: flex; flex-direction: column; gap: 7px; }
#stage .panel h2 { margin: 0; font-size: 22px; color: var(--org-d); letter-spacing: 1px; }
#stage .panel h3 { margin: 6px 0 2px; font-size: 14px; color: var(--ink); text-align: left; }
#stage .logo { display: flex; flex-direction: column; line-height: 1; }
#stage .logo span { font-size: 15px; letter-spacing: 6px; color: #3b82f6; font-weight: 800; }
#stage .logo b { font-size: clamp(32px, 11vw, 46px); color: var(--org); letter-spacing: 3px; text-shadow: 0 3px 0 rgba(120,50,0,.25); }
#stage .tag { margin: 0; font-size: 13px; color: #4b5563; }
#stage .tag.small { font-size: 12px; }
#stage .rankbar { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; color: var(--org-d); }
#stage .rankbar .bar { flex: 1; height: 10px; background: rgba(31,41,55,.15); border-radius: 6px; overflow: hidden; }
#stage .rankbar .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--org), #ffb066); }
#stage .coinpill { display: inline-flex; align-items: center; gap: 5px; background: #fff; border-radius: 99px; padding: 3px 10px 3px 8px; font-weight: 800; color: #6a4a00; font-size: 14px; }
#stage .row2, #stage .row2c { display: flex; gap: 8px; justify-content: center; }
#stage .row2 .btn { flex: 1; padding: 0 6px; }
#stage .btn { min-height: 48px; border-radius: 14px; border: 0; background: #fff; color: var(--ink); font-weight: 900; font-size: 16px; padding: 6px 14px; box-shadow: 0 4px 0 rgba(0,0,0,.18); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
#stage .btn small { font-size: 11px; font-weight: 700; opacity: .75; }
#stage .btn.primary { background: var(--org); color: #fff; box-shadow: 0 4px 0 var(--org-d); }
#stage .btn.ghost { background: transparent; box-shadow: none; color: #4b5563; min-height: 44px; }
#stage .btn.small { min-height: 44px; font-size: 13px; padding: 4px 10px; }
#stage .btn:disabled, #stage .chip:disabled { opacity: .5; cursor: default; }
#stage .chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#stage .chip { min-height: 44px; min-width: 44px; padding: 6px 12px; border-radius: 12px; border: 2px solid #e2d3bb; background: #fff; color: var(--ink); font-weight: 800; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
#stage .chip small { font-size: 10px; font-weight: 700; opacity: .7; max-width: 110px; }
#stage .chip.on { border-color: var(--org); background: #ffe9d2; color: var(--org-d); }
#stage .chip.warn { border-color: #e11d48; color: #be123c; }
#stage .swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #cbbfa8; color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
#stage .swatch.on { box-shadow: 0 0 0 3px var(--org); }
#stage .swatch small { background: rgba(0,0,0,.5); border-radius: 6px; padding: 0 4px; margin-bottom: 2px; }
#stage .srow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 14px; text-align: left; }
#stage .list { gap: 6px; }
#stage .parkhead { text-align: left; font-weight: 900; color: #3b82f6; font-size: 13px; letter-spacing: 1px; margin-top: 4px; text-transform: uppercase; }
#stage .lvl { min-height: 48px; border-radius: 12px; border: 2px solid #e2d3bb; background: #fff; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 12px; color: var(--ink); text-align: left; }
#stage .lvl .ln { font-weight: 800; font-size: 14px; flex: 1; }
#stage .lvl small { font-size: 11px; color: #6b7280; }
#stage .lvl.locked { opacity: .55; }
#stage .stars { letter-spacing: 2px; }
#stage .st { color: #d1d5db; font-size: 20px; }
#stage .st.on { color: #f5b400; }
#stage .goalbox { background: #fff; border-radius: 12px; padding: 8px 10px; text-align: left; font-size: 13px; }
#stage .goals { margin: 4px 0 0; padding-left: 18px; font-size: 13px; text-align: left; }
#stage .goals li.done { color: #15803d; font-weight: 800; }
#stage .part { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #fff; border-radius: 12px; padding: 6px 10px; text-align: left; }
#stage .part .pi { display: flex; flex-direction: column; font-size: 13px; }
#stage .part small { font-size: 11px; color: #6b7280; }
#stage .mrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #fff; border-radius: 10px; padding: 7px 10px; font-size: 13px; text-align: left; font-weight: 700; }
#stage .mrow small { color: #6b7280; white-space: nowrap; }
#stage .mrow.done { background: #dcfce7; }
#stage .big-score { font-size: 40px; font-weight: 900; color: var(--org-d); }
#stage .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#stage .grid div { background: #fff; border-radius: 10px; padding: 5px; display: flex; flex-direction: column; font-size: 11px; color: #4b5563; }
#stage .grid b { font-size: 16px; color: var(--ink); }
#stage .gain { margin: 0; font-weight: 800; font-size: 13px; color: #15803d; }
#stage .goal { margin: 0; font-weight: 800; font-size: 13px; color: #1d4bb8; background: #e6efff; border-radius: 10px; padding: 7px 9px; }
#stage .actions { display: flex; flex-direction: column; gap: 6px; }

@media (orientation: landscape) and (max-height: 520px) {
  #stage.is-big .screen .panel { max-width: 460px; }
  #stage.is-big { --k: 56px; }
  #stage.is-big .steerpad, #stage.is-big .actpad { grid-template-columns: repeat(2, 56px); }
}
@media (max-height: 560px) { #stage .logo b { font-size: 30px; } #stage .big-score { font-size: 30px; } }
@media (prefers-reduced-motion: reduce) { #stage * { animation: none !important; transition: none !important; } }

/* page chrome under the game */
.bx-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.bx-bar .btn { min-height: 44px; min-width: 44px; }
.bx-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.bx-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.bx-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.bx-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.bx-guide p { margin-bottom: .5rem; font-size: .95rem; }
#stage .stat.low { background: rgba(200,50,40,.85); animation: bxlow .8s ease-in-out infinite; }
#stage .fl.best { background: rgba(245,180,20,.95); color: #2a1a00; font-size: 16px; }
@keyframes bxlow { 50% { transform: scale(1.08); } }

/* ---- full screen on phones (shell: html.pip-immersive / html.pip-native / :fullscreen) ---- */
html.pip-immersive .game-wrap.pip-stage, html.pip-native .game-wrap.pip-stage, .game-wrap.pip-stage:fullscreen { display: flex; flex-direction: column; overflow: hidden !important; }
html.pip-immersive .bx-keys, html.pip-native .bx-keys { display: none !important; }
html.pip-immersive .game-wrap.pip-stage #stage, html.pip-native .game-wrap.pip-stage #stage, .game-wrap.pip-stage:fullscreen #stage {
  flex: 1 1 0; min-height: 0; width: 100%; max-width: none; height: auto; aspect-ratio: auto; border-radius: 0; margin: 0;
  --k: clamp(48px, calc(min(100vw - 24px, 52vh) * 0.25 - 8px), 66px); }
html.pip-immersive .game-wrap.pip-stage #stage { padding-bottom: env(safe-area-inset-bottom, 0px); }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive .game-wrap.pip-stage #stage, html.pip-native .game-wrap.pip-stage #stage, .game-wrap.pip-stage:fullscreen #stage { --k: 52px; }
}
/* the page bar duplicates the shell Full screen button */
.bx-bar { display: none; }
/* depth: 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,20,40,.22) 100%); }
