/* Pinecrest Discs 3D - stage, HUD and menu panels. Everything is scoped under #stage so site styles never leak in. */
html.pip-big, html.pip-big body { overflow: hidden; }
#stage { --pine: #1f7a4d; --pine-d: #135636; --sun: #ffc21a; --orange: #ff7a2f; --ink: #1d2b3a; --cream: #fff6e0; --sky: #4aa8ff;
  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(#7ec8ff 0%, #e8f6ff 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 .panel, #stage #ui input, #stage #ui label { 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(#7ec8ff 0%, #e8f6ff 100%); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(20,60,110,.4); 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(--sun); animation: dgspin .8s linear infinite; }
@keyframes dgspin { 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(20,32,50,.88); color: #fff; font-weight: 700; }

/* HUD */
#stage .hud { position: absolute; inset: 0; padding: max(8px, env(safe-area-inset-top)) 8px 0; pointer-events: none; }
#stage .hud-top { display: flex; gap: 6px; align-items: flex-start; padding-right: 52px; }
#stage .plate { background: rgba(16,40,58,.62); color: #fff; border-radius: 12px; padding: 5px 10px; display: flex; flex-direction: column; font-size: 12px; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
#stage .plate b { font-size: 14px; }
#stage .plate.wind { flex-direction: row; align-items: center; gap: 6px; padding: 4px 8px; margin-left: auto; font-weight: 800; }
#stage .plate.dist { position: absolute; left: 8px; top: 62px; padding: 4px 10px; font-weight: 800; font-size: 13px; }
#stage .iconbtn { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 8px; width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(16,40,58,.7); color: #fff; font-weight: 900; font-size: 15px; letter-spacing: 2px; pointer-events: auto; }
#stage #h-arrow { transition: transform .15s; }
#stage .readout { position: absolute; left: 0; right: 0; bottom: 188px; text-align: center; font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.7); pointer-events: none; padding: 0 8px; }
#stage .swipe i { position: absolute; height: 5px; margin-top: -2px; border-radius: 3px; background: rgba(255,255,255,.85); transform-origin: 0 50%; box-shadow: 0 0 6px rgba(0,0,0,.5); }
#stage .swipe b { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: var(--sun); border: 3px solid #fff; box-shadow: 0 0 8px rgba(0,0,0,.5); }
#stage .swipe { position: absolute; inset: 0; pointer-events: none; }
#stage .feed { position: absolute; left: 0; right: 0; top: 108px; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#stage .feed .f { background: rgba(255,255,255,.93); color: var(--ink); font-weight: 800; font-size: 13px; padding: 5px 12px; border-radius: 99px; max-width: 92%; text-align: center; animation: dgfeed 2s ease-out forwards; }
#stage .feed .f.pw { background: var(--sun); color: #4a3200; }
@keyframes dgfeed { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
#stage .banner { position: absolute; left: 0; right: 0; top: 24%; text-align: center; pointer-events: none; opacity: 0; transform: scale(.85); transition: opacity .25s, transform .25s; color: #fff; text-shadow: 0 3px 0 rgba(10,50,40,.55); padding: 0 12px; }
#stage .banner.show { opacity: 1; transform: scale(1); }
#stage .b-main { font-size: clamp(26px, 9vw, 40px); font-weight: 900; letter-spacing: 1px; }
#stage .b-sub { font-size: 14px; font-weight: 700; }
#stage .hint { position: absolute; left: 50%; top: 34%; transform: translateX(-50%); width: 84%; 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,50,40,.3); pointer-events: none; }

/* controls */
#stage .ctrl { position: absolute; left: 6px; right: 6px; bottom: max(6px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 5px; padding: 6px; border-radius: 16px; background: rgba(16,40,58,.55); pointer-events: auto; }
#stage .crow { display: flex; gap: 5px; align-items: stretch; }
#stage .cbtn { min-width: 46px; min-height: 46px; border: 0; border-radius: 12px; background: rgba(255,255,255,.9); color: var(--pine-d); font-weight: 900; font-size: 15px; box-shadow: 0 3px 0 rgba(0,0,0,.3); touch-action: none; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; }
#stage .cbtn.wide { flex: 1; min-width: 0; }
#stage .cbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
#stage .dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0,0,0,.25); background: #ffd23f; flex: none; }
#stage .sliders label { flex: 1; display: flex; flex-direction: column; color: #fff; font-size: 11px; font-weight: 800; min-height: 44px; justify-content: center; }
#stage input[type=range] { width: 100%; height: 26px; accent-color: var(--sun); margin: 0; touch-action: pan-x; }
#stage .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 8px 14px; border: 0; border-radius: 14px; background: var(--pine); color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 4px 0 var(--pine-d); }
#stage .btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--pine-d); }
#stage .btn:disabled { background: #9aa7a0; box-shadow: 0 4px 0 #7b8681; color: #eef2f0; cursor: default; }
#stage .btn.big { min-height: 52px; font-size: 20px; letter-spacing: 2px; color: #fff; text-shadow: none; background: var(--orange); box-shadow: 0 5px 0 #b3490f; }
#stage .btn.alt { background: #e4efe9; color: var(--pine-d); box-shadow: 0 4px 0 #b3c7bd; }
#stage .btn.ghost { background: transparent; color: var(--pine-d); box-shadow: none; text-decoration: underline; }
#stage .btn.danger { background: #d94a4a; box-shadow: 0 4px 0 #962b2b; }
#stage .btn.sm { min-height: 44px; font-size: 14px; padding: 6px 12px; }
#stage .btn small { font-weight: 600; opacity: .85; font-size: 12px; }
#stage .throw { width: 100%; }

/* screens */
#stage .screen { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 8px; pointer-events: none; background: linear-gradient(rgba(10,30,40,0), rgba(10,30,40,.35)); }
#stage .panel { pointer-events: auto; width: 100%; max-height: 100%; background: rgba(255,246,224,.97); border-radius: 20px; padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
#stage .panel h2 { font-size: 22px; margin: 0; color: var(--pine-d); }
#stage .panel h3 { font-size: 15px; margin: 4px 0 0; text-align: left; color: var(--pine-d); }
#stage .panel p { margin: 0; font-size: 13px; color: #44566a; }
#stage .ph { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#stage .logo { font-size: clamp(28px, 10vw, 40px); font-weight: 900; line-height: 1; color: var(--pine); letter-spacing: 2px; text-shadow: 0 3px 0 rgba(0,0,0,.12); }
#stage .chips, #stage .rewards { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
#stage .chip { background: #fff; border-radius: 99px; padding: 4px 10px; font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; color: var(--ink); }
#stage .chip.hot { background: var(--sun); color: #4a3200; }
#stage .coin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2a8, #f2b200); border: 2px solid #c98a00; }
#stage .xpbar { height: 8px; border-radius: 4px; background: #d9e3dd; overflow: hidden; }
#stage .xpbar i { display: block; height: 100%; background: var(--orange); }
#stage .row2 { display: flex; gap: 8px; } #stage .row2 > * { flex: 1; }
#stage .goal { background: #e0f0e8; border-radius: 10px; padding: 7px 9px; font-weight: 800; color: var(--pine-d); }
#stage .list { display: flex; flex-direction: column; gap: 8px; }
#stage .card { background: #fff; border-radius: 14px; padding: 9px 10px; text-align: left; display: flex; flex-direction: column; gap: 5px; }
#stage .card.locked { opacity: .65; }
#stage .card.ach.done { background: #d8f5dc; }
#stage .cardtop { display: flex; justify-content: space-between; align-items: center; gap: 8px; } #stage .cardtop b { font-size: 15px; display: flex; align-items: center; gap: 6px; } #stage .cardtop span { font-size: 12px; color: #5a6b7c; font-weight: 700; }
#stage .cardrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: #44566a; }
#stage .lock { font-size: 12px; font-weight: 800; color: #9a6a1a; }
#stage .lvls { display: flex; gap: 6px; } #stage .lvl { flex: 1; flex-direction: column; gap: 2px; padding: 6px 4px; min-height: 64px; }
#stage .stars { color: #f2b200; letter-spacing: 1px; } #stage .stars i { color: #cfd6cf; font-style: normal; }
#stage .pips { display: flex; gap: 3px; } #stage .pips u { width: 16px; height: 7px; border-radius: 4px; background: #d5dcd8; } #stage .pips u.on { background: var(--pine); }
#stage .stats { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 3px 6px; font-size: 11px; color: #5a6b7c; align-items: center; }
#stage .bar { display: block; height: 6px; border-radius: 3px; background: #dde5e0; overflow: hidden; } #stage .bar b { display: block; height: 100%; background: var(--pine); }
#stage .seg { display: flex; gap: 6px; } #stage .seg .btn { flex: 1; }
#stage .grid2 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 5px; } #stage .stat { background: #fff; border-radius: 10px; padding: 5px 2px; display: flex; flex-direction: column; } #stage .stat b { font-size: 16px; } #stage .stat span { font-size: 10px; color: #5a6b7c; }
#stage .big { font-size: clamp(30px, 11vw, 46px); font-weight: 900; color: var(--orange); text-shadow: 0 3px 0 rgba(120,50,0,.2); line-height: 1.05; }
#stage .holedone .big { text-align: center; } #stage .panel .sub { font-weight: 800; color: var(--pine-d); font-size: 14px; } #stage .extra, #stage .note { font-weight: 700; }
#stage .note.ach { color: #8a5a00; }
#stage table.board { width: 100%; border-collapse: collapse; font-size: 14px; font-weight: 700; } #stage .board td { padding: 5px 6px; text-align: left; } #stage .board td:nth-child(n+3) { text-align: right; } #stage .board tr.me { background: #ffe9b0; border-radius: 8px; }
#stage .holes { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; } #stage .hc { min-width: 30px; padding: 4px 0; border-radius: 8px; background: #fff; font-weight: 800; } #stage .hc.under { background: #cfeedd; } #stage .hc.over { background: #fbd9d0; }
#stage .panel.menu, #stage .panel.pause, #stage .panel.holedone, #stage .panel.results { gap: 8px; }

@media (orientation: landscape) and (max-height: 520px) {
  #stage.is-big .screen { align-items: center; }
  #stage.is-big .panel { max-width: 460px; }
}
@media (max-height: 560px) { #stage .logo { font-size: 26px; } #stage .readout { bottom: 170px; } }
@media (prefers-reduced-motion: reduce) { #stage * { animation: none !important; transition: none !important; } }

html.pip-immersive #stage { width: min(100%, calc((var(--pip-vvh, 100svh) - 70px) * 0.5625)); }
/* page chrome below the stage */
.dg-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.dg-bar .btn { min-height: 44px; min-width: 44px; }
.dg-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.dg-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.dg-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.dg-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.dg-guide p { margin-bottom: .5rem; font-size: .95rem; }
#stage .holedone.under .big { color: #1f7a4d; animation: dg-pop .5s ease-out; }
#stage .holedone.over .big { color: #b3490f; }
#stage .holedone.even .big { color: #35506b; }
#stage .holedone.under { box-shadow: 0 0 0 3px #1f7a4d, 0 10px 30px rgba(0,0,0,.35); }
#stage .hc.now { outline: 2px solid #1f7a4d; }
#stage .hc.todo { background: transparent; color: #8a98a8; border: 1px dashed #b9c4cf; }
@keyframes dg-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ---- pass 3: full screen fill (shell immersive and native) ---- */
html.pip-immersive .game-wrap.pip-stage { display: flex; flex-direction: column; }
html.pip-immersive .dg-bar, html.pip-immersive .dg-keys, html.pip-immersive .game-title { display: none; }
html.pip-immersive #stage { flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; aspect-ratio: auto; margin: 0; border-radius: 12px; }
html.pip-immersive #stage .hud { padding-top: 6px; }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .ctrl { left: auto; right: 6px; width: min(310px, 42%); bottom: 6px; }
  html.pip-immersive #stage .readout { right: min(320px, 44%); bottom: 14px; }
  html.pip-immersive #stage .hud-top { padding-right: 56px; }
  html.pip-immersive #stage .feed { top: 70px; }
  html.pip-immersive #stage .hint { top: 22%; width: 50%; }
  html.pip-immersive #stage .banner { top: 14%; right: min(320px, 44%); }
  html.pip-immersive #stage .cbtn { min-height: 44px; }
  html.pip-immersive #stage .btn.big { min-height: 48px; }
}

/* ---- pass 3: finish ---- */
#stage .ctrl { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.16); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
#stage .btn.big { background: linear-gradient(#ff9a52, #ff7a2f); }
#stage .btn.big:active { filter: brightness(.95); }
#stage .plate { border: 1px solid rgba(255,255,255,.14); box-shadow: 0 3px 10px rgba(0,0,0,.2); }
#stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1; box-shadow: inset 0 0 70px rgba(10,30,20,.28); border-radius: inherit; }
