/* Gearhollow Workshop 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 { --walnut:#54331e; --walnut2:#7a4b2b; --cream:#f4e8cc; --cream2:#e6d2a6; --brass:#d9a441; --brass2:#a97a2a; --red:#d9453b; --ink:#3a261a; --green:#3f9a4d; --bot:146px; --top:52px; --side:0px;
  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: #4a3220; 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.land { --side:172px; --bot:0px; --top:48px; }
#stage.is-big { 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 { aspect-ratio: auto; width: 100%; max-width: none; height: 100%; border-radius: 0; }
#stage *, #stage *::before, #stage *::after { box-sizing: border-box; }
#stage #app { position: absolute; left: 0; top: var(--top); right: var(--side); bottom: var(--bot); }
#stage #app canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
#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, #stage #ctxlost, #stage #nowebgl { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: #4a3220; color: var(--cream); font-weight: 700; }
#stage #ctxlost { z-index: 40; background: rgba(40,24,12,.88); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 30px); letter-spacing: 4px; color: var(--brass); }
#stage .load-in span { font-size: 14px; }
#stage .spinner { width: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.25); border-top-color: var(--brass); animation: ghspin .8s linear infinite; }
@keyframes ghspin { to { transform: rotate(360deg); } }

/* HUD */
#stage .hud { position: absolute; inset: 0; pointer-events: none; }
#stage .topbar { position: absolute; left: 0; right: 0; top: 0; height: var(--top); display: flex; align-items: center; gap: 8px; padding: 4px 8px; padding-top: max(4px, env(safe-area-inset-top)); background: linear-gradient(rgba(40,24,12,.92), rgba(40,24,12,.55)); }
#stage .tt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#stage .ttl { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage .sub { font-size: 11px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage .cogpill { background: rgba(244,232,204,.16); border-radius: 99px; padding: 4px 10px; font-weight: 800; font-size: 12px; color: var(--brass); white-space: nowrap; }
#stage .btn { pointer-events: auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; min-width: 44px; padding: 8px 14px; border: 2px solid var(--walnut); border-radius: 14px; background: linear-gradient(#f0c868, #d9a441 60%, #b98630); color: var(--ink); font-weight: 800; font-size: 15px; box-shadow: 0 3px 0 var(--walnut); text-decoration: none; }
#stage .btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--walnut); }
#stage .btn:disabled { opacity: .45; cursor: default; transform: none; }
#stage .btn.icon { min-height: 44px; padding: 0 12px; font-size: 13px; background: rgba(244,232,204,.2); color: var(--cream); border-color: rgba(244,232,204,.35); box-shadow: none; }
#stage .btn.side { min-height: 44px; min-width: 52px; padding: 0 8px; font-size: 12px; background: rgba(40,24,12,.7); color: var(--cream); border-color: rgba(244,232,204,.3); box-shadow: none; }
#stage .btn.act { min-width: 0; padding: 6px 4px; font-size: 13px; background: linear-gradient(#fff6de, #f0dfb4); }
#stage .btn.act.ok { background: linear-gradient(#8fd69a, #4fae5d); color: #08300f; }
#stage .btn.act.go { background: linear-gradient(#f0c868, #d9a441 60%, #b98630); font-size: 15px; }
#stage .btn.big { min-height: 56px; font-size: 18px; letter-spacing: 1px; width: 100%; background: linear-gradient(#ee6d62, #d9453b 60%, #b2332b); color: #fff7e8; border-color: #6b1d17; box-shadow: 0 4px 0 #6b1d17; }
#stage .btn.hot { background: linear-gradient(#ee6d62, #d9453b 60%, #b2332b); color: #fff7e8; border-color: #6b1d17; box-shadow: 0 3px 0 #6b1d17; }
#stage .btn.ghost { background: rgba(84,51,30,.08); color: var(--walnut); border-color: rgba(84,51,30,.35); box-shadow: none; }
#stage .btn.danger { background: #d94a4a; color: #fff; border-color: #7c2323; box-shadow: 0 3px 0 #7c2323; }
#stage .btn.sm { min-height: 44px; font-size: 13px; }
#stage .btn.buy { min-width: 84px; font-size: 14px; }
#stage .sidebar { position: absolute; right: 8px; top: calc(var(--top) + 8px); display: flex; flex-direction: column; gap: 6px; }
#stage.land .sidebar { right: calc(var(--side) + 8px); }
#stage .bottom { position: absolute; left: 0; right: 0; bottom: 0; min-height: var(--bot); padding: 6px 8px max(8px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; background: linear-gradient(rgba(40,24,12,0), rgba(40,24,12,.88) 22%); pointer-events: auto; justify-content: flex-end; }
#stage .tray { display: flex; gap: 6px; justify-content: center; overflow-x: auto; touch-action: pan-x; padding: 2px 0; min-height: 70px; }
#stage .tb { position: relative; flex: 0 0 auto; width: 64px; height: 68px; border: 2px solid var(--walnut); border-radius: 12px; background: linear-gradient(#fff6de, #ecd9ab); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px; }
#stage .tb img { width: 38px; height: 38px; pointer-events: none; }
#stage .tb .lab { font-size: 9px; font-weight: 800; line-height: 1; margin-top: 2px; white-space: nowrap; }
#stage .tb .cnt { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
#stage .tb.on { border-color: #fff; box-shadow: 0 0 0 3px var(--brass); }
#stage .tb.hint { animation: ghpulse .8s ease-in-out infinite alternate; }
#stage .tb.empty { opacity: .4; }
@keyframes ghpulse { to { box-shadow: 0 0 0 4px #ffe08a; } }
#stage .row { display: grid; gap: 6px; }
#stage .row.plan { grid-template-columns: 1fr 1fr 1fr 1fr 1.3fr; }
#stage .row.run { grid-template-columns: 1fr 1fr; }
#stage .tip { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--bot) + 6px); max-width: 88%; background: rgba(255,247,226,.96); color: var(--ink); font-weight: 800; font-size: 14px; text-align: center; padding: 8px 14px; border-radius: 14px; box-shadow: 0 3px 0 rgba(0,0,0,.35); animation: ghfloat 1.1s ease-in-out infinite alternate; }
@keyframes ghfloat { to { transform: translate(-50%, -5px); } }
#stage .banner { position: absolute; left: 8px; right: 8px; top: calc(var(--top) + 10px); text-align: center; pointer-events: none; opacity: 0; transition: opacity .25s; font-weight: 900; font-size: clamp(16px, 5vw, 22px); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.55); }
#stage .banner.show { opacity: 1; }
#stage .toast { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--bot) + 56px); max-width: 90%; background: rgba(40,24,12,.92); color: var(--cream); font-weight: 700; font-size: 13px; padding: 7px 14px; border-radius: 99px; opacity: 0; transition: opacity .2s; pointer-events: none; text-align: center; }
#stage .toast.show { opacity: 1; }
#stage.land .tip, #stage.land .toast { bottom: 14px; left: calc(50% - var(--side) / 2); }

/* landscape: the controls move to a column on the right */
#stage.land .bottom { left: auto; top: var(--top); width: var(--side); min-height: 0; padding: 8px; justify-content: flex-start; background: rgba(40,24,12,.9); overflow-y: auto; }
#stage.land .tray { flex-wrap: wrap; justify-content: flex-start; overflow: visible; touch-action: auto; min-height: 0; }
#stage.land .tb { width: 74px; }
#stage.land .row.plan { grid-template-columns: 1fr 1fr; }
#stage.land .row.plan .go { grid-column: 1 / 3; }

/* overlay screens */
#stage .screens { position: absolute; inset: 0; pointer-events: none; }
#stage .screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 10px; background: rgba(34,20,10,.5); pointer-events: auto; }
#stage .panel { width: 100%; max-width: 440px; max-height: 100%; background: rgba(250,241,217,.97); color: var(--ink); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 9px; box-shadow: 0 6px 0 rgba(0,0,0,.35); text-align: center; }
#stage .panel.scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
#stage .panel h2 { margin: 0; font-size: 22px; color: var(--walnut); letter-spacing: 1px; }
#stage .panel h3 { margin: 4px 0 0; font-size: 14px; color: var(--walnut2); text-align: left; }
#stage .logo { display: flex; flex-direction: column; line-height: 1; margin-top: 2px; }
#stage .logo span { font-size: 15px; letter-spacing: 7px; color: var(--brass2); font-weight: 800; }
#stage .logo b { font-size: clamp(30px, 10vw, 44px); color: var(--red); letter-spacing: 3px; text-shadow: 0 3px 0 rgba(84,51,30,.25); }
#stage .tag { margin: 0; font-size: 13px; color: #6a5238; } #stage .tag.small { font-size: 12px; }
#stage .chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#stage .chip { background: #fff; border-radius: 99px; padding: 4px 11px; font-weight: 800; font-size: 12px; color: var(--walnut); }
#stage .row2, #stage .row3 { display: grid; gap: 8px; } #stage .row2 { grid-template-columns: 1fr 1fr; } #stage .row3 { grid-template-columns: 1fr 1fr 1fr; }
#stage .row3 .btn { padding: 6px 4px; font-size: 13px; }
#stage .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#stage .grid > div { background: #fff; border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: #6a5238; }
#stage .grid b { font-size: 15px; color: var(--ink); }
#stage .stars i { font-style: normal; font-size: 18px; color: #cdbd9a; margin: 0 1px; } #stage .stars i.on { color: #e8a317; }
#stage .bigstars .stars i { font-size: 44px; }
#stage .gain { margin: 0; font-weight: 800; font-size: 13px; color: #2a7a3a; }
#stage .goal { margin: 0; font-weight: 800; font-size: 13px; color: var(--walnut); background: #f1e2b6; border-radius: 10px; padding: 8px 10px; }
#stage .chapter { background: #fff; border-radius: 14px; padding: 8px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
#stage .chapter.locked { opacity: .85; background: #efe6cf; }
#stage .chhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; } #stage .chhead small { flex: 1 1 100%; color: #6a5238; font-size: 11px; } #stage .chs { margin-left: auto; font-weight: 800; font-size: 12px; color: var(--brass2); }
#stage .lockmsg { margin: 0; font-size: 12px; color: #6a5238; }
#stage .lvgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#stage .lv { min-height: 56px; border-radius: 12px; border: 2px solid #c9b78c; background: #fbf3dc; color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
#stage .lv.done { border-color: var(--brass); background: #fff3c9; } #stage .lv.off { opacity: .45; }
#stage .lv b { font-size: 14px; } #stage .lv .stars i { font-size: 13px; }
#stage .items { display: flex; flex-direction: column; gap: 8px; text-align: left; }
#stage .item { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 8px; }
#stage .swatch { width: 44px; height: 44px; border-radius: 50%; flex: none; border: 3px solid rgba(0,0,0,.15); }
#stage .meta { flex: 1; display: flex; flex-direction: column; min-width: 0; font-size: 12px; color: #6a5238; } #stage .meta b { font-size: 14px; color: var(--ink); }
#stage .mlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
#stage .mlist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #fff; border-radius: 10px; padding: 8px 10px; font-size: 13px; font-weight: 700; }
#stage .mlist li.done { background: #dcf1d8; } #stage .mlist small { display: block; font-weight: 600; opacity: .7; font-size: 11px; } #stage .mlist em { font-style: normal; font-weight: 800; font-size: 12px; white-space: nowrap; }
#stage .settings { display: flex; flex-direction: column; gap: 4px; }
#stage .srow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 14px; text-align: left; min-height: 44px; }
#stage .srow input[type=range] { flex: 1; height: 32px; accent-color: var(--brass2); touch-action: none; } #stage .srow output { width: 30px; text-align: right; font-size: 12px; }
#stage .seg { display: flex; gap: 4px; } #stage .seg button { min-height: 44px; min-width: 54px; border: 2px solid #c9b78c; background: #fff; border-radius: 10px; font-weight: 800; font-size: 13px; color: var(--ink); }
#stage .seg button.on { background: var(--walnut2); border-color: var(--walnut); color: #fff; }
#stage .plain { text-align: left; margin: 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
@media (max-height: 560px) { #stage .logo b { font-size: 28px; } }
@media (prefers-reduced-motion: reduce) { #stage * { animation: none !important; transition: none !important; } }

/* page chrome under the game */
.gh-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.gh-bar .btn { min-height: 44px; min-width: 44px; }
.gh-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.gh-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.gh-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.gh-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.gh-guide p { margin-bottom: .5rem; font-size: .95rem; }
/* touch exit for the CSS full-screen overlay (no Esc key on phones) */
#stage .fsx { position: absolute; z-index: 60; right: calc(var(--side) + 8px); bottom: calc(var(--bot) + 8px); min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 22px; border: 2px solid rgba(244,232,204,.5); background: rgba(40,24,12,.88); color: var(--cream); font-weight: 800; font-size: 13px; }
#stage .record { margin: 0; font-size: 13px; font-weight: 800; color: var(--brass2); }
#stage .lv small { font-size: 10px; color: #6a5238; max-width: 100%; padding: 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stage .bigstars .stars i.on { display: inline-block; animation: ghstarpop .5s cubic-bezier(.2,1.6,.4,1) backwards; }
#stage .bigstars .stars i.on:nth-child(2) { animation-delay: .3s; } #stage .bigstars .stars i.on:nth-child(3) { animation-delay: .6s; }
@keyframes ghstarpop { from { transform: scale(0) rotate(-40deg); opacity: 0; } }

/* ---- full screen (shell native + immersive): the stage fills the area under the dock ---- */
html.pip-immersive .game-wrap { display: flex; flex-direction: column; overflow: hidden; }
html.pip-immersive .game-wrap > .gh-bar, html.pip-immersive .game-wrap > .gh-keys, html.pip-immersive .game-wrap > noscript { display: none; }
html.pip-immersive .game-wrap #stage { flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; height: auto; aspect-ratio: auto; border-radius: 0; margin: 0; }
html.pip-immersive #stage #ui .bottom { padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
html.pip-immersive #stage button { min-height: 44px; }
/* depth: a soft vignette over the 3D view, painted once by the compositor */
#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(30,16,6,.38) 100%); }
