/* Moto Highway 3D - stage + in-game UI. Everything is scoped under #stage so site styles never leak in. */
html.pip-big, html.pip-big body { overflow: hidden; }
#stage { --acc:#f26b1d; --acc-d:#c4500f; --ink:#0d1530; --panel:rgba(10,16,38,.9); --txt:#f2f5ff; --dim:#aab4d6; --good:#43d17a; --warn:#ffd23f;
  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: #101a3a; color: var(--txt);
  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, .game-wrap:fullscreen #stage, .game-wrap:-webkit-full-screen #stage, html.pip-immersive #stage { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; z-index: 99999; }
.game-wrap:fullscreen #stage, .game-wrap:-webkit-full-screen #stage { position: absolute; z-index: 1; }
#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 { 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 #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#101a3a, #2a2f5e); }
#stage #loader[hidden], #stage #ctxlost[hidden], #stage .hud[hidden], #stage [hidden] { display: none !important; }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 0 18px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 30px); letter-spacing: 3px; }
#stage .load-in span { font-size: 14px; color: var(--dim); }
#stage .spinner { width: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.25); border-top-color: var(--acc); animation: mhspin .8s linear infinite; }
@keyframes mhspin { 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(10,16,38,.92); font-weight: 700; }

/* screens */
#stage .screens { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
#stage .screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 10px; pointer-events: none; background: linear-gradient(rgba(6,10,26,.15), rgba(6,10,26,.55)); }
#stage .panel { width: 100%; max-width: 400px; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; background: var(--panel); border: 1px solid rgba(255,255,255,.12); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 9px; }
#stage .panel h2 { font-size: 22px; text-align: center; letter-spacing: .5px; }
#stage .panel h3 { font-size: 15px; margin-bottom: 4px; }
#stage .logo { text-align: center; line-height: 1; padding: 4px 0; }
#stage .logo b { display: block; font-size: 44px; letter-spacing: 6px; color: var(--acc); text-shadow: 0 3px 0 #2a1204; }
#stage .logo span { font-size: 17px; letter-spacing: 8px; color: #fff; }
#stage .note { font-size: 12.5px; color: var(--dim); text-align: center; }
#stage .rank { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
#stage .coins { margin-left: auto; color: var(--warn); font-weight: 800; font-size: 13px; white-space: nowrap; }
#stage .bar { flex: 1; height: 8px; border-radius: 5px; background: rgba(255,255,255,.15); overflow: hidden; display: inline-block; min-width: 40px; vertical-align: middle; }
#stage .bar i { display: block; height: 100%; background: var(--acc); }
#stage .b { min-height: 46px; border: 0; border-radius: 12px; background: #27346a; font-weight: 800; font-size: 15px; padding: 8px 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
#stage .b small { font-weight: 600; font-size: 10.5px; opacity: .8; }
#stage .b.big { min-height: 54px; font-size: 20px; letter-spacing: 1px; background: #33427f; }
#stage .b.go { background: linear-gradient(var(--acc), var(--acc-d)); color: #fff; box-shadow: 0 4px 0 #6b2a07; }
#stage .b.small { min-height: 44px; min-width: 56px; font-size: 13px; padding: 6px 10px; }
#stage .b.ok { background: var(--good); color: #05260f; }
#stage .b.danger { background: #8a2430; }
#stage .b[aria-disabled="true"] { opacity: .45; }
#stage .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#stage .segs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
#stage .seg { min-height: 44px; border: 2px solid transparent; border-radius: 10px; background: #1c2650; font-size: 12.5px; font-weight: 700; padding: 4px 6px; text-transform: capitalize; }
#stage .seg.on { border-color: var(--acc); background: #3a2a2a; }
#stage .seg.locked, #stage .chip.locked { opacity: .5; }
#stage .chips { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
#stage .chips.bikes { grid-template-columns: repeat(3, 1fr); }
#stage .chip { min-height: 46px; border: 2px solid transparent; border-radius: 10px; background: #1c2650; font-size: 12.5px; font-weight: 700; padding: 4px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#stage .chip.on { border-color: var(--acc); }
#stage .chip small { font-size: 10px; font-weight: 600; color: var(--dim); }
#stage .chip .stars { color: var(--warn); }
#stage .topbar { display: flex; align-items: center; gap: 8px; }
#stage .topbar h2 { flex: 1; font-size: 18px; }
#stage .card { background: rgba(255,255,255,.06); border-radius: 12px; padding: 10px; }
#stage .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; font-size: 12px; color: var(--dim); margin-top: 6px; }
#stage .ups { display: flex; flex-direction: column; gap: 6px; }
#stage .up { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: rgba(255,255,255,.06); border-radius: 10px; padding: 6px 8px; font-size: 13px; }
#stage .up > div { flex: 1; display: flex; flex-direction: column; gap: 3px; }
#stage .up small { font-size: 10.5px; color: var(--dim); }
#stage .maxed { color: var(--good); font-weight: 800; font-size: 12px; }
#stage .list { list-style: none; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
#stage .list li.done { color: var(--good); }
#stage .list small { color: var(--warn); }
#stage .res { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#stage .res div { background: rgba(255,255,255,.07); border-radius: 10px; padding: 8px; text-align: center; }
#stage .res b { display: block; font-size: 19px; }
#stage .res span { font-size: 11px; color: var(--dim); }
#stage .earn { text-align: center; color: var(--warn); font-weight: 800; }
#stage .goal { font-size: 13px; text-align: center; background: rgba(242,107,29,.15); border-radius: 10px; padding: 8px; }
#stage .badge { text-align: center; font-weight: 800; font-size: 13px; color: #fff; background: #2d7a4a; border-radius: 8px; padding: 4px 8px; }
#stage .stars.big { text-align: center; font-size: 30px; color: var(--warn); letter-spacing: 6px; }

/* HUD */
#stage .hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; padding: max(8px, env(safe-area-inset-top)) 10px 8px; }
#stage .hud-top { display: flex; gap: 6px; padding-right: 54px; }
#stage .stat { background: rgba(10,16,38,.6); border-radius: 12px; padding: 4px 10px; display: flex; align-items: baseline; gap: 5px; min-height: 36px; }
#stage .stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
#stage .stat.sc { margin-left: auto; }
#stage .stat.sc b { font-size: 19px; }
#stage .lbl { font-size: 10px; letter-spacing: 1px; color: var(--dim); }
#stage .shields { color: #66e0ff; font-size: 13px; letter-spacing: 2px; }
#stage .hud-sub { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 13px; font-weight: 700; text-shadow: 0 1px 2px #000; }
#stage .timer { background: rgba(10,16,38,.65); border-radius: 8px; padding: 1px 8px; font-size: 17px; font-variant-numeric: tabular-nums; }
#stage .timer.low { background: #a32033; animation: mhblink .5s infinite alternate; }
@keyframes mhblink { to { opacity: .55; } }
#stage .mult { background: var(--warn); color: #3a2a00; border-radius: 8px; padding: 1px 7px; font-size: 11px; }
#stage .cpbar { height: 6px; margin-top: 6px; background: rgba(255,255,255,.2); border-radius: 4px; overflow: hidden; }
#stage .cpbar i { display: block; height: 100%; width: 0; background: var(--good); }
#stage .pausebtn { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 8px; width: 46px; height: 46px; border-radius: 12px; border: 0; background: rgba(10,16,38,.7); font-weight: 800; font-size: 16px; pointer-events: auto; }
#stage .combo { position: absolute; left: 0; right: 0; top: 24%; text-align: center; font-weight: 900; font-size: 20px; color: var(--warn); text-shadow: 0 2px 0 #000; }
#stage .combo.pop { animation: mhpop .3s ease-out; }
@keyframes mhpop { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }
#stage .feed { position: absolute; left: 0; right: 0; top: 31%; text-align: center; font-weight: 800; font-size: 16px; text-shadow: 0 2px 0 #000; }
#stage .banner { position: absolute; left: 10px; right: 10px; top: 18%; text-align: center; font-weight: 900; font-size: 24px; letter-spacing: 1px; text-shadow: 0 3px 0 #000; }
#stage .hint-bubble { position: absolute; left: 14px; right: 14px; bottom: 126px; text-align: center; background: rgba(10,16,38,.85); border: 1px solid var(--acc); border-radius: 12px; padding: 8px 10px; font-size: 14px; font-weight: 700; }
#stage .pad { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); width: 92px; height: 92px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); background: rgba(10,16,38,.55); font-size: 15px; letter-spacing: 1px; pointer-events: auto; display: flex; align-items: center; justify-content: center; }
#stage .pad.gas { right: 14px; background: rgba(40,160,80,.55); }
#stage .pad.brake { left: 14px; background: rgba(190,50,50,.55); }
#stage .hud.swap .pad.gas { right: auto; left: 14px; }
#stage .hud.swap .pad.brake { left: auto; right: 14px; }
#stage .pad.held { transform: scale(.94); border-color: #fff; background-color: rgba(255,255,255,.35); }
#stage .flash { position: absolute; inset: 0; pointer-events: none; animation: mhflash .4s ease-out forwards; }
#stage .flash.near { box-shadow: inset 0 0 60px 6px rgba(255,210,63,.55); }
#stage .flash.hit { background: rgba(102,224,255,.3); }
#stage .flash.crash { background: rgba(220,40,40,.45); }
@keyframes mhflash { to { opacity: 0; } }
#stage .toast { position: absolute; left: 20px; right: 20px; bottom: 70px; z-index: 30; text-align: center; background: rgba(10,16,38,.95); border: 1px solid var(--acc); border-radius: 10px; padding: 10px; font-weight: 700; font-size: 14px; pointer-events: none; }
@media (max-height: 560px) { #stage .logo b { font-size: 34px; } #stage .pad { width: 78px; height: 78px; } #stage .panel { padding: 10px; gap: 7px; } }
@media (prefers-reduced-motion: reduce) { #stage .flash, #stage .combo.pop, #stage .timer.low { animation: none; } }

/* page chrome below the stage */
.mh-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.mh-bar .btn { min-height: 44px; min-width: 44px; }
.mh-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.mh-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.mh-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.mh-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.mh-guide p { margin-bottom: .5rem; font-size: .95rem; }

#stage .bestchip { margin-left: auto; margin-right: 56px; font-size: 12px; letter-spacing: .06em; opacity: .85; }
#stage .bestchip[hidden] { display: none; }
#stage .bestchip.hit { color: var(--warn); opacity: 1; }
#stage .streaks { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: linear-gradient(90deg, rgba(255,255,255,.22), transparent 14%, transparent 86%, rgba(255,255,255,.22)),
  repeating-linear-gradient(90deg, transparent 0 22px, rgba(255,255,255,.07) 22px 24px);
  -webkit-mask-image: radial-gradient(ellipse at 50% 60%, transparent 38%, #000 100%); mask-image: radial-gradient(ellipse at 50% 60%, transparent 38%, #000 100%); }
@media (prefers-reduced-motion: reduce) { #stage .streaks { display: none; } }

/* Full screen (shell native + immersive): the stage fills the shell's box below the dock, nothing else takes space. */
html.pip-immersive .game-wrap, html.pip-native .game-wrap, .game-wrap:fullscreen { display: flex; flex-direction: column; }
html.pip-immersive .mh-bar, html.pip-immersive .mh-keys, html.pip-native .mh-bar, html.pip-native .mh-keys,
.game-wrap:fullscreen .mh-bar, .game-wrap:fullscreen .mh-keys, html.pip-immersive .mh-guide { display: none; }
html.pip-immersive #stage, html.pip-native #stage, .game-wrap:fullscreen #stage, .game-wrap:-webkit-full-screen #stage {
  position: relative; inset: auto; flex: 1 1 0; min-height: 0; width: 100%; height: auto; max-width: none; aspect-ratio: auto; border-radius: 0; z-index: 1; }
html.pip-immersive #stage .pad, html.pip-native #stage .pad { bottom: max(14px, env(safe-area-inset-bottom)); }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .pad, html.pip-native #stage .pad { width: 84px; height: 84px; }
  html.pip-immersive #stage .panel, html.pip-native #stage .panel { max-width: 520px; }
}

/* Depth: soft vignette over the 3D view, under the HUD and menus. Static, no per-frame cost. */
#stage #app::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, transparent 55%, rgba(5,8,22,.38) 100%); }
