/* 江南書院（收集系統）面板樣式
   專案規範：所有 class 一律加 fm-collection 前綴
   500x850 邏輯舞台
*/

/* 遮罩 */
.fm-collection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: hsla(0, 0%, 0%, 0.85);
    z-index: 2100;
    /* 高於遊戲 overlay (2000) 與 GameMessage (2050)；4 個覆蓋層統一 2100 */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.fm-collection-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* 主卡片 — 宣紙底色與卷軸感 */
.fm-collection-container {
    background: linear-gradient(135deg, hsl(36, 60%, 92%), hsl(36, 50%, 86%));
    border-radius: 20px;
    box-shadow: 0 12px 38px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: hsl(0, 50%, 20%);
    /* font-family: 'Noto Serif TC', serif;*/
    /*思源宋體*/
    font-family: 'Noto Sans TC';
    /*思源黑體*/
    position: absolute;
    border: 3px solid hsl(0, 60%, 30%);
}

/* 標題（朱紅卷頭） */
.fm-collection-header {
    background: hsl(0, 60%, 36%);
    color: hsl(34, 64%, 98%);
    padding: 8px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(0, 0, 0, 0.3);
    font-family: 'Noto Serif TC', serif;
}

.fm-collection-title {
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 5px;
    padding-left: 30px;
}

.fm-collection-close {
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: bold;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    color: #fdfaf6;
}

/* 上方資源橫條（時辰 + 文錢 + 文位） */
.fm-collection-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 14px;
    background: hsl(36, 35%, 80%);
    border-bottom: 1px solid hsl(0, 30%, 50%);
    font-size: 22px;
    color: hsl(0, 60%, 26%);
    font-weight: bold;
    font-family: 'Noto Serif TC', serif;
}

.fm-collection-hud-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fm-collection-hud-cell-label {
    font-size: 18px;
    color: hsl(0, 0%, 20%);
    font-weight: normal;
}

/* Canvas 場景 */
.fm-collection-stage {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, hsl(195, 30%, 88%) 0%, hsl(110, 30%, 84%) 100%);
    touch-action: none;
}

.fm-collection-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: default;
    touch-action: none;
    /* 確保雙指 pinch 縮放與單指拖曳不被瀏覽器手勢攔截 */
}

.fm-collection-canvas.hover-tool {
    cursor: pointer;
}

.fm-collection-canvas.hover-detail {
    cursor: help;
}

.fm-collection-canvas.grabbing {
    cursor: grabbing;
}

/* 場景內右上方工具列：工具 / 詳情 切換 */
.fm-collection-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 50;
}

.fm-collection-tool-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: hsla(36, 60%, 96%, 0.92);
    border: 2px solid hsl(0, 60%, 36%);
    color: hsl(0, 50%, 25%);
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.fm-collection-tool-btn.active {
    background: hsl(0, 60%, 46%);
    color: #fdfaf6;
    box-shadow: 0 0 0 2px hsl(48, 89%, 50%);
}

/* 商店列：擁有數量小字 */
.fm-collection-shop-own {
    font-size: 14px;
    color: hsl(0, 0%, 35%);
    margin-left: 4px;
}

/* 考棚雙鉤子：差距文字（積分/銀兩不足時的紅字） */
.fm-collection-gap-red {
    color: hsl(0, 80%, 42%);
    font-weight: bold;
}

.fm-collection-gap-ok {
    color: hsl(110, 50%, 30%);
    font-weight: bold;
}

/* 彈出選單 — 卷軸風格 */
.fm-collection-popup {
    position: absolute;
    background: linear-gradient(180deg, hsl(36, 60%, 96%), hsl(36, 60%, 88%));
    border: 2px solid hsl(0, 60%, 36%);
    border-radius: 8px;
    padding: 10px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    font-size: 24px;
    color: hsl(0, 50%, 20%);
    z-index: 100;
    min-width: 400px;
    max-width: 450px;
}

/* 彈出選單標題*/
.fm-collection-popup-title {
    font-size: 24px;
    font-weight: bold;
    color: hsl(0, 60%, 36%);
    margin-bottom: 6px;
    text-align: center;
    border-bottom: 1px dashed hsl(0, 30%, 50%);
    padding-bottom: 4px;
}

/* 彈出選單內文*/
.fm-collection-popup-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 18px;
}

/* 彈出選單按鈕*/
.fm-collection-popup-btn {
    display: block;
    width: 100%;
    margin: 4px 0;
    padding: 6px 10px;
    background: hsl(0, 60%, 36%);
    color: hsl(34, 64%, 98%);
    border: 1px solid hsl(0, 60%, 26%);
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 18px;
    text-align: center;
}

.fm-collection-popup-btn:hover {
    background: hsl(0, 60%, 46%);
}

.fm-collection-popup-btn:disabled {
    background: hsl(0, 0%, 60%);
    cursor: not-allowed;
    opacity: 0.7;
}

/* 商店浮層 */
.fm-collection-shop {
    position: absolute;
    inset: 8% 6%;
    background: linear-gradient(180deg, hsl(36, 60%, 96%), hsl(36, 50%, 88%));
    border: 3px solid hsl(0, 60%, 36%);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 200;
}

.fm-collection-shop-header {
    background: hsl(0, 60%, 36%);
    color: #fdfaf6;
    padding: 6px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
}

.fm-collection-shop-tabs {
    display: flex;
    background: hsl(36, 40%, 80%);
}

.fm-collection-shop-tab {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    cursor: pointer;
    font-size: 18px;
    color: hsl(0, 50%, 30%);
    border-right: 1px solid hsl(0, 30%, 60%);
}

.fm-collection-shop-tab.active {
    background: hsl(0, 60%, 46%);
    color: #fdfaf6;
}

.fm-collection-shop-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    scrollbar-width: none;
}

.fm-collection-shop-body::-webkit-scrollbar {
    display: none;
}

.fm-collection-shop-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: hsla(36, 60%, 90%, 1);
    border: 1px solid hsl(0, 30%, 50%);
    border-radius: 6px;
    font-size: 18px;
}

.fm-collection-shop-name {
    color: hsl(0, 50%, 25%);
}

.fm-collection-shop-tier-下品 {
    color: hsl(0, 0%, 40%);
}

.fm-collection-shop-tier-中品 {
    color: hsl(110, 50%, 30%);
}

.fm-collection-shop-tier-上品 {
    color: hsl(220, 60%, 38%);
}

.fm-collection-shop-tier-極品 {
    color: hsl(330, 70%, 38%);
    font-weight: bold;
}

.fm-collection-shop-price {
    color: hsl(0, 60%, 36%);
    font-weight: bold;
    min-width: 60px;
    text-align: right;
}

.fm-collection-shop-btn {
    background: hsl(0, 60%, 36%);
    color: #fdfaf6;
    border: 0;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 18px;
}

.fm-collection-shop-btn:disabled {
    background: hsl(0, 0%, 60%);
    opacity: 0.7;
    cursor: not-allowed;
}

/* 通知條 */
.fm-collection-toast {
    position: absolute;
    left: 50%;
    bottom: 60px;
    transform: translateX(-50%);
    background: hsl(0, 60%, 26%);
    border-bottom: 3px solid hsl(40, 60%, 60%);
    color: #fdfaf6;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 18px;
    z-index: 300;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    min-width: 400px;
    max-width: 450px;
    text-align: center;
}

.fm-collection-toast.show {
    opacity: 1;
}

/* 文位徽章 */
.fm-collection-rank-badge {
    background: hsl(48, 89%, 50%);
    color: hsl(0, 60%, 20%);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 18px;
    margin-left: 6px;
}