/* ==========================================
   牌阵选择器 - 参考塔罗大师选择器样式
   ========================================== */

/* 主容器（固定在底部中央，塔罗大师选择器的右侧） */
.spread-selector {
    position: fixed;
    bottom: 12vh;
    left: 50%;
    transform: translateX(calc(-50% + 220px)); /* 向右偏移，与塔罗大师对称 */
    z-index: 1002;
    width: auto;
    max-width: 400px;
    min-width: 280px; /* 🔧 与塔罗师保持一致 */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 1;
    visibility: visible;
}

/* 隐藏状态 */
.spread-selector[style*="display: none"] {
    display: none !important;
}

/* 🎯 迷你模式（左上角显示，在塔罗师右侧） */
.spread-selector.mini-mode {
    position: fixed;
    top: 20px;
    left: 120px; /* 🔧 在塔罗师迷你模式右侧，留10px间距 (70px + 40px + 10px) */
    bottom: auto;
    transform: none;
    width: 40px; /* 🔧 固定宽度，避免flex布局影响 */
    height: 40px; /* 🔧 固定高度，避免flex布局影响 */
    min-width: 40px; /* 🔧 覆盖父容器的min-width */
    max-width: 40px; /* 🔧 覆盖父容器的max-width */
    display: block; /* 🔧 覆盖flex布局 */
    gap: 0; /* 🔧 移除gap */
    z-index: 1003;
}

.spread-selector.mini-mode .spread-toggle-btn {
    display: none !important; /* 迷你模式下隐藏切换按钮 */
}

.spread-selector.mini-mode .current-spread-display {
    padding: 0;
    margin: 0;
    width: 40px !important;  /* 🔧 强制与侧栏按钮完全一致 */
    height: 40px !important; /* 🔧 强制与侧栏按钮完全一致 */
    min-width: 40px;
    max-width: 40px;
    min-height: 40px;
    max-height: 40px;
    background: rgba(0, 0, 0, 0.5); /* 🔧 与sidebar-toggle完全一致 */
    border: none; /* 🔧 与sidebar-toggle完全一致 */
    border-radius: 50%; /* 🔧 改为正圆形 */
    cursor: default;
    transition: all 0.3s ease;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.spread-selector.mini-mode .current-spread-icon {
    width: 28px;
    height: 28px;
    font-size: 18px;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
}

.spread-selector.mini-mode .current-spread-info {
    display: none; /* 迷你模式下隐藏名字和描述 */
}

/* 切换按钮（完全复刻塔罗师样式） */
.spread-toggle-btn {
    background: linear-gradient(135deg, rgba(80, 80, 90, 0.95) 0%, rgba(60, 60, 70, 0.95) 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
    padding: 14px 28px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 8px;
    height: 50px; /* 🔧 固定高度，与塔罗师按钮完全一致 */
    box-sizing: border-box;
}

.spread-toggle-btn:hover {
    background: linear-gradient(135deg, rgba(90, 90, 100, 0.95) 0%, rgba(70, 70, 80, 0.95) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.spread-toggle-btn i {
    font-size: 18px;
}

/* 当前牌阵显示框（完全复刻塔罗师样式，仅用于展示） */
.current-spread-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(60, 60, 70, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    max-width: 320px; /* 🔧 增加宽度以容纳更长的文本 */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: default; /* 不可点击 */
    pointer-events: none; /* 禁用所有鼠标事件 */
    min-height: 56px; /* 🔧 固定最小高度，与塔罗师信息框完全一致 */
    box-sizing: border-box;
}

.current-spread-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
}

.current-spread-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: center;
    min-width: 0; /* 🔧 允许文本收缩 */
}

.current-spread-name {
    font-size: 15px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.2;
    white-space: nowrap; /* 🔧 防止名称换行 */
}

.current-spread-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.3;
    white-space: nowrap; /* 🔧 防止描述换行 */
}

/* ==========================================
   模态框面板样式（完全复刻塔罗师选择器）
   ========================================== */

.spread-list-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.85);
    display: none; /* 初始隐藏 */
    z-index: 10000 !important;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    overflow: hidden !important;
    box-sizing: border-box;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.spread-list-panel.show {
    display: block !important; /* 显示时用block，不用flex */
}

/* 内容容器（黑色性冷淡风格） */
.spread-list-content {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.9);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: pan-y !important; /* 🎯 只允许垂直滚动 */
    overscroll-behavior-x: none !important; /* 🎯 禁止横向过度滚动 */
    overflow-x: hidden !important; /* 🎯 完全禁止横向滚动 */
}

/* 标题区域 */
.spread-list-title {
    color: rgba(255, 255, 255, 0.95);
    font-size: 20px;
    font-weight: 400;
    padding: 28px 32px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    letter-spacing: 1px;
    text-align: center;
    flex-shrink: 0;
}

/* 卡片列表区域（只允许垂直滚动） */
.spread-cards-wrapper {
    padding: 24px 32px 32px;
    overflow-y: auto !important;
    overflow-x: hidden !important; /* 🎯 完全禁止横向滚动 */
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
    flex: 1;
    min-height: 0; /* 确保flex子元素可以滚动 */
    display: flex;
    flex-direction: column;
    gap: 16px;
    touch-action: pan-y !important; /* 🎯 只允许垂直滚动 */
    overscroll-behavior-x: none !important; /* 🎯 禁止横向过度滚动 */
    overscroll-behavior-y: contain; /* 🎯 允许垂直滚动但不触发页面刷新 */
}

.spread-cards-wrapper::-webkit-scrollbar {
    width: 6px;
}

.spread-cards-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.spread-cards-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* ==========================================
   牌阵按钮卡片（21:9比例，高度增加一倍）
   ========================================== */

.spread-card {
    position: relative;
    width: 100%;
    height: 280px; /* 🎯 固定高度（原来约140px，现在增加一倍） */
    min-height: 280px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.spread-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border-color: rgba(147, 51, 234, 0.3);
}

.spread-card.active {
    border-color: rgba(147, 51, 234, 0.5);
    box-shadow: 0 0 20px rgba(147, 51, 234, 0.3);
}

.spread-card.locked {
    cursor: not-allowed;
    opacity: 0.5;
}

/* 背景图片层 */
.spread-card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover; /* 填满按钮，可能裁切边缘 */
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
}

/* 渐变遮罩（从左到右：透明 → 半透明黑色） */
.spread-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.5) 60%,
        rgba(0, 0, 0, 0.75) 100%
    );
    z-index: 2;
}

/* 内容层 */
.spread-card-content {
    position: relative;
    z-index: 3;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px 32px;
    gap: 6px;
}

.spread-card-icon {
    font-size: 28px;
    margin-bottom: 4px;
}

.spread-card-name {
    font-size: 20px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
    line-height: 1.2;
}

.spread-card-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.8);
    max-width: 90%; /* 🔧 限制最大宽度，避免文字延伸到右边背景图 */
}

.spread-card-meta {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

.spread-card-count,
.spread-card-difficulty,
.spread-card-scenario {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.8);
}

.spread-card-difficulty::before {
    content: '｜';
    margin-right: 12px;
    color: rgba(255, 255, 255, 0.4);
}

.spread-card-scenario::before {
    content: '｜';
    margin-right: 12px;
    color: rgba(255, 255, 255, 0.4);
}

/* 🗑️ 删除旧的类名 */
.spread-name {
    font-size: 20px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
}

.spread-difficulty {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.8);
}

.spread-description {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.8);
}

.spread-active-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    padding: 6px 14px;
    background: rgba(147, 51, 234, 0.9);
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(147, 51, 234, 0.4);
}

.spread-locked-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    padding: 6px 14px;
    background: rgba(100, 100, 100, 0.9);
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
}

/* ==========================================
   响应式设计
   ========================================== */

@media (max-width: 768px) {
    /* 移动端迷你模式 */
    .spread-selector.mini-mode {
        /* 🔒 强制fixed定位 - 关键修复！ */
        position: fixed !important;
        top: 20px !important;
        left: 120px !important;
        right: auto !important;
        bottom: auto !important;
        
        /* 🔒 锁定尺寸 */
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        
        /* 🔒 清除所有可能的偏移 */
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
        translate: none !important;
    }
    
    .spread-selector.mini-mode .current-spread-display {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .spread-selector.mini-mode .current-spread-icon {
        width: 24px;
        height: 24px;
        font-size: 16px;
    }
    
    /* 🔧 移动端：牌阵选择器使用左右对称布局 */
    .spread-selector {
        transform: translateX(calc(-50% + 110px)); /* 向右偏移，与塔罗大师对称 */
        width: 45%;
        max-width: 180px;
        bottom: 10vh; /* 与塔罗大师同高 */
    }
    
    /* 🔧 移动端按钮固定高度：44px（与塔罗师按钮一致） */
    .spread-toggle-btn {
        padding: 10px 18px;
        font-size: 14px;
        height: 44px !important;
        min-height: 44px !important;
        max-height: 44px !important;
        box-sizing: border-box !important;
    }
    
    /* 🔧 移动端信息框固定高度：50px（与塔罗师信息框一致） */
    .current-spread-display {
        padding: 8px 12px;
        max-width: none;
        height: 50px !important;
        min-height: 50px !important;
        max-height: 50px !important;
        box-sizing: border-box !important;
    }
    
    .current-spread-icon {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
    
    .current-spread-name {
        font-size: 14px;
    }
    
    .current-spread-desc {
        font-size: 11px;
    }
    
    .spread-list-container {
        width: 92%;
        max-width: 500px;
    }
    
    .spread-list-title {
        padding: 24px 24px 16px;
        font-size: 18px;
    }
    
    .spread-cards-wrapper {
        padding: 20px 20px 24px;
        gap: 12px;
    }
    
    .spread-name {
        font-size: 16px;
    }
    
    .spread-difficulty {
        font-size: 11px;
    }
    
    .spread-description {
        font-size: 12px;
    }
}

/* 🎯 480px以下确保水平对齐 - 终极锁定版本 */
@media (max-width: 480px) {
    /* 🔧 主界面牌阵选择器 - 与塔罗师选择器保持同一高度 */
    .spread-selector {
        bottom: 8vh !important; /* 🔧 与塔罗师选择器一致 */
        width: 85%;
        max-width: 300px;
    }
    
    .spread-selector.mini-mode {
        /* 🔒 完全锁定定位 - 不受任何元素影响 */
        position: fixed !important;
        top: 20px !important;
        left: 120px !important;
        right: auto !important;
        bottom: auto !important;
        
        /* 🔒 锁定尺寸 */
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        
        /* 🔒 清除所有偏移和变换 */
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        transform: none !important;
        translate: none !important;
        
        /* 🔒 确保层级和独立性 */
        z-index: 1003 !important;
        isolation: isolate !important;
        
        /* 🔒 强制盒模型 */
        box-sizing: border-box !important;
        overflow: visible !important;
    }
    
    .spread-selector.mini-mode .current-spread-display {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 40px !important;
        height: 40px !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        transform: none !important;
        
        /* 🔧 强制flex布局 */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
    }
    
    .spread-selector.mini-mode .current-spread-icon {
        width: 26px !important;
        height: 26px !important;
        font-size: 16px !important;
        margin: 0 !important;
        padding: 0 !important;
        border-width: 1.5px !important;
        flex-shrink: 0 !important;
    }
}

/* 🎯 展开模式（点击"为您解读"后）*/
.spread-selector.expanded-mode {
    /* 🔧 关键：覆盖bottom定位，改为top定位 */
    position: fixed !important;
    top: 20px !important;
    bottom: auto !important;
    left: 70px !important;
    transform: none !important; /* 移除transform */
    
    /* 展开宽度以显示完整文字 */
    width: auto !important;
    min-width: 150px !important;
    max-width: 250px !important;
    
    /* 保持高度不变 */
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    
    /* 移除flex列布局 */
    flex-direction: row !important;
    gap: 0 !important;
    
    /* 过渡动画 */
    transition: all 0.3s ease !important;
    
    /* z-index确保在上层 */
    z-index: 1003 !important;
}

.spread-selector.expanded-mode .current-spread-display {
    /* 展开显示完整内容 */
    width: 100% !important;
    padding: 0 12px !important;
    
    /* 保持高度 */
    height: 40px !important;
    box-sizing: border-box !important;
    
    /* 显示为flex布局 */
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.spread-selector.expanded-mode .current-spread-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.spread-selector.expanded-mode .current-spread-info {
    flex: 1;
    min-width: 0;
}

.spread-selector.expanded-mode .current-spread-name {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 隐藏切换按钮 */
.spread-selector.expanded-mode .spread-toggle-btn {
    display: none !important;
}

/* 移动端展开模式 */
@media (max-width: 768px) {
    .spread-selector.expanded-mode {
        left: 70px !important;
        min-width: 120px !important;
        max-width: 180px !important;
        height: 40px !important; /* 🔧 与历史记录按钮（768px以下）对齐 */
    }
    
    .spread-selector.expanded-mode .current-spread-name {
        font-size: 12px;
    }
}

/* 🎯 480px以下展开模式 - 与历史记录按钮对齐 */
@media (max-width: 480px) {
    .spread-selector.expanded-mode {
        position: fixed !important;
        top: 20px !important;
        left: 70px !important;
        right: auto !important;
        bottom: auto !important;
        
        /* 🔧 与历史记录按钮尺寸对齐（480px以下为40px） */
        width: auto !important;
        height: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        min-width: 120px !important;
        max-width: 180px !important;
        
        /* 清除所有可能干扰的属性 */
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
        translate: none !important;
        
        z-index: 1003 !important;
        box-sizing: border-box !important;
    }
    
    .spread-selector.expanded-mode .current-spread-display {
        height: 40px !important;
        padding: 0 10px !important;
        box-sizing: border-box !important;
    }
    
    .spread-selector.expanded-mode .current-spread-icon {
        width: 20px !important;
        height: 20px !important;
        font-size: 16px !important;
    }
    
    .spread-selector.expanded-mode .current-spread-name {
        font-size: 12px !important;
    }
}

