/* Relic Dig 3D - stage + UI. Everything is scoped under #stage so site styles never leak in. */
html.pip-big, html.pip-big body { overflow: hidden; }
#stage { --view: 40%; --earth: #c4813a; --earth-d: #8f5a22; --gold: #ffc94a; --ink: #2b2118; --cream: #fff3d6; --panel: #2b2118; --row: #3b2e21; --green: #5fd07a;
  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: #f6d9a0; 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; }
#stage *, #stage *::before, #stage *::after { box-sizing: border-box; }
#stage [hidden] { display: none !important; }
#stage #app { position: absolute; left: 0; right: 0; top: 0; bottom: calc(100% - var(--view)); cursor: pointer; }
#stage #app canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; color: inherit; }
#stage button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#stage button:disabled { opacity: .45; cursor: default; }

#stage #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#c4813a, #f6d9a0); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 2px 0 rgba(60,30,0,.5); 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: 40px; height: 40px; border-radius: 50%; border: 6px solid rgba(255,255,255,.35); border-top-color: var(--gold); animation: dgspin .8s linear infinite; }
@keyframes dgspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; left: 0; right: 0; top: 0; bottom: calc(100% - var(--view)); z-index: 40; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; background: rgba(43,33,24,.88); color: #fff; font-weight: 700; font-size: 14px; pointer-events: none; }
#stage #ctxlost.soft { background: linear-gradient(#c4813a, #8f5a22); }

/* HUD sits over the 3D view */
#stage .hud { position: absolute; left: 0; right: 0; top: 0; height: var(--view); pointer-events: none; }
#stage .hud > * { position: absolute; }
#stage .hud-coins { left: 8px; top: 8px; background: rgba(43,33,24,.7); padding: 5px 12px 5px 8px; border-radius: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; max-width: 62%; }
#stage .hud-coins b { font-size: 20px; color: var(--gold); }
#stage .sub { font-size: 11px; opacity: .8; display: block; }
#stage .hud-coins .sub { flex-basis: 100%; margin-top: -2px; }
#stage .coin-ico { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2a8, #e5a91a); border: 2px solid #b87d0b; }
#stage .hud-depth { left: 10px; bottom: 24px; text-shadow: 0 1px 3px rgba(0,0,0,.7); color: #fff; }
#stage .hud-depth b { font-size: 16px; }
#stage .hud-leg { right: 10px; top: 58px; background: rgba(43,33,24,.7); color: var(--gold); padding: 3px 10px; border-radius: 10px; font-weight: 700; font-size: 12px; }
#stage .hud-timer { right: 10px; bottom: 24px; background: #c0392b; padding: 5px 12px; border-radius: 12px; font-weight: 800; font-size: 14px; }
#stage .hud-btns { right: 6px; top: 6px; display: flex; gap: 6px; pointer-events: auto; }
#stage .ico-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(43,33,24,.75); font-size: 18px; font-weight: 800; }
#stage .ico-btn.off { opacity: .5; text-decoration: line-through; }
#stage .layerbar { left: 8px; right: 8px; bottom: 8px; height: 10px; border-radius: 6px; background: rgba(0,0,0,.45); overflow: hidden; }
#stage .layerbar i { display: block; height: 100%; background: linear-gradient(90deg, #ffd35a, #ff9a2e); transform-origin: left center; transform: scaleX(0); }
#stage .hint-bubble { left: 10px; right: 10px; top: 62px; background: #fff3d6; color: var(--ink); padding: 8px 12px; border-radius: 12px; font-weight: 700; font-size: 13px; text-align: center; box-shadow: 0 3px 0 rgba(0,0,0,.3); }
#stage .toast { left: 10px; right: 10px; bottom: 40px; margin: 0 auto; width: max-content; max-width: 94%; background: rgba(43,33,24,.9); padding: 7px 12px; border-radius: 12px; font-size: 13px; font-weight: 700; text-align: center; }
#stage .toast.good { background: #2f7d46; } #stage .toast.find { background: #7a4fc0; } #stage .toast.warn { background: #b4472f; }
#stage .pop { color: #fff; font-weight: 800; font-size: 16px; text-shadow: 0 2px 2px rgba(0,0,0,.7); transform: translate(-50%, 0); opacity: 0; pointer-events: none; }
#stage .pop.go { opacity: 1; animation: dgpop .8s ease-out forwards; }
@keyframes dgpop { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -46px); } }
#stage .flash { inset: 0; background: rgba(255,255,255,.4); opacity: 0; transition: opacity .2s; }
#stage .flash.on { opacity: 1; }
#stage .hud-goal { right: 8px; bottom: 24px; max-width: 58%; background: rgba(43,33,24,.78); color: var(--cream); padding: 4px 10px; border-radius: 10px; font-weight: 800; font-size: 12px; text-align: right; border: 1px solid rgba(255,201,74,.45); }
#stage .hud-goal[hidden], #stage .hud-combo[hidden] { display: none !important; }
#stage .hud-combo { left: 50%; top: 66px; transform: translateX(-50%); background: linear-gradient(#ffd35a, #ff9a2e); color: var(--ink); padding: 3px 12px; border-radius: 12px; font-weight: 900; font-size: 14px; box-shadow: 0 2px 0 rgba(0,0,0,.35); }
#stage .hud-combo.bump { animation: dgbump .18s ease-out; }
@keyframes dgbump { from { transform: translateX(-50%) scale(1.3); } to { transform: translateX(-50%) scale(1); } }
#stage.is-big .hud-coins { top: calc(8px + env(safe-area-inset-top, 0px)); left: calc(8px + env(safe-area-inset-left, 0px)); }
#stage.is-big .hud-btns { top: calc(6px + env(safe-area-inset-top, 0px)); right: calc(6px + env(safe-area-inset-right, 0px)); }
#stage.is-big .panelwrap { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* bottom panel */
#stage .panelwrap { position: absolute; left: 0; right: 0; top: var(--view); bottom: 0; display: flex; flex-direction: column; background: var(--panel); pointer-events: auto; border-top: 3px solid var(--earth); }
#stage .tabs { display: flex; flex: 0 0 auto; background: #1d1610; }
#stage .tab { flex: 1 1 0; min-width: 0; min-height: 44px; border: 0; background: transparent; font-size: 11px; font-weight: 700; position: relative; padding: 4px 1px; white-space: nowrap; }
#stage .tab:last-of-type { flex-grow: 1.4; }
#stage .tab.on { background: var(--earth); color: #fff; }
#stage .dot { position: absolute; top: 5px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: #ff5a4a; }
#stage .panelbody { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: 8px; overscroll-behavior: contain; }
#stage .pane { display: block; }
#stage .sec { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--gold); margin: 8px 0 5px; }
#stage .row { display: flex; align-items: center; gap: 8px; background: var(--row); border-radius: 10px; padding: 7px 8px; margin-bottom: 6px; }
#stage .row.col { display: block; }
#stage .row-i { flex: 1; min-width: 0; }
#stage .row-i b, #stage .row b { font-size: 14px; display: block; }
#stage .btns { display: flex; flex-direction: column; gap: 4px; }
#stage .btn { background: var(--earth); color: #fff; border: 0; border-radius: 10px; padding: 8px 12px; font-weight: 800; font-size: 13px; min-height: 44px; min-width: 44px; white-space: pre-line; text-align: center; text-decoration: none; display: inline-block; line-height: 1.2; }
#stage .btn.buy { min-width: 86px; background: #3f9b52; }
#stage .btn.alt { background: #5a4a38; }
#stage .btn.warn { background: #b4472f; }
#stage .btn.go { background: #3f9b52; font-size: 15px; }
#stage .seg { display: flex; gap: 6px; margin-bottom: 6px; }
#stage .seg.wrap { flex-wrap: wrap; }
#stage .seg-b { flex: 1; background: #4a3b2b; padding: 6px 8px; font-size: 12px; min-width: 60px; }
#stage .seg-b.on { background: var(--earth); outline: 2px solid var(--gold); }
#stage .seg-b.locked { opacity: .55; }
#stage .bar { height: 8px; border-radius: 4px; background: #1a130c; overflow: hidden; margin-top: 4px; }
#stage .bar i { display: block; height: 100%; width: 0; background: var(--green); }
#stage .bar.gold i { background: var(--gold); }
#stage .note { font-size: 12px; opacity: .85; margin: 6px 0; }
#stage .note.big { font-size: 15px; font-weight: 800; color: var(--gold); opacity: 1; }
#stage .card, #stage .ach { background: var(--row); border-radius: 10px; padding: 8px; margin-bottom: 6px; }
#stage .card.done { outline: 2px solid var(--gold); }
#stage .ach { opacity: .55; } #stage .ach.on { opacity: 1; background: #2f5a3b; }
#stage .chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
#stage .chip { background: #1d1610; border-radius: 8px; padding: 3px 7px; font-size: 11px; opacity: .6; }
#stage .chip.got { opacity: 1; background: #4a3b2b; color: var(--gold); }

#stage .overlay { position: absolute; inset: 0; z-index: 30; background: rgba(20,12,4,.65); display: flex; align-items: center; justify-content: center; padding: 14px; pointer-events: auto; overflow-y: auto; touch-action: pan-y; }
#stage .card-o { background: var(--cream); color: var(--ink); border-radius: 16px; padding: 16px; width: 100%; max-width: 330px; box-shadow: 0 6px 0 rgba(0,0,0,.35); max-height: 100%; overflow-y: auto; }
#stage .card-o h2 { font-size: 20px; margin-bottom: 8px; }
#stage .card-o p { font-size: 14px; margin-bottom: 8px; }
#stage .btnrow { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
#stage .settings { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
#stage .settings .seg-b { color: #fff; }

/* Full screen (shell immersive and native): the page-frame wrapper becomes a flex column and the stage fills it. */
html.pip-immersive .game-wrap { display: flex !important; flex-direction: column; overflow: hidden !important; }
html.pip-immersive .dg-bar, html.pip-immersive .dg-keys { display: none !important; }
html.pip-immersive #stage, html.pip-native #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 #stage.is-fs .hud-btns { top: 6px; }
html.pip-immersive #stage.is-fs .panelwrap { padding-bottom: 0; }
@media (min-aspect-ratio: 1/1) {
  #stage.is-big, #stage.is-fs { --view: 100%; }
  #stage.is-big #app, #stage.is-fs #app { right: 46%; bottom: 0; }
  #stage.is-big .hud, #stage.is-big #ctxlost, #stage.is-fs .hud, #stage.is-fs #ctxlost { right: 46%; height: 100%; bottom: 0; }
  #stage.is-big .panelwrap, #stage.is-fs .panelwrap { left: 54%; top: 0; border-top: 0; border-left: 3px solid var(--earth); }
}
.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; }
@media (prefers-reduced-motion: reduce) { #stage .hud-combo.bump { animation: none; } #stage .flash { transition: none; } #stage .pop.go { animation-duration: .01s; } #stage .spinner { animation: none; } }
/* finish: soft vignette over the dig view, lit panel edge, press feedback */
#stage #app::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 55%, rgba(30,15,0,.28) 100%); }
#stage .panelwrap { box-shadow: 0 -6px 14px rgba(0,0,0,.28); background: linear-gradient(#33281c, #2b2118 40%); }
#stage .btn, #stage .tab, #stage .ico-btn { transition: transform .08s ease-out, filter .12s; }
#stage .btn:active:not(:disabled), #stage .tab:active, #stage .ico-btn:active { transform: scale(.95); filter: brightness(1.12); }
#stage .row { box-shadow: inset 0 1px 0 rgba(255,255,255,.06); }
@media (prefers-reduced-motion: reduce) { #stage .btn, #stage .tab, #stage .ico-btn { transition: none; } }

/* Full screen pass: a bigger dig view, compact shop rows, no scrolling stage. */
@media (orientation: portrait) {
  html.pip-big #stage.is-fs { --view: 66%; }
}
html.pip-big #stage.is-fs .panelbody { padding: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
html.pip-big #stage.is-fs .row { padding: 5px 7px; margin-bottom: 4px; }
html.pip-big #stage.is-fs .tab { min-height: 44px; }
@media (min-aspect-ratio: 1/1) {
  html.pip-big #stage.is-fs #app { right: 42%; }
  html.pip-big #stage.is-fs .hud, html.pip-big #stage.is-fs #ctxlost { right: 42%; }
  html.pip-big #stage.is-fs .panelwrap { left: 58%; padding-right: env(safe-area-inset-right, 0px); }
}
