/* 阵营导航 */
.faction-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
    position: relative;
    z-index: 100;
}

.faction-btn {
    padding: 0.8rem 1.5rem;
    border: 2px solid var(--neon-purple);
    border-radius: 25px;
    background: rgba(42,15,71,0.6);
    color: var(--stardust);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.faction-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        rgba(138,43,226,0.2),
        transparent 60%
    );
    transform: rotate(45deg);
}

.faction-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 20px rgba(138,43,226,0.5);
}

.faction-btn.active {
    background: var(--neon-purple);
    box-shadow: 0 0 25px rgba(138,43,226,0.8);
}

/* 阵营特效标签 */
.story-card::after {
    content: attr(data-faction);
    position: absolute;
    top: 10px;
    right: -25px;
    padding: 4px 25px;
    background: rgba(138,43,226,0.8);
    color: #fff;
    transform: rotate(45deg);
    font-size: 0.8rem;
    box-shadow: 0 0 8px rgba(138,43,226,0.6);
}

/* === 新增：卡片网格布局 === */
/* 强制所有屏幕尺寸下每行一个卡片 */
.card-grid {
    display: grid;
    grid-template-columns: 1fr; /* 单列布局 */
    gap: 1.5rem; /* 增加间距使卡片更突出 */
    padding: 1.5rem 0;
}

/* 卡片样式优化 */
.story-card {
    width: 100%; /* 确保占满网格宽度 */
    max-width: 600px; /* 限制最大宽度 */
    margin: 0 auto; /* 居中显示 */
    box-sizing: border-box;
}

/* 移动端优化 */
@media (max-width: 768px) {
    /* 导航栏调整为横向滚动 */
    .faction-nav {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
        width: 100%;
        border-radius: 0;
        margin: 1rem 0;
    }

    .faction-nav::-webkit-scrollbar {
        height: 4px;
        background: rgba(42,15,71,0.3);
    }

    .faction-nav::-webkit-scrollbar-thumb {
        background: var(--neon-purple);
        border-radius: 2px;
    }

    /* 按钮尺寸优化 */
    .faction-btn {
        flex: 0 0 auto;
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
        border-radius: 8px;
        margin: 0 4px;
    }

    .faction-btn span {
        display: inline-flex;
        align-items: center;
    }

    /* 卡片布局优化 (移除多列设置) */
    .story-card {
        border-radius: 12px;
        margin: 0 0.5rem;
    }

    /* 标题优化 */
    .title-box {
        margin: 1.5rem 0;
    }

    h1 {
        font-size: 2rem;
        padding: 0 1rem;
    }

    /* 模态框优化 */
    .modal-content {
        max-width: 95vw;
        max-height: 90vh;
        border-radius: 12px;
    }

    #imageDesc {
        font-size: 0.9rem;
        padding: 0.8rem;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 480px) {
    /* 底部导航 */
    .cosmic-portal {
        bottom: 15px;
        width: 90%;
    }

    .star-gate {
        width: 100%;
        justify-content: center;
        padding: 10px 15px;
        font-size: 0.95rem;
    }

    /* 图片优化 */
    .card-image {
        max-height: 60vh;
    }

    /* 按钮文字精简 */
    .faction-btn span::after {
        content: attr(data-矮人族);
        display: inline;
    }
    .faction-btn span::before {
        content: attr(data-emoji);
        margin-right: 4px;
    }
    .faction-btn span > span {
        display: none;
    }
}