/* ========== 全局容器 ========== */
.top-tuanluo-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    padding: 28px;
    margin: 20px auto;
    max-width: 1200px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow-x: hidden;
    box-sizing: border-box;
}
.rank-title {
    font-size: 26px;
    color: #1a1a1a;
    margin-bottom: 24px;
    font-weight: 700;
    text-align: center;
}

/* ========== 时间筛选 ========== */
.time-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.tab-btn {
    padding: 8px 16px;
    background: #1890ff;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}
.tab-btn:hover,
.tab-btn.active {
    background: #0d71e2;
    box-shadow: 0 2px 6px rgba(24, 144, 255, 0.3);
    transform: translateY(-1px);
}

/* ========== 内容区 ========== */
.rank-content {
    margin-bottom: 30px;
}
.tab-pane {
    display: none;
}
.tab-pane.active {
    display: block;
}
.section-title {
    font-size: 18px;
    color: #333;
    margin-bottom: 18px;
    font-weight: 600;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
}
.rank-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}
.rank-column {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.column-title {
    font-size: 15px;
    margin-bottom: 12px;
    font-weight: 600;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px dashed #eee;
}

/* 三大榜单标题颜色区分 */
.rank-column[data-type="post"] .column-title { color: #3b82f6; }
.rank-column[data-type="circle"] .column-title { color: #ec4899; }
.rank-column[data-type="ask"] .column-title { color: #22c55e; }

/* ========== 榜单项 ========== */
.rank-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.rank-item {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: fadeInUp 0.4s forwards;
    opacity: 0;
    width: 100%;
    box-sizing: border-box;
}
.rank-item:last-child {
    border-bottom: none;
}
.rank-item:hover {
    background: #f9f9f9;
    border-radius: 6px;
    transform: translateY(-1px);
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

/* 序号 —— 20px */
.rank-badge,
.rank-number {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border-radius: 50%;
    flex-shrink: 0;
    line-height: 1;
}
.rank-badge {
    background: transparent;
    color: inherit;
}
.rank-badge::after { content: "🔥"; }
.rank-number {
    color: #666;
    background: #f0f0f0;
}
.rank-number.top-1 { background: #FF4D4F; color: white; }
.rank-number.top-2 { background: #FA8C16; color: white; }
.rank-number.top-3 { background: #7CB305; color: white; }
.rank-number.top-4 { background: #13C2C2; color: white; }
.rank-number.top-5 { background: #9254DE; color: white; }

/* 内容区域 */
.rank-content-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.rank-link {
    color: #222;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    line-height: 1.3;
}
.rank-link:hover {
    color: #0d71e2 !important;
}

/* 第二行：作者 + 指标（无头像） */
.rank-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #888;
    width: 100%;
    flex-wrap: wrap;
}
.author-name {
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.metric {
    color: #999;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    font-size: 11px;
}

.no-data {
    color: #ccc;
    text-align: center;
    padding: 15px 0;
    font-size: 14px;
}

/* ========== 用户榜（无头像） ========== */
.user-rank-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px dashed #eee;
}
.user-rank-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.user-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    gap: 10px;
    border-bottom: 1px solid #f0f0f0;
    width: 100%;
    box-sizing: border-box;
}
.user-item:last-child {
    border-bottom: none;
}
.user-rank {
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background: #1890ff;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    flex-shrink: 0;
}
.user-name a {
    color: #333;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.user-name a:hover {
    color: #0d71e2;
}
.reward-tag {
    background: #f6ffed;
    color: #52c41a;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
}

/* 动画 */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 响应式优化 */
@media (max-width: 768px) {
    .top-tuanluo-container {
        padding: 16px !important;
        margin: 10px !important;
        width: calc(100vw - 20px) !important;
        max-width: 100% !important;
    }
    .rank-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .rank-column {
        padding: 12px;
    }
    .rank-link {
        font-size: 13px;
        margin-bottom: 3px;
    }
    .rank-meta {
        gap: 5px;
        font-size: 11px;
    }
    .metric {
        font-size: 10px;
    }
    .author-name {
        font-size: 11px;
    }
    .user-name a {
        font-size: 13px;
    }
}

/* 超窄屏优化（如 iPhone SE） */
@media (max-width: 480px) {
    .rank-link {
        font-size: 12px;
    }
    .rank-number,
    .rank-badge {
        width: 18px;
        height: 18px;
        font-size: 11px;
    }
    .user-rank {
        width: 16px;
        height: 16px;
        font-size: 10px;
    }
    .reward-tag {
        font-size: 11px;
        padding: 1px 4px;
    }
}

/* ==============================
   📱 手机端终极修复：限制整个数据内容容器宽度，防止撑破布局
   ============================== */
@media (max-width: 768px) {
    /* 关键：限制整个内容容器最大宽度，防止被内部长内容撑开 */
    .rank-content-wrap {
        max-width: calc(100% - 28px) !important; /* 20px 序号 + 8px gap */
        min-width: 0 !important;
        overflow: hidden !important;
        width: auto !important;
    }

    /* 确保所有子元素不会突破容器 */
    .rank-link,
    .rank-meta,
    .author-name {
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
    }

    /* 恢复指标右对齐，同时防止其自身过长 */
    .rank-meta {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        flex-wrap: nowrap !important;
        gap: 6px !important;
    }

    .metric {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        text-align: right !important;
        min-width: auto !important;
        max-width: 45% !important; /* 极端情况防护 */
        color: #999 !important;
        font-size: 11px !important;
    }
}

/* 超窄屏（<375px）微调 */
@media (max-width: 375px) {
    .rank-content-wrap {
        max-width: calc(100% - 26px) !important;
    }
    .rank-link,
    .author-name {
        font-size: 10px !important;
    }
    .metric {
        font-size: 10px !important;
        max-width: 50% !important;
    }
}