/* Team Flipcard Plugin Styles - Final Fix Version */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.tfc-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1a2e 50%, #16213e 100%);
    position: relative;
    overflow-x: hidden;
    font-family: 'Rajdhani', 'Arial', sans-serif;
}

/* 背景效果 */
.tfc-bg-effect {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.bg-grid {
    background-image: 
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    width: 100%;
    height: 100%;
    position: absolute;
    animation: grid-move 10s linear infinite;
}

@keyframes grid-move {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

.bg-particles {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* 头部样式 */
.tfc-header {
    padding: 60px 20px 40px;
    text-align: center;
    position: relative;
    z-index: 10;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
}

.main-title {
    margin: 0 0 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.title-text {
    font-size: clamp(2em, 5vw, 4em);
    font-weight: 900;
    background: linear-gradient(45deg, #e94560, #0f3460, #e94560);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 3px;
    text-transform: uppercase;
    animation: gradient-shift 3s ease infinite;
    position: relative;
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.title-sub {
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 5px;
    font-weight: 300;
}

/* 统计信息 */
.header-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 30px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(233, 69, 96, 0.3);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.1);
    border-color: #e94560;
    box-shadow: 0 10px 30px rgba(233, 69, 96, 0.3);
}

.stat-label {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #fff;
}

.status-online {
    color: #4ade80;
    position: relative;
}

.status-online::before {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
    50% { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); }
}

/* 主要内容区域 */
.tfc-main {
    padding: 40px 20px;
    position: relative;
    z-index: 10;
}

.teams-grid {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 40px;
}

/* 队伍区块 */
.team-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.team-section:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(233, 69, 96, 0.3);
}

/* 队长卡片 */
.leader-card {
    position: relative;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.1), rgba(15, 52, 96, 0.1));
    border-radius: 15px;
    border: 1px solid rgba(233, 69, 96, 0.2);
}

.leader-badge {
    position: absolute;
    top: -10px;
    left: 20px;
    background: linear-gradient(45deg, #e94560, #0f3460);
    color: #fff;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
    letter-spacing: 1px;
}

.leader-avatar {
    width: 100px;
    height: 100px;
    margin: 20px auto;
    position: relative;
}

.leader-avatar img,
.avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid #e94560;
    object-fit: cover;
}

.avatar-placeholder {
    background: linear-gradient(135deg, #1a1a2e, #0f3460);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e94560;
    font-size: 2em;
    font-weight: bold;
}

.leader-rank {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: #e94560;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    border: 3px solid #1a1a2e;
}

.leader-info {
    text-align: center;
}

.leader-name {
    font-size: 1.5em;
    color: #fff;
    margin-bottom: 10px;
    font-weight: 700;
}

.leader-desc {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.95em;
    margin-bottom: 15px;
    line-height: 1.4;
}

.leader-meta {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.meta-item {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 翻牌区域 */
.members-flipcard-area {
    margin-top: 30px;
}

.area-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.area-title {
    color: rgba(255, 255, 255, 0.7);
    font-weight: bold;
    letter-spacing: 2px;
    font-size: 0.9em;
}

.btn-reset {
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid rgba(233, 69, 96, 0.3);
    color: #e94560;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-reset:hover {
    background: rgba(233, 69, 96, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.3);
}

/* ==========================================
   核心修复: 翻牌网格和3D效果
   ========================================== */

/* 翻牌网格布局 */
.flipcards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    /* 保持网格稳定 */
    align-items: start;
    justify-items: stretch;
}

/* 翻牌容器 - 保持在网格位置 */
.flip-card {
    /* 关键: 使用相对定位，保持在grid流中 */
    position: relative;
    width: 100%;
    aspect-ratio: 5/7;
    /* 3D空间设置 */
    perspective: 1000px;
    cursor: pointer;
    /* 防止选中文字 */
    user-select: none;
    -webkit-user-select: none;
    /* 确保不会溢出 */
    overflow: visible;
    /* 防止点击高亮 */
    -webkit-tap-highlight-color: transparent;
}

/* 内部容器 - 执行翻转 */
.flip-card-inner {
    /* 关键: 相对于父容器定位 */
    position: relative;
    width: 100%;
    height: 100%;
    /* 3D变换设置 */
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    /* 重要: 确保变换中心在中间 */
    transform-origin: center center;
}

/* 翻转状态 - 只改变旋转，不改变位置 */
.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

/* 翻转中状态 */
.flip-card.flipping {
    z-index: 10; /* 翻转时稍微提高层级 */
    pointer-events: none; /* 防止重复点击 */
}

/* 卡片正反面 */
.flip-card-back,
.flip-card-front {
    /* 关键: 绝对定位相对于inner容器 */
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    /* 背面不可见 */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    /* 样式 */
    border-radius: 15px;
    overflow: hidden;
    /* 防止内容溢出 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* 卡片背面（初始显示） */
.flip-card-back {
    background: linear-gradient(135deg, #1a1a2e, #0f3460);
    border: 2px solid rgba(233, 69, 96, 0.3);
    /* 背面朝向正面 */
    transform: rotateY(0deg);
}

/* 卡片正面（翻转后显示） */
.flip-card-front {
    background: linear-gradient(135deg, #16213e, #0f3460);
    border: 2px solid #e94560;
    /* 正面初始朝向背面 */
    transform: rotateY(180deg);
    padding: 10px;
}

/* 卡片背面图案 */
.card-pattern {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.card-pattern svg {
    width: 100%;
    height: 100%;
}

/* 发光效果 */
.card-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(233, 69, 96, 0.3), transparent);
    animation: glow-pulse 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes glow-pulse {
    0%, 100% { 
        opacity: 0.5; 
    }
    50% { 
        opacity: 1; 
    }
}

/* 成员内容布局 */
.member-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    position: relative;
    z-index: 2;
}

.member-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #e94560;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.member-avatar img,
.member-avatar > div {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.member-details {
    color: #fff;
    text-align: center;
    width: 100%;
}

.member-name {
    font-size: 0.9em;
    margin-bottom: 4px;
    font-weight: bold;
    word-break: break-word;
    line-height: 1.2;
}

.member-role {
    font-size: 0.7em;
    padding: 2px 5px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 2px;
}

.member-level {
    font-size: 0.65em;
    margin-bottom: 2px;
}

.member-desc {
    font-size: 0.6em;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 光效 */
.card-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: shine 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes shine {
    0% { transform: translateX(-150%); }
    100% { transform: translateX(150%); }
}

/* Hover效果 - 不改变位置 */
.flip-card:hover .flip-card-inner {
    /* 轻微的缩放效果，不影响位置 */
    transform: scale(1.02);
}

.flip-card.flipped:hover .flip-card-inner {
    /* 翻转后的hover效果 */
    transform: rotateY(180deg) scale(1.02);
}

/* 成功匹配动画 */
.flip-card.match-success {
    animation: success-glow 1s ease;
}

@keyframes success-glow {
    0% { 
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); 
    }
    50% { 
        box-shadow: 0 0 20px 10px rgba(74, 222, 128, 0.5); 
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); 
    }
}

/* 底部操作区 */
.tfc-footer {
    padding: 40px 20px;
    display: flex;
    justify-content: center;
    gap: 20px;
    position: relative;
    z-index: 10;
    flex-wrap: wrap;
}

.btn-action {
    background: linear-gradient(45deg, #e94560, #0f3460);
    border: none;
    color: #fff;
    padding: 15px 30px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-action:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(233, 69, 96, 0.4);
}

.btn-icon {
    font-size: 1.5em;
}

.btn-text {
    position: relative;
    z-index: 1;
}

/* 加载动画 */
.tfc-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 音效开关 */
.sound-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(233, 69, 96, 0.2);
    border: 1px solid #e94560;
    color: #e94560;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sound-toggle:hover {
    background: rgba(233, 69, 96, 0.3);
    transform: scale(1.1);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .teams-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
}

@media (max-width: 768px) {
    .teams-grid {
        padding: 0 10px;
    }
    
    .flipcards-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .flip-card:hover .flip-card-inner {
        /* 移动端禁用hover缩放 */
        transform: scale(1);
    }
    
    .flip-card.flipped:hover .flip-card-inner {
        transform: rotateY(180deg);
    }
    
    .header-stats {
        flex-direction: column;
        align-items: center;
    }
    
    .stat-item {
        width: 200px;
    }
    
    .title-text {
        font-size: 2em;
    }
    
    .member-avatar {
        width: 40px;
        height: 40px;
    }
    
    .member-name {
        font-size: 0.8em;
    }
}

@media (max-width: 480px) {
    .flipcards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

/* 浏览器兼容性 */
@supports (-webkit-transform-style: preserve-3d) {
    .flip-card-inner {
        -webkit-transform-style: preserve-3d;
    }
    
    .flip-card.flipped .flip-card-inner {
        -webkit-transform: rotateY(180deg);
    }
}

/* Safari特殊处理 */
@supports (-webkit-backdrop-filter: none) {
    .flip-card-back,
    .flip-card-front {
        -webkit-backface-visibility: hidden;
    }
}

/* 防止iOS弹性滚动影响 */
.tfc-container {
    -webkit-overflow-scrolling: touch;
}

/* 确保动画性能 */
.flip-card,
.flip-card-inner {
    will-change: transform;
}

/* 调试类（开发时使用） */
.debug-border {
    border: 2px solid red !important;
}

.debug-position {
    outline: 2px dashed yellow !important;
}