/* Forklift Shift 3D - stage, HUD, touch pad and screens. Everything is scoped under #stage so site styles never leak in. */
html.pip-big, html.pip-big body { overflow: hidden; }
[hidden] { display: none !important; }
#stage { --amber:#e8912d; --amber-d:#b86a14; --ink:#1d1a14; --panel:#1b2230; --line:rgba(255,255,255,.22); --ok:#4ad06a; --bad:#ff5b4a;
  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: #1b2230; 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; }
#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 { 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 #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#2d3a5c, #e8912d); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-align: center; padding: 0 18px; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
#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: 6px solid rgba(255,255,255,.3); border-top-color: #ffd23a; animation: fkspin .8s linear infinite; }
@keyframes fkspin { 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(15,20,32,.9); color: #fff; font-size: 15px; }

/* HUD */
#stage .hud { position: absolute; left: 0; right: 0; top: 0; padding: 8px 8px 0; pointer-events: none; }
#stage .hud-top { display: flex; align-items: center; gap: 8px; }
#stage .hud-time { min-width: 62px; padding: 6px 10px; border-radius: 12px; background: rgba(15,20,32,.72); font-weight: 800; font-size: 20px; text-align: center; font-variant-numeric: tabular-nums; }
#stage .hud-time.low { background: var(--bad); animation: fkpulse .6s ease-in-out infinite alternate; }
@keyframes fkpulse { to { transform: scale(1.06); } }
#stage .hud-goal { flex: 1; padding: 7px 10px; border-radius: 12px; background: rgba(15,20,32,.72); font-size: 13px; font-weight: 700; min-height: 36px; display: flex; align-items: center; overflow: hidden; }
#stage .hud-pause { width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--line); background: rgba(15,20,32,.72); color: #fff; font-weight: 900; font-size: 15px; pointer-events: auto; }
#stage .hud-combo { margin-top: 6px; display: inline-block; padding: 3px 10px; border-radius: 10px; background: rgba(15,20,32,.6); font-size: 13px; font-weight: 700; }
#stage .hud-combo:empty { display: none; }
#stage .hud-wob { margin: 6px 0 0 auto; width: 46%; height: 10px; border-radius: 6px; background: rgba(15,20,32,.6); overflow: hidden; }
#stage .hud-wob i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s linear; }
#stage .hud-wob.warn i { background: var(--bad); }

#stage .hint-bubble { position: absolute; left: 12px; right: 12px; top: 116px; z-index: 5; padding: 10px 12px; border-radius: 14px; background: #fff7dc; color: var(--ink); font-size: 14px; font-weight: 700; text-align: center; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
#stage .toast { position: absolute; left: 50%; transform: translateX(-50%); top: 170px; z-index: 6; max-width: 90%; padding: 8px 14px; border-radius: 12px; background: rgba(15,20,32,.88); color: #fff; font-size: 14px; font-weight: 700; text-align: center; }

/* touch pad: 8 large held buttons */
#stage .pad { position: absolute; inset: 0; pointer-events: none; --pb: 52px; --g: 4px; --st: calc(var(--pb) + var(--g)); }
@supports (width: 1cqw) { #stage { container-type: size; } #stage .pad { --pb: clamp(44px, 21cqw, 64px); } }
#stage .pb { position: absolute; width: var(--pb); height: var(--pb); min-width: 44px; min-height: 44px; border-radius: 16px; border: 2px solid rgba(255,255,255,.5); background: rgba(20,26,40,.55); color: #fff; font-weight: 900; font-size: 15px; letter-spacing: .5px; pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; padding: 0; }
#stage .pb.on { background: var(--amber); color: var(--ink); border-color: #fff; transform: scale(.96); }
#stage #btn-steerL { left: var(--g); bottom: var(--g); } #stage #btn-steerR { left: calc(var(--g) + var(--st)); bottom: var(--g); }
#stage #btn-drive { right: var(--g); bottom: var(--g); background: rgba(232,145,45,.55); } #stage #btn-rev { right: calc(var(--g) + var(--st)); bottom: var(--g); }
#stage #btn-forkUp { right: var(--g); bottom: calc(var(--g) + var(--st)); } #stage #btn-forkDown { right: var(--g); bottom: calc(var(--g) + var(--st) * 2); }
#stage #btn-tiltBack { left: var(--g); bottom: calc(var(--g) + var(--st)); font-size: 12px; } #stage #btn-tiltFwd { left: var(--g); bottom: calc(var(--g) + var(--st) * 2); font-size: 12px; }

/* screens */
#stage .screen { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(12,16,26,.78); padding: 10px; pointer-events: auto; }
#stage .panel { width: 100%; max-width: 340px; max-height: 100%; overflow-y: auto; padding: 14px; border-radius: 18px; background: var(--panel); border: 2px solid var(--line); display: flex; flex-direction: column; gap: 8px; text-align: center; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
#stage .panel h2.logo { font-size: 28px; letter-spacing: 2px; color: var(--amber); margin: 4px 0 0; }
#stage .panel h3 { font-size: 20px; margin: 2px 0; }
#stage .panel p { font-size: 14px; color: #dfe5f1; }
#stage .panel .sub { color: #aab3c5; }
#stage .panel .goal { font-size: 13px; color: #ffd98a; }
#stage .panel .earn { color: #ffd23a; font-weight: 800; font-size: 16px; }
#stage .panel .trophy { color: #9be6ff; font-weight: 700; }
#stage .panel .coins { font-weight: 800; color: #ffd23a; font-size: 14px; }
#stage .stars { font-size: 38px; color: #ffd23a; letter-spacing: 6px; }
#stage .btn { min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); background: #2a3347; color: #fff; font-weight: 800; font-size: 15px; }
#stage .btn.primary { background: var(--amber); color: var(--ink); border-color: #ffd29a; }
#stage .btn.danger { background: #8e2b22; border-color: #d6574a; }
#stage .btn.dim { opacity: .55; }
#stage .row { display: flex; gap: 8px; } #stage .row .btn { flex: 1; padding: 10px 4px; font-size: 13px; }
#stage .seg { display: flex; gap: 6px; } #stage .seg .btn { flex: 1; padding: 8px 4px; font-size: 13px; min-height: 44px; }
#stage .srow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; } #stage .srow .btn { min-width: 84px; }
#stage .depot { padding: 8px; border-radius: 14px; background: #232c3f; text-align: left; }
#stage .depot.locked { opacity: .6; }
#stage .depot .dn { font-weight: 800; font-size: 15px; } #stage .depot small { font-weight: 600; color: #aab3c5; }
#stage .depot .db { font-size: 12px; margin: 2px 0 6px; color: #aab3c5; }
#stage .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#stage .tile { min-height: 52px; border-radius: 12px; border: 2px solid var(--line); background: #2f3a52; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px; }
#stage .tile b { font-size: 17px; } #stage .tile span { font-size: 12px; color: #ffd23a; letter-spacing: 1px; }
#stage .tile.done { border-color: #ffd23a; } #stage .tile.locked { opacity: .5; cursor: default; }
#stage .upg { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 12px; background: #232c3f; text-align: left; }
#stage .upg .ut { flex: 1; display: flex; flex-direction: column; gap: 2px; } #stage .upg .ut span { font-size: 12px; color: #aab3c5; }
#stage .upg .btn { min-width: 84px; }
#stage .dots { display: flex; gap: 4px; margin-top: 3px; } #stage .dots i { width: 14px; height: 8px; border-radius: 3px; background: #46506a; } #stage .dots i.on { background: var(--amber); }
#stage .ach { padding: 8px; border-radius: 12px; background: #232c3f; text-align: left; opacity: .65; display: flex; flex-direction: column; }
#stage .ach.got { opacity: 1; border-left: 4px solid #ffd23a; } #stage .ach span { font-size: 12px; color: #aab3c5; }

.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; }
@media (max-height: 520px) { #stage .pad { --pb: 44px; --g: 4px; } }
@media (prefers-reduced-motion: reduce) { #stage .spinner, #stage .hud-time.low { animation: none; } }
#stage .screen .panel { animation: fkpop .22s ease-out; }
#stage .panel .stars { font-size: 34px; letter-spacing: 6px; color: #ffd23a; animation: fkstar .5s ease-out; }
@keyframes fkpop { from { transform: scale(.94); opacity: 0; } }
@keyframes fkstar { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { #stage .screen .panel, #stage .panel .stars { animation: none; } }

/* Full screen on phones: the stage fills the shell's fullscreen box, the page-frame extras step aside. */
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 > #stage { flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; height: auto; aspect-ratio: auto; margin: 0; border-radius: 0; }
html.pip-immersive .game-wrap.pip-stage > .er-bar,
html.pip-immersive .game-wrap.pip-stage > .er-keys { display: none; }
html.pip-immersive #stage #ui { padding-bottom: env(safe-area-inset-bottom, 0px); }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .pad { --pb: 48px; --g: 4px; }
}

/* Full screen landscape: roomy menu lists, Back always reachable */
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .screen, html.pip-native #stage .screen { padding: 6px 8px; padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
  html.pip-immersive #stage .panel, html.pip-native #stage .panel { max-width: 760px; padding: 8px 10px; gap: 6px; }
  html.pip-immersive #stage .panel.garage, html.pip-native #stage .panel.garage,
  html.pip-immersive #stage .panel.trophies, html.pip-native #stage .panel.trophies { display: grid; grid-template-columns: repeat(3, 1fr); align-content: start; }
  html.pip-immersive #stage .panel.garage > h3, html.pip-native #stage .panel.garage > h3,
  html.pip-immersive #stage .panel.garage > .coins, html.pip-native #stage .panel.garage > .coins,
  html.pip-immersive #stage .panel.trophies > h3, html.pip-native #stage .panel.trophies > h3,
  html.pip-immersive #stage .panel.garage > #btnBack2, html.pip-native #stage .panel.garage > #btnBack2,
  html.pip-immersive #stage .panel.trophies > #btnBack3, html.pip-native #stage .panel.trophies > #btnBack3 { grid-column: 1 / -1; }
  html.pip-immersive #stage .panel.garage .upg, html.pip-native #stage .panel.garage .upg { flex-direction: column; align-items: stretch; gap: 4px; padding: 6px; }
  html.pip-immersive #stage .panel .btn, html.pip-native #stage .panel .btn { min-height: 44px; padding-top: 6px; padding-bottom: 6px; }
  html.pip-immersive #stage .panel > #btnBack, html.pip-native #stage .panel > #btnBack,
  html.pip-immersive #stage .panel > #btnBack2, html.pip-native #stage .panel > #btnBack2,
  html.pip-immersive #stage .panel > #btnBack3, html.pip-native #stage .panel > #btnBack3,
  html.pip-immersive #stage .panel > #btnBack4, html.pip-native #stage .panel > #btnBack4 { position: sticky; bottom: 0; z-index: 2; }
}
