/* ==========================================
   塔罗师选择器 - 全新模态框版本
   ========================================== */

/* 主容器（固定在底部中央，向左偏移与牌阵选择器对称） */
.tarot-master-selector {
    position: fixed;
    bottom: 12vh;
    left: 50%;
    transform: translateX(calc(-50% - 220px)); /* 向左偏移220px，与牌阵选择器对称 */
    z-index: 1002; /* 🔧 高于 UI 覆盖层 (1000)，确保按钮可点击 */
    width: auto; /* 改为auto，让内容决定宽度 */
    max-width: 400px;
    min-width: 280px; /* 🔧 设置最小宽度，与牌阵保持一致 */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 1;
    visibility: visible;
}

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

/* 🎯 迷你模式（左上角显示） - 完全复制牌阵选择器的定位方式 */
.tarot-master-selector.mini-mode {
    position: fixed;
    top: 20px;
    left: 70px; /* 🔧 在历史记录按钮右侧，留10px间距 (20px + 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;
}

.tarot-master-selector.mini-mode .current-master-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: pointer;
    transition: all 0.3s ease;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.tarot-master-selector.mini-mode .current-master-display:hover {
    background: rgba(0, 0, 0, 0.8); /* 🔧 与sidebar-toggle:hover完全一致 */
    transform: scale(1.1); /* 🔧 与sidebar-toggle:hover完全一致 */
}

.tarot-master-selector.mini-mode .current-master-avatar {
    width: 32px;
    height: 32px;
    border: 1.5px solid rgba(147, 51, 234, 0.3);
}

.tarot-master-selector.mini-mode .current-master-info {
    display: none; /* 迷你模式下隐藏名字和风格 */
}

/* 🎯 移动端迷你模式 */
@media (max-width: 768px) {
    .tarot-master-selector.mini-mode {
        /* 🔒 强制fixed定位 - 关键修复！ */
        position: fixed !important;
        top: 20px !important;
        left: 70px !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;
    }
    
    .tarot-master-selector.mini-mode .current-master-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;
    }
    
    .tarot-master-selector.mini-mode .current-master-avatar {
        width: 28px;
        height: 28px;
    }
}

/* 🎯 480px以下确保水平对齐 - 终极锁定版本 */
@media (max-width: 480px) {
    .tarot-master-selector.mini-mode {
        /* 🔒 完全锁定定位 - 不受任何元素影响 */
        position: fixed !important;
        top: 20px !important;
        left: 70px !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;
    }
    
    .tarot-master-selector.mini-mode .current-master-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;
    }
    
    .tarot-master-selector.mini-mode .current-master-avatar {
        width: 26px !important;
        height: 26px !important;
        margin: 0 !important;
        padding: 0 !important;
        flex-shrink: 0 !important;
    }
}

/* 切换按钮 */
.master-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;
}

.master-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);
}

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

/* 当前塔罗师显示 */
.current-master-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: 280px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    min-height: 56px; /* 🔧 固定最小高度，与牌阵信息框完全一致 */
    box-sizing: border-box;
}

.current-master-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%; /* 圆形裁切 */
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    object-fit: cover; /* 图片覆盖整个圆形区域 */
    object-position: center; /* 图片居中显示 */
}

.current-master-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: center;
}

.current-master-name {
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.2;
}

.current-master-style {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    line-height: 1.2;
}

/* ==========================================
   模态框弹窗（完全复刻auth模态框样式）
   ========================================== */

.master-list-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !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;
}

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

/* 内容容器（黑色性冷淡风格） */
.master-list-container {
    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; /* 只允许垂直滚动 */
}

/* 标题区域 */
.master-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;
}

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

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

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

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

/* ==========================================
   塔罗师按钮卡片（9:21比例）
   ========================================== */

.master-card {
    position: relative;
    width: 100%;
    aspect-ratio: 21 / 9; /* 宽21：高9（扁平长方形）CSS语法：宽/高 */
    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);
}

.master-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 215, 0, 0.3);
}

.master-card.active {
    border-color: rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

/* 背景图片层 */
.master-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;
}

/* 半透明毛玻璃遮罩（从左到右渐变：透明 → 模糊） */
.master-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* 使用伪元素创建渐变遮罩效果（移除毛玻璃） */
.master-card-overlay::before {
    content: '';
    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%
    );
    /* 🎯 移除毛玻璃效果 */
}

/* 文本内容区域（右侧三分之一） */
.master-card-content {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 33.33%; /* 右侧三分之一 */
    padding: 0 5%;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.master-name {
    color: rgba(255, 255, 255, 0.95);
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.5px;
    line-height: 1.3;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.master-style {
    color: rgba(255, 215, 0, 0.85);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.3px;
    line-height: 1.2;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.master-description {
    color: rgba(255, 255, 255, 0.75);
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: 0.2px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 激活标签 */
.master-active-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 215, 0, 0.2);
    border: 1px solid rgba(255, 215, 0, 0.5);
    color: rgba(255, 215, 0, 0.95);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 500;
    z-index: 4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 锁定状态 */
.master-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(60%);
}

.master-card.locked:hover {
    transform: none;
    box-shadow: none;
}

.master-locked-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 100, 100, 0.2);
    border: 1px solid rgba(255, 100, 100, 0.5);
    color: rgba(255, 150, 150, 0.9);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 500;
    z-index: 4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

@media (max-width: 768px) {
    /* 🔧 移动端：塔罗师选择器使用左右对称布局 */
    .tarot-master-selector {
        transform: translateX(calc(-50% - 110px)); /* 向左偏移，与牌阵对称 */
        width: 45%;
        max-width: 180px;
        bottom: 10vh; /* 与牌阵同高 */
    }
    
    /* 🔧 移动端按钮固定高度：44px（与牌阵按钮一致） */
    .master-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-master-display {
        padding: 8px 12px;
        max-width: none;
        height: 50px !important;
        min-height: 50px !important;
        max-height: 50px !important;
        box-sizing: border-box !important;
    }
    
    .current-master-avatar {
        width: 32px;
        height: 32px;
    }
    
    .current-master-name {
        font-size: 14px;
    }
    
    .current-master-style {
        font-size: 11px;
    }
    
    .master-list-container {
        width: 92%;
        max-width: 500px;
    }
    
    .master-list-title {
        padding: 24px 24px 16px;
        font-size: 18px;
    }
    
    .master-cards-wrapper {
        padding: 20px 20px 24px;
        gap: 12px;
    }
    
    .master-name {
        font-size: 16px;
    }
    
    .master-style {
        font-size: 12px;
    }
    
    .master-description {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .tarot-master-selector {
        bottom: 8vh;
        width: 85%;
        max-width: 300px;
    }
    
    .master-toggle-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .current-master-display {
        padding: 8px 14px;
    }
    
    .master-list-container {
        width: 95%;
    }
    
    .master-list-title {
        padding: 20px 20px 14px;
        font-size: 17px;
    }
    
    .master-cards-wrapper {
        padding: 16px 16px 20px;
        gap: 10px;
    }
    
    .master-name {
        font-size: 15px;
    }
    
    .master-style {
        font-size: 11px;
    }
    
    .master-description {
        font-size: 10px;
        -webkit-line-clamp: 1;
    }
}
