/**
 * VOID GACHA · itch.io iframe / 全螢幕嵌入版面
 * 維持卡牌 2:3 比例，適應 itch 視窗拉伸與行動端全螢幕
 */

html.void-itch-embed,
html.void-itch-embed body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    background-color: var(--void-cosmic-bg-color, #060613);
}

/* itch：星空底圖鋪滿寬度，避免捲動後左右露出純黑邊 */
html.void-itch-embed::before {
    background-attachment: scroll;
    background-size: cover;
    background-position: center center;
    width: 100%;
    min-height: 100%;
}

html.void-itch-embed body {
    min-height: var(--void-embed-vh, 100dvh);
}

html.void-itch-embed #screen-app {
    width: 100%;
    max-width: 100%;
    min-height: var(--void-embed-vh, 100dvh);
    box-sizing: border-box;
}

/* itch 全螢幕：僅限制卡牌展示尺寸，不鎖定殼層高度（避免全屏錯位） */
html.void-itch-embed.void-itch-mobile-shell.void-itch-expanded #screen-app,
html.void-itch-embed.void-itch-mobile-shell.void-itch-compact #screen-app {
    height: auto;
    max-height: none;
    overflow: visible;
    display: block;
}

html.void-itch-embed.void-itch-mobile-shell.void-itch-expanded .void-app-main,
html.void-itch-embed.void-itch-mobile-shell.void-itch-compact .void-app-main {
    overflow: visible;
    flex: none;
    min-height: 0;
}

/* 非 itch 手機殼時的舊版大視窗適配（僅影響非 itch 主機的 iframe 測試） */
html.void-itch-embed:not(.void-itch-mobile-shell).void-itch-expanded #screen-app {
    min-height: var(--void-embed-vh, 100dvh);
    height: var(--void-embed-vh, 100dvh);
    max-height: var(--void-embed-vh, 100dvh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
}

html.void-itch-embed:not(.void-itch-mobile-shell).void-itch-expanded .void-app-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* 首頁卡牌展示：限制最大尺寸、保持比例，避免全螢幕拉伸 */
html.void-itch-embed.void-itch-expanded .home-arena .card-3d-wrap,
html.void-itch-embed.void-itch-expanded .mythic-rising-wall .card-3d-wrap,
html.void-itch-embed.void-itch-expanded .bag-card-mount .card-3d-wrap {
    aspect-ratio: var(--void-card-aspect, 2 / 3);
    width: auto;
    height: auto;
    max-height: min(46dvh, 400px);
    max-width: min(36vw, 280px);
}

/* 展示櫃：卡牌須填滿格線，勿用 dvh 上限（否則頂部被裁切） */
html.void-itch-embed.void-itch-expanded .showcase-slot .card-3d-wrap,
html.void-itch-embed.void-itch-compact .showcase-slot .card-3d-wrap {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

html.void-itch-embed.void-itch-expanded .epic-hero-card {
    aspect-ratio: 5 / 7;
    width: min(var(--epic-card-w, 168px), 32vw, 240px);
    height: auto;
    max-height: min(44dvh, 360px);
}

html.void-itch-embed.void-itch-expanded .home-stage--browse {
    width: 100%;
    max-width: min(1200px, 100%);
    margin-inline: auto;
}

html.void-itch-embed.void-itch-expanded .gacha-view .machine-center-glow .card-3d-wrap {
    aspect-ratio: 5 / 7;
    width: min(220px, 42vw);
    height: auto;
    max-height: min(50dvh, 420px);
}

/* 刮刮樂 canvas：觸控不觸發外層捲動，維持格子比例 */
html.void-itch-embed canvas.scratch-fog {
    touch-action: none;
    max-width: 100%;
    height: auto;
    aspect-ratio: 1;
}

html.void-itch-embed .scratch-grid {
    width: min(100%, 360px);
    margin-inline: auto;
}

html.void-itch-embed #wheel-canvas {
    max-width: min(100%, 420px);
    height: auto;
    aspect-ratio: 1;
    touch-action: none;
}

/* 瀏覽器 Fullscreen API（若引擎自行 requestFullscreen） */
html.void-itch-embed:fullscreen,
html.void-itch-embed.void-browser-fullscreen {
    width: 100%;
    height: 100%;
    background: var(--bg, #06060c);
}

html.void-itch-embed:fullscreen body,
html.void-itch-embed.void-browser-fullscreen body {
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
}

html.void-itch-embed:fullscreen #screen-app,
html.void-itch-embed.void-browser-fullscreen #screen-app {
    min-height: 100%;
    height: auto;
    max-height: none;
}

/* 小視窗維持可捲動 */
html.void-itch-embed.void-itch-compact:not(.void-itch-mobile-shell) #screen-app {
    min-height: auto;
    height: auto;
    max-height: none;
    overflow: visible;
}

html.void-itch-embed.void-itch-compact:not(.void-itch-mobile-shell) .void-app-main {
    overflow: visible;
}

@media (max-width: 720px) {
    html.void-itch-embed.void-itch-expanded .epic-hero-card {
        max-width: min(44vw, 200px);
        max-height: min(40dvh, 300px);
    }

    html.void-itch-embed.void-itch-expanded .home-arena .card-3d-wrap,
    html.void-itch-embed.void-itch-expanded .mythic-rising-wall .card-3d-wrap {
        max-width: min(46vw, 210px);
        max-height: min(38dvh, 290px);
    }
}

/* itch 嵌入：勿載入 Google GSI（第三方 iframe 會 403） */
html.void-itch-embed #g_id_onload,
html.void-itch-embed #btn-google,
html.void-itch-embed .auth-divider {
    display: none;
}

/* itch 嵌入：頁尾法律條款預設收起，僅留細條展開鈕 */
html.void-itch-embed .void-global-footer {
    margin-top: 0;
    margin-left: 0;
    margin-right: 0;
    padding: 0;
    border-top: none;
    background: transparent;
    flex-shrink: 0;
}

html.void-itch-embed .void-global-footer.void-itch-footer-collapsed .footer-content {
    display: none;
}

html.void-itch-embed .void-global-footer:not(.void-itch-footer-collapsed) {
    padding: 10px 8px 6px;
    background: rgba(8, 4, 15, 0.92);
    border-top: 1px solid rgba(0, 240, 255, 0.12);
}

html.void-itch-embed .void-global-footer:not(.void-itch-footer-collapsed) .footer-logo {
    font-size: 14px;
}

html.void-itch-embed .void-global-footer:not(.void-itch-footer-collapsed) .footer-info p,
html.void-itch-embed .void-global-footer:not(.void-itch-footer-collapsed) .footer-copyright p {
    font-size: 11px;
    line-height: 1.45;
}

html.void-itch-embed .void-global-footer:not(.void-itch-footer-collapsed) .footer-links a {
    font-size: 12px;
}

html.void-itch-embed .void-global-footer:not(.void-itch-footer-collapsed) .footer-links .divider {
    margin: 0 6px;
}

html.void-itch-embed .void-itch-footer-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 28px;
    padding: 4px 10px;
    margin: 0;
    border: none;
    border-top: 1px solid rgba(0, 240, 255, 0.1);
    background: rgba(8, 4, 15, 0.88);
    color: #8a829e;
    font-size: 11px;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

html.void-itch-embed .void-itch-footer-toggle:hover,
html.void-itch-embed .void-itch-footer-toggle:focus-visible {
    color: #00f0ff;
    background: rgba(12, 6, 22, 0.95);
    outline: none;
}

html.void-itch-embed .void-global-footer:not(.void-itch-footer-collapsed) .void-itch-footer-toggle {
    border-top: none;
    border-bottom: 1px solid rgba(0, 240, 255, 0.08);
    margin-bottom: 6px;
    background: transparent;
    min-height: 24px;
    padding-top: 0;
}

/* itch 寬螢幕：恢復右側直欄導航與桌面頂欄留白（與 void-gacha.com 一致） */
html.void-itch-embed:not(.void-itch-mobile-shell) {
    --void-side-nav: 102px;
}

html.void-itch-embed:not(.void-itch-mobile-shell) #screen-app {
    padding-top: var(--void-app-header-offset, clamp(108px, 13vh, 148px));
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: calc(var(--void-side-nav, 102px) + max(10px, env(safe-area-inset-right, 0px)));
    height: auto;
    max-height: none;
    overflow: visible;
    display: block;
}

html.void-itch-embed:not(.void-itch-mobile-shell) .void-app-main {
    overflow: visible;
    min-height: 0;
    width: 100%;
    max-width: 100%;
}

html.void-itch-embed:not(.void-itch-mobile-shell) .void-itch-nav-dock {
    display: none !important;
}

html.void-itch-embed:not(.void-itch-mobile-shell) #screen-app > .side-nav {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: var(--void-side-nav, 102px);
    flex-direction: column;
    overflow: hidden;
    z-index: 120;
}

@media (max-width: 1100px) {
    html.void-itch-embed:not(.void-itch-mobile-shell) {
        --void-side-nav: 88px;
    }
}

/* itch：統一用手機底部導航 + 整頁捲動，避免放大後側欄裁切與點擊失效 */
html.void-itch-embed.void-itch-mobile-shell {
    --void-side-nav: 0px;
    --void-app-header-offset: 0px;
    --void-mobile-nav-h: calc(58px + env(safe-area-inset-bottom, 0px));
    --void-mobile-chat-gap: 62px;
    --void-itch-footer-bar-h: 28px;
}

html.void-itch-embed.void-itch-mobile-shell:not(.np-embed-mode),
html.void-itch-embed.void-itch-mobile-shell:not(.np-embed-mode) body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100%;
}

html.void-itch-embed.void-itch-mobile-shell:not(.np-embed-mode) #screen-app {
    padding-top: max(6px, env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--void-mobile-nav-h) + var(--void-mobile-chat-gap) + 16px);
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
    height: auto;
    max-height: none;
    overflow: visible;
    display: block;
}

html.void-itch-embed.void-itch-mobile-shell:not(.np-embed-mode) .void-app-main {
    overflow: visible;
    min-height: 0;
    width: 100%;
    max-width: 100%;
}

html.void-itch-embed.void-itch-mobile-shell .void-app-main > .view-panel {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

html.void-itch-embed.void-itch-mobile-shell #screen-app > .app-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    width: 100%;
    max-width: 100%;
    padding: 4px max(42px, calc(8px + env(safe-area-inset-right, 0px))) 6px max(8px, env(safe-area-inset-left, 0px));
    margin-bottom: 6px;
    box-sizing: border-box;
    isolation: isolate;
}

/* 嵌入 iframe（含 CrazyGames）：寬視窗也啟用頂欄收起鈕與精簡模式 */
html.void-itch-embed.void-itch-mobile-shell .hdr-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 6px;
    right: max(6px, env(safe-area-inset-right, 0px));
    z-index: 2;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.45);
    color: rgba(255, 255, 255, 0.82);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-level-block,
html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-tools,
html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-job-badge {
    display: none !important;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-command-panel {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-profile-card {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    padding: 4px 6px 4px 4px;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-profile-body {
    min-width: 0;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-name-row strong {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-currencies {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
    width: auto;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-coin {
    width: auto;
    min-width: 0;
    padding: 3px 6px 3px 4px;
    gap: 4px;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-coin-visual {
    transform: scale(0.72);
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-coin-label {
    display: none;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-coin strong {
    font-size: 11px;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-avatar-ring {
    width: 34px;
    height: 34px;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-avatar {
    font-size: 22px;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-lv-shield {
    width: 18px;
    height: 22px;
}

html.void-itch-embed.void-itch-mobile-shell .app-header.is-collapsed .hdr-live-feed {
    display: none;
}

/* 底欄導航：dock 外殼 + 左右切換鈕 + 可見橫向捲動 */
html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-dock {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 230;
    display: flex;
    align-items: stretch;
    gap: 0;
    width: 100%;
    max-width: 100%;
    padding: 0 max(2px, env(safe-area-inset-right, 0px)) max(0px, env(safe-area-inset-bottom, 0px)) max(2px, env(safe-area-inset-left, 0px));
    box-sizing: border-box;
    background: linear-gradient(180deg, rgba(12, 8, 28, 0.97), rgba(6, 10, 22, 0.98));
    border-top: 1px solid rgba(140, 100, 255, 0.4);
    box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.55);
}

html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-scroll {
    flex: 0 0 28px;
    width: 28px;
    min-width: 28px;
    border: none;
    border-radius: 0;
    background: rgba(8, 4, 18, 0.92);
    color: #00f0ff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    align-self: stretch;
}

html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-scroll:disabled {
    opacity: 0.28;
    cursor: default;
    color: #6a6280;
}

html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-scroll--prev {
    border-right: 1px solid rgba(140, 100, 255, 0.22);
}

html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-scroll--next {
    border-left: 1px solid rgba(140, 100, 255, 0.22);
}

html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-dock .side-nav,
html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-dock > .side-nav {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    flex: 1 1 auto;
    min-width: 0;
    z-index: 1;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    width: auto;
    max-width: none;
    max-height: none;
    height: auto;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 240, 255, 0.45) rgba(8, 4, 18, 0.5);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding: 5px 4px;
    border: none;
    border-radius: 0;
    box-shadow: none;
    transform: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    touch-action: pan-x pan-y;
}

html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-dock .side-nav .nav-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 58px;
    max-width: 72px;
    min-height: 46px;
    padding: 4px 6px;
    touch-action: manipulation;
    cursor: pointer;
    pointer-events: auto;
}

/* 覆寫 app.css 桌面側欄均分（≥721px 時會把底欄按鈕壓扁導致無法捲動／點擊） */
@media (min-width: 721px) {
    html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-dock .side-nav .nav-btn {
        flex: 0 0 auto;
        width: auto;
        min-width: 58px;
        max-width: 72px;
        min-height: 46px;
        padding: 4px 6px;
        gap: 4px;
    }

    html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-dock .side-nav .nav-icon {
        font-size: 17px;
    }

    html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-dock .side-nav .nav-label {
        font-size: 9px;
        line-height: 1.15;
    }
}

/* itch：卡包立繪維持 absolute 鋪滿（避免 void-option-glass 覆寫） */
html.void-itch-embed .pack-tile .pack-art {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

html.void-itch-embed .pack-tile .pack-art-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-dock .side-nav::-webkit-scrollbar {
    display: block;
    height: 6px;
}

html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-dock .side-nav::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.45);
    border-radius: 999px;
}

html.void-itch-embed.void-itch-mobile-shell .void-itch-nav-dock .side-nav::-webkit-scrollbar-track {
    background: rgba(8, 4, 18, 0.55);
}

/* 無 dock 包裝時的後備（初始化前） */
html.void-itch-embed.void-itch-mobile-shell .side-nav,
html.void-itch-embed.void-itch-mobile-shell #screen-app > .side-nav {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 220;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: none;
    height: auto;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 240, 255, 0.45) rgba(8, 4, 18, 0.5);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding: 5px max(4px, env(safe-area-inset-right, 0px)) max(5px, env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
    border: 1px solid rgba(140, 100, 255, 0.4);
    border-right: 1px solid rgba(140, 100, 255, 0.4);
    border-bottom: none;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

html.void-itch-embed.void-itch-mobile-shell .side-nav::-webkit-scrollbar,
html.void-itch-embed.void-itch-mobile-shell #screen-app > .side-nav::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

html.void-itch-embed.void-itch-mobile-shell .side-nav .nav-btn,
html.void-itch-embed.void-itch-mobile-shell #screen-app > .side-nav .nav-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-width: 56px;
    max-width: 68px;
    min-height: 46px;
    padding: 4px 5px;
}

html.void-itch-embed.void-itch-mobile-shell .side-nav .nav-icon,
html.void-itch-embed.void-itch-mobile-shell #screen-app > .side-nav .nav-icon {
    font-size: 17px;
}

html.void-itch-embed.void-itch-mobile-shell .side-nav .nav-label,
html.void-itch-embed.void-itch-mobile-shell #screen-app > .side-nav .nav-label {
    font-size: 9px;
    line-height: 1.15;
}

@media (min-width: 721px) {
    html.void-itch-embed.void-itch-mobile-shell .side-nav .nav-btn,
    html.void-itch-embed.void-itch-mobile-shell #screen-app > .side-nav .nav-btn {
        flex: 0 0 auto;
        min-height: 46px;
        padding: 4px 5px;
        gap: 4px;
    }

    html.void-itch-embed.void-itch-mobile-shell .side-nav .nav-icon,
    html.void-itch-embed.void-itch-mobile-shell #screen-app > .side-nav .nav-icon {
        font-size: 17px;
    }

    html.void-itch-embed.void-itch-mobile-shell .side-nav .nav-label,
    html.void-itch-embed.void-itch-mobile-shell #screen-app > .side-nav .nav-label {
        font-size: 9px;
    }
}

/* itch 整頁可捲動，隱藏置頂鈕以免遮擋 VOID LINK 與底欄 */
html.void-itch-embed.void-itch-mobile-shell .void-scroll-top {
    display: none;
}

html.void-itch-embed.void-itch-mobile-shell .void-global-footer.void-itch-footer-collapsed {
    position: relative;
    z-index: 1;
}

html.void-itch-embed.void-itch-mobile-shell .void-itch-footer-toggle {
    position: relative;
    z-index: 2;
}

html.void-itch-embed body.side-mode-modal-open .void-itch-nav-dock,
html.void-itch-embed body.abyss-modal-open .void-itch-nav-dock,
html.void-itch-embed body.void-card-modal-open .void-itch-nav-dock,
html.void-itch-embed body.lb-modal-open .void-itch-nav-dock,
html.void-itch-embed body.player-modal-open .void-itch-nav-dock {
    pointer-events: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

html.void-itch-embed body.void-card-modal-open .void-chat-panel,
html.void-itch-embed body.lb-modal-open .void-chat-panel,
html.void-itch-embed body.player-modal-open .void-chat-panel {
    pointer-events: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* itch：彈窗開啟時鎖定整頁捲動，滾輪只作用於彈窗 */
html.void-itch-embed body.void-card-modal-open,
html.void-itch-embed.void-card-modal-open,
html.void-itch-embed body.lb-modal-open,
html.void-itch-embed.lb-modal-open,
html.void-itch-embed body.player-modal-open,
html.void-itch-embed.player-modal-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

html.void-itch-embed body.void-card-modal-open #screen-app,
html.void-itch-embed body.void-card-modal-open .void-app-main,
html.void-itch-embed body.lb-modal-open #screen-app,
html.void-itch-embed body.lb-modal-open .void-app-main,
html.void-itch-embed body.player-modal-open #screen-app,
html.void-itch-embed body.player-modal-open .void-app-main {
    overflow: hidden !important;
}

html.void-itch-embed body.void-card-modal-open #card-modal:not(.hidden) {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: var(--void-embed-vh, 100dvh);
    box-sizing: border-box;
    padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px)) !important;
}

html.void-itch-embed.void-itch-mobile-shell body.void-card-modal-open #card-modal:not(.hidden) {
    align-items: flex-start !important;
}

html.void-itch-embed body.void-card-modal-open #card-modal:not(.hidden) .modal-inner.modal-inner--zoom {
    margin: auto !important;
    max-height: min(92dvh, calc(var(--void-embed-vh, 100dvh) - 24px)) !important;
}

html.void-itch-embed body.lb-modal-open #lb-showcase-modal:not(.hidden),
html.void-itch-embed body.player-modal-open .player-profile-modal:not(.hidden),
html.void-itch-embed body.player-modal-open .player-showcase-modal:not(.hidden) {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* itch：卡牌詳情卡圖放大、去除多餘暗色外框 */
html.void-itch-embed #card-modal .modal-inner.modal-inner--zoom .modal-art-panel.catalog-card-art-modal {
    width: min(340px, 92vw) !important;
    background: transparent !important;
}
html.void-itch-embed body.adventure-picker-open .void-itch-nav-dock {
    display: none;
}

html.void-itch-embed .mythic-rising-panel--cards .legend-card .legend-title {
    font-size: clamp(7px, 2.15vw, 9.5px);
    letter-spacing: -0.05em;
}

html.void-itch-embed .mythic-rising-panel--cards .legend-card .legend-line {
    font-size: clamp(6.5px, 1.9vw, 9px);
}

html.void-itch-embed #screen-auth .auth-box {
    border-radius: var(--auth-box-radius-sm, 22px);
    overflow: hidden;
}

html.void-itch-embed #screen-auth .auth-gate-banner {
    border-radius: 18px;
}

/* itch 遊樂場：手機殼維持每列兩格 */
html.void-itch-embed .playground-hub,
html.void-itch-embed .playground-guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 100%;
}

html.void-itch-embed .playground-view {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    scroll-margin-top: 8px;
}

html.void-itch-embed .view-panel[data-view="playground"]:not(.hidden) {
    padding-top: 4px;
}

html.void-itch-embed #playground-runner-panel:not(.hidden),
html.void-itch-embed #playground-mines-panel:not(.hidden),
html.void-itch-embed #playground-scratch-panel:not(.hidden),
html.void-itch-embed #playground-quiz-panel:not(.hidden),
html.void-itch-embed #playground-match-panel:not(.hidden) {
    scroll-margin-top: 12px;
}

html.void-itch-embed .playground-game-guide-slot {
    padding-bottom: 0.5rem;
}

/* itch 遊樂場單一遊戲：撐滿寬度、跑者畫布置中 */
html.void-itch-embed .playground-runner-panel,
html.void-itch-embed .playground-mines-panel,
html.void-itch-embed .playground-scratch-panel,
html.void-itch-embed .playground-quiz-panel,
html.void-itch-embed .playground-match-panel {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    box-sizing: border-box;
}

html.void-itch-embed .runner-layout,
html.void-itch-embed .mines-layout,
html.void-itch-embed .scratch-layout {
    width: 100%;
    max-width: 100%;
}

html.void-itch-embed .runner-stage-wrap {
    width: 100%;
    max-width: 100%;
}

html.void-itch-embed .runner-stage {
    width: 100%;
    max-width: 100%;
    margin-inline: auto;
}

html.void-itch-embed .runner-sidebar {
    width: 100%;
    max-width: 100%;
}

html.void-itch-embed .playground-quiz-panel__head {
    width: 100%;
    justify-content: space-between;
}

html.void-itch-embed .mines-board-wrap,
html.void-itch-embed .scratch-board-wrap {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
}

/* itch 窄螢幕：卡包橫向捲動＋原始 168×238 比例（僅手機殼） */
html.void-itch-embed.void-itch-mobile-shell .mythic-rising-panel--packs {
    overflow: visible;
    padding-top: 12px;
}

html.void-itch-embed.void-itch-mobile-shell .mythic-rising-packs-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 12px;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    touch-action: pan-x pan-y;
    padding: 4px 4px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 240, 255, 0.4) rgba(8, 4, 18, 0.45);
}

html.void-itch-embed.void-itch-mobile-shell .mythic-rising-packs-row::-webkit-scrollbar {
    display: block;
    height: 5px;
}

html.void-itch-embed.void-itch-mobile-shell .mythic-rising-packs-row::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.4);
    border-radius: 999px;
}

html.void-itch-embed.void-itch-mobile-shell .mythic-rising-packs-row .pack-tile {
    flex: 0 0 168px;
    width: 168px;
    min-width: 168px;
    max-width: 168px;
    height: 238px;
    min-height: 238px;
    scroll-snap-align: start;
}

html.void-itch-embed.void-itch-mobile-shell .mythic-rising-packs-row .pack-name {
    font-size: 11px;
    line-height: 1.2;
}

html.void-itch-embed.void-itch-mobile-shell .mythic-rising-packs-row .pack-en,
html.void-itch-embed.void-itch-mobile-shell .mythic-rising-packs-row .pack-ur,
html.void-itch-embed.void-itch-mobile-shell .mythic-rising-packs-row .pack-format {
    font-size: 9px;
    line-height: 1.25;
}

html.void-itch-embed.void-itch-mobile-shell .mythic-rising-packs-row .pack-foot {
    padding: 8px 6px 9px;
}

html.void-itch-embed.void-itch-mobile-shell .pack-scroll {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    touch-action: pan-x pan-y;
}

html.void-itch-embed.void-itch-mobile-shell .pack-scroll .pack-tile {
    flex: 0 0 168px;
    width: 168px;
    min-width: 168px;
    height: 238px;
    min-height: 238px;
    scroll-snap-align: start;
}

/* itch：聊天面板一律浮在底欄上方（不受 ≥721px 桌面定位影響，避免放大後重疊） */
html.void-itch-embed.void-itch-mobile-shell .void-chat-panel {
    min-height: 0;
}

html.void-itch-embed.void-itch-mobile-shell .void-chat-panel::after {
    display: none;
}

html.void-itch-embed.void-itch-mobile-shell .void-chat-panel:not(.is-hidden) {
    --void-chat-w: min(400px, calc(var(--void-embed-vw, 100vw) - 16px));
    left: max(8px, env(safe-area-inset-left, 0px));
    right: auto;
    width: var(--void-chat-w);
    max-width: min(400px, calc(100vw - 12px));
    bottom: var(--void-itch-chat-bottom, calc(var(--void-mobile-nav-h, 58px) + 10px));
    z-index: 210;
    max-height: calc(var(--void-embed-vh, 100dvh) - var(--void-mobile-nav-h, 58px) - 20px);
    font-size: 15px;
}

html.void-itch-embed.void-itch-mobile-shell .void-chat-panel:not(.is-hidden).is-collapsed {
    --void-chat-h: auto;
    height: auto;
    max-height: none;
    min-height: 0;
}

html.void-itch-embed.void-itch-mobile-shell .void-chat-panel:not(.is-hidden).is-collapsed .void-chat-body,
html.void-itch-embed.void-itch-mobile-shell .void-chat-panel:not(.is-hidden).is-collapsed .void-chat-foot {
    display: none;
    min-height: 0;
    height: 0;
    padding: 0;
    margin: 0;
    border: none;
}

html.void-itch-embed.void-itch-mobile-shell .void-chat-panel:not(.is-hidden):not(.is-collapsed) {
    --void-chat-h: min(560px, calc(var(--void-embed-vh, 100dvh) - var(--void-mobile-nav-h, 58px) - 28px));
    height: var(--void-chat-h);
    max-height: calc(var(--void-embed-vh, 100dvh) - var(--void-mobile-nav-h, 58px) - 28px);
    min-height: min(400px, calc(var(--void-embed-vh, 100dvh) - var(--void-mobile-nav-h, 58px) - 28px));
}

html.void-itch-embed.void-itch-mobile-shell .void-chat-panel:not(.is-hidden):not(.is-collapsed) .void-chat-body {
    flex: 1 1 auto;
    min-height: min(420px, calc(var(--void-embed-vh, 100dvh) - var(--void-mobile-nav-h, 58px) - 96px));
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

/* 平台 iframe（RainyNightFrog 等）矮視窗：登入頁改單欄，避免卡面／表單重疊 */
@media (max-height: 720px) {
    html.void-in-iframe #screen-auth:not(.hidden) {
        height: auto !important;
        min-height: var(--void-embed-vh, 100%) !important;
        max-height: none !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        padding: max(44px, env(safe-area-inset-top, 0px)) 10px 16px !important;
        box-sizing: border-box !important;
        background: var(--void-cosmic-bg-color, #060613) !important;
    }

    html.void-in-iframe #screen-auth .auth-stage {
        grid-template-columns: 1fr !important;
        min-height: 0 !important;
        height: auto !important;
        padding: 32px 6px 12px !important;
        gap: 10px !important;
        align-items: stretch !important;
    }

    html.void-in-iframe #screen-auth .auth-wing--left,
    html.void-in-iframe #screen-auth .auth-wing--right {
        display: none !important;
    }

    html.void-in-iframe #screen-auth .auth-center,
    html.void-in-iframe #screen-auth .auth-box {
        grid-column: 1 !important;
        width: 100% !important;
        max-width: min(420px, 100%) !important;
        margin-inline: auto !important;
    }

    html.void-in-iframe #screen-auth .auth-preview-mount--featured,
    html.void-in-iframe #screen-auth .auth-tilt-hint {
        display: none !important;
    }

    html.void-in-iframe #screen-auth .auth-hero-copy {
        margin: 0 0 6px !important;
    }

    html.void-in-iframe body.auth-gate-active #screen-app,
    html.void-in-iframe body.auth-gate-active #hero-welcome {
        visibility: hidden !important;
        opacity: 0 !important;
    }
}

/* RainyNightFrog 等平台 iframe：登入頁置中（與 embed-html-patch 同步） */
html.void-portal-embed #screen-auth:not(.hidden) {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 100% !important;
    min-height: 100% !important;
    padding: max(40px, env(safe-area-inset-top, 0px)) 12px 16px !important;
    background: var(--void-cosmic-bg-color, #060613) !important;
}

html.void-portal-embed #screen-auth .auth-stage {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    max-width: min(420px, 100%) !important;
    margin: 0 auto !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 24px 0 12px !important;
    gap: 12px !important;
}

html.void-portal-embed #screen-auth .auth-wing--left,
html.void-portal-embed #screen-auth .auth-wing--right,
html.void-portal-embed #screen-auth .auth-preview-mount--featured,
html.void-portal-embed #screen-auth .auth-tilt-hint {
    display: none !important;
}

html.void-portal-embed body.auth-gate-active #screen-app,
html.void-portal-embed body.auth-gate-active #hero-welcome {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
