/* Wizard Survivor 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 { --pu:#6b4fe0; --pu-d:#3b2a8f; --gold:#ffd34d; --ink:#1d1538; --cream:#fff4dc; --red:#ff5a6e; --mint:#5ef2d0;
  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(#2b1d5e, #6b4fe0); 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; }
.game-wrap.pip-stage #stage { width: min(100%, calc((100vh - 64px) * 0.5625)); width: min(100%, calc((100svh - 64px) * 0.5625)); }
#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 #pad { position: absolute; inset: 0; touch-action: none; }
#stage #joy { position: absolute; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 3px solid rgba(255,255,255,.55); background: rgba(255,255,255,.12); pointer-events: none; }
#stage #joy[hidden] { display: none; }
#stage #knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(255,255,255,.75); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
#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 button:disabled { opacity: .45; cursor: default; }
#stage #ui.hurt::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 60px 10px rgba(255,40,60,.55); pointer-events: none; }

#stage #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#2b1d5e, #6b4fe0); }
#stage #loader[hidden] { display: none; }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 0 18px; text-shadow: 0 3px 0 rgba(10,5,40,.5); }
#stage .load-in b { font-size: clamp(20px, 6vw, 30px); letter-spacing: 2px; }
#stage .load-in span { font-size: 14px; opacity: .9; }
#stage .spinner { width: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.3); border-top-color: var(--gold); animation: wsspin .8s linear infinite; }
@keyframes wsspin { 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(20,10,50,.88); font-weight: 700; }
#stage #ctxlost[hidden] { display: none; }

/* HUD */
#stage .hud { position: absolute; inset: 0; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); pointer-events: none; }
#stage .hud[hidden], #stage .screen[hidden], #stage .bossbar[hidden], #stage .hint[hidden], #stage .toast[hidden] { display: none; }
#stage .hud-top { display: flex; align-items: center; gap: 8px; }
#stage .hp { position: relative; flex: 1; height: 22px; border-radius: 11px; background: rgba(20,10,50,.65); overflow: hidden; border: 2px solid rgba(255,255,255,.35); }
#stage .hp-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(#ff7a8a, #e0344f); transition: width .12s; }
#stage .hp-t { position: relative; display: block; text-align: center; font-size: 12px; font-weight: 800; line-height: 18px; text-shadow: 0 1px 0 #000; }
#stage .tmw { text-align: center; min-width: 60px; }
#stage .bestt { font-size: 10px; font-weight: 700; opacity: .8; text-shadow: 0 1px 0 #000; line-height: 1; min-height: 10px; }
#stage .tm { min-width: 52px; text-align: center; font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
#stage .pausebtn { pointer-events: auto; width: 44px; height: 44px; border-radius: 12px; border: 2px solid rgba(255,255,255,.5); background: rgba(20,10,50,.65); color: #fff; font-weight: 900; font-size: 16px; letter-spacing: 1px; }
#stage .xpbar { position: relative; margin-top: 6px; height: 14px; border-radius: 7px; background: rgba(20,10,50,.6); overflow: hidden; }
#stage .xp-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(#8ff8e0, #2bc4a4); }
#stage .lv { position: relative; display: block; text-align: center; font-size: 10px; font-weight: 800; line-height: 14px; text-shadow: 0 1px 0 #000; }
#stage .hud-sub { display: flex; justify-content: space-between; align-items: flex-start; margin-top: 6px; font-size: 12px; font-weight: 700; text-shadow: 0 1px 0 #000; }
#stage .loadout { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; max-width: 70%; }
#stage .ico { position: relative; width: 24px; height: 24px; border-radius: 7px; background: var(--c, #8fd4a8); color: #1d1538; font-weight: 900; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid rgba(255,255,255,.7); }
#stage .ico.pas { background: #cfd8ff; }
#stage .ico.evo { box-shadow: 0 0 8px 2px #ffe066; border-color: #ffe066; }
#stage .ico sub { position: absolute; right: -4px; bottom: -6px; font-size: 9px; background: #1d1538; color: #fff; border-radius: 5px; padding: 0 3px; line-height: 12px; }
#stage .bossbar { margin-top: 8px; text-align: center; }
#stage .bn { font-size: 13px; text-shadow: 0 1px 0 #000; letter-spacing: 1px; }
#stage .bt { margin-top: 2px; height: 12px; border-radius: 6px; background: rgba(20,10,50,.7); overflow: hidden; border: 2px solid rgba(255,255,255,.4); }
#stage .bf { display: block; height: 100%; width: 100%; background: linear-gradient(#ff9a5a, #d6342a); }
#stage .hint { position: absolute; left: 12px; right: 12px; bottom: 14%; text-align: center; background: rgba(20,10,50,.78); border: 2px solid rgba(255,255,255,.4); border-radius: 14px; padding: 8px 12px; font-size: 14px; font-weight: 700; }
#stage .toast { position: absolute; left: 12px; right: 12px; top: 26%; text-align: center; font-size: 20px; font-weight: 900; color: var(--gold); text-shadow: 0 2px 0 #000, 0 0 12px rgba(0,0,0,.6); }

/* screens */
#stage .screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 10px; background: rgba(18,10,48,.62); pointer-events: auto; }
#stage .screen.s-home { background: linear-gradient(rgba(18,10,48,.35), rgba(18,10,48,.8)); }
#stage .panel { width: 100%; max-height: 100%; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 18px; background: rgba(36,22,84,.94); border: 2px solid rgba(255,255,255,.25); }
#stage .panel h2 { text-align: center; font-size: 22px; letter-spacing: 1px; color: var(--gold); text-shadow: 0 2px 0 rgba(0,0,0,.4); }
#stage .panel h2.win { color: #8ff8a0; } #stage .panel h2.lose { color: #ff9aa8; }
#stage .panel h3 { font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; opacity: .8; margin-top: 4px; }
#stage .sub, #stage .mini { text-align: center; font-size: 13px; opacity: .88; }
#stage .mini { text-align: left; font-size: 12px; line-height: 1.4; }
#stage .logo { text-align: center; line-height: 1; margin: 2px 0 4px; }
#stage .logo span { display: block; font-size: 15px; letter-spacing: 6px; opacity: .85; }
#stage .logo b { display: block; font-size: clamp(30px, 10vw, 46px); color: var(--gold); text-shadow: 0 3px 0 #7a4b00, 0 6px 14px rgba(0,0,0,.5); letter-spacing: 2px; }
#stage .logo i { display: inline-block; margin-top: 2px; font-style: normal; font-weight: 900; font-size: 18px; background: var(--mint); color: #0b3d33; border-radius: 8px; padding: 2px 10px; }
#stage .statrow { display: flex; gap: 8px; justify-content: center; }
#stage .pill { background: rgba(255,255,255,.14); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 800; }
#stage .pill.gold { color: var(--gold); }
#stage .rankbar { height: 8px; border-radius: 4px; background: rgba(0,0,0,.35); overflow: hidden; }
#stage .rankbar i { display: block; height: 100%; background: linear-gradient(#ffe58a, #f0a823); }
#stage .setup-card { text-align: center; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.1); font-size: 14px; }
#stage .setup-card span { font-size: 12px; opacity: .8; }
#stage .btn { min-height: 46px; min-width: 44px; padding: 8px 14px; border-radius: 13px; border: 2px solid rgba(255,255,255,.35); background: #4a3aa8; color: #fff; font-weight: 800; font-size: 15px; text-align: center; display: block; }
#stage .btn.big { min-height: 58px; font-size: 22px; background: linear-gradient(#ffd34d, #f0a823); color: #3a2300; border-color: #fff3c4; text-shadow: none; letter-spacing: 1px; }
#stage .btn.ghost { background: transparent; }
#stage .btn.sm { min-height: 44px; font-size: 13px; padding: 6px 10px; white-space: nowrap; }
#stage .btn.on { background: #2bc4a4; color: #05332b; }
#stage .btn.danger { background: #a33046; }
#stage .grid2b { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .grid2 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
#stage .grid2 div { background: rgba(255,255,255,.1); border-radius: 10px; padding: 6px 2px; }
#stage .grid2 b { display: block; font-size: 18px; } #stage .grid2 span { font-size: 10px; opacity: .8; text-transform: uppercase; }
#stage .reward { text-align: center; font-size: 16px; font-weight: 800; color: var(--gold); }
#stage .reward em { color: #8ff8e0; font-style: normal; }
#stage .note { font-size: 13px; text-align: center; padding: 4px 8px; border-radius: 8px; background: rgba(255,255,255,.1); }
#stage .note.ok { background: rgba(94,242,208,.18); } #stage .note.up { background: rgba(255,211,77,.22); font-weight: 800; }
#stage .goal { font-size: 13px; text-align: center; opacity: .95; }
#stage .row { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.08); }
#stage .row .rt { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
#stage .row .rt span { font-size: 12px; opacity: .85; }
#stage .row.q.done { opacity: .6; }
#stage .badge { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; flex: none; }
#stage .pips { display: flex; gap: 4px; margin-top: 3px; }
#stage .pips i { width: 14px; height: 8px; border-radius: 3px; background: rgba(255,255,255,.2); }
#stage .pips i.f { background: var(--gold); }
#stage .opt { display: flex; flex-direction: column; text-align: left; gap: 2px; min-height: 52px; padding: 8px 12px; border-radius: 12px; border: 2px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; }
#stage .opt span { font-size: 12px; opacity: .85; } #stage .opt em { font-style: normal; color: var(--gold); font-size: 12px; }
#stage .opt.on { border-color: var(--mint); background: rgba(94,242,208,.16); }
#stage .seg { display: flex; border-radius: 10px; overflow: hidden; border: 2px solid rgba(255,255,255,.3); }
#stage .seg button { min-height: 44px; min-width: 44px; padding: 0 10px; border: 0; background: transparent; color: #fff; font-weight: 800; font-size: 13px; }
#stage .seg button.on { background: #2bc4a4; color: #05332b; }
#stage .back { margin-top: 4px; }

/* level up */
#stage .screen.s-levelup { background: rgba(12,6,36,.7); }
#stage .lvl .cards { display: flex; flex-direction: column; gap: 8px; }
#stage .card { position: relative; display: flex; flex-direction: column; gap: 2px; text-align: left; min-height: 74px; padding: 10px 40px 10px 14px; border-radius: 14px; border: 3px solid var(--c, #fff); background: rgba(255,255,255,.08); color: #fff; }
#stage .card b { font-size: 16px; } #stage .card .d { font-size: 12px; opacity: .9; }
#stage .card .tag { font-size: 10px; letter-spacing: 1.5px; font-weight: 800; color: var(--c); }
#stage .card .key { position: absolute; right: 12px; top: 10px; width: 24px; height: 24px; border-radius: 6px; background: rgba(255,255,255,.18); text-align: center; line-height: 24px; font-size: 13px; font-weight: 800; }
#stage .card.evo { background: linear-gradient(135deg, rgba(198,139,255,.35), rgba(255,224,102,.3)); animation: wsglow 1.2s ease-in-out infinite alternate; }
@keyframes wsglow { from { box-shadow: 0 0 4px 0 #ffe066; } to { box-shadow: 0 0 16px 3px #ffe066; } }

@media (min-height: 760px) { #stage .panel { padding: 18px; gap: 10px; } }
@media (prefers-reduced-motion: reduce) { #stage .card.evo { animation: none; } #stage .spinner { animation-duration: 2s; } }

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

#stage #ui.lowhp::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 70px 6px rgba(255,40,60,.4); pointer-events: none; animation: lowpulse 1s ease-in-out infinite; }
@keyframes lowpulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
#stage .toast { animation: toastpop .25s ease-out; }
@keyframes toastpop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #stage #ui.lowhp::after { animation: none; opacity: .6; } #stage .toast { animation: none; } }

/* Full screen (shell native + immersive): the shell makes .game-wrap the fixed stage under the dock;
   fill it with the canvas at any aspect (the camera follows the aspect), drop the page furniture. */
html.pip-immersive .game-wrap.pip-stage, .game-wrap.pip-stage:fullscreen { display: flex; flex-direction: column; overflow: hidden; }
html.pip-immersive .game-wrap.pip-stage > #stage, .game-wrap.pip-stage:fullscreen > #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 .ws-bar, html.pip-immersive .ws-keys, .game-wrap.pip-stage:fullscreen .ws-bar, .game-wrap.pip-stage:fullscreen .ws-keys { display: none; }
html.pip-immersive #stage .hud { padding-top: 8px; }
html.pip-immersive #stage .panel { max-width: 560px; margin-left: auto; margin-right: auto; }
html.ws-has-shell .ws-bar { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .panel { padding: 10px 14px; gap: 6px; }
  html.pip-immersive #stage .panel h2 { font-size: 18px; }
}
/* soft vignette: static layer, no per-frame cost */
#stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(ellipse at 50% 45%, transparent 58%, rgba(20,10,50,.38) 100%); }
#stage #ui, #stage #pad { z-index: 2; }
