/* Fletchfield Archery 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 { --leaf:#3fae4a; --leaf-d:#2a7f35; --gold:#ffc21a; --red:#e0453a; --ink:#1b2a3d; --paper:#f6f1e3; --panel:rgba(17,32,48,.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(#8fd0ff 0%, #cfeeff 60%, #6cc24a 100%); 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; }
.game-wrap.pip-stage { display: flex; flex-direction: column; }
.game-wrap.pip-stage .game-title, .game-wrap.pip-stage .ar-bar, .game-wrap.pip-stage .ar-keys { display: none; }
.game-wrap.pip-stage #stage { flex: 1; min-height: 0; width: 100%; max-width: none; height: 100%; aspect-ratio: auto; border-radius: 0; }
#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 .panel, #stage #ui input { pointer-events: auto; }
#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 [hidden] { display: none !important; }

#stage #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#8fd0ff 0%, #cfeeff 60%, #6cc24a 100%); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(20,60,40,.45); 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,.4); border-top-color: var(--gold); animation: arspin .8s linear infinite; }
@keyframes arspin { to { transform: rotate(360deg); } }
#stage #ctxlost, #stage #nogl { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(17,32,48,.92); color: #fff; font-weight: 700; }
#stage #nogl { z-index: 60; }

/* HUD */
#stage .hud { position: absolute; inset: 0; padding: max(8px, env(safe-area-inset-top)) 10px 10px; pointer-events: none; }
#stage .hud-top { display: flex; gap: 6px; align-items: stretch; padding-right: 52px; }
#stage .stat { background: rgba(17,32,48,.6); border-radius: 12px; padding: 4px 9px; display: flex; flex-direction: column; min-width: 0; justify-content: center; }
#stage .stat small { font-size: 9px; letter-spacing: 1px; opacity: .8; }
#stage .stat b { font-size: 22px; line-height: 1; }
#stage .stat span { font-size: 10px; opacity: .85; }
#stage .pipsrow { display: flex; gap: 4px; margin-top: 3px; min-height: 12px; }
#stage .pipsrow i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--gold); background: transparent; }
#stage .pipsrow i.on { background: var(--gold); }
#stage .windbox { background: rgba(17,32,48,.6); border-radius: 12px; padding: 4px 9px; display: flex; align-items: baseline; gap: 4px; margin-left: auto; }
#stage .windbox .warr { font-size: 22px; color: #9be3ff; font-weight: 700; }
#stage .windbox b { font-size: 20px; }
#stage .windbox small { font-size: 10px; opacity: .8; }
#stage .icon-btn { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 8px; width: 46px; height: 46px; border-radius: 14px; border: 0; background: rgba(17,32,48,.6); display: flex; gap: 5px; align-items: center; justify-content: center; }
#stage .icon-btn i { width: 5px; height: 18px; border-radius: 2px; background: #fff; }
#stage .rangebar { position: absolute; top: 66px; left: 10px; display: flex; gap: 6px; }
#stage .reticle { position: absolute; left: 50%; top: 50%; width: 0; height: 0; --ret: 1; }
#stage .reticle i { position: absolute; display: block; }
#stage .r-ring { width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 2px solid rgba(255,255,255,.9); border-radius: 50%; transform: scale(var(--ret)); box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
#stage .r-h { width: 90px; height: 2px; margin: -1px 0 0 -45px; background: rgba(255,255,255,.75); box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
#stage .r-v { width: 2px; height: 90px; margin: -45px 0 0 -1px; background: rgba(255,255,255,.75); box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
#stage .windtick { width: 4px; height: 22px; margin: 0; left: 0; top: 0; background: #ffd23a; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
#stage .hint { position: absolute; left: 14px; right: 14px; top: 26%; background: rgba(17,32,48,.78); border: 2px solid var(--gold); border-radius: 14px; padding: 10px 14px; text-align: center; font-size: 15px; font-weight: 700; }
#stage .feed { position: absolute; left: 0; right: 0; top: 36%; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#stage .feed-item { font-weight: 800; font-size: 20px; text-shadow: 0 2px 0 rgba(0,0,0,.5); animation: arfeed 1.3s ease-out forwards; }
#stage .feed-item.gold { color: var(--gold); font-size: 24px; }
#stage .feed-item.miss { color: #ffb0a8; font-size: 16px; }
#stage .feed-item.pop { color: #ff9a8a; }
@keyframes arfeed { 0% { transform: translateY(8px) scale(.8); opacity: 0; } 15% { transform: none; opacity: 1; } 100% { transform: translateY(-26px); opacity: 0; } }
#stage .hud-bottom { position: absolute; left: 12px; right: 90px; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; }
#stage .distlbl { font-size: 13px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
#stage .drawbar { position: relative; height: 16px; border-radius: 10px; background: rgba(17,32,48,.6); border: 2px solid rgba(255,255,255,.8); overflow: hidden; }
#stage .drawbar #drawfill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #7ad64a, #ffd23a); }
#stage .drawbar #drawfill.full { background: #ff7a3a; }
#stage .drawmark { position: absolute; left: 35%; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,.8); }
#stage .focus-btn { position: absolute; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); width: 72px; height: 72px; border-radius: 50%; border: 3px solid #fff; background: rgba(42,127,53,.85); color: #fff; font-weight: 800; font-size: 11px; letter-spacing: .5px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; touch-action: none; }
#stage .focus-btn.on { background: #38b6ff; }
#stage .focus-btn.lock { background: #777; }
#stage .focusbar { display: block; width: 44px; height: 6px; border-radius: 3px; background: rgba(0,0,0,.4); overflow: hidden; }
#stage .focusbar #focusfill { display: block; height: 100%; width: 100%; background: #fff; }

/* screens */
#stage .screen { position: absolute; inset: 0; display: flex; align-items: stretch; justify-content: center; background: linear-gradient(rgba(10,24,40,.25), rgba(10,24,40,.55)); }
#stage .panel { width: 100%; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: max(14px, env(safe-area-inset-top)) 14px 16px; display: flex; flex-direction: column; gap: 10px; }
#stage .panel.menu, #stage .panel.pause, #stage .panel.brief, #stage .panel.results { justify-content: center; }
#stage .panel-head { display: flex; align-items: center; gap: 10px; flex: none; }
#stage .panel-head h2 { font-size: 22px; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
#stage .back { width: 46px; height: 46px; border-radius: 14px; border: 0; background: rgba(17,32,48,.75); color: #fff; font-size: 22px; flex: none; }
#stage .list { display: flex; flex-direction: column; gap: 8px; background: var(--panel); border-radius: 16px; padding: 10px; }
#stage .brand { text-align: center; text-shadow: 0 3px 0 rgba(0,0,0,.4); margin-bottom: 4px; }
#stage .brand b { display: block; font-size: 34px; letter-spacing: 3px; color: #fff; }
#stage .brand span { display: block; font-size: 15px; letter-spacing: 6px; color: var(--gold); font-weight: 800; }
#stage .status { display: flex; align-items: center; gap: 8px; background: rgba(17,32,48,.65); border-radius: 12px; padding: 8px 10px; font-weight: 700; }
#stage .meter { flex: 1; height: 8px; border-radius: 5px; background: rgba(255,255,255,.25); overflow: hidden; display: block; }
#stage .meter > i { display: block; height: 100%; background: linear-gradient(90deg, #7ad64a, #ffd23a); }
#stage .coin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2a8, #ffc21a 60%, #c98b00); vertical-align: -2px; margin-right: 4px; }
#stage .btn { position: relative; min-height: 46px; border-radius: 14px; border: 0; padding: 10px 16px; background: rgba(255,255,255,.92); color: var(--ink); font-weight: 800; font-size: 15px; box-shadow: 0 3px 0 rgba(0,0,0,.3); }
#stage .btn.primary { background: linear-gradient(#5fd35a, #2f9f3a); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
#stage .btn.danger { background: #e0453a; color: #fff; }
#stage .btn.poor { opacity: .65; }
#stage .btn:disabled { opacity: .55; box-shadow: none; }
#stage .btn.big { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; font-size: 18px; }
#stage .btn.big small { font-size: 11px; font-weight: 600; opacity: .85; }
#stage .btn.sm { min-height: 44px; padding: 8px 12px; font-size: 14px; }
#stage .badge { position: absolute; top: -6px; right: 10px; background: var(--red); color: #fff; font-size: 10px; font-style: normal; padding: 2px 6px; border-radius: 8px; }
#stage .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#stage .gear-line { text-align: center; font-size: 12px; opacity: .9; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
#stage .tier { font-size: 14px; letter-spacing: 1px; margin-top: 4px; text-shadow: 0 1px 0 rgba(0,0,0,.4); }
#stage .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#stage .cell { min-height: 72px; border-radius: 14px; border: 2px solid transparent; background: rgba(255,255,255,.14); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
#stage .cell b { font-size: 22px; }
#stage .cell small { font-size: 11px; opacity: .85; }
#stage .cell.now { border-color: var(--gold); background: rgba(255,194,26,.2); }
#stage .cell.locked, #stage .row.locked { opacity: .45; }
#stage .row { display: flex; align-items: center; gap: 10px; min-height: 56px; border-radius: 14px; border: 0; background: rgba(255,255,255,.14); color: #fff; padding: 8px 12px; text-align: left; }
#stage .row > b { font-size: 22px; width: 28px; text-align: center; }
#stage .row > span { flex: 1; display: flex; flex-direction: column; }
#stage .row small { font-size: 11px; opacity: .8; }
#stage .stars { color: var(--gold); letter-spacing: 2px; font-size: 18px; text-align: center; }
#stage .tabs { display: flex; gap: 6px; }
#stage .tab { flex: 1; min-height: 44px; border-radius: 12px; border: 0; background: rgba(255,255,255,.18); color: #fff; font-weight: 800; }
#stage .tab.on { background: var(--gold); color: var(--ink); }
#stage .coinline { font-weight: 700; }
#stage .card { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.1); border-radius: 14px; padding: 8px; }
#stage .swatch { width: 10px; align-self: stretch; border-radius: 5px; flex: none; }
#stage .card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
#stage .card-main small { font-size: 11px; opacity: .8; }
#stage .stat-row { display: flex; align-items: center; gap: 6px; font-size: 10px; }
#stage .stat-row > span { width: 66px; opacity: .8; }
#stage .pips { display: flex; gap: 5px; margin-top: 3px; }
#stage .pips i { width: 16px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.25); }
#stage .pips i.on { background: var(--gold); }
#stage .setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
#stage .setting input[type=range] { flex: 1; max-width: 190px; min-height: 44px; touch-action: pan-y; }
#stage .seg { display: flex; gap: 4px; }
#stage .facts { list-style: none; display: flex; flex-direction: column; gap: 4px; background: rgba(17,32,48,.65); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
#stage .tip { font-size: 13px; background: rgba(17,32,48,.65); border-radius: 12px; padding: 8px 12px; }
#stage .callout { background: var(--gold); color: var(--ink); font-weight: 800; border-radius: 12px; padding: 8px 12px; text-align: center; }
#stage .mission { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; font-size: 14px; }
#stage .mission .meter { grid-column: 1 / 2; }
#stage .mission.done span { text-decoration: line-through; opacity: .7; }
#stage .ach { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; font-size: 13px; opacity: .6; }
#stage .ach.got { opacity: 1; }
#stage .ach small { grid-column: 1 / 2; font-size: 11px; }
#stage .ach em { grid-row: 1 / 3; grid-column: 2; align-self: center; font-style: normal; font-size: 12px; }
#stage .results h2 { text-align: center; font-size: 26px; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
#stage .results h2.win { color: #9ef08a; }
#stage .results h2.lose { color: #ffb0a8; }
#stage .score { text-align: center; font-size: 15px; }
#stage .score b { font-size: 42px; }
#stage .btnrow { display: flex; flex-direction: column; gap: 8px; }
#stage .pause h2 { text-align: center; font-size: 28px; }

/* page chrome under the stage */
.ar-bar { display: flex; justify-content: center; margin-top: .75rem; }
.ar-bar .btn { min-height: 44px; min-width: 44px; padding: .6rem 1.4rem; }
.ar-keys { text-align: center; font-size: .8rem; color: #64748b; margin-top: .5rem; }
.ar-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.ar-guide h2 { font-size: 1.35rem; margin: 0 0 .6rem; }
.ar-guide h3 { font-size: 1.05rem; margin: 1.1rem 0 .3rem; }
.ar-guide p { margin: 0 0 .7rem; }
@keyframes ar-pop { 0% { transform: scale(.2); opacity: 0; } 70% { transform: scale(1.25); opacity: 1; } 100% { transform: scale(1); } }
@keyframes ar-rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
#stage .results .stars { display: flex; justify-content: center; gap: 6px; font-size: 34px; }
#stage .results .callout { animation: ar-rise .45s .5s both; }
#stage .results h2 { animation: ar-pop .45s both; }
#stage .results .callout.best { background: #9ef08a; }
@media (prefers-reduced-motion: reduce) { #stage .results h2, #stage .results .callout { animation: none; } }
@media (prefers-reduced-motion: reduce) { #stage .feed-item { animation-duration: .01s; } #stage .spinner { animation-duration: 2s; } }
@media (max-height: 560px) { #stage .brand b { font-size: 26px; } #stage .btn.big { min-height: 48px; } }

/* Wave 3: full screen on phones. The shell makes .game-wrap the stage; #stage fills it at any aspect. */
html.pip-immersive .ad-well, html.pip-immersive .ar-bar, html.pip-immersive .ar-keys, html.pip-immersive .ar-guide, html.pip-immersive #similar-games { display: none; }
html.pip-immersive .game-wrap.pip-stage #stage, :fullscreen #stage { width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; }
html.pip-immersive #stage .hud { padding-left: 10px; padding-right: 10px; }
html.pip-immersive #stage .icon-btn { min-width: 46px; min-height: 46px; }
/* Soft vignette over the 3D view: static, drawn once by the compositor. */
#stage #app::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 55%, rgba(8,24,16,.28) 100%); }
@media (orientation: landscape) and (max-height: 560px) {
  html.pip-immersive #stage .panel { max-width: 560px; margin: 0 auto; padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  html.pip-immersive #stage .hint { top: 18%; left: 20%; right: 20%; }
  html.pip-immersive #stage .rangebar { top: 56px; }
  html.pip-immersive #stage .stat b { font-size: 18px; }
}
