/* Frostline Jump 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 { --ice:#2b7fd8; --ice-d:#1b57a6; --org:#ff8a2b; --org-d:#b8570c; --green:#38c172; --ink:#1f2f4a; --cream:#f4f9ff;
  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(#7fb8ea, #dff0fb); 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; }
#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 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(#2b7fd8, #9fd0f5 60%, #eaf5ff); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 2px 0 rgba(20,50,110,.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: 40px; height: 40px; border-radius: 50%; border: 5px solid rgba(255,255,255,.35); border-top-color: #fff; animation: sjspin .8s linear infinite; }
@keyframes sjspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(20,40,80,.88); color: #fff; font-weight: 700; }

/* HUD */
#stage .hit { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }
#stage .hud-top { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
#stage .hud-wind { display: flex; align-items: center; gap: 4px; background: rgba(20,40,90,.6); color: #fff; border-radius: 12px; padding: 4px 9px; min-height: 36px; font-size: 13px; }
#stage .hud-wind .arrow { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 14px solid #ffd35a; display: inline-block; transition: transform .15s; }
#stage .hud-wind b { font-size: 15px; min-width: 34px; text-align: right; }
#stage .hud-title { flex: 1; text-align: center; color: #fff; font-weight: 800; font-size: 12px; text-shadow: 0 1px 0 rgba(0,0,0,.45); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stage .pbtn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(20,40,90,.7); color: #fff; font-weight: 800; font-size: 16px; pointer-events: auto; }
#stage .hud-dist { position: absolute; top: 14%; left: 0; right: 0; text-align: center; color: #fff; text-shadow: 0 3px 0 rgba(20,50,110,.55); pointer-events: none; }
#stage .hud-dist b { font-size: clamp(34px, 12vw, 54px); font-weight: 900; } #stage .hud-dist span { font-size: 18px; margin-left: 4px; font-weight: 800; }
#stage .hud-speed { position: absolute; top: 14%; left: 0; right: 0; text-align: center; color: #fff; font-weight: 800; font-size: 20px; text-shadow: 0 2px 0 rgba(20,50,110,.55); pointer-events: none; }
#stage .hud-msg { position: absolute; top: 28%; left: 0; right: 0; text-align: center; font-size: clamp(22px, 7vw, 32px); font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(20,50,110,.6); opacity: 0; transition: opacity .2s; pointer-events: none; }
#stage .hud-msg.show { opacity: 1; } #stage .hud-msg.good { color: #b8ffd0; } #stage .hud-msg.warn { color: #ffe08a; } #stage .hud-msg.bad { color: #ffb3a8; }
#stage .hud-coach { position: absolute; left: 50%; top: 38%; transform: translateX(-50%); max-width: 84%; background: rgba(255,255,255,.95); color: var(--ink); font-weight: 800; font-size: 15px; text-align: center; padding: 9px 14px; border-radius: 14px; box-shadow: 0 4px 0 rgba(20,50,110,.35); pointer-events: none; }
#stage .bal { position: absolute; left: 50%; bottom: 150px; width: 150px; margin-left: -75px; height: 18px; border-radius: 9px; background: rgba(20,40,90,.55); pointer-events: none; }
#stage .bal-ok { position: absolute; left: 40%; width: 20%; top: 0; bottom: 0; background: rgba(56,193,114,.7); border-radius: 9px; }
#stage .bal-dot { position: absolute; left: 50%; top: -3px; width: 24px; height: 24px; margin-left: -12px; border-radius: 50%; background: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.35); }
#stage .bal span, #stage .gauge span { position: absolute; top: 22px; left: 0; right: 0; text-align: center; font-size: 10px; letter-spacing: 1.5px; color: #fff; font-weight: 800; text-shadow: 0 1px 0 rgba(0,0,0,.5); }
#stage .gauge { position: absolute; right: 12px; top: 26%; width: 30px; height: 160px; border-radius: 15px; background: rgba(20,40,90,.55); pointer-events: none; }
#stage .gauge span { top: 164px; left: -14px; right: -14px; }
#stage .g-band { position: absolute; left: 0; right: 0; background: rgba(56,193,114,.75); }
#stage .g-mark { position: absolute; left: -4px; right: -4px; top: -5px; height: 10px; border-radius: 5px; background: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.35); }
#stage .g-mark.in { background: #c8ffd9; }
#stage .roll { position: absolute; left: 50%; bottom: 150px; width: 110px; margin-left: -55px; height: 12px; border-radius: 6px; background: rgba(20,40,90,.55); pointer-events: none; }
#stage .roll-ok { position: absolute; left: 36%; width: 28%; top: 0; bottom: 0; background: rgba(56,193,114,.6); border-radius: 6px; }
#stage .roll-dot { position: absolute; left: 50%; top: -3px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: #fff; }
#stage .act-wrap { position: absolute; left: 50%; bottom: 36px; width: 84px; height: 84px; margin-left: -42px; }
#stage .act { position: absolute; inset: 0; border-radius: 50%; border: 0; background: var(--org); color: #fff; font-size: 17px; font-weight: 900; letter-spacing: 1px; box-shadow: 0 5px 0 var(--org-d); touch-action: none; }
#stage .act.pulse { animation: sjpulse .5s infinite alternate; }
#stage .hit.padmode .act-wrap { bottom: 120px; }
@keyframes sjpulse { to { transform: scale(1.1); background: #ffb13b; } }
#stage .ring { position: absolute; inset: 0; border-radius: 50%; border: 4px solid rgba(255,255,255,.95); pointer-events: none; }
#stage .ring.hot { border-color: #7dff9f; box-shadow: 0 0 14px #7dff9f; }
#stage .pad { position: absolute; left: 8px; right: 8px; bottom: 44px; display: flex; gap: 6px; pointer-events: none; }
#stage .pad button { width: 52px; height: 64px; border: 0; border-radius: 16px; background: rgba(255,255,255,.85); color: var(--ice-d); font-size: 24px; box-shadow: 0 4px 0 rgba(20,50,110,.4); pointer-events: auto; touch-action: none; }
#stage .pad button:nth-child(3) { margin-left: auto; }

/* screens */
#stage .screen { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 10px; pointer-events: none; }
#stage .panel { pointer-events: auto; width: 100%; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch;
  background: rgba(244,249,255,.97); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 9px; box-shadow: 0 6px 0 rgba(20,50,110,.35); text-align: center; }
#stage .panel h3 { margin: 0; font-size: 20px; color: var(--ice-d); letter-spacing: .5px; }
#stage .muted { margin: 0; font-size: 12.5px; color: #55657f; }
#stage .logo h2 { margin: 0; font-size: clamp(28px, 9vw, 40px); color: var(--org); letter-spacing: 2px; text-shadow: 0 3px 0 rgba(120,60,0,.22); }
#stage .logo p { margin: 2px 0 0; font-size: 13px; color: #55657f; }
#stage .topbar { display: flex; align-items: center; gap: 8px; }
#stage .chip { background: #fff; border-radius: 99px; padding: 4px 10px; font-weight: 800; font-size: 13px; border: 2px solid #d3e0f3; white-space: nowrap; }
#stage .chip.coin { color: #7a5200; }
#stage .xp { flex: 1; height: 8px; border-radius: 4px; background: #d3e0f3; overflow: hidden; } #stage .xp i { display: block; height: 100%; background: var(--green); }
#stage .menu { display: flex; flex-direction: column; gap: 8px; }
#stage .row2 { display: flex; gap: 8px; } #stage .row2 > * { flex: 1; }
#stage .btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 46px; padding: 8px 14px; border: 0; border-radius: 14px; background: var(--ice); color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 4px 0 var(--ice-d); }
#stage .btn small { font-size: 11px; font-weight: 700; opacity: .9; }
#stage .btn.big { min-height: 56px; font-size: 20px; background: var(--org); box-shadow: 0 5px 0 var(--org-d); }
#stage .btn.alt { background: #7a5be0; box-shadow: 0 5px 0 #4d3a9c; }
#stage .btn.ghost { background: #e4edf9; color: var(--ice-d); box-shadow: 0 4px 0 #c3d4ec; }
#stage .btn.dim, #stage .btn:disabled { opacity: .55; }
#stage .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
#stage .list { display: flex; flex-direction: column; gap: 7px; }
#stage .card { display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; text-align: left; background: #fff; border: 2px solid #d3e0f3; border-radius: 14px; padding: 8px 10px; min-height: 52px; color: var(--ink); font-size: 14px; }
#stage button.card { width: 100%; }
#stage .card b { font-size: 15px; } #stage .card span { font-weight: 800; color: var(--ice-d); font-size: 13px; } #stage .card em { grid-column: 1 / -1; font-style: normal; font-size: 12px; color: #55657f; }
#stage .card.locked { opacity: .55; } #stage .card.flat { display: flex; flex-direction: column; align-items: stretch; gap: 4px; } #stage .card.done { border-color: var(--green); }
#stage .tabs { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
#stage .tab { flex: 1; min-height: 44px; min-width: 64px; border: 2px solid #c9d8ee; background: #fff; border-radius: 12px; font-weight: 800; font-size: 13px; color: var(--ink); padding: 4px 6px; }
#stage .tab.on { border-color: var(--ice); background: #e1eeff; color: var(--ice-d); } #stage .tab.locked { opacity: .5; } #stage .tab.danger { background: #ffe4e0; border-color: #e0584a; color: #8a1d12; }
#stage .set { display: flex; flex-direction: column; gap: 4px; text-align: left; } #stage .set > span { font-weight: 800; font-size: 13px; }
#stage .pips { display: flex; gap: 3px; } #stage .pips i { width: 16px; height: 7px; border-radius: 3px; background: #d3e0f3; } #stage .pips i.on { background: var(--green); }
#stage .bar { height: 8px; border-radius: 4px; background: #d3e0f3; overflow: hidden; } #stage .bar i { display: block; height: 100%; background: var(--ice); }
#stage .tbl { width: 100%; border-collapse: collapse; font-size: 14px; } #stage .tbl td { padding: 6px 5px; border-bottom: 1px solid #d3e0f3; text-align: left; } #stage .tbl td:last-child { text-align: right; font-weight: 800; } #stage .tbl tr.you { background: #fff1d6; font-weight: 800; }
#stage .prize { background: #fff1d6; border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 2px; } #stage .prize b { font-size: 20px; color: var(--org-d); } #stage .prize em { font-style: normal; font-weight: 800; color: #1f7a4a; }
#stage .steps { text-align: left; font-size: 13px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
#stage .plain { list-style: none; font-size: 13px; text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 0; }
#stage .big-n { font-size: 46px; font-weight: 900; color: var(--ice-d); line-height: 1; } #stage .big-n small { display: block; font-size: 12px; letter-spacing: 2px; color: #55657f; }
#stage .kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; text-align: left; font-size: 13px; background: #fff; border-radius: 12px; padding: 7px 10px; } #stage .kv b { text-align: right; }
#stage .judges { display: flex; gap: 5px; justify-content: center; } #stage .judges i { font-style: normal; background: #fff; border: 2px solid #d3e0f3; border-radius: 8px; padding: 4px 6px; font-weight: 800; font-size: 14px; } #stage .judges i.drop { opacity: .4; text-decoration: line-through; }
#stage .land { margin: 0; font-weight: 800; } #stage .land.good { color: #1f7a4a; } #stage .land.bad { color: #b32d1f; }
#stage .earn { margin: 0; font-weight: 800; color: #7a5200; } #stage .goal { margin: 0; font-weight: 800; font-size: 13px; color: var(--ice-d); background: #e1eeff; border-radius: 10px; padding: 7px 9px; }
#stage .ach { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; } #stage .a { text-align: left; background: #fff; border: 2px solid #d3e0f3; border-radius: 10px; padding: 6px; font-size: 11px; opacity: .6; display: flex; flex-direction: column; } #stage .a b { font-size: 12px; } #stage .a.got { opacity: 1; border-color: var(--green); } #stage .a em { font-style: normal; color: #7a5200; font-weight: 800; }
#stage .toast { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: 90%; background: rgba(20,40,90,.92); color: #fff; font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 12px; pointer-events: none; z-index: 40; }
@media (prefers-reduced-motion: reduce) { #stage .act.pulse, #stage .spinner { animation: none; } #stage .hud-msg { transition: none; } }
@media (max-height: 560px) { #stage.is-big .panel { max-width: 460px; } }
#stage.is-big .screen { align-items: center; } #stage.is-big .panel { max-width: 460px; }

/* page chrome under the game (not part of the stage) */
.sj-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.sj-bar .btn { min-height: 44px; min-width: 44px; }
.sj-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.sj-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.sj-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.sj-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.sj-guide p { margin-bottom: .5rem; font-size: .95rem; }
#stage .hud-goal { position: absolute; top: calc(14% + 66px); left: 0; right: 0; display: block; text-align: center; font-size: 13px; font-weight: 800; color: #fff; text-shadow: 0 2px 0 rgba(20,50,110,.55); pointer-events: none; }
#stage .hud-goal[hidden] { display: none; }
#stage .hud-dist.past-k b { color: #ffe08a; } #stage .hud-dist.past-best b { color: #b8ffd0; }
#stage .hud-dist b { transition: color .25s; }
#stage .dbar { position: relative; height: 12px; border-radius: 8px; background: #dbe7f7; overflow: hidden; margin: 8px 0 4px; }
#stage .dbar b { display: block; height: 100%; background: linear-gradient(90deg, #3d8cf0, #2b6fc8); border-radius: 8px; }
#stage .dbar.best b { background: linear-gradient(90deg, #35b86b, #1f9a52); }
#stage .dbar i { position: absolute; top: 0; bottom: 0; width: 3px; background: #1e293b; opacity: .75; }
#stage .dbar i.pb { background: #d97706; }
#stage .newbest { margin: 0 0 4px; font-weight: 800; font-size: 13px; color: #1f7a45; }
@media (prefers-reduced-motion: reduce) { #stage .hud-dist b { transition: none; } }

/* ---- Third pass: shell full screen (immersive and native), finish ---- */
html.pip-immersive .game-wrap.pip-stage { display: flex; flex-direction: column; overflow: hidden; padding-left: 0; padding-right: 0; padding-bottom: 0; }
html.pip-immersive .game-wrap.pip-stage > .sj-bar,
html.pip-immersive .game-wrap.pip-stage > .sj-keys,
html.pip-immersive .game-wrap.pip-stage > .game-title,
html.pip-immersive .game-wrap.pip-stage > noscript { display: none; }
html.pip-immersive #stage, html.pip-immersive #stage.is-big {
  position: relative; inset: auto; z-index: auto; flex: 1 1 0; min-height: 0; width: 100%; max-width: none; height: auto;
  aspect-ratio: auto; margin: 0; border-radius: 0;
}
html.pip-immersive #stage .act-wrap { bottom: calc(36px + env(safe-area-inset-bottom, 0px)); }
html.pip-immersive #stage .hud-top { left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); }
html.pip-immersive #stage .screen { padding-bottom: env(safe-area-inset-bottom, 0px); overflow-y: auto; }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .act-wrap { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); width: 76px; height: 76px; margin-left: -38px; }
  html.pip-immersive #stage .hud-goal { top: calc(10% + 52px); }
}
/* depth: soft vignette and a lit button */
#stage #app::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, rgba(255,255,255,0) 55%, rgba(18,45,96,.22) 100%); }
#stage .act { background: radial-gradient(circle at 35% 28%, #ffb066, var(--org) 55%, #e56d12); box-shadow: 0 5px 0 var(--org-d), 0 10px 18px rgba(20,40,90,.3); transition: transform .08s; }
#stage .act:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--org-d), 0 4px 8px rgba(20,40,90,.3); }

/* ---- Fourth pass: keep the Back / action row on screen in full screen ---- */
html.pip-immersive #stage .screen, html.pip-native #stage .screen { padding-top: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)); overflow: hidden; }
html.pip-immersive #stage .panel, html.pip-native #stage .panel { max-height: 100%; }
html.pip-immersive #stage .panel > .actions, html.pip-native #stage .panel > .actions {
  position: sticky; bottom: -12px; z-index: 2; margin: 0 -12px -12px; padding: 8px 12px 12px; background: rgba(244,249,255,.97); border-radius: 0 0 18px 18px;
}
html.pip-immersive #stage .panel > .actions .btn, html.pip-native #stage .panel > .actions .btn { min-height: 46px; }
