/* ── 玩家排名 Section ── */
#section-player-ranking .back-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    background: linear-gradient(135deg, var(--red), var(--dark-red));
    color: var(--light-gold);
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    z-index: 999;
}

#section-player-ranking .back-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(216,30,68,0.5);
}

#section-player-ranking.active {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.ranking-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 40px 30px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.ranking-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold, #D4AF37);
    text-align: center;
    margin-bottom: 10px;
}

.ranking-subtitle {
    text-align: center;
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* ── S1 赛季信息横幅 ── */
.season-banner {
    background: transparent;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 10px;
    padding: 18px 22px;
    margin-bottom: 25px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.season-header {
    margin-bottom: 10px;
    position: relative;
}

.season-badge {
    display: inline-block;
    background: linear-gradient(135deg, #D4AF37, #FFD700);
    color: #1a1a2e;
    font-weight: 900;
    font-size: 1.2rem;
    padding: 3px 12px;
    border-radius: 4px;
    margin-right: 10px;
    vertical-align: middle;
    position: relative;
}

/* 桌面端：S1 徽章呼吸发光 */
@media (min-width: 769px) {
    .season-badge {
        animation: badge-glow 2s ease-in-out infinite;
        box-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
    }
}

@keyframes badge-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(212, 175, 55, 0.4); }
    50%      { box-shadow: 0 0 20px rgba(255, 215, 0, 0.7), 0 0 40px rgba(212, 175, 55, 0.3); }
}

.season-title {
    color: #D4AF37;
    font-size: 1.3rem;
    font-weight: 700;
    vertical-align: middle;
}

.season-detail {
    color: #bbb;
    font-size: 0.85rem;
    line-height: 1.8;
    margin-bottom: 14px;
    position: relative;
}

.season-detail strong {
    color: #FFD700;
}

.season-tiers {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 14px;
    position: relative;
}

.tier-item {
    color: #ccc;
    font-size: 0.82rem;
    white-space: nowrap;
}

/* 桌面端：巅峰称号闪烁 */
@media (min-width: 769px) {
    .tier-item:first-child {
        animation: peak-shine 1.5s ease-in-out infinite;
    }
}

@keyframes peak-shine {
    0%, 100% { color: #ccc; }
    50%      { color: #FFD700; text-shadow: 0 0 6px rgba(255, 215, 0, 0.6); }
}

.tier-item em {
    font-style: normal;
    color: #888;
    margin-left: 2px;
}

.tier-item small {
    color: #FF9800;
    margin-left: 4px;
    font-size: 0.78rem;
}

/* 桌面端：段位悬停微动 */
@media (min-width: 769px) {
    .tier-item {
        transition: transform 0.2s;
    }
    .tier-item:hover {
        transform: translateY(-1px);
    }
}

@media (max-width: 768px) {
    .season-banner {
        padding: 14px 12px;
    }
    .season-title {
        font-size: 1rem;
    }
    .season-tiers {
        gap: 4px 8px;
    }
    .tier-item {
        font-size: 0.75rem;
    }
}
.ranking-search {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
}

.ranking-search input {
    flex: 1;
    padding: 12px 16px;
    background: #1E1E1E;
    border: 1px solid #333;
    border-radius: 6px;
    color: #fff;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.ranking-search input:focus {
    outline: none;
    border-color: var(--gold, #D4AF37);
}

.ranking-search input::placeholder {
    color: #666;
}

.ranking-search button {
    padding: 12px 20px;
    background: var(--red, #D81E44);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.ranking-search button:hover {
    background: var(--dark-red, #A51834);
}

.ranking-search .search-clear {
    background: #333;
}

.ranking-search .search-clear:hover {
    background: #555;
}

/* ── 排名表格 ── */
.rank-table {
    width: 100%;
    border-collapse: collapse;
}

.rank-table th,
.rank-table td {
    padding: 12px 10px;
    text-align: center;
    border-bottom: 1px solid #2a2a2a;
}

.rank-table th {
    color: #aaa;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rank-table td {
    font-size: 0.95rem;
}

.rank-table tbody tr {
    transition: background 0.2s;
}

.rank-table tbody tr:hover {
    background: rgba(212, 175, 55, 0.08);
}

.rank-num {
    font-weight: 700;
    color: #888;
}

.rank-table tbody tr:nth-child(1) .rank-num { color: var(--gold); }
.rank-table tbody tr:nth-child(2) .rank-num { color: #C0C0C0; }
.rank-table tbody tr:nth-child(3) .rank-num { color: #CD7F32; }

.rank-name {
    text-align: left;
    color: #eee;
    font-weight: 600;
}

.rank-rating {
    color: var(--gold);
    font-weight: 700;
    font-size: 1.05rem;
}

.rank-record {
    color: #aaa;
    font-size: 0.85rem;
}

.rank-winrate {
    color: #4CAF50;
    font-weight: 600;
}

.rank-streak {
    color: #FF9800;
    font-weight: 600;
}

/* ── 搜索结果高亮 ── */
.rank-table tbody tr.search-highlight {
    background: rgba(212, 175, 55, 0.15) !important;
    outline: 1px solid var(--gold);
    border-radius: 4px;
}

/* ── 空状态 ── */
.ranking-empty {
    text-align: center;
    color: #888;
    padding: 60px 0;
    font-size: 1.1rem;
}

.ranking-empty span {
    display: block;
    margin-top: 8px;
    font-size: 0.85rem;
    color: #555;
}

/* ── 底部信息 ── */
.ranking-footer {
    text-align: center;
    color: #555;
    font-size: 0.8rem;
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid #2a2a2a;
}

/* ── 响应式 ── */
@media (max-width: 768px) {
    #section-player-ranking .back-btn {
        top: 60px;
    }

    .ranking-wrapper {
        padding: 20px 12px;
    }

    .ranking-title {
        font-size: 1.4rem;
    }

    .ranking-search {
        flex-wrap: wrap;
    }

    .ranking-search input {
        min-width: 0;
    }

    .rank-table th,
    .rank-table td {
        padding: 8px 4px;
        font-size: 0.78rem;
    }

    .rank-table th:nth-child(4),
    .rank-table td:nth-child(4),
    .rank-table th:nth-child(6),
    .rank-table td:nth-child(6),
    .rank-table th:nth-child(7),
    .rank-table td:nth-child(7) {
        display: none;
    }

    .deck-btn {
        font-size: 0.7rem;
        padding: 4px 8px;
    }
}

/* ── 查看卡组按钮 ── */
.deck-btn {
    background: linear-gradient(135deg, var(--red, #D81E44), var(--dark-red, #A51834));
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.deck-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 8px rgba(216, 30, 68, 0.5);
}

/* ── 卡组弹窗（全屏自适应）── */
.deck-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.deck-modal-overlay.active {
    display: flex;
}

.deck-modal {
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    width: 98vw;
    max-width: 1800px;
    max-height: 96vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--red, #D81E44) transparent;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.deck-modal::-webkit-scrollbar { width: 5px; }
.deck-modal::-webkit-scrollbar-track { background: transparent; }
.deck-modal::-webkit-scrollbar-thumb { background: var(--red, #D81E44); border-radius: 3px; }

.deck-modal-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid #333;
    background: #1a1a1a;
}

.deck-modal-title {
    color: var(--gold, #D4AF37);
    font-size: 1.1rem;
    font-weight: 700;
}

.deck-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.deck-modal-close:hover {
    color: #fff;
}

.deck-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.deck-modal-dl-btn {
    background: rgba(216, 30, 68, 0.75);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.deck-modal-dl-btn:hover {
    background: rgba(216, 30, 68, 1);
}

.deck-modal-body {
    flex: 1;
    padding: 8px 16px 10px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-x: clip;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--red, #D81E44) transparent;
}

.deck-modal-body::-webkit-scrollbar { width: 5px; }
.deck-modal-body::-webkit-scrollbar-track { background: transparent; }
.deck-modal-body::-webkit-scrollbar-thumb { background: var(--red, #D81E44); border-radius: 3px; }

.deck-loading,
.deck-empty {
    text-align: center;
    color: #888;
    padding: 30px 0;
    font-size: 1rem;
}

.deck-info {
    display: flex;
    gap: 20px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #2a2a2a;
    flex-shrink: 0;
}

.deck-info-item {
    color: #aaa;
    font-size: 0.8rem;
}

.deck-section-title {
    color: var(--gold, #D4AF37);
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 3px;
    flex-shrink: 0;
}

/* ── 卡图网格 ── */
.deck-cards-grid {
    display: grid;
    gap: 2px;
    background: #111;
    padding: 4px;
    border-radius: 4px;
    border: 1px solid #2a2a2a;
    align-content: start;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--red, #D81E44) transparent;
}

.deck-cards-grid::-webkit-scrollbar {
    width: 5px;
}
.deck-cards-grid::-webkit-scrollbar-track {
    background: transparent;
}
.deck-cards-grid::-webkit-scrollbar-thumb {
    background: var(--red, #D81E44);
    border-radius: 3px;
}

.deck-cards-main {
    flex: 1;
    min-height: 0;
}


.deck-card-img {
    width: 100%;
    aspect-ratio: 42/61;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid #444;
    background: #1a1a1a;
}

/* ── 卡图容器 + 禁限分数角标 ── */
.card-img-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 42/61;
    align-self: start;
    overflow: hidden;
    border-radius: 2px;
}

.card-img-wrapper .deck-card-img {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
}

.card-score-badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    min-width: 18px;
    height: 17px;
    line-height: 15px;
    text-align: center;
    background: rgba(0, 0, 0, 0.85);
    color: #FFD700;
    font-size: 0.65rem;
    font-weight: 700;
    border: 1px solid var(--red, #D81E44);
    border-radius: 2px;
    padding: 0 4px;
    pointer-events: none;
    z-index: 2;
}

.card-score-badge.forbidden {
    font-size: 0.55rem;
    min-width: 17px;
    line-height: 15px;
}

.card-diy-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    height: 14px;
    line-height: 12px;
    text-align: center;
    background: rgba(0, 0, 0, 0.85);
    color: #FFD700;
    font-size: 0.5rem;
    font-weight: 700;
    border: 1px solid var(--red, #D81E44);
    border-radius: 2px;
    padding: 0 3px;
    pointer-events: none;
    z-index: 2;
}

/* ── 卡图悬停 tooltip ── */
.card-tooltip {
    position: fixed;
    z-index: 99999;
    max-width: 280px;
    padding: 10px 12px;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid var(--red, #D81E44);
    border-radius: 6px;
    color: #ddd;
    font-size: 0.78rem;
    line-height: 1.5;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.7);
}

.tooltip-name {
    color: var(--gold, #D4AF37);
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.tooltip-type {
    color: #aaa;
    font-size: 0.7rem;
}

.tooltip-raceattr {
    color: #999;
    font-size: 0.7rem;
}

.tooltip-atkdef {
    color: #ccc;
    font-size: 0.75rem;
    font-weight: 600;
}

.tooltip-desc {
    color: #bbb;
    font-size: 0.72rem;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.1);
    white-space: pre-wrap;
}

.deck-empty-tip {
    color: #666;
    font-size: 0.8rem;
    text-align: center;
    padding: 10px;
}

/* ── 双栏布局：桌面左右 / 手机上下 ── */
.deck-two-col {
    flex: 1;
    display: flex;
    gap: 10px;
    min-height: 0;
    overflow: hidden;
}

.deck-col-main {
    flex: 1 1 58%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.deck-col-side {
    flex: 0 0 38%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    gap: 2px;
}

.deck-cards-main {
    flex: 1;
    min-height: 0;
    /* grid columns set via JS inline style for 4-row layout */
}

.deck-cards-extra {
    flex: 1;
    min-height: 0;
    grid-template-columns: repeat(8, 1fr);
}

.deck-cards-side {
    flex: 1;
    min-height: 0;
    grid-template-columns: repeat(8, 1fr);
}

/* ── 手机端：上下堆叠 ── */
@media (max-width: 1024px) {
    .deck-two-col {
        flex-direction: column;
        overflow-y: auto; padding-bottom: 60px;
    }
    .deck-col-main,
    .deck-col-side {
        flex: auto;
        min-height: auto;
    }
    .deck-cards-main {
        flex: none;
        grid-template-columns: repeat(10, 1fr) !important;
        grid-template-rows: auto !important;
    }
    .deck-cards-extra {
        flex: none;
        grid-template-columns: repeat(10, 1fr) !important;
    }
    .deck-cards-side {
        flex: none;
        grid-template-columns: repeat(10, 1fr) !important;
    }
    .deck-modal {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    .deck-modal-body {
        overflow-y: auto; padding-bottom: 60px;
    }
    .podium-top .stat-card { width: 50% !important; }
    .podium-bottom .stat-card { width: 40% !important; }
    .stats-panel .deck-cards-grid { grid-template-columns: repeat(5, 1fr) !important; }
}

/* ── 卡片统计 ── */
.stats-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.stats-tab {
    flex: 1;
    padding: 10px;
    background: #222;
    border: 1px solid #333;
    border-radius: 8px;
    color: #aaa;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.stats-tab.active {
    background: var(--red, #D81E44);
    border-color: var(--red, #D81E44);
    color: #fff;
    font-weight: 600;
}

.stats-tab:hover:not(.active) {
    border-color: #555;
    color: #fff;
}

.stats-panel {
    display: none;
}

.stats-panel.active {
    display: block;
    flex: 1;
    overflow-x: clip;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--red, #D81E44) transparent;
}

.stats-panel.active::-webkit-scrollbar { width: 5px; }
.stats-panel.active::-webkit-scrollbar-track { background: transparent; }
.stats-panel.active::-webkit-scrollbar-thumb { background: var(--red, #D81E44); border-radius: 3px; }

.stats-panel .deck-cards-grid {
    grid-template-columns: repeat(10, 1fr);
    gap: 3px;
    overflow-x: clip;
    overflow-y: visible;
}

/* ── 领奖台 TOP3 ── */
.stats-podium {
    margin-bottom: 12px;
}

.podium-top {
    display: flex;
    justify-content: center;
    margin-bottom: 6px;
}

.podium-top .stat-card {
    width: 14%;
    position: relative;
}

.podium-top .stat-card::before {
    content: '🥇';
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 1.2rem;
    z-index: 3;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8));
}

.podium-bottom {
    display: flex;
    justify-content: center;
    gap: 8%;
}

.podium-bottom .stat-card {
    width: 11%;
    position: relative;
}

.podium-bottom .stat-card:first-child::before {
    content: '🥈';
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 1rem;
    z-index: 3;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8));
}

.podium-bottom .stat-card:last-child::before {
    content: '🥉';
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 1rem;
    z-index: 3;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8));
}

.stats-footer {
    text-align: center;
    color: #666;
    font-size: 0.8rem;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #2a2a2a;
}

/* 统计卡片 */
.stat-card {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s;
}

.stat-card:hover {
    transform: scale(1.08);
    z-index: 2;
}

.stat-card .deck-card-img {
    width: 100%;
    aspect-ratio: 42/61;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #444;
    display: block;
}

.stat-card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    padding: 3px 2px 2px;
    text-align: center;
}

.stat-card-rate {
    display: block;
    color: var(--gold, #D4AF37);
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

.stat-card-count {
    display: block;
    color: #aaa;
    font-size: 0.7rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

/* ── 手机端：角标缩小防止重叠 ── */
@media (max-width: 768px) {
    .card-score-badge {
        bottom: 1px;
        left: 1px;
        min-width: 13px;
        height: 12px;
        line-height: 10px;
        font-size: 0.48rem;
        padding: 0 2px;
        border-radius: 1px;
    }
    .card-score-badge.forbidden {
        font-size: 0.42rem;
        min-width: 12px;
    }
    .card-diy-badge {
        bottom: 1px;
        right: 1px;
        height: 11px;
        line-height: 9px;
        font-size: 0.4rem;
        padding: 0 2px;
        border-radius: 1px;
    }
    .card-tooltip {
        max-width: 220px;
        font-size: 0.7rem;
        padding: 8px 10px;
    }
    .tooltip-name { font-size: 0.75rem; }
    .tooltip-desc { font-size: 0.65rem; }
}

@media (max-width: 900px) {
    .deck-cards-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    .stats-tab {
        font-size: 0.78rem;
        padding: 8px 6px;
    }
    .stat-card-rate {
        font-size: 0.7rem;
    }
}
