/* Kestrel Links 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 { --g:#2e9b57; --gd:#1d6b3c; --gl:#8be0a4; --gold:#ffc21a; --ink:#1f3a2a; --cream:#fff8e6; --red:#e2503f; --sky:#9fd8ff;
  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(#9fd8ff 0%, #d8f0ff 55%, #9ad884 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; }
.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 #ui button, #stage #ui .panel, #stage #ui .screen, #stage #ui .swingzone { pointer-events: auto; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; 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(#2e9b57 0%, #8be0a4 60%, #e9ffe0 100%); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(10,60,30,.45); text-align: center; padding: 0 18px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 30px); letter-spacing: 3px; }
#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(--gold); animation: glspin .8s linear infinite; }
@keyframes glspin { 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(15,40,25,.88); color: #fff; font-weight: 700; font-size: 15px; }

/* HUD */
#stage .hud { position: absolute; inset: 0; pointer-events: none; }
#stage .hud-top { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 60px; display: flex; gap: 6px; flex-wrap: wrap; }
#stage .chip { background: rgba(14,50,30,.62); color: #fff; border-radius: 12px; padding: 4px 9px; display: inline-flex; align-items: baseline; gap: 5px; font-size: 12px; min-height: 30px; align-items: center; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
#stage .chip b { font-size: 15px; font-variant-numeric: tabular-nums; }
#stage .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,50,30,.7); color: #fff; font-weight: 800; font-size: 16px; letter-spacing: 1px; pointer-events: auto; }
#stage .windchip { position: absolute; right: 8px; top: calc(max(8px, env(safe-area-inset-top)) + 52px); }
#stage .windchip i { display: inline-block; font-style: normal; font-size: 18px; transition: transform .2s; }
#stage .mini { position: absolute; left: 8px; top: calc(max(8px, env(safe-area-inset-top)) + 40px); width: 64px; height: 100px; border-radius: 10px; background: rgba(14,50,30,.45); border: 2px solid rgba(255,255,255,.55); }
#stage .matchchip { position: absolute; left: 80px; top: calc(max(8px, env(safe-area-inset-top)) + 40px); }
#stage .readerbtn { position: absolute; right: 8px; top: calc(max(8px, env(safe-area-inset-top)) + 96px); min-width: 66px; min-height: 44px; border: 0; border-radius: 12px; background: rgba(14,50,30,.7); color: #fff; font-weight: 800; font-size: 13px; pointer-events: auto; }
#stage .readerbtn.on { background: var(--gold); color: #3a2a00; }
#stage .hud-info { position: absolute; left: 64px; right: 64px; bottom: 150px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
#stage .hud-info b { font-size: 18px; } #stage .hud-info span { font-size: 12px; opacity: .95; }
#stage .aimbtn { position: absolute; bottom: 150px; width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.72); color: var(--gd); font-size: 20px; box-shadow: 0 3px 0 rgba(0,0,0,.28); pointer-events: auto; touch-action: none; }
#stage .aimbtn.left { left: 8px; } #stage .aimbtn.right { right: 8px; }
#stage .aimbtn:active { background: #fff; }
#stage .hint-bubble { position: absolute; left: 50%; top: 36%; transform: translateX(-50%); width: 82%; max-width: 300px; background: rgba(255,255,255,.96); color: var(--ink); font-weight: 800; font-size: 14px; text-align: center; padding: 10px 14px; border-radius: 16px; box-shadow: 0 4px 0 rgba(10,60,30,.35); }
#stage .feed { position: absolute; left: 0; right: 0; top: 30%; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; padding: 0 10px; }
#stage .feed .f { background: rgba(255,255,255,.93); color: var(--ink); font-weight: 800; font-size: 13px; padding: 4px 12px; border-radius: 99px; text-align: center; animation: glfeed 2.6s ease-out forwards; max-width: 100%; }
#stage .feed .f.good { background: #d9ffdf; } #stage .feed .f.bad { background: #ffe0da; }
@keyframes glfeed { 0% { opacity: 0; transform: translateY(8px); } 10% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
#stage .ctrl { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 8px max(8px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(8,34,20,.78) 28%); pointer-events: none; }
#stage .meterwrap { margin: 0 0 6px; pointer-events: none; }
#stage .meter { position: relative; height: 24px; border-radius: 12px; background: rgba(0,0,0,.5); border: 2px solid rgba(255,255,255,.7); overflow: hidden; }
#stage .meter i { position: absolute; top: 0; bottom: 0; left: 0; display: block; }
#stage #mBand { background: rgba(139,224,164,.55); border-right: 2px solid #8be0a4; }
#stage #mFill { background: linear-gradient(90deg, #ffd23a, #ff7b3a); width: 0; opacity: .9; }
#stage #mPeak { width: 4px; background: #fff; left: -10%; margin-left: -2px; }
#stage #mTxt { display: block; text-align: center; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 0 #000; margin-top: 2px; }
#stage .ctrl-row { display: flex; gap: 6px; align-items: stretch; height: 58px; }
#stage .clubarrow { width: 44px; border: 0; border-radius: 12px; background: rgba(255,255,255,.85); color: var(--gd); font-size: 28px; font-weight: 800; box-shadow: 0 3px 0 rgba(0,0,0,.3); pointer-events: auto; }
#stage .clubbtn { flex: 1; min-width: 0; border: 0; border-radius: 12px; background: #fff; color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 3px 0 rgba(0,0,0,.3); pointer-events: auto; padding: 0 4px; }
#stage .clubbtn b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; } #stage .clubbtn small { font-size: 11px; color: #4a6a55; }
#stage .swingbtn { width: 92px; border: 0; border-radius: 14px; background: linear-gradient(#ffd23a, #ff9a1f); color: #3a2200; font-weight: 800; font-size: 16px; letter-spacing: 1px; box-shadow: 0 4px 0 #a85d00; pointer-events: auto; touch-action: none; }
#stage .swingbtn:active { transform: translateY(2px); box-shadow: 0 2px 0 #a85d00; }
#stage .swingzone { width: 130px; border-radius: 14px; border: 3px dashed rgba(255,255,255,.85); background: rgba(255,255,255,.18); color: #fff; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 12px; font-weight: 800; padding: 4px; touch-action: none; }
#stage .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 30; }

/* screens */
#stage .screen { position: absolute; inset: 0; z-index: 20; display: flex; align-items: flex-start; justify-content: center; background: rgba(10,40,24,.5); overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; padding: 10px; }
#stage .panel { width: 100%; background: var(--cream); border-radius: 18px; padding: 14px; box-shadow: 0 6px 0 rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 8px; margin: auto 0; touch-action: pan-y; }
#stage .panel h1, #stage .panel h2, #stage .panel h3, #stage .panel p { margin: 0; }
#stage .panel h2 { font-size: 21px; color: var(--gd); letter-spacing: .5px; }
#stage .panel h3 { font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: #5b7a66; margin-top: 6px; }
#stage .bar { display: flex; align-items: center; gap: 8px; } #stage .bar h2 { flex: 1; }
#stage .logo { font-size: clamp(30px, 10vw, 42px); color: var(--gd); letter-spacing: 1px; text-align: center; line-height: 1; text-shadow: 0 3px 0 rgba(0,0,0,.12); }
#stage .logo em { color: #ff8a1f; font-style: normal; }
#stage .sub { text-align: center; font-size: 13px; color: #4a6a55; }
#stage .statrow { display: flex; justify-content: space-around; font-size: 13px; font-weight: 700; color: #355a44; }
#stage .coin { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; color: #6a4a00; }
#stage .coin i { display: inline-block; width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff1a6, #ffc21a 60%, #c88a00); border: 1px solid #a87000; }
#stage .xpbar { height: 10px; border-radius: 6px; background: rgba(31,58,42,.15); overflow: hidden; } #stage .xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--g), #8be0a4); }
#stage .panel button { min-height: 44px; border: 0; border-radius: 12px; background: #dff0e4; color: var(--gd); font-weight: 800; font-size: 14px; padding: 8px 12px; box-shadow: 0 3px 0 rgba(0,0,0,.18); }
#stage .panel button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
#stage .panel .big { min-height: 54px; background: linear-gradient(#3fcb73, var(--g)); color: #fff; font-size: 18px; box-shadow: 0 4px 0 var(--gd); }
#stage .panel .big.alt { background: linear-gradient(#ffd23a, #ff9a1f); color: #3a2200; box-shadow: 0 4px 0 #a85d00; }
#stage .panel .big small { display: block; font-size: 11px; opacity: .8; }
#stage .panel .big.sticky { position: sticky; bottom: 0; }
#stage .panel .small { min-height: 44px; padding: 6px 12px; font-size: 13px; }
#stage .panel .danger { background: #ffd9d3; color: #8a2a1c; }
#stage .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#stage .dot { font-style: normal; background: var(--red); color: #fff; border-radius: 99px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
#stage .tabs { display: flex; flex-wrap: wrap; gap: 6px; } #stage .tab { flex: 1 1 40%; } #stage .tab.on { background: var(--g); color: #fff; } #stage .tab.lock, #stage .opp.lock, #stage .card.lock { opacity: .65; } #stage .tab small { display: block; font-size: 10px; }
#stage .note { font-size: 12px; color: #4a6a55; } #stage .note.warn { color: #8a2a1c; font-weight: 700; }
#stage .card { background: #fff; border-radius: 14px; padding: 9px 11px; display: flex; flex-direction: column; gap: 2px; border: 3px solid transparent; cursor: pointer; min-height: 44px; }
#stage .card.on { border-color: var(--g); } #stage .card b { font-size: 15px; } #stage .card span { font-size: 12px; color: #355a44; } #stage .card small { font-size: 11px; color: #6a8a75; } #stage .card em { font-style: normal; font-size: 12px; font-weight: 700; color: #a85d00; }
#stage .opps { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; } #stage .opp { display: flex; flex-direction: column; align-items: flex-start; text-align: left; } #stage .opp.on { background: var(--g); color: #fff; } #stage .opp small { font-weight: 600; font-size: 10px; opacity: .85; }
#stage .row { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 12px; padding: 6px 10px; min-height: 48px; } #stage .row > div { flex: 1; min-width: 0; } #stage .row b { font-size: 14px; display: block; } #stage .row small { font-size: 11px; color: #6a8a75; } #stage .row em { font-style: normal; font-weight: 800; color: var(--g); font-size: 13px; }
#stage .buy { min-width: 74px; background: linear-gradient(#ffd23a, #ff9a1f) !important; color: #3a2200 !important; } #stage .buy.off { background: #ddd !important; color: #777 !important; }
#stage .toggle { min-width: 110px; }
#stage .balls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; } #stage .ballbtn { display: grid; grid-template-columns: 22px 1fr; column-gap: 6px; text-align: left; align-items: center; } #stage .ballbtn i { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #1f3a2a; grid-row: span 2; } #stage .ballbtn span { font-size: 12px; } #stage .ballbtn small { font-size: 10px; font-weight: 600; } #stage .ballbtn.on { background: var(--g); color: #fff; }
#stage .mis { position: relative; background: #fff; border-radius: 12px; padding: 8px 10px; display: grid; grid-template-columns: 1fr auto; overflow: hidden; } #stage .mis b { font-size: 13px; z-index: 1; } #stage .mis span { font-weight: 800; font-size: 13px; z-index: 1; } #stage .mis small { font-size: 11px; color: #a85d00; z-index: 1; } #stage .mis i { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--g); } #stage .mis.done { background: #d9ffdf; }
#stage .ach { display: grid; grid-template-columns: 1fr auto; background: #fff; border-radius: 12px; padding: 6px 10px; opacity: .65; } #stage .ach.got { opacity: 1; background: #fff3c4; } #stage .ach b { font-size: 13px; } #stage .ach small { font-size: 11px; color: #5b7a66; grid-column: 1; } #stage .ach em { font-style: normal; font-weight: 800; font-size: 12px; grid-row: span 2; align-self: center; color: #a85d00; }
#stage .help { padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
#stage .result { text-align: center; } #stage .result h2 { font-size: 30px; } #stage .result h2.good { color: #1d9a4a; } #stage .result h2.bad { color: var(--red); } #stage .result h2.even { color: var(--gd); }
#stage .coins { font-weight: 800; color: #a85d00; } #stage .rival { font-size: 13px; } #stage .goal { font-size: 12px; font-weight: 700; color: #355a44; }
#stage .rew { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; text-align: left; background: #fff; border-radius: 12px; padding: 8px 12px; } #stage .rew li { display: flex; justify-content: space-between; gap: 8px; } #stage .rew .trophy { color: #a85d00; font-weight: 800; }
#stage .sc { overflow-x: auto; } #stage .sc table { border-collapse: collapse; width: 100%; font-size: 11px; background: #fff; border-radius: 8px; } #stage .sc th, #stage .sc td { padding: 3px 2px; text-align: center; border: 1px solid #dfe9e2; min-width: 24px; } #stage .sc td.u { background: #cfeeda; font-weight: 800; } #stage .sc td.o { background: #ffe3dd; }
#stage .pausep { text-align: center; }

/* page chrome under the game */
.gl-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.gl-bar .btn { min-height: 44px; min-width: 44px; }
.gl-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.gl-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.gl-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.gl-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.gl-guide p { margin-bottom: .5rem; font-size: .95rem; }
@media (prefers-reduced-motion: reduce) { #stage .spinner { animation-duration: 2s; } #stage .feed .f { animation-duration: 4s; } }
#stage .scorebanner { position: absolute; left: 0; right: 0; top: 18%; text-align: center; pointer-events: none; font-weight: 900; font-size: clamp(30px, 9vw, 54px); letter-spacing: .02em; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.35), 0 0 18px rgba(0,0,0,.4); opacity: 0; transform: scale(.6); z-index: 25; }
#stage .scorebanner.on { animation: glbanner 1.4s ease-out forwards; }
#stage .scorebanner.gold { color: #ffd23a; } #stage .scorebanner.good { color: #8bf0a4; } #stage .scorebanner.bad { color: #ffb4a6; }
@keyframes glbanner { 0% { opacity: 0; transform: scale(.6); } 15% { opacity: 1; transform: scale(1.08); } 25% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { #stage .scorebanner.on { animation-duration: 1.8s; } }

/* Full screen on phones: the stage fills the shell's stage below the dock; extra page chrome steps aside. */
html.pip-immersive .game-wrap.pip-stage { display: flex; flex-direction: column; overflow: hidden; }
html.pip-immersive .game-wrap.pip-stage > .gl-bar,
html.pip-immersive .game-wrap.pip-stage > .gl-keys,
html.pip-immersive .game-wrap.pip-stage > noscript { display: none; }
html.pip-immersive .game-wrap.pip-stage #stage { flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; aspect-ratio: auto; margin: 0; border-radius: 0; }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .panel { max-width: 560px; margin-left: auto; margin-right: auto; }
  html.pip-immersive #stage .hud-info { bottom: 118px; }
  html.pip-immersive #stage .aimbtn { bottom: 118px; }
}
