/* Idle Fish Market 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 { --teal:#1e8fb0; --teal-d:#126a85; --sun:#ffc940; --coral:#ff7a59; --green:#3fcf7a; --ink:#143447; --paper:#f4fbfd; --line:#cfe6ee;
  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: #a8def5; color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", Verdana, system-ui, sans-serif; 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; }
@media (max-width: 480px) { #stage { width: 100%; } }
.game-wrap.pip-stage #stage { width: min(100%, calc((100vh - 64px) * 0.5625)); width: min(100%, calc((100svh - 64px) * 0.5625)); }
html.pip-immersive #stage:not(.is-big) { width: min(100%, calc(88vh * 0.5625)); width: min(100%, calc(88svh * 0.5625)); }
#stage *, #stage *::before, #stage *::after { box-sizing: border-box; }
#stage #app { position: absolute; left: 0; right: 0; top: 0; height: 40%; touch-action: none; overflow: hidden; }
#stage #app canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#stage #floats { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
#stage .fl { position: absolute; transform: translate(-50%, -50%); font-weight: 800; font-size: 15px; color: #fff; text-shadow: 0 2px 0 rgba(10,40,60,.6); white-space: nowrap; animation: flup 1.1s ease-out forwards; }
#stage .fl.b { animation-name: flup2; }
#stage .fl.gold { color: var(--sun); font-size: 17px; }
#stage .fl[hidden] { display: none; }
@keyframes flup { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -46px; } }
@keyframes flup2 { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -46px; } }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage #ui button, #stage #ui .sheet, #stage #ui .menu, #stage #ui .modal-bg, #stage #ui input, #stage #ui .hint-bubble { pointer-events: auto; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; color: inherit; }
#stage button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

#stage #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#38a3c8 0%, #a8def5 60%, #e3f6fc 100%); }
#stage #loader[hidden], #stage #ctxlost[hidden], #stage [hidden] { display: none !important; }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(10,60,90,.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(--sun); animation: fmspin .8s linear infinite; }
@keyframes fmspin { 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,40,60,.85); color: #fff; font-weight: 700; }

/* HUD */
#stage .hud { position: absolute; left: 0; right: 0; top: 0; padding: 6px 8px 0; z-index: 4; pointer-events: none; }
#stage .hud-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
#stage .coinbox { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; display: flex; align-items: baseline; gap: 6px; background: rgba(10,52,71,.72); color: #fff; border-radius: 12px; padding: 4px 10px; min-height: 36px; }
#stage .coin-ico { width: 14px; height: 14px; border-radius: 50%; background: var(--sun); box-shadow: inset 0 0 0 3px #e0a000; align-self: center; flex: none; }
#stage .coins { font-size: 20px; }
#stage .rate { font-size: 12px; color: #bfeaff; }
#stage .hud-right { flex: none; display: flex; gap: 5px; align-items: center; }
#stage .pearl-chip { position: absolute; right: 8px; top: 56px; background: rgba(255,255,255,.88); border-radius: 12px; padding: 3px 8px; font-size: 12px; font-weight: 700; }
#stage .ibtn { min-width: 44px; min-height: 44px; border-radius: 12px; border: 0; background: rgba(255,255,255,.9); font-size: 12px; font-weight: 800; padding: 0 6px; pointer-events: auto; box-shadow: 0 2px 0 rgba(10,52,71,.35); }
#stage .topline { margin-top: 4px; display: inline-block; background: rgba(255,255,255,.88); border-radius: 10px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
#stage .bottle-btn { position: absolute; z-index: 5; left: 50%; top: calc(40% - 52px); transform: translateX(-50%); min-height: 44px; padding: 0 16px; border-radius: 22px; border: 0; background: var(--sun); font-weight: 800; font-size: 14px; box-shadow: 0 3px 0 #b88400; animation: fmpulse 1s ease-in-out infinite; }
@keyframes fmpulse { 50% { transform: translateX(-50%) scale(1.06); } }
#stage .hint-bubble { position: absolute; z-index: 5; left: 10px; right: 10px; top: calc(40% - 118px); background: rgba(10,52,71,.9); color: #fff; border-radius: 12px; padding: 8px 10px; font-size: 12px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
#stage .hint-skip { flex: none; min-height: 32px; border: 0; border-radius: 8px; background: rgba(255,255,255,.2); color: #fff; font-size: 11px; padding: 0 8px; }
#stage .toasts { position: absolute; z-index: 6; left: 0; right: 0; top: 78px; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#stage .toast { background: rgba(10,52,71,.9); color: #fff; font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 12px; max-width: 92%; text-align: center; animation: fmtoast 2.6s ease forwards; }
#stage .toast.good { background: #1d8a52; }
#stage .toast.warn { background: #b2552b; }
@keyframes fmtoast { 0% { opacity: 0; transform: translateY(-6px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* sheet */
#stage .sheet { position: absolute; left: 0; right: 0; top: 40%; bottom: 0; background: var(--paper); border-radius: 16px 16px 0 0; box-shadow: 0 -4px 12px rgba(10,52,71,.25); display: flex; flex-direction: column; z-index: 2; touch-action: pan-y; }
#stage .tabbar { display: flex; gap: 2px; padding: 6px 6px 0; flex: none; }
#stage .tab { flex: 1 1 0; min-height: 44px; border: 0; border-radius: 10px 10px 0 0; background: #dcedf3; font-size: 12px; font-weight: 800; padding: 0 2px; }
#stage .tab.on { background: var(--teal); color: #fff; }
#stage .tab.pulse { animation: fmtab 1s ease-in-out infinite; }
@keyframes fmtab { 50% { background: var(--sun); } }
#stage .sheet-body { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; padding: 8px; border-top: 3px solid var(--teal); }
#stage .panel-body { display: flex; flex-direction: column; gap: 8px; }
#stage .list { display: flex; flex-direction: column; gap: 8px; }
#stage .chips { display: flex; flex-wrap: wrap; gap: 6px; }
#stage .chip { min-height: 44px; min-width: 52px; padding: 0 12px; border-radius: 22px; border: 2px solid var(--teal); background: #fff; font-weight: 800; font-size: 13px; }
#stage .chip.on { background: var(--teal); color: #fff; }
#stage .chip.dis { opacity: .5; }
#stage .card { background: #fff; border: 2px solid var(--line); border-left: 8px solid var(--tc, var(--teal)); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 5px; }
#stage .card.locked { opacity: .6; }
#stage .card-head { display: flex; align-items: center; gap: 8px; }
#stage .swatch { width: 22px; height: 22px; border-radius: 6px; background: var(--tc, var(--teal)); flex: none; }
#stage .card-tw { display: flex; flex-direction: column; min-width: 0; }
#stage .card-title { font-size: 15px; }
#stage .card-sub { font-size: 12px; color: #4b6a79; }
#stage .price { margin-left: auto; font-weight: 800; font-size: 15px; }
#stage .price.up { color: #1d8a52; }
#stage .price.down { color: #b2552b; }
#stage .info { font-size: 12px; color: #4b6a79; }
#stage .info.warn { color: #b2552b; font-weight: 700; }
#stage .lock-line { font-size: 13px; font-weight: 700; color: #4b6a79; }
#stage .sec { font-weight: 800; font-size: 13px; margin-top: 4px; }
#stage .banner-line { background: #e5f4fa; border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 700; }
#stage .banner-line.hot { background: #ffe9a8; }
#stage .banner-line.cold { background: #e4d9f6; }
#stage .bar { height: 10px; background: #e1eef3; border-radius: 6px; overflow: hidden; }
#stage .bar > i { display: block; height: 100%; width: 0; background: var(--tc, var(--teal)); }
#stage .bar > i.full { background: var(--coral); }
#stage .acts { display: flex; flex-wrap: wrap; gap: 6px; }
#stage .act { flex: 1 1 120px; min-height: 44px; border-radius: 10px; border: 0; background: var(--teal); color: #fff; font-weight: 800; font-size: 13px; padding: 4px 8px; box-shadow: 0 2px 0 var(--teal-d); }
#stage .act.alt { background: #5b7f8f; box-shadow: 0 2px 0 #3e5966; flex: 0 1 90px; }
#stage .act.buy { background: var(--green); color: #07301a; box-shadow: 0 2px 0 #1f9a56; }
#stage .act.hot { background: var(--sun); color: #3b2a00; box-shadow: 0 2px 0 #b88400; }
#stage .act.on { background: var(--coral); }
#stage .act.done { background: #8aa7b4; }
#stage .act.dis { opacity: .45; box-shadow: none; }
#stage .ach { font-size: 12px; opacity: .55; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); padding: 3px 0; }
#stage .ach.got { opacity: 1; }
#stage .ach.got b::before { content: "\2713  "; color: #1d8a52; }

/* menu + modal */
#stage .menu { position: absolute; inset: 0; z-index: 8; display: flex; align-items: flex-end; justify-content: center; background: linear-gradient(rgba(10,52,71,0) 0%, rgba(10,52,71,.2) 35%, rgba(10,52,71,.82) 100%); }
#stage .menu-box { width: 100%; padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; text-align: center; color: #fff; }
#stage .menu-title { font-size: clamp(24px, 8vw, 34px); text-shadow: 0 3px 0 rgba(10,52,71,.6); }
#stage .menu-sub { font-size: 14px; margin-bottom: 4px; }
#stage .menu-stat { font-size: 12px; opacity: .9; }
#stage .big { min-height: 48px; border: 0; border-radius: 14px; background: #fff; color: var(--ink); font-weight: 800; font-size: 16px; padding: 0 14px; box-shadow: 0 3px 0 rgba(10,52,71,.35); }
#stage .big.go { background: var(--sun); box-shadow: 0 3px 0 #b88400; }
#stage .big.alt { background: #dcedf3; }
#stage .big.danger { background: #ffd6cc; }
#stage .modal-bg { position: absolute; inset: 0; z-index: 12; background: rgba(10,40,60,.6); display: flex; align-items: center; justify-content: center; padding: 14px; }
#stage .modal { width: 100%; max-height: 100%; overflow-y: auto; touch-action: pan-y; background: var(--paper); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
#stage .modal h2 { font-size: 20px; }
#stage .modal p { font-size: 14px; }
#stage .modal-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
#stage .set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 700; min-height: 44px; }
#stage .set-row input { flex: 1; min-height: 44px; }

.fm-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.fm-bar .btn { min-height: 44px; min-width: 44px; }
.fm-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.fm-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.fm-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.fm-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.fm-guide p { margin-bottom: .5rem; font-size: .95rem; }
@media (prefers-reduced-motion: reduce) { #stage .bottle-btn, #stage .tab.pulse, #stage .toast { animation: none; } }
#stage .goalstrip { display: block; position: relative; margin-top: 4px; width: min(100%, 300px); min-height: 26px; padding: 4px 10px 8px; border: 0; border-radius: 10px; background: rgba(10,52,71,.78); color: #fff; font-family: inherit; font-weight: 700; font-size: 12px; line-height: 1.2; text-align: left; pointer-events: none; overflow: hidden; }
#stage .goalstrip .gs-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage .goalstrip .gs-track { position: absolute; left: 10px; right: 10px; bottom: 3px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); overflow: hidden; }
#stage .goalstrip .gs-fill { display: block; height: 100%; width: 0; background: #ffd24a; border-radius: 2px; transition: width .3s ease-out; }
#stage .goalstrip.ready { pointer-events: auto; min-height: 44px; background: #ffd24a; color: #0a3447; cursor: pointer; animation: fmtab 1s ease-in-out infinite; }
#stage .goalstrip.ready .gs-label { padding-top: 6px; }
#stage .goalstrip.ready .gs-fill { background: #0a3447; }
#stage .hud { padding-top: max(6px, env(safe-area-inset-top)); padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
#stage .tabbar { padding-bottom: env(safe-area-inset-bottom); }
#stage button:focus-visible { outline: 3px solid #ffd24a; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { #stage .goalstrip, #stage .goalstrip .gs-fill { animation: none; transition: none; } }

/* Full screen on phones (shell immersive + native). The game fills the stage under the dock. */
html.pip-immersive .game-wrap.pip-stage { display: flex; flex-direction: column; padding-left: 0; padding-right: 0; padding-bottom: 0; overflow: hidden; }
html.pip-immersive .game-wrap.pip-stage > .fm-bar, html.pip-immersive .game-wrap.pip-stage > .fm-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; height: auto; aspect-ratio: auto; border-radius: 0; }
html.pip-immersive #stage .fsbtn { display: none; }
html.pip-immersive #stage .sheet-body { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
html.pip-immersive #stage .tab { min-height: 44px; }
@media (orientation: landscape) and (max-height: 620px) {
  html.pip-immersive #stage #app { right: auto; width: 50%; height: 100%; }
  html.pip-immersive #stage .sheet { left: 50%; top: 0; border-radius: 16px 0 0 16px; }
  html.pip-immersive #stage .hud { right: auto; width: 50%; }
  html.pip-immersive #stage .pearl-chip { right: auto; left: calc(50% - 96px); }
  html.pip-immersive #stage .bottle-btn { left: 25%; top: calc(100% - 64px); }
  html.pip-immersive #stage .hint-bubble { right: auto; width: calc(50% - 20px); top: auto; bottom: 76px; }
  html.pip-immersive #stage .menu-box { padding: 8px 16px 10px; gap: 6px; }
  html.pip-immersive #stage .menu-title { font-size: 22px; }
  html.pip-immersive #stage .toasts { top: 60px; right: 50%; }
  html.pip-immersive #stage .modal { max-height: 100%; }
}
