/* Sandlot Slam 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 { --grass:#2e9e4f; --grass-d:#1d6f35; --sun:#ffd23a; --red:#e8552b; --ink:#1b2a3d; --cream:#fff7df; --panel:rgba(14,28,46,.9);
  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(#66b7ff, #cfeaff); 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; }
html.pip-immersive #stage, .game-wrap.pip-stage #stage { width: min(100%, calc((var(--pip-vvh, 100dvh) - var(--pip-dock-h, 0px) - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) * 0.5625)); }
.game-wrap.pip-stage .hr-barwrap, .game-wrap.pip-stage .hr-keys { display: none; }
#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, #stage input: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(#2e9e4f, #8fd39a); }
#stage #loader[hidden], #stage #ctxlost[hidden], #stage .hr-hud[hidden], #stage .hr-flash[hidden], #stage [hidden] { display: none; }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(10,60,30,.5); 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: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.35); border-top-color: var(--sun); animation: hrspin .8s linear infinite; }
@keyframes hrspin { 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(14,28,46,.9); color: #fff; font-weight: 700; }

/* HUD */
#stage .hr-hud { position: absolute; inset: 0; pointer-events: none; padding: max(8px, env(safe-area-inset-top)) 10px 8px; }
#stage .hr-top { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; max-width: calc(100% - 60px); }
#stage .hr-chip { background: rgba(14,28,46,.62); border-radius: 12px; padding: 5px 10px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; text-shadow: 0 1px 0 rgba(0,0,0,.35); }
#stage .hr-chip b { font-size: 14px; letter-spacing: 1px; }
#stage .hr-chip span { font-size: 13px; font-variant-numeric: tabular-nums; }
#stage .hr-main span { color: var(--sun); font-weight: 800; }
#stage .hr-outs { display: inline-flex; gap: 3px; margin-left: 2px; }
#stage .hr-outs u { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.22); display: block; }
#stage .hr-outs u.on { background: var(--sun); } #stage .hr-outs u.half { background: linear-gradient(90deg, var(--sun) 50%, rgba(255,255,255,.22) 50%); }
#stage .hr-pausebtn { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 8px; width: 46px; height: 46px; border-radius: 12px; border: 0; background: rgba(14,28,46,.7); color: #fff; font-weight: 800; font-size: 16px; letter-spacing: 1px; pointer-events: auto; }
#stage .hr-pitchname { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); background: rgba(14,28,46,.7); padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: 14px; letter-spacing: 1px; color: #7fe3ff; }
#stage .hr-hint { position: absolute; left: 10px; right: 10px; bottom: 9%; background: rgba(14,28,46,.82); border: 2px solid var(--sun); border-radius: 14px; padding: 10px 12px; text-align: center; font-size: 14px; font-weight: 700; }
#stage .hr-floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#stage .hr-float { position: absolute; left: 50%; top: 38%; transform: translateX(-50%); font-size: 26px; font-weight: 900; letter-spacing: 2px; white-space: nowrap; text-shadow: 0 3px 0 rgba(0,0,0,.45); animation: hrfloat 1.4s ease-out forwards; }
#stage .hr-float.bad { color: #ffb3a1; } #stage .hr-float.good { color: #b9ffc8; } #stage .hr-float.gold { color: var(--sun); }
#stage .hr-float.big { font-size: 34px; top: 30%; }
@keyframes hrfloat { 0% { opacity: 0; transform: translate(-50%, 14px) scale(.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.15); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -46px) scale(1); } }
#stage .hr-flash { position: absolute; inset: 0; opacity: .55; pointer-events: none; animation: hrflash .25s ease-out forwards; }
@keyframes hrflash { to { opacity: 0; } }

/* screens */
#stage .hr-screenhost { position: absolute; inset: 0; pointer-events: none; }
#stage .hr-screenhost.on { pointer-events: auto; }
#stage .hr-screen { position: absolute; inset: 0; display: flex; align-items: stretch; justify-content: center; background: rgba(8,18,32,.62); padding: max(10px, env(safe-area-inset-top)) 10px 10px; }
#stage .hr-panel { width: 100%; max-width: 420px; background: var(--panel); border: 2px solid rgba(255,255,255,.14); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px; align-self: center; max-height: 100%; }
#stage .hr-scroll { overflow-y: auto; overflow-x: hidden; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#stage .hr-pause .hr-panel, #stage .hr-results .hr-panel { align-self: center; }
#stage .hr-head { display: flex; align-items: center; gap: 8px; }
#stage .hr-head .hr-h { flex: 1; font-size: 18px; text-align: left; }
#stage .hr-h { font-size: 22px; font-weight: 900; text-align: center; letter-spacing: .5px; }
#stage .hr-h3 { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: #9fd4ff; margin-top: 4px; }
#stage .hr-sub, #stage .hr-lead { text-align: center; font-size: 14px; color: #d6e6f5; } #stage .hr-lead { text-align: left; }
#stage .hr-small { font-size: 12px; color: #aac3d8; text-align: center; }
#stage .hr-btn { min-height: 46px; min-width: 46px; padding: 8px 14px; border: 0; border-radius: 12px; background: #2f4660; color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 3px 0 rgba(0,0,0,.35); }
#stage .hr-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
#stage .hr-btn.hr-primary { background: var(--grass); box-shadow: 0 3px 0 var(--grass-d); font-size: 17px; }
#stage .hr-btn.hr-hero { min-height: 58px; font-size: 19px; background: var(--red); box-shadow: 0 4px 0 #a33414; animation: hrpulse 1.6s ease-in-out infinite; }
@keyframes hrpulse { 50% { transform: scale(1.03); } }
#stage .hr-btn.hr-back { padding: 8px 12px; font-size: 14px; }
#stage .hr-btn.hr-danger { background: #8e2b2b; }
#stage .hr-row { display: flex; gap: 8px; } #stage .hr-row .hr-btn { flex: 1; }
#stage .hr-coins { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; color: var(--sun); font-size: 14px; }
#stage .hr-coin { width: 14px; height: 14px; border-radius: 50%; background: var(--sun); box-shadow: inset 0 0 0 3px #e0a800; display: inline-block; }
#stage .hr-logo { text-align: center; line-height: 1; }
#stage .hr-logo b { display: block; font-size: 38px; letter-spacing: 3px; color: #fff; text-shadow: 0 4px 0 #1d6f35; }
#stage .hr-logo b.two { color: var(--sun); font-size: 40px; text-shadow: 0 4px 0 #a33414; }
#stage .hr-logo span { display: block; margin-top: 6px; font-size: 12px; letter-spacing: 4px; text-transform: uppercase; color: #cfe6ff; }
#stage .hr-lvl { display: flex; flex-direction: column; gap: 4px; }
#stage .hr-lvlrow { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
#stage .hr-bar { height: 10px; border-radius: 6px; background: rgba(255,255,255,.16); overflow: hidden; }
#stage .hr-bar i { display: block; height: 100%; background: linear-gradient(90deg, #7fe3ff, #4ad48a); border-radius: 6px; }
#stage .hr-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .hr-mode { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; min-height: 76px; text-align: left; background: #26405b; }
#stage .hr-mode b { font-size: 15px; } #stage .hr-mode span { font-size: 12px; font-weight: 600; color: #cfe6ff; }
#stage .hr-mode.m-derby { background: linear-gradient(135deg, #2e9e4f, #1d6f35); } #stage .hr-mode.m-chal { background: linear-gradient(135deg, #c9751f, #8e4a10); }
#stage .hr-mode.m-lad { background: linear-gradient(135deg, #3a6fd8, #274b9a); } #stage .hr-mode.m-daily { background: linear-gradient(135deg, #9a4ad8, #6a2a9e); }
#stage .hr-list { display: flex; flex-direction: column; gap: 7px; }
#stage .hr-card { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; text-align: left; align-items: center; background: #26405b; min-height: 54px; }
#stage .hr-card b { font-size: 14px; } #stage .hr-card span { grid-column: 1; font-size: 12px; font-weight: 600; color: #bcd3e8; }
#stage .hr-card em { grid-column: 2; grid-row: 1 / span 2; font-style: normal; font-size: 12px; color: var(--sun); font-weight: 800; text-align: right; }
#stage .hr-card.sel { outline: 3px solid var(--sun); } #stage .hr-card.lock { opacity: .55; } #stage .hr-card.done em { color: #7dffa8; }
#stage .hr-stars { color: var(--sun); letter-spacing: 2px; } #stage .hr-stars i { font-style: normal; color: rgba(255,255,255,.25); }
#stage .hr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#stage .hr-cell { background: rgba(255,255,255,.08); border-radius: 10px; padding: 7px 4px; text-align: center; display: flex; flex-direction: column; }
#stage .hr-cell b { font-size: 18px; } #stage .hr-cell span { font-size: 11px; color: #bcd3e8; }
#stage .hr-rewardbox { display: flex; flex-direction: column; gap: 5px; }
#stage .hr-reward { display: flex; justify-content: space-between; font-weight: 800; } #stage .hr-reward b { color: var(--sun); }
#stage .hr-note { font-size: 13px; padding: 6px 9px; border-radius: 9px; background: rgba(255,255,255,.08); }
#stage .hr-note.good { background: rgba(74,212,138,.2); } #stage .hr-note.gold { background: rgba(255,210,58,.22); }
#stage .hr-next { background: rgba(127,227,255,.14); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; } #stage .hr-next b { color: #7fe3ff; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
#stage .hr-stat { display: flex; justify-content: space-between; gap: 8px; align-items: center; background: rgba(255,255,255,.07); border-radius: 12px; padding: 8px 10px; }
#stage .hr-stat b { font-size: 15px; } #stage .hr-stat span { display: block; font-size: 12px; color: #bcd3e8; }
#stage .hr-pips { display: flex; gap: 3px; margin: 4px 0; } #stage .hr-pips u { width: 14px; height: 8px; border-radius: 2px; background: rgba(255,255,255,.2); } #stage .hr-pips u.on { background: var(--sun); }
#stage .hr-buy { background: var(--grass); min-width: 76px; } #stage .hr-buy.off { background: #3a4a5c; color: #9db0c4; }
#stage .hr-mission, #stage .hr-trophy { background: rgba(255,255,255,.07); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
#stage .hr-mission em, #stage .hr-trophy em { font-style: normal; font-size: 12px; color: var(--sun); } #stage .hr-mission.done, #stage .hr-trophy.got { background: rgba(74,212,138,.2); } #stage .hr-trophy span { font-size: 12px; color: #bcd3e8; }
#stage .hr-set { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; } #stage .hr-set input[type=range] { width: 55%; min-height: 44px; accent-color: var(--grass); touch-action: pan-x; }
#stage .hr-seg { display: flex; gap: 4px; } #stage .hr-seg .hr-btn { padding: 8px 10px; font-size: 13px; text-transform: capitalize; } #stage .hr-seg .hr-btn.on { background: var(--grass); }
#stage .hr-pause .hr-panel { gap: 12px; }

.hr-barwrap { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.hr-barwrap .btn { min-height: 44px; min-width: 44px; }
.hr-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.hr-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.hr-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.hr-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.hr-guide p { margin-bottom: .5rem; font-size: .95rem; }
@media (prefers-reduced-motion: reduce) { #stage .hr-btn.hr-hero { animation: none; } }

/* feedback: small call-outs (timing, streak, new best) */
#stage .hr-float.small { font-size: 18px; letter-spacing: 1.5px; top: 44%; }
#stage .hr-float.small.gold { color: var(--sun); }
@media (prefers-reduced-motion: reduce) {
  #stage .hr-float { animation: hrfade 1.4s linear forwards; }
  #stage .hr-btn.hr-hero { animation: none; }
  #stage .hr-flash { animation: none; opacity: 0; }
  #stage .spinner, #stage .load-in .spinner { animation-duration: 3s; }
}
@keyframes hrfade { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* ---- full screen: the stage fills the area under the dock, any aspect (camera adapts in render.resize) ---- */
.game-wrap.pip-stage { display: flex; flex-direction: column; overflow: hidden !important; padding-bottom: 0; }
.game-wrap.pip-stage #stage { flex: 1 1 0; min-height: 0; width: 100%; max-width: none; height: auto; aspect-ratio: auto; border-radius: 0; margin: 0; }
html.pip-immersive .game-wrap.pip-stage #stage { width: 100%; }
html.pip-immersive .game-wrap.pip-stage .hr-barwrap, html.pip-immersive .game-wrap.pip-stage .hr-keys,
html.pip-immersive .game-wrap.pip-stage > noscript, html.pip-immersive .hr-guide { display: none; }
#stage:fullscreen { width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; }
/* soft vignette over the 3D view, drawn once by the compositor */
#stage #app::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 58%, rgba(8,18,32,.28) 100%); }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .hr-hint { bottom: 4%; max-width: 70%; left: 15%; right: 15%; }
  html.pip-immersive #stage .hr-pitchname { top: 12%; }
}
