/* Penalty Kicks 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 { --navy: #12315f; --green: #3fcf6a; --red: #ff5a4a; --gold: #ffc61a; --paper: #f4f8ff; --ink: #14233d;
  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(#143a73, #4b86c8 60%, #3fa04a 61%); 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; }
.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; touch-action: none; }
#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 { 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(#143a73, #4b86c8); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-align: center; padding: 0 20px; }
#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: var(--gold); animation: pkspin .8s linear infinite; }
@keyframes pkspin { 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(10,20,45,.88); color: #fff; font-weight: 700; }

/* HUD */
#stage .hud { position: absolute; inset: 0; pointer-events: none; padding: max(8px, env(safe-area-inset-top)) 10px 8px; }
#stage .hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
#stage .board { display: flex; flex-direction: column; gap: 3px; background: rgba(10,25,55,.62); color: #fff; border-radius: 12px; padding: 6px 9px; min-height: 36px; font-size: 12px; }
#stage .br { display: flex; align-items: center; gap: 5px; }
#stage .br b { width: 32px; font-size: 11px; letter-spacing: 1px; opacity: .85; }
#stage .br em { font-style: normal; font-weight: 800; font-size: 16px; margin-left: 4px; }
#stage .board i { width: 13px; height: 13px; border-radius: 50%; background: rgba(255,255,255,.25); display: inline-block; }
#stage .board i.g { background: var(--green); } #stage .board i.m { background: var(--red); }
#stage .board .bt { font-weight: 800; font-size: 14px; padding: 2px 2px; }
#stage .board .sd { font-size: 10px; letter-spacing: 2px; color: var(--gold); font-weight: 800; }
#stage .pausebtn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(10,25,55,.7); color: #fff; font-weight: 800; font-size: 16px; letter-spacing: 1px; pointer-events: auto; }
#stage .hud-label { position: absolute; left: 10px; right: 64px; top: 62px; font-size: 12px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); font-weight: 700; }
#stage .pressure { position: absolute; left: 10px; top: 82px; width: 120px; height: 12px; background: rgba(10,25,55,.55); border-radius: 8px; overflow: hidden; }
#stage .pressure i { display: block; height: 100%; width: 0; background: #ffb020; transition: width .25s; }
#stage .pressure.hot i { background: var(--red); }
#stage .pressure span { position: absolute; inset: 0; font-size: 8px; letter-spacing: 2px; color: #fff; text-align: center; line-height: 12px; font-weight: 800; }
#stage .hud-wind { position: absolute; right: 10px; top: 66px; background: rgba(10,25,55,.6); color: #fff; font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 8px; }
#stage .hud-msg { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font-size: clamp(30px, 10vw, 48px); font-weight: 900; letter-spacing: 2px; color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,.35); opacity: 0; transform: scale(.7); transition: opacity .15s, transform .15s; }
#stage .hud-msg.show { opacity: 1; transform: scale(1); }
#stage .hud-msg.good { color: #7dffa0; } #stage .hud-msg.bad { color: #ff8a7a; }
#stage .hint-bubble { position: absolute; left: 14px; right: 14px; bottom: 16px; background: rgba(255,255,255,.95); color: var(--ink); border-radius: 14px; padding: 10px 12px; font-size: 14px; font-weight: 700; text-align: center; }
#stage .power { position: absolute; right: 12px; bottom: 90px; width: 12px; height: 120px; background: rgba(10,25,55,.55); border-radius: 8px; overflow: hidden; display: flex; align-items: flex-end; }
#stage .power i { display: block; width: 100%; height: 0; background: linear-gradient(#ffd23a, #ff5a4a); }
#stage .toasts { position: absolute; left: 10px; right: 10px; top: 110px; display: flex; flex-direction: column; gap: 4px; align-items: center; pointer-events: none; }
#stage .toast { background: rgba(10,25,55,.85); color: #fff; padding: 6px 12px; border-radius: 14px; font-size: 13px; font-weight: 700; animation: pkfade 2.4s ease both; }
@keyframes pkfade { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }
#stage .flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .12s; }

/* screens */
#stage .screen { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 10px; pointer-events: none; }
#stage .panel { pointer-events: auto; width: 100%; max-height: 100%; background: rgba(244,248,255,.97); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 9px; box-shadow: 0 8px 30px rgba(0,0,0,.35); overflow: hidden; }
#stage .panel.small { max-height: 92%; overflow-y: auto; touch-action: pan-y; align-self: center; }
#stage .panel.home { overflow-y: auto; touch-action: pan-y; }
#stage .scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
#stage .scroll.grid { display: grid; grid-template-columns: 1fr 1fr; align-content: start; }
#stage .panel h2 { margin: 0; font-size: 22px; color: var(--navy); letter-spacing: 1px; }
#stage .panel h3 { margin: 0; font-size: 15px; color: var(--navy); }
#stage .panel p { margin: 0; font-size: 13px; color: #44546f; }
#stage .shead { display: flex; align-items: center; gap: 8px; }
#stage .grow { flex: 1 1 auto; }
#stage .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#stage .row.center { justify-content: center; }
#stage .logo { font-size: clamp(30px, 10vw, 44px); font-weight: 900; line-height: 1; color: var(--navy); letter-spacing: 2px; text-align: center; }
#stage .logo em { color: #ff7a1a; font-style: normal; }
#stage .chip { background: #e4ecfb; color: var(--navy); border-radius: 12px; padding: 4px 10px; font-size: 12px; font-weight: 800; }
#stage .chip.coin { background: #fff0b8; } #stage .chip.ok { background: #cbf5d6; color: #14633a; }
#stage .menu { display: flex; flex-direction: column; gap: 8px; }
#stage .b { min-height: 48px; min-width: 44px; border: 0; border-radius: 14px; background: #dfe8fa; color: var(--navy); font-weight: 800; font-size: 16px; padding: 8px 14px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; }
#stage .b small { font-size: 11px; font-weight: 600; opacity: .8; }
#stage .b.main { background: var(--navy); color: #fff; }
#stage .b.hot { background: #ff7a1a; color: #fff; }
#stage .b.ghost { background: transparent; border: 2px solid #c5d3ee; }
#stage .b.danger { background: var(--red); color: #fff; }
#stage .b.sm { min-height: 44px; font-size: 14px; padding: 6px 12px; }
#stage .b:disabled { opacity: .45; cursor: default; }
#stage .goal { text-align: center; font-weight: 700; color: var(--navy) !important; }
#stage .mini { list-style: none; margin: 0; padding: 0; font-size: 12px; color: #44546f; }
#stage .mini li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
#stage .card { background: #fff; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 5px; border: 2px solid #e1e9f7; text-align: left; font: inherit; color: inherit; }
#stage .card.row { flex-direction: row; align-items: center; }
#stage .card.locked { opacity: .55; }
#stage .card.done { border-color: #8fdba8; }
#stage button.tile { cursor: pointer; min-height: 88px; justify-content: space-between; }
#stage button.tile:disabled { cursor: default; }
#stage .match { display: flex; align-items: center; gap: 8px; font-size: 13px; }
#stage .match span:nth-child(2) { flex: 1 1 auto; }
#stage .stars i { font-style: normal; color: #c9d3e8; font-size: 18px; } #stage .stars i.on { color: var(--gold); }
#stage .tabs { display: flex; gap: 6px; justify-content: center; }
#stage .pips { display: flex; gap: 4px; } #stage .pips i { width: 22px; height: 8px; background: #d5dff2; border-radius: 4px; } #stage .pips i.on { background: var(--green); }
#stage .sw { width: 34px; height: 34px; border-radius: 10px; border: 5px solid #fff; box-shadow: 0 0 0 2px #cdd8ee; } #stage .sw.ball { border-radius: 50%; }
#stage .bar { height: 8px; background: #dbe4f5; border-radius: 4px; overflow: hidden; } #stage .bar i { display: block; height: 100%; background: var(--green); }
#stage .seg { display: flex; gap: 4px; }
#stage .big { font-size: 40px; font-weight: 900; color: var(--navy) !important; text-align: center; }
#stage small { font-size: 11px; color: #5a6b88; }

.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 .b.go { background: #ff7a1a; color: #fff; min-height: 56px; box-shadow: 0 3px 0 #b8520a; }
#stage .badge { text-align: center; font-weight: 900; color: #14633a !important; background: #cbf5d6; border-radius: 12px; padding: 4px 10px; align-self: center; animation: pkpop .5s ease-out both .25s; }
#stage .tip { text-align: center; font-size: 13px; font-weight: 600; color: #5a6b88 !important; }
#stage h2.pop, #stage .big, #stage .stars { animation: pkpop .45s ease-out both; }
@keyframes pkpop { 0% { opacity: 0; transform: scale(.7); } 70% { transform: scale(1.08); } 100% { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #stage .badge, #stage h2.pop, #stage .big, #stage .stars { animation: none; } }
@media (prefers-reduced-motion: reduce) { #stage .toast, #stage .spinner { animation: none; } #stage .hud-msg { transition: none; } }

/* Full screen on phones (shell immersive on iPhone, native on Android): the stage fills the shell stage below the dock. */
#stage #app::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 58%, rgba(5,15,40,.32) 100%); }
html.pip-immersive .er-bar, html.pip-immersive .er-keys, html.pip-native .er-bar, html.pip-native .er-keys { display: none !important; }

html.pip-immersive .game-wrap.pip-stage, html.pip-native .game-wrap:fullscreen { display: flex; align-items: center; justify-content: center; padding: 0; margin: 0; overflow: hidden; }
html.pip-immersive #stage, html.pip-immersive #stage.is-big, html.pip-native #stage, html.pip-native #stage.is-big {
  position: relative; inset: auto; z-index: auto; border-radius: 0; flex: 0 1 auto; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; }
html.pip-immersive #stage .hud, html.pip-native #stage .hud { padding-top: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
html.pip-immersive #stage .hint-bubble, html.pip-native #stage .hint-bubble { bottom: max(16px, env(safe-area-inset-bottom)); }
