/* Ice Slide 3D - stage + UI. Everything is scoped under #stage so site styles never leak in. */
html.isd-lock, html.isd-lock body { overflow: hidden; }
#stage { --ice:#2e9be0; --ice-d:#1b6fa8; --snow:#f4fbff; --ink:#173452; --gold:#ffcf3f; --rose:#e8453c;
  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(#cfeeff 0%, #eaf7ff 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-fixed { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; z-index: 99999; }
#stage.is-big { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; 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 button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
#stage button:focus-visible { outline: 3px solid var(--ink); 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(#cfeeff, #f4fbff); }
#stage #loader[hidden] { display: none; }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--ice-d); 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(46,155,224,.25); border-top-color: var(--ice); animation: isdspin .8s linear infinite; }
@keyframes isdspin { 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(20,40,70,.88); color: #fff; font-weight: 700; }
#stage #ctxlost[hidden], #stage .screen[hidden], #stage .dpad[hidden], #stage .hint-bubble[hidden], #stage .stat[hidden], #stage .ctl[hidden] { display: none; }

/* screens: each is a full-stage layer; menus swallow pointer events so swipes never leak to the board */
#stage .screen { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 10px; pointer-events: auto; overflow: hidden; }
#stage .screen.hud { pointer-events: none; padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom)); }
#stage .screen.hud.dim { opacity: .35; }
#stage .screen.hud button { pointer-events: auto; }
#stage .screen.pause, #stage .screen.results { justify-content: center; background: rgba(23,52,82,.45); }
#stage .screen.menu, #stage .screen.select, #stage .screen.shop, #stage .screen.missions, #stage .screen.settings { background: linear-gradient(rgba(214,240,255,.93), rgba(244,251,255,.96)); }

#stage .btn2 { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 46px; min-width: 46px; padding: 8px 14px; border: 0; border-radius: 14px; background: #fff; color: var(--ink); font-size: 16px; font-weight: 800; box-shadow: 0 3px 0 rgba(23,52,82,.25); }
#stage .btn2 small { font-size: 12px; font-weight: 600; opacity: .75; }
#stage .btn2.primary { background: var(--ice); color: #fff; box-shadow: 0 3px 0 var(--ice-d); }
#stage .btn2.big { min-height: 60px; font-size: 20px; }
#stage .btn2.small { min-height: 44px; font-size: 14px; padding: 6px 12px; }
#stage .btn2.locked { opacity: .6; }
#stage .btn2.danger { background: #ffe1de; color: #9a2a22; }
#stage .btn2:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(23,52,82,.25); }

/* HUD */
#stage .hud-top { display: flex; gap: 6px; align-items: flex-start; padding-right: 54px; flex-wrap: wrap; }
#stage .stat { background: rgba(23,52,82,.72); color: #fff; border-radius: 12px; padding: 5px 10px; display: flex; align-items: baseline; gap: 4px; min-height: 32px; font-size: 14px; }
#stage .stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
#stage .stat .lbl { font-size: 10px; letter-spacing: 1px; opacity: .8; }
#stage .hud-par { font-size: 11px; opacity: .85; }
#stage .hud-title { margin-top: 6px; color: var(--ink); font-weight: 800; font-size: 13px; text-shadow: 0 1px 0 rgba(255,255,255,.8); }
#stage .pausebtn { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 8px; width: 48px; height: 44px; min-height: 44px; padding: 0; border-radius: 12px; font-size: 13px; background: rgba(23,52,82,.78); color: #fff; box-shadow: none; }
#stage .hud-bottom { margin-top: auto; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
#stage .hud-bottom .ctl { min-height: 52px; background: rgba(255,255,255,.92); }
#stage .hint-bubble { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); width: min(88%, 340px); background: #fff; color: var(--ink); font-weight: 700; font-size: 14px; border-radius: 14px; padding: 9px 12px; text-align: center; box-shadow: 0 3px 0 rgba(23,52,82,.3); pointer-events: none; }
#stage .dpad { position: absolute; left: 10px; right: 10px; bottom: 74px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
#stage .dpad .dbtn { height: 56px; border: 0; border-radius: 14px; background: rgba(255,255,255,.9); color: var(--ice-d); font-size: 26px; font-weight: 900; box-shadow: 0 3px 0 rgba(23,52,82,.25); }
#stage .dpad.dpad:not([hidden]) ~ .hint-bubble { bottom: 142px; }

/* panels */
#stage .panel { width: 100%; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; background: #fff; border-radius: 20px; padding: 16px 14px; display: flex; flex-direction: column; gap: 9px; text-align: center; box-shadow: 0 6px 0 rgba(23,52,82,.3); }
#stage .panel h2 { font-size: 22px; }
#stage .stars { display: flex; justify-content: center; gap: 6px; font-size: 44px; line-height: 1; }
#stage .star { color: #c9d9e6; display: inline-block; }
#stage .star.on { color: var(--gold); text-shadow: 0 2px 0 #b8860b; animation: isdpop .5s ease-out both; }
@keyframes isdpop { 0% { transform: scale(0.2); opacity: 0; } 70% { transform: scale(1.3); opacity: 1; } 100% { transform: scale(1); } }
#stage .reward { font-weight: 800; color: #1b8a4d; font-size: 18px; }
#stage .ach { font-weight: 700; color: #7a4a00; background: #fff3d1; border-radius: 10px; padding: 4px 8px; font-size: 13px; }
#stage .goal { font-size: 13px; font-weight: 700; color: var(--ice-d); }
#stage .line { font-size: 14px; }

/* menu */
#stage .screen.menu { justify-content: center; gap: 10px; }
#stage .title-block { text-align: center; }
#stage .logo { font-size: clamp(34px, 12vw, 52px); font-weight: 900; letter-spacing: 3px; color: var(--ice-d); text-shadow: 0 3px 0 #fff; line-height: 1; }
#stage .logo2 { font-size: clamp(24px, 8vw, 34px); font-weight: 900; color: var(--rose); letter-spacing: 6px; text-shadow: 0 2px 0 #fff; }
#stage .tag { margin-top: 6px; font-size: 13px; color: var(--ink); }
#stage .menu-list { display: flex; flex-direction: column; gap: 8px; }
#stage .row2 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
#stage .chip { display: inline-block; background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 800; box-shadow: 0 2px 0 rgba(23,52,82,.2); }
#stage .chip.corner { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 10px; }

/* lists */
#stage .mhead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
#stage .mhead h2 { flex: 1; font-size: 20px; }
#stage .scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding-bottom: 12px; }
#stage .zone-h { display: flex; flex-direction: column; margin: 12px 2px 6px; font-size: 13px; }
#stage .zone-h b { font-size: 16px; }
#stage .lvgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
#stage .lvbtn { min-height: 52px; border: 0; border-radius: 12px; background: #fff; color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 2px 0 rgba(23,52,82,.25); }
#stage .lvbtn b { font-size: 16px; }
#stage .lvbtn small { font-size: 10px; color: #b8860b; }
#stage .lvbtn.done { background: #e9f7ff; }
#stage .lvbtn.locked { opacity: .45; }
#stage .shop-row { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 12px; padding: 8px 10px; margin-bottom: 6px; box-shadow: 0 2px 0 rgba(23,52,82,.15); }
#stage .shop-row .grow { flex: 1; display: flex; flex-direction: column; text-align: left; }
#stage .shop-row small { font-size: 12px; opacity: .8; }
#stage .shop-row.got { background: #eafbea; }
#stage .set-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #fff; border-radius: 12px; padding: 8px 10px; margin-bottom: 8px; flex-wrap: wrap; }
#stage .seg { display: flex; gap: 6px; flex-wrap: wrap; }
#stage .small-note { font-size: 12px; opacity: .75; text-align: center; }

#stage .toasts { position: absolute; left: 0; right: 0; top: 64px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 30; }
#stage .toast { background: rgba(23,52,82,.92); color: #fff; font-weight: 700; font-size: 14px; padding: 8px 14px; border-radius: 999px; max-width: 90%; text-align: center; animation: isdtoast .25s ease-out; }
@keyframes isdtoast { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (orientation: landscape) and (max-height: 520px) {
  #stage.is-big .panel, #stage.is-fixed .panel { max-width: 440px; margin: 0 auto; }
  #stage.is-big .screen.menu, #stage.is-fixed .screen.menu { max-width: 440px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) { #stage .star.on, #stage .toast { animation: none; } }

.isd-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.isd-bar .btn { min-height: 44px; min-width: 44px; }
.isd-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.isd-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.isd-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.isd-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.isd-guide p { margin-bottom: .5rem; font-size: .95rem; }

/* Shell full screen (native and immersive): the stage fills the area under the dock, any aspect, nothing scrolls. */
html.pip-immersive .game-wrap.pip-stage, .game-wrap.pip-stage:fullscreen { display: flex; flex-direction: column; overflow: hidden; box-sizing: border-box; }
html.pip-immersive .game-wrap.pip-stage > #stage, .game-wrap.pip-stage:fullscreen > #stage {
  position: relative; inset: auto; flex: 1 1 0; min-height: 0; width: 100%; max-width: none; height: auto; aspect-ratio: auto; margin: 0; border-radius: 0; }
html.pip-immersive .game-wrap.pip-stage > .isd-bar, html.pip-immersive .game-wrap.pip-stage > .isd-keys,
html.pip-immersive .game-wrap.pip-stage > .game-title, .game-wrap.pip-stage:fullscreen > .isd-bar, .game-wrap.pip-stage:fullscreen > .isd-keys,
html.pip-immersive .ad-well, html.pip-immersive .isd-guide { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #stage .panel, html.pip-immersive #stage .screen.menu { max-width: 440px; margin: 0 auto; }
}
