/* Blast Yard 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:#e4572e; --acc-d:#b53a18; --sun:#ffc21a; --ink:#2a2230; --cream:#fff3d6; --panel:rgba(32,24,40,.92);
  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(#6ec6ff 0%, #dff3ff 100%); color: var(--ink);
  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; touch-action: none; }
#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 .screen, #stage #ui .kinds { pointer-events: auto; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; border: 0; color: inherit; }
#stage button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#stage [hidden] { display: none !important; }

#stage #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#e4572e 0%, #ffb36b 100%); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(90,30,10,.4); text-align: center; padding: 0 18px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 32px); letter-spacing: 2px; }
#stage .load-in span { font-size: 14px; opacity: .95; }
#stage .spinner { width: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.35); border-top-color: var(--sun); animation: bspin .8s linear infinite; }
@keyframes bspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(32,24,40,.9); color: #fff; font-weight: 700; }

/* HUD */
#stage .hud { position: absolute; inset: 0; pointer-events: none; padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; justify-content: space-between; }
#stage .hud-top { display: flex; gap: 6px; align-items: flex-start; }
#stage .ib { width: 44px; height: 44px; min-width: 44px; border-radius: 12px; background: var(--panel); color: #fff; font-weight: 800; font-size: 16px; pointer-events: auto; }
#stage .goal { flex: 1; min-width: 0; background: var(--panel); color: #fff; border-radius: 12px; padding: 5px 9px; display: flex; flex-direction: column; font-size: 11px; min-height: 44px; justify-content: center; }
#stage .goal b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage .goal span { opacity: .85; }
#stage .pill { background: var(--panel); color: #fff; border-radius: 12px; padding: 6px 10px; font-weight: 800; font-size: 13px; display: inline-block; min-height: 32px; line-height: 20px; }
#stage .hud-top .pill { min-height: 44px; display: flex; align-items: center; }
#stage .progress { --p: 0%; align-self: center; margin-top: 6px; background: linear-gradient(90deg, rgba(60,170,110,.85) var(--p), rgba(32,24,40,.8) var(--p)); transition: background .2s; color: #fff; border-radius: 10px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
#stage .hint-bubble { position: absolute; left: 50%; top: 20%; transform: translateX(-50%); width: min(86%, 300px); background: var(--cream); color: var(--ink); border-radius: 14px; padding: 9px 12px; font-weight: 800; font-size: 14px; text-align: center; box-shadow: 0 6px 0 rgba(0,0,0,.2); }
#stage .hud-bottom { display: flex; flex-direction: column; gap: 6px; }
#stage .kinds { display: flex; gap: 6px; justify-content: center; }
#stage .kind { flex: 1 1 0; min-width: 0; min-height: 48px; border-radius: 12px; background: var(--panel); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3px 2px; position: relative; font-size: 12px; }
#stage .kind i { width: 14px; height: 14px; border-radius: 50%; display: block; margin-bottom: 1px; box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
#stage .kind b { font-size: 12px; }
#stage .kind small { font-size: 11px; opacity: .85; }
#stage .kind.sel { outline: 3px solid var(--sun); background: #4a3a58; }
#stage .kind.out { opacity: .4; }
#stage .actions { display: flex; gap: 6px; pointer-events: none; }
#stage .ab { pointer-events: auto; flex: 1 1 0; min-height: 48px; min-width: 44px; border-radius: 12px; background: var(--panel); color: #fff; font-weight: 800; font-size: 13px; }
#stage .boom { pointer-events: auto; flex: 2 1 0; min-height: 48px; border-radius: 12px; background: var(--acc); color: #fff; font-weight: 900; font-size: 18px; letter-spacing: 1px; box-shadow: 0 4px 0 var(--acc-d); }
#stage .boom:disabled { opacity: .5; box-shadow: none; }
#stage .toast { position: absolute; left: 50%; bottom: 24%; transform: translateX(-50%); max-width: 86%; background: rgba(32,24,40,.95); color: #fff; padding: 8px 14px; border-radius: 12px; font-weight: 700; font-size: 13px; text-align: center; pointer-events: none; }
#stage .flash { position: absolute; inset: 0; pointer-events: none; opacity: .6; }

/* screens */
#stage .screen { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: max(14px, env(safe-area-inset-top)) 14px 18px; color: #fff; background: linear-gradient(rgba(32,24,40,.55), rgba(32,24,40,.82)); }
#stage .screen.dim { background: rgba(32,24,40,.82); }
#stage .screen h3 { font-size: 22px; text-align: center; margin: 6px 0 8px; }
#stage .sub { text-align: center; font-size: 13px; opacity: .88; margin: 4px 0 10px; }
#stage .logo { text-align: center; margin: 14px 0 6px; }
#stage .logo h2 { font-size: clamp(28px, 9vw, 40px); letter-spacing: 3px; color: var(--sun); text-shadow: 0 4px 0 rgba(0,0,0,.35); }
#stage .logo p { font-size: 13px; opacity: .9; }
#stage .blocks { display: flex; justify-content: center; gap: 4px; margin-bottom: 8px; }
#stage .blocks i { width: 26px; height: 26px; background: #d9a35f; border: 3px solid #a8742e; border-radius: 4px; display: block; }
#stage .blocks i:nth-child(2) { background: #ff8a3d; border-color: #c4561a; transform: rotate(8deg); }
#stage .blocks i:nth-child(3) { background: #9aa4b2; border-color: #6b7686; }
#stage .wal { display: flex; justify-content: center; gap: 8px; margin: 6px 0 10px; }
#stage .pill.coin { color: var(--sun); }
#stage .menu { display: flex; flex-direction: column; gap: 9px; max-width: 320px; margin: 8px auto 0; }
#stage .big { min-height: 52px; border-radius: 14px; background: #4a3a58; color: #fff; font-size: 17px; font-weight: 800; padding: 8px 14px; }
#stage .big.pri { background: var(--acc); box-shadow: 0 4px 0 var(--acc-d); }
#stage .big.lock { opacity: .55; }
#stage .big.danger, #stage button.danger { background: #b3263e; }
#stage .big em { font-style: normal; font-size: 12px; background: var(--sun); color: #4a3200; border-radius: 8px; padding: 1px 6px; margin-left: 4px; }
#stage .big small { font-size: 11px; opacity: .85; margin-left: 4px; }
#stage .row3 { display: flex; gap: 8px; }
#stage .row3 button { flex: 1; min-height: 46px; border-radius: 12px; background: #4a3a58; color: #fff; font-weight: 800; font-size: 14px; }
#stage .back { position: absolute; left: 10px; top: max(10px, env(safe-area-inset-top)); }
#stage .tabs { display: flex; gap: 8px; justify-content: center; margin: 4px 0; }
#stage .tab { width: 46px; height: 46px; border-radius: 12px; background: #4a3a58; color: #fff; font-weight: 900; font-size: 17px; }
#stage .tab.on { background: var(--acc); }
#stage .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 6px; }
#stage .lv { min-height: 64px; border-radius: 12px; background: #4a3a58; color: #fff; padding: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
#stage .lv b { font-size: 18px; }
#stage .lv small { font-size: 11px; opacity: .85; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage .lv.lock { opacity: .5; }
#stage .st { color: #6b5e78; font-size: 16px; }
#stage .st.on { color: var(--sun); }
#stage .stars.big .st { font-size: 46px; padding: 0 3px; }
#stage .stars { text-align: center; margin: 4px 0; }
#stage .gain { text-align: center; color: var(--sun); font-weight: 800; margin: 2px 0; }
#stage .ach { text-align: center; color: #9be3ff; font-weight: 700; font-size: 13px; margin: 2px 0; }
#stage .goal2 { text-align: center; font-size: 13px; margin: 8px 0; opacity: .92; }
#stage .row { display: flex; align-items: center; gap: 10px; background: #3a2c48; border-radius: 12px; padding: 8px 10px; margin: 7px 0; min-height: 52px; }
#stage .row.got { background: #2d4a3a; }
#stage .row .rt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#stage .row .rt small { opacity: .8; font-size: 12px; }
#stage .row button { min-width: 64px; min-height: 44px; border-radius: 10px; background: var(--acc); color: #fff; font-weight: 800; padding: 0 12px; }
#stage .row button:disabled { background: #5a4b68; opacity: .8; }
#stage .sw { width: 38px; height: 38px; border-radius: 10px; flex: 0 0 38px; }
#stage .segs { display: flex; gap: 4px; }
#stage .seg { min-width: 44px !important; padding: 0 8px !important; background: #5a4b68 !important; text-transform: capitalize; }
#stage .seg.on { background: var(--acc) !important; }
@media (prefers-reduced-motion: reduce) { #stage * { animation: none !important; transition: none !important; } }
@media (max-height: 520px) { #stage .big { min-height: 44px; font-size: 15px; } #stage .logo { margin-top: 4px; } }

/* page chrome under the game */
.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; }

#stage .progress[hidden] { display: none; }
@keyframes bystar { from { transform: scale(.2) rotate(-25deg); opacity: 0; } 70% { transform: scale(1.25) rotate(6deg); opacity: 1; } to { transform: none; opacity: 1; } }
#stage .result .stars.big .st.on { display: inline-block; animation: bystar .5s cubic-bezier(.2,.8,.3,1) both; }
#stage .result .stars.big .st:nth-child(2) { animation-delay: .18s; }
#stage .result .stars.big .st:nth-child(3) { animation-delay: .36s; }

/* ---- phone full screen (shell immersive on iPhone, native Fullscreen API on Android) ----
   The shell makes .game-wrap the stage. Let the 3D view fill all of it, in portrait and landscape;
   render.js refits the camera from the container size on every resize. */
html.pip-immersive .game-wrap.pip-stage, html.pip-native .game-wrap.pip-stage, .game-wrap.pip-stage:fullscreen { display: flex; flex-direction: column; padding: 0; margin: 0; overflow: hidden; }
html.pip-immersive .game-wrap.pip-stage #stage, html.pip-native .game-wrap.pip-stage #stage, .game-wrap.pip-stage:fullscreen #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 .er-bar, html.pip-immersive .game-wrap.pip-stage .er-keys,
html.pip-native .game-wrap.pip-stage .er-bar, html.pip-native .game-wrap.pip-stage .er-keys,
.game-wrap.pip-stage:fullscreen .er-bar, .game-wrap.pip-stage:fullscreen .er-keys { display: none; }
html.pip-immersive #stage .hud, html.pip-native #stage .hud { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .hud-bottom, html.pip-native #stage .hud-bottom { flex-direction: row; align-items: flex-end; }
  html.pip-immersive #stage .kinds, html.pip-native #stage .kinds { flex: 1 1 0; }
  html.pip-immersive #stage .actions, html.pip-native #stage .actions { flex: 1 1 0; }
}
