/**
 * 社務所 - 手機版樣式
 * 獨立檔案，方便維護
 */

@media (max-width: 768px) {
    /* ========================================
       社務所首頁
       ======================================== */
    .shrine-office-page {
        padding: 0;
        align-items: flex-start;
    }
    
    .office-stage {
        border-radius: 0;
        aspect-ratio: auto;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100%;
        margin-top: -60px;
        padding-top: 80px;
        box-sizing: border-box;
    }
    
    .office-bg {
        object-fit: cover;
        object-position: center bottom;
    }
    
    /* Q北 */
    .qbei-shopkeeper {
        width: 50%;
        bottom: 20%;
    }
    
    .qbei-bubble {
        top: -45px;
        padding: 0.5rem 1rem;
        max-width: 200px;
        white-space: normal;
    }
    
    .qbei-text {
        font-size: 0.8rem;
        white-space: normal;
        line-height: 1.4;
    }
    
    /* 互動物件 */
    .saisen-box {
        left: 5%;
        bottom: 22%;
        width: 25%;
    }
    
    .omikuji-cylinder {
        right: 8%;
        bottom: 22%;
        width: 14%;
    }
    
    /* 頂部欄 */
    .office-top-bar {
        padding: 0.5rem 0.75rem;
    }
    
    .back-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .back-btn img {
        height: 28px;
    }
    
    .currency-group {
        gap: 0.4rem;
    }
    
    .coin-display {
        padding: 0.3rem 0.6rem;
        border-radius: 16px;
    }
    
    .coin-display img {
        width: 22px;
        height: 22px;
    }
    
    .coin-display span {
        font-size: 0.9rem;
        min-width: 25px;
    }
    
    /* Q北選單 - 手機版位置調整 */
    .qbei-menu {
        padding: 0.75rem;
        gap: 0.5rem;
        min-width: 180px;
        bottom: 55% !important;
    }
    
    /* 頂部欄 - 確保在 navbar 下方可見 */
    .office-top-bar {
        top: 10px !important;
        z-index: 50 !important;
    }
    
    .qbei-menu-item {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .qbei-menu-item img {
        width: 28px;
        height: 28px;
    }

    /* ========================================
       商店 / 背包 Modal - 終極修復版
       ======================================== */
    #shop-modal,
    #inventory-modal {
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 1. 容器 */
    .shop-container,
    .inventory-container {
        position: relative !important;
        width: 95% !important;
        max-width: 400px;
        height: 75vh !important;
        max-height: 75vh !important;
        margin: 0 auto;
        padding: 0 !important;
        overflow: visible !important;
    }
    
    .shop-bg {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 8px;
        z-index: 0;
    }
    
    /* 隱藏 Q北 */
    .shop-qbei-wrapper,
    .shop-qbei-head {
        display: none !important;
    }
    
    /* 關閉按鈕 */
    .shop-close-btn,
    .shop-container .shop-close-btn,
    button.shop-close-btn {
        position: absolute !important;
        top: 10px !important;
        right: 10px !important;
        z-index: 100 !important;
    }
    
    .shop-close-btn img,
    .shop-container .shop-close-btn img,
    button.shop-close-btn img {
        width: 44px !important;
        height: 44px !important;
    }
    
    /* 貨幣顯示 */
    .shop-currency-group {
        position: absolute;
        top: 8px;
        left: 8px;
        z-index: 100;
        gap: 0.4rem;
    }
    
    .shop-currency-group .coin-display {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
    
    .shop-currency-group .coin-display img {
        width: 16px;
        height: 16px;
    }

    /* ========================================
       V8 修復版：格子置中
       ======================================== */
    .shop-split-layout {
        position: absolute !important;
        top: 40px !important;
        left: 10px !important;
        right: 10px !important;
        bottom: 60px !important; /* 底部留空間給按鈕 */
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important; /* 垂直置中 */
        z-index: 10;
        overflow: hidden !important;
    }
    
    /* 格子區：固定高度，不要 flex-grow */
    .shop-left-panel {
        flex: 0 0 auto !important;
        height: auto !important;
        max-height: none !important;
        width: 100% !important;
        border-bottom: 2px solid rgba(62, 39, 35, 0.15);
        padding: 4px !important;
        margin-bottom: 8px;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box !important;
    }
    
    .shop-items-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        grid-auto-rows: 75px !important;
        gap: 4px !important;
        padding: 0 !important;
    }
    
    /* 格子 */
    .shop-item-slot {
        position: relative !important;
        width: 100% !important;
        height: 75px !important;
        min-width: 0 !important;
        background-size: contain;
        background-position: center;
        background-repeat: no-repeat;
        border-radius: 6px;
        box-sizing: border-box;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
        overflow: hidden !important;
    }
    
    /* 鎮壓浮動圖示 */
    .shop-item-slot img,
    .shop-item-slot.selected img {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 55% !important;
        height: auto !important;
        max-width: 55% !important;
        max-height: 80% !important;
        z-index: 1 !important;
        margin: 0 !important;
    }
    
    .shop-item-slot.selected {
        box-shadow: 0 0 0 3px #fbbf24, 0 0 12px rgba(251, 191, 36, 0.6);
    }
    
    /* 價格標籤 */
    .shop-item-price-tag,
    .inventory-item-badge {
        position: absolute;
        font-size: 0.5rem;
        padding: 1px 3px;
        right: 2px;
        bottom: 2px;
        border-radius: 3px;
        z-index: 5;
    }

    /* ========================================
       詳情區：不伸展
       ======================================== */
    .shop-right-panel {
        flex: 0 0 auto !important;
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        padding: 8px !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    /* 隱藏頂部圖示 */
    .shop-preview-top {
        display: none !important;
    }
    
    /* 說明框 */
    .shop-preview-middle {
        width: 100% !important;
        overflow: hidden !important;
    }
    
    .shop-preview-middle .shop-preview-desc-box,
    .shop-right-panel .shop-preview-desc-box,
    div.shop-preview-desc-box {
        width: 90% !important;
        max-width: 350px !important;
        min-height: 120px !important;
        background: rgba(253, 251, 247, 0.98) !important;
        border: 2px solid #8d6e63 !important;
        border-radius: 12px !important;
        padding: 16px 24px !important;
        box-sizing: border-box !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
        overflow: visible !important;
        margin: 0 auto !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .shop-preview-desc-box p {
        font-size: 0.95rem !important;
        line-height: 1.5;
        color: #2c1810;
        margin: 0 0 8px 0 !important;
        text-align: center !important;
    }
    
    /* 價格顯示 - 放在說明框內 */
    .shop-preview-price,
    .inventory-count,
    .inventory-sell-price {
        font-size: 1.05rem !important;
        text-align: center !important;
        margin: 0 !important;
        font-weight: bold;
        color: #b45309;
    }
    
    /* 按鈕容器：正常顯示 */
    .shop-preview-bottom {
        flex: 0 0 auto !important;
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding-top: 16px !important;
    }
    
    /* 按鈕：使用原本的圖片樣式 */
    .shop-buy-btn {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        width: auto !important;
        height: auto !important;
        min-height: auto !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    
    .shop-buy-btn img {
        width: 160px !important;
        height: auto !important;
        filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
    }
    
    /* 出售按鈕（文字版） */
    .inventory-sell-btn {
        width: 75% !important;
        max-width: 200px !important;
        height: 40px !important;
        min-height: 40px !important;
        border-radius: 20px !important;
        font-size: 0.95rem !important;
        font-weight: bold;
        display: flex !important;
        align-items: center;
        justify-content: center;
        background-color: #d7ccc8 !important;
        box-shadow: 0 3px 6px rgba(0,0,0,0.2);
    }
}

/* ========================================
   更小螢幕 (480px 以下)
   ======================================== */
@media (max-width: 480px) {
    /* 首頁調整 */
    .qbei-shopkeeper {
        width: 55%;
        bottom: 18%;
    }
    
    .qbei-bubble {
        top: -40px;
        padding: 0.4rem 0.8rem;
        max-width: 160px;
    }
    
    .qbei-text {
        font-size: 0.75rem;
    }
    
    .saisen-box {
        left: 3%;
        bottom: 20%;
        width: 22%;
    }
    
    .omikuji-cylinder {
        right: 5%;
        bottom: 20%;
        width: 12%;
    }
    
    .back-btn img {
        height: 24px;
    }
    
    .coin-display img {
        width: 18px;
        height: 18px;
    }
    
    .coin-display span {
        font-size: 0.8rem;
    }
    
    /* 商店/背包調整 */
    .shop-split-layout {
        top: 40px !important;
        left: 6px !important;
        right: 6px !important;
        bottom: 6px !important;
    }
    
    .shop-left-panel {
        flex: 0 0 auto !important;
        padding: 4px !important;
    }
    
    .shop-items-grid {
        gap: 5px !important;
    }
    
    .shop-item-slot img {
        width: 55% !important;
    }
    
    .shop-right-panel {
        min-height: 160px !important;
        padding: 5px 6px !important;
    }
    
    .shop-preview-image {
        width: 32px;
        height: 32px;
    }
    
    .shop-preview-image img {
        width: 24px;
    }
    
    .shop-preview-name {
        font-size: 0.8rem;
    }
    
    .shop-preview-desc-box {
        max-height: 45px !important;
        min-height: 30px !important;
        padding: 4px 6px !important;
    }
    
    .shop-preview-desc-box p {
        font-size: 0.6rem;
    }
    
    .shop-buy-btn,
    .inventory-sell-btn {
        font-size: 0.75rem !important;
        padding: 8px 14px !important;
        min-height: 34px !important;
    }
    
    .shop-close-btn img {
        width: 24px;
        height: 24px;
    }
}
