/* Monster Truck 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 { --org:#e8731a; --org-d:#b3500a; --sun:#ffd23f; --green:#4ad45a; --ink:#2a1a12; --cream:#fff3dc; --panel:rgba(32,20,14,.93); --line:rgba(255,230,190,.18);
  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(#ffc98a 0%, #ffe9c2 100%); color: var(--cream);
  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%; touch-action: none; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage #ui button, #stage #ui .panel, #stage #ui .scroll { 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; }

/* loader and context-lost notice */
#stage #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#e8731a 0%, #ffb35c 60%, #ffe9c2 100%); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(90,40,0,.5); text-align: center; padding: 0 18px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 32px); letter-spacing: 3px; }
#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: mtspin .8s linear infinite; }
@keyframes mtspin { 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(40,20,10,.88); color: #fff; font-weight: 700; }

/* HUD */
#stage .hud { position: absolute; inset: 0; pointer-events: none; }
#stage .hud-pause { position: absolute; top: 8px; left: 8px; width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--line); background: rgba(32,20,14,.7); font-weight: 800; font-size: 16px; letter-spacing: 2px; pointer-events: auto; }
#stage .hud-c { position: absolute; top: 6px; left: 62px; right: 74px; text-align: center; text-shadow: 0 2px 0 rgba(0,0,0,.55); }
#stage #h-main { font-size: clamp(22px, 7vw, 32px); font-weight: 800; }
#stage #h-sub { font-size: 12px; opacity: .92; }
#stage .hud-r { position: absolute; top: 8px; right: 8px; text-align: right; text-shadow: 0 2px 0 rgba(0,0,0,.55); }
#stage #h-spd { font-size: 12px; font-weight: 700; }
#stage #h-mult { font-size: 22px; font-weight: 800; color: var(--sun); }
#stage .prog { position: absolute; top: 58px; left: 14px; right: 14px; height: 8px; border-radius: 4px; background: rgba(0,0,0,.35); }
#stage .prog i { position: absolute; top: -3px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--sun); border: 2px solid #fff; }
#stage .prog i.r { background: #e0457b; z-index: 0; }
#stage .prog i.r2 { background: #3f8fe0; z-index: 0; }
#stage #feed { position: absolute; left: 0; right: 0; top: 78px; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#stage .fi { padding: 4px 12px; border-radius: 14px; background: rgba(32,20,14,.78); font-weight: 700; font-size: 14px; animation: mtfade 1.5s forwards; }
#stage .fi.trick, #stage .fi.pts { color: var(--sun); }
#stage .fi.bad { color: #ff8a7a; }
#stage .fi.ok { color: #8dff9a; }
@keyframes mtfade { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
#stage #banner { position: absolute; left: 0; right: 0; top: 26%; text-align: center; pointer-events: none; text-shadow: 0 4px 0 rgba(0,0,0,.5); }
#stage #banner b { display: block; font-size: clamp(44px, 16vw, 78px); color: #fff; line-height: 1; }
#stage #banner span { font-size: 16px; font-weight: 700; }
#stage #hint { position: absolute; left: 12px; right: 12px; bottom: 150px; padding: 8px 12px; border-radius: 12px; background: rgba(32,20,14,.85); text-align: center; font-size: 14px; font-weight: 700; pointer-events: none; }

/* touch pad */
#stage .pad { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px)); pointer-events: none; }
#stage .pad.hand-left { flex-direction: row-reverse; }
#stage .pl, #stage .pr { display: flex; gap: 10px; align-items: flex-end; }
#stage .ctl { pointer-events: auto; touch-action: none; border: 3px solid rgba(255,255,255,.55); background: rgba(32,20,14,.55); border-radius: 50%; width: 76px; height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; color: #fff; padding: 0; }
#stage .ctl span { font-size: 26px; line-height: 1; }
#stage .ctl small { font-size: 10px; opacity: .85; }
#stage .ctl.gas { width: 100px; height: 100px; background: rgba(74,212,90,.55); }
#stage .ctl.gas span { font-size: 20px; letter-spacing: 1px; }
#stage .ctl.brake { background: rgba(224,69,69,.5); }
#stage .ctl.brake span { font-size: 12px; }
/* narrow stages (a 9:16 box on a 360px phone is only ~250-280px wide): scale the pad so five buttons never overlap */
@supports (width: 1cqw) {
  #stage { container-type: inline-size; }
  #stage .pl, #stage .pr { gap: 6px; }
  #stage .ctl { width: clamp(44px, 17cqw, 76px); height: clamp(44px, 17cqw, 76px); }
  #stage .ctl.gas { width: clamp(56px, 24cqw, 100px); height: clamp(56px, 24cqw, 100px); }
  #stage .ctl small { font-size: clamp(8px, 2.6cqw, 10px); }
}
.game-wrap.pip-stage #stage { width: min(100%, calc((100vh - 64px) * 0.5625)); width: min(100%, calc((100svh - 64px) * 0.5625)); }
.game-wrap.pip-stage #stage.is-big { width: 100%; }
#stage .ctl.on { background: rgba(255,210,63,.8); color: var(--ink); transform: scale(.94); }

/* screens */
#stage .screen { position: absolute; inset: 0; display: flex; align-items: stretch; justify-content: center; pointer-events: none; }
#stage .panel { pointer-events: auto; width: 100%; max-height: 100%; margin: 0; padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--panel); overflow-x: hidden; overflow-y: auto; touch-action: pan-y; }
#stage .panel.menu, #stage .panel.pause, #stage .panel.results { justify-content: center; background: linear-gradient(rgba(32,20,14,.62), rgba(32,20,14,.9)); }
#stage .panel.pause, #stage .panel.results { background: rgba(32,20,14,.9); text-align: center; }
#stage .bar { display: flex; align-items: center; gap: 8px; }
#stage .bar h2 { flex: 1; font-size: 20px; text-align: center; }
#stage .bar .logo { font-size: 26px; letter-spacing: 3px; color: var(--sun); text-shadow: 0 3px 0 var(--org-d); line-height: 1; }
#stage .bar .logo small { display: block; font-size: 12px; letter-spacing: 3px; color: var(--cream); text-shadow: none; margin-top: 4px; }
#stage .ib { width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--line); background: rgba(255,255,255,.08); font-size: 22px; font-weight: 800; }
#stage .ib.sp { visibility: hidden; border: 0; }
#stage .coins { min-width: 70px; text-align: right; font-weight: 800; color: var(--sun); }
#stage .coins b { color: var(--org); }
#stage .rank { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; justify-content: center; }
#stage .xpbar { display: block; width: 120px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.15); overflow: hidden; }
#stage .xpbar i { display: block; height: 100%; background: var(--green); }
#stage .big { min-height: 52px; border-radius: 14px; border: 2px solid var(--line); background: rgba(255,255,255,.1); font-size: 17px; font-weight: 800; padding: 0 14px; }
#stage .big.primary { background: linear-gradient(var(--org), var(--org-d)); border-color: #ffb36b; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
#stage .big.dim, #stage .buy.dim { opacity: .5; }
#stage .big.danger { background: #a82a2a; border-color: #ff8a7a; margin-top: 8px; }
#stage .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#stage .tile { min-height: 74px; border-radius: 14px; border: 2px solid var(--line); background: rgba(255,255,255,.08); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px; }
#stage .tile b { font-size: 16px; }
#stage .tile span { font-size: 11px; opacity: .85; }
#stage .tile.daily { border-color: var(--sun); }
#stage .link { background: none; border: 0; min-height: 44px; font-size: 14px; text-decoration: underline; opacity: .85; }
#stage .link.danger { color: #ff9a8a; }
#stage .scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; padding-right: 2px; }
#stage .scroll.short { flex: 1; min-height: 120px; }
#stage .wh { font-size: 13px; letter-spacing: 1px; text-transform: uppercase; color: var(--sun); margin-top: 6px; }
#stage .lv { display: flex; align-items: center; gap: 10px; min-height: 56px; border-radius: 12px; border: 2px solid var(--line); background: rgba(255,255,255,.07); padding: 6px 10px; text-align: left; }
#stage .lv.lock { opacity: .45; }
#stage .lv .n { width: 30px; height: 30px; border-radius: 50%; background: var(--org); display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
#stage .lv .t { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#stage .lv .t small { font-size: 11px; opacity: .8; }
#stage .medals { display: inline-flex; gap: 4px; }
#stage .md { width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.18); display: inline-block; }
#stage .md.on.m1 { background: #cd7f32; } #stage .md.on.m2 { background: #c9d2dc; } #stage .md.on.m3 { background: #ffd23f; }
#stage .rm { display: flex; justify-content: center; } #stage .rm .md { width: 26px; height: 26px; }
#stage .lead { font-size: 14px; opacity: .95; }
#stage .lead.small { font-size: 12px; opacity: .8; }
#stage .stat { display: inline-flex; flex-direction: column; align-items: center; margin-right: 18px; } #stage .stat b { font-size: 24px; color: var(--sun); } #stage .stat span { font-size: 11px; }
#stage .trow { display: flex; gap: 8px; overflow-x: auto; touch-action: pan-x; padding-bottom: 2px; }
#stage .tk { flex: none; width: 82px; min-height: 64px; border-radius: 12px; border: 2px solid var(--line); background: rgba(255,255,255,.07); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 700; }
#stage .tk i { width: 34px; height: 18px; border-radius: 6px; display: block; }
#stage .tk.sel { border-color: var(--sun); } #stage .tk.off { opacity: .6; }
#stage .sb { display: flex; align-items: center; gap: 8px; font-size: 12px; } #stage .sb span { width: 78px; } #stage .sb em { flex: 1; height: 8px; border-radius: 4px; background: rgba(255,255,255,.15); overflow: hidden; } #stage .sb em i { display: block; height: 100%; background: var(--org); }
#stage .up { display: flex; align-items: center; gap: 10px; border-radius: 12px; background: rgba(255,255,255,.07); padding: 8px 10px; }
#stage .ut { flex: 1; display: flex; flex-direction: column; gap: 2px; } #stage .ut small { font-size: 11px; opacity: .8; }
#stage .pips { display: flex; gap: 4px; } #stage .pips i { width: 16px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.2); } #stage .pips i.on { background: var(--green); }
#stage .buy { min-width: 76px; min-height: 46px; border-radius: 12px; border: 2px solid #ffb36b; background: var(--org-d); font-weight: 800; }
#stage .maxed { font-weight: 800; color: var(--green); }
#stage .ach { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; border-radius: 12px; background: rgba(255,255,255,.07); padding: 8px 10px; } #stage .ach small { grid-column: 1; font-size: 11px; opacity: .8; } #stage .ach span { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-weight: 800; color: var(--sun); } #stage .ach.done { opacity: .6; } #stage .ach.done span { color: var(--green); }
#stage .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; }
#stage .seg { display: inline-flex; border-radius: 10px; overflow: hidden; border: 2px solid var(--line); } #stage .seg button { min-height: 44px; min-width: 52px; padding: 0 10px; border: 0; background: rgba(255,255,255,.06); font-weight: 700; font-size: 13px; } #stage .seg button.on { background: var(--org); color: #fff; }
#stage .note { padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.1); font-size: 13px; text-align: center; } #stage .note.ok { background: rgba(74,212,90,.2); } #stage .note.warn { background: rgba(168,42,42,.3); }
#stage .big-num { font-size: 38px; font-weight: 800; color: var(--sun); }
#stage .stats { display: flex; justify-content: center; gap: 18px; } #stage .stats div { display: flex; flex-direction: column; } #stage .stats b { font-size: 20px; } #stage .stats span { font-size: 11px; opacity: .8; }
#stage .earn { font-weight: 700; }
#stage .goal { font-size: 14px; color: #ffe2b0; }

@media (max-height: 560px) { #stage .big { min-height: 46px; } #stage .tile { min-height: 60px; } }
.er-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.er-bar .btn { min-height: 44px; min-width: 44px; }
.er-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.er-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.er-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.er-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.er-guide p { margin-bottom: .5rem; font-size: .95rem; }

/* ---- wave3: full screen fill (shell stage = .game-wrap; phone portrait and landscape) ---- */
html.pip-immersive .game-wrap.pip-stage { display: flex; flex-direction: column; align-items: stretch; justify-content: stretch; padding: 0; margin: 0; overflow: hidden; }
html.pip-immersive .game-wrap.pip-stage > .er-bar,
html.pip-immersive .game-wrap.pip-stage > .er-keys,
html.pip-immersive .game-wrap.pip-stage > noscript { display: none !important; }
html.pip-immersive .game-wrap.pip-stage #stage,
html.pip-immersive .game-wrap.pip-stage #stage.is-big { position: relative; inset: auto; flex: 1 1 auto; width: 100%; max-width: none; height: 100%; min-height: 0; aspect-ratio: auto; border-radius: 0; z-index: 1; margin: 0; }
html.pip-immersive #stage .pad { padding-left: calc(12px + env(safe-area-inset-left, 0px)); padding-right: calc(12px + env(safe-area-inset-right, 0px)); }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage #hint { bottom: 112px; left: 25%; right: 25%; font-size: 13px; padding: 5px 10px; }
  html.pip-immersive #stage .prog { top: 54px; left: 22%; right: 22%; }
  html.pip-immersive #stage #banner { top: 18%; }
  html.pip-immersive #stage #feed { top: 70px; }
}

/* ---- wave3: finish on the touch pad and HUD (static paint only) ---- */
#stage .ctl { background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.22), rgba(32,20,14,.62) 62%); box-shadow: 0 4px 0 rgba(0,0,0,.35), inset 0 2px 3px rgba(255,255,255,.25); transition: transform .08s ease-out, background .1s; }
#stage .ctl.gas { background: radial-gradient(circle at 35% 28%, rgba(190,255,190,.5), rgba(46,170,66,.7) 65%); }
#stage .ctl.brake { background: radial-gradient(circle at 35% 28%, rgba(255,190,190,.45), rgba(190,50,50,.68) 65%); }
#stage .ctl.on { box-shadow: 0 1px 0 rgba(0,0,0,.35), inset 0 2px 6px rgba(0,0,0,.25); }
#stage .hud-pause { box-shadow: 0 3px 0 rgba(0,0,0,.3); }
#stage .fi { box-shadow: 0 2px 0 rgba(0,0,0,.35); border: 1px solid rgba(255,230,190,.16); }
#stage .hud-pause, #stage .ctl { min-width: 44px; min-height: 44px; }
#stage .ctl.on, #stage .ctl.gas.on, #stage .ctl.brake.on { background: rgba(255,210,63,.85); color: var(--ink); }
