/* ===== ОБЩИЕ СТИЛИ ===== */

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    padding-top: env(safe-area-inset-top, 0px);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg, #0c0c18);
    overscroll-behavior: none;
}

/* ===== COMPARE PAGE — фикс-верх + скролл-низ ===== */

#comparePage {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 0;
}

#comparePage .max-w-5xl {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 12px 16px 0;
    box-sizing: border-box;
    max-width: 640px;
    margin: 0 auto;
}

.compare-sticky {
    flex-shrink: 0;
}

.compare-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
    .compare-scroll {
        padding-bottom: 24px;
    }
}

/* ===== ШАПКА ===== */

.compare-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    padding: 0 4px;
}

.compare-title {
    font-size: 22px;
    font-weight: 900;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 50%, var(--accent, #6366f1) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
    text-shadow: none;
    position: relative;
    display: inline-block;
    line-height: 1.1;
}

.compare-title::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent, #6366f1), #a5b4fc, transparent);
    border-radius: 2px;
    opacity: 0.7;
}

@media (min-width: 768px) {
    .compare-title {
        font-size: 28px;
        letter-spacing: -1px;
    }
}

.compare-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.period-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(165, 180, 252, 0.18);
    background: rgba(99, 102, 241, 0.06);
    color: #e0e7ff;
    transition: all 0.25s ease;
}

.period-toggle:hover {
    background: rgba(99, 102, 241, 0.14);
}

.period-toggle:active {
    transform: scale(0.97);
}

/* ===== КНОПКА СРАВНИТЬ ===== */

#h2hCompareBtnWrapper {
    margin: 14px 0 16px;
}

.h2h-compare-btn {
    background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
    color: #fff;
    font-weight: 700;
    border: 1px solid rgba(199,210,254,0.28);
    border-radius: 14px;
    padding: 12px 36px;
    cursor: pointer;
    font-size: 0.95rem;
    letter-spacing: -0.2px;
    box-shadow: 0 4px 14px rgba(99,102,241,0.45), inset 0 1px 0 rgba(255,255,255,0.22);
    transition: all 0.25s ease;
    text-transform: none;
}

.h2h-compare-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(99,102,241,0.65), inset 0 1px 0 rgba(255,255,255,0.32);
}

.h2h-compare-btn:active {
    transform: scale(0.98);
}

.h2h-compare-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===== H2H КАРТОЧКА ===== */

.h2h-card {
    position: relative;
    display: flex;
    flex-direction: column;
    /* Эффект стекла */
    background: linear-gradient(145deg, rgba(30, 27, 55, 0.75) 0%, rgba(15, 14, 25, 0.85) 100%);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(165, 180, 252, 0.2);
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.15);
    overflow: hidden;
    margin-top: 4px;
    height: calc(100dvh - 340px);
    min-height: 420px;
    max-height: 780px;
}

.h2h-card.salary-mode {
    height: auto;
    min-height: 420px;
    max-height: none;
}

.h2h-card::before {
    content: '';
    position: absolute;
    top: 0; left: 10%; right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    pointer-events: none;
}

.h2h-title {
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #8b87a8;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

/* ===== Противостояние ===== */

.h2h-players {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.h2h-player {
    text-align: center;
    min-width: 0;
}

.h2h-player-name {
    font-size: 14px;
    font-weight: 500;
    color: #a1a1aa;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Суммы — тёплый белый с сиянием */
.h2h-player-wins {
    font-size: 1.6rem;
    font-weight: 700;
    color: #f5f3ff;
    line-height: 1.1;
    letter-spacing: -0.5px;
    text-shadow: 0 0 25px rgba(165,180,252,0.6);
}

.h2h-player-diff {
    font-size: 13px;
    font-weight: 600;
    margin-top: 4px;
    color: #6d6a8a;
}

/* ===== VS ===== */

.h2h-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.h2h-vs-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(139, 135, 168, 0.15);
    border: 1px solid rgba(165, 180, 252, 0.4);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 4px 15px rgba(99,102,241,0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.vs-gradient {
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 50%, var(--accent, #6366f1) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    font-weight: 900;
    font-style: italic;
    letter-spacing: 0.5px;
    line-height: 1;
    display: inline-block;
    font-size: 11px;
    text-shadow: none;
}

/* ===== ПЛАШКИ ЛИГ ===== */

.h2h-leagues-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 0 2px;
}

.h2h-league-badge {
    font-size: 12px;
    font-weight: 600;
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.15);
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid rgba(165, 180, 252, 0.3);
    justify-self: start;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    backdrop-filter: blur(5px);
}

.h2h-league-badge.right {
    justify-self: end;
    color: #ddd6fe;
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(196, 181, 253, 0.3);
}

.h2h-league-spacer {
    width: 36px;
    flex-shrink: 0;
}

/* ===== ТАБЛИЦА МЕТРИК ===== */

.salary-metrics-table {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.salary-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(165, 180, 252, 0.1);
}

.salary-metric-row:last-child {
    border-bottom: none;
}

.salary-val {
    width: 30%;
    font-weight: 600;
    font-size: 0.9rem;
    color: #ede9fe;
}

.salary-val:first-child { text-align: left; }
.salary-val:last-child { text-align: right; }

.salary-label {
    width: 40%;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 500;
    color: #8b87a8;
}

/* ===== ИТОГОВЫЙ РЕЙТИНГ (Стекло + Неон) ===== */

.salary-topsis-block {
    /* Глубокий стеклянный фон с фиолетовым свечением */
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(30, 27, 55, 0.4) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    /* Светящаяся рамка */
    border: 1px solid rgba(165, 180, 252, 0.35);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(99, 102, 241, 0.15);

    border-radius: 16px;
    padding: 20px;
    margin: 0 4px 16px 4px;
    box-sizing: border-box;
    width: calc(100% - 8px);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Блик сверху блока */
.salary-topsis-block::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
}

.salary-topsis-score {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 12px;
}

/* Победитель — неоновый градиент */
.salary-topsis-score span:not(.vs) {
    color: #8b87a8;
}
.salary-topsis-score span.win {
    background: linear-gradient(135deg, #ffffff 0%, #c7d2fe 50%, #818cf8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    text-shadow: 0 0 25px rgba(165, 180, 252, 0.8);
    filter: drop-shadow(0 0 8px rgba(165, 180, 252, 0.5));
}

.salary-topsis-score .vs {
    font-size: 11px;
    font-weight: 900;
    font-style: italic;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 2px;
}

.salary-topsis-text-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.salary-topsis-text {
    font-size: 13px;
    color: #d1d0e0;
    line-height: 1.5;
    max-width: 85%;
}

.salary-methodology-btn {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(165, 180, 252, 0.2);
    border: 1px solid rgba(165, 180, 252, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #e0e7ff;
    font-size: 11px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.salary-methodology-btn:hover {
    background: rgba(165, 180, 252, 0.4);
    box-shadow: 0 0 10px rgba(165, 180, 252, 0.4);
}

/* ===== Список матчей ===== */

.h2h-matches-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
    margin-right: -4px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 8px;
}

.h2h-matches-scroll::-webkit-scrollbar { width: 0; }

.h2h-matches-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.h2h-match-row {
    display: grid;
    grid-template-columns: 92px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(165,180,252,0.1);
    font-size: 0.75rem;
}

.h2h-match-date { color: #8b87a8; font-weight: 500; }
.h2h-match-score { color: #ede9fe; font-weight: 600; text-align: center; }
.h2h-match-winner { color: #b8b4d4; text-align: right; }

.h2h-match-row.is-p1 { border-color: rgba(99,102,241,0.4); background: rgba(99,102,241,0.1); }
.h2h-match-row.is-p1 .h2h-match-winner, .h2h-match-row.is-p1 .h2h-match-score { color: #a5b4fc; }

.h2h-match-row.is-p2 { border-color: rgba(244,114,182,0.4); background: rgba(244,114,182,0.1); }
.h2h-match-row.is-p2 .h2h-match-winner, .h2h-match-row.is-p2 .h2h-match-score { color: #f0abfc; }

.h2h-matches-loader, .h2h-matches-empty {
    text-align: center; padding: 12px; color: #8b87a8; font-size: 0.75rem;
}
.h2h-matches-empty.hidden { display: none; }

/* ===== Мобилка ===== */

@media (max-width: 400px) {
    .h2h-player-wins { font-size: 2.2rem; }
    .h2h-card { padding: 14px 12px; height: calc(100dvh - 320px); min-height: 400px; }
    .h2h-match-row { grid-template-columns: 72px 1fr auto; gap: 6px; padding: 7px 8px; font-size: 0.68rem; }
    .h2h-match-date { font-size: 0.6rem; }
    .salary-topsis-block { padding: 16px 14px; }
}

/* ===== КАРТОЧКИ (DESKTOP) ===== */

.cards-row { display: flex; gap: 12px; margin-top: 16px; }
.result-card { flex: 1; background: rgba(255,255,255,0.02); border: 1px solid rgba(165, 180, 252, 0.15); border-radius: 12px; padding: 10px 8px; text-align: left; }
.result-card .player-name { color: #ede9fe; font-weight: 800; font-size: 1.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; margin-bottom: 2px; }
.result-card .player-league { color: #a5b4fc; font-size: 0.6rem; text-align: center; margin-bottom: 6px; }
.stat-row { display: flex; justify-content: space-between; font-size: 0.65rem; margin-bottom: 3px; }
.stat-label { color: #8b87a8; font-size: 0.6rem; }
.stat-value { color: #ede9fe; font-weight: 700; font-size: 0.65rem; }
.card-spacer { width: 52px; flex-shrink: 0; }

/* ===== Salary Card Styles ===== */

.salary-period { text-align: center; color: #8b87a8; font-size: 0.7rem; margin-bottom: 16px; margin-top: -6px; }
.salary-diff { text-align: center; color: #a5b4fc; font-size: 0.75rem; font-weight: 600; margin-bottom: 12px; }
.salary-topsis-winner { font-size: 0.8rem; font-weight: 700; color: #c7d2fe; }
/* ===== СТЕКЛЯННЫЕ БЛОКИ В КАРТОЧКЕ ЗАРПЛАТЫ ===== */

.h2h-glass-header {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.01) 100%);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 4px 12px rgba(0, 0, 0, 0.2);
}

.h2h-glass-table {
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.h2h-league-badge {
    display: inline-block; font-size: 10px; font-weight: 700; color: #a1a1aa;
    background: rgba(255,255,255,0.06); padding: 2px 8px; border-radius: 4px;
    text-transform: uppercase; letter-spacing: 0.5px;
}

.h2h-diff-badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 700; margin-top: 6px;
}
.h2h-diff-badge.win { background: rgba(52, 211, 153, 0.15); border: 1px solid rgba(52, 211, 153, 0.3); color: #34d399; }
.h2h-diff-badge.lose { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); color: #71717a; }