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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    min-height: 100vh;
}

/* === ХЕДЕР === */
header {
    background: #252525;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #c23c2a;
}

h1 {
    font-size: 24px;
    color: #fff;
}

#app-title {
    cursor: pointer;
    transition: 0.2s;
}

#app-title:hover {
    color: #c23c2a;
}

#login-btn {
    background: #171a21;
    color: #fff;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 4px;
    border: 1px solid #66c0f4;
    transition: 0.2s;
}

#login-btn:hover {
    background: #66c0f4;
    color: #171a21;
}

main {
    max-width: 1920px;
    margin: 20px auto;
    padding: 0 16px;
}

.hidden {
    display: none !important;
}

h2 {
    margin-bottom: 12px;
    color: #fff;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

h3 {
    margin: 0 0 15px 0;
    color: #fff;
    font-size: 16px;
}

h4 {
    margin: 10px 0 8px 0;
    color: #ccc;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === ОСНОВНАЯ СЕТКА === */
.player-layout {
    display: grid;
    grid-template-columns: 220px 1fr 270px;
    gap: 20px;
    align-items: start;
}

.col-users,
.col-main,
.col-peers {
    min-width: 0;
}

/* === КАРТОЧКА === */
.card {
    background: #252525;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #2f2f2f;
}

.card:last-child {
    margin-bottom: 0;
}

/* === ДРУЗЬЯ === */
.users-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-card {
    background: #252525;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid #2f2f2f;
}

.user-card:hover {
    background: #2f2f2f;
    border-color: #c23c2a;
}

.user-card--me {
    border-color: #c23c2a;
    background: #2a1f1f;
}

.user-card--me:hover {
    background: #332222;
    border-color: #c23c2a;
}

.user-card img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #333;
    flex-shrink: 0;
}

.user-card .user-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
    flex: 1;
}

.user-card .name {
    font-weight: 600;
    color: #fff;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-card .updated-small {
    font-size: 10px;
    color: #777;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === ПРОФИЛЬ + СТАТИСТИКА === */
.profile-row {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.profile-header .profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #333;
    flex-shrink: 0;
}

.profile-header .rank-icon {
    width: 80px;
    height: 80px;
    object-fit: contain;
    flex-shrink: 0;
}

.profile-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.profile-rank {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: #c23c2a;
    font-weight: 600;
}

.rank-icon {
    width: 28px;
    height: 28px;
}

/* === ОБЩАЯ СТАТИСТИКА === */
.stats-block {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    flex: 1;
    min-width: 0;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #c23c2a;
}

.stat-value.stat-wl {
    color: inherit;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
}

.stat-value.stat-wl .wins {
    color: #4caf50;
}

.stat-value.stat-wl .losses {
    color: #f44336;
}

.stat-value.stat-wl .wl-dash {
    color: #666;
    margin: 0 2px;
}

.stat-label {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.stat-sub {
    font-size: 12px;
    color: #666;
    margin-top: 3px;
}

.stat-sub .wins {
    color: #4caf50;
    font-weight: 600;
}

.stat-sub .losses {
    color: #f44336;
    font-weight: 600;
}

/* === 20 матчей + За патч === */
.row-two {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.row-two .card {
    margin-bottom: 0;
}

/* === Последние матчи === */
.recent-summary {
    background: #1e1e1e;
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #ccc;
}

.recent-summary .big {
    font-size: 18px;
    font-weight: 700;
}

.recent-summary .big:not(.low) {
    color: #4caf50;
}

.recent-summary .big.low {
    color: #f44336;
}

/* === Мини-герои === */
.mini-heroes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.mini-hero {
    background: #1e1e1e;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: 0.15s;
}

.mini-hero:hover {
    background: #2a2a2a;
}

.mini-hero img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #333;
    display: block;
}

.mini-hero-info {
    padding: 6px 8px;
    width: 100%;
    overflow: hidden;
}

.mini-hero-name {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-hero-stats {
    font-size: 10px;
    color: #999;
    margin-top: 2px;
}

.mini-hero-stats span {
    color: #4caf50;
    font-weight: 600;
}

.mini-hero-stats span.low {
    color: #f44336;
}

/* === Статистика за патч === */
.patch-summary {
    background: #1e1e1e;
    padding: 12px 15px;
    border-radius: 6px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.patch-tops {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.patch-section {
    min-width: 0;
}

/* === ПРАВАЯ КОЛОНКА === */
.col-peers .card {
    padding: 16px;
}

.col-peers .card h2 {
    margin-bottom: 12px;
}

/* === Пиры === */
.peers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.peer-row {
    background: #1e1e1e;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.15s;
}

.peer-row:hover {
    background: #2a2a2a;
}

.peer-row img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #333;
    flex-shrink: 0;
}

.peer-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    flex: 1;
}

.peer-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.peer-stats {
    font-size: 12px;
    color: #999;
}

.peer-games-count {
    color: #ffc107;
    font-weight: 600;
}

.peer-stats .wr {
    color: #4caf50;
    font-weight: 600;
}

.peer-stats .wr.low {
    color: #f44336;
}

/* === Переключатель scope === */
.toggle-group {
    display: flex;
    gap: 4px;
    background: #1a1a1a;
    padding: 3px;
    border-radius: 6px;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: #999;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: 0.2s;
}

.toggle-btn.active {
    background: #c23c2a;
    color: #fff;
}

.toggle-btn:hover:not(.active) {
    color: #fff;
}

.toggle-group--compact .toggle-btn {
    padding: 4px 10px;
    font-size: 11px;
}

/* === Герои === */
.heroes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.heroes-header h2 {
    margin-bottom: 0;
}

.heroes-list-compact {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hero-card {
    background: #1e1e1e;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.15s;
}

.hero-card:hover {
    background: #2a2a2a;
}

.hero-card img {
    width: 48px;
    height: 27px;
    object-fit: cover;
    border-radius: 4px;
    background: #333;
    flex-shrink: 0;
}

.hero-card .hero-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    flex: 1;
}

.hero-card .hero-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hero-card .hero-stats {
    font-size: 12px;
    color: #999;
}

.hero-card .winrate {
    color: #4caf50;
    font-weight: 600;
}

.hero-card .winrate.low {
    color: #f44336;
}

/* === Утилиты === */
.loading {
    color: #999;
    font-style: italic;
    font-size: 13px;
}

.error {
    color: #f44336;
    padding: 10px;
    background: #2a1515;
    border-radius: 4px;
    font-size: 13px;
}

/* === СОСТОЯНИЯ СТРАНИЦЫ === */

/* Гость: landing, статистика скрыта */
body.state-guest .col-main .stats-content,
body.state-guest .col-peers {
    display: none !important;
}
body.state-guest .landing-content {
    display: block !important;
}

/* Авторизован / другой игрок: статистика, landing скрыт */
body.state-user-me .col-main .stats-content,
body.state-user-me .col-peers,
body.state-user-other .col-main .stats-content,
body.state-user-other .col-peers {
    display: block !important;
}
body.state-user-me .landing-content,
body.state-user-other .landing-content {
    display: none !important;
}

/* Пиры видны только в своём профиле */
body.state-user-other #peers-card {
    display: none !important;
}

/* === LANDING === */
.landing-content {
    display: block;
}

.landing-card {
    background: #252525;
    border-radius: 8px;
    padding: 40px;
    border: 1px solid #2f2f2f;
    text-align: center;
    max-width: 720px;
    margin: 0 auto;
}

.landing-logo {
    width: 100%;
    max-width: 240px;
    height: auto;
    margin: 0 auto 20px;
    display: block;
    opacity: 0.95;
    border-radius: 8px;
}

.landing-title {
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 10px;
}

.landing-subtitle {
    font-size: 15px;
    color: #aaa;
    line-height: 1.5;
    margin-bottom: 30px;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

.landing-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    text-align: left;
    margin-bottom: 30px;
}

.landing-feature {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: #1e1e1e;
    padding: 14px;
    border-radius: 6px;
    border: 1px solid #2a2a2a;
    transition: 0.2s;
}

.landing-feature:hover {
    border-color: #c23c2a;
    background: #232323;
}

.landing-feature-icon {
    font-size: 24px;
    flex-shrink: 0;
    line-height: 1;
}

.landing-feature-title {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 3px;
}

.landing-feature-text {
    font-size: 12px;
    color: #999;
    line-height: 1.4;
}

.landing-hint {
    background: #1e1e1e;
    border-left: 3px solid #c23c2a;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 13px;
    color: #ccc;
    text-align: left;
    margin-bottom: 20px;
}

.landing-future {
    font-size: 12px;
    color: #777;
    padding-top: 20px;
    border-top: 1px solid #2a2a2a;
}

.landing-future-badge {
    display: inline-block;
    background: #c23c2a;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 8px;
}

/* === Адаптив === */
@media (max-width: 1100px) {
    .player-layout {
        grid-template-columns: 200px 1fr;
    }
    .col-peers {
        grid-column: 1 / -1;
    }
    .peers-list {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .peer-row {
        flex: 1 1 200px;
    }
    .heroes-list-compact {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .hero-card {
        flex: 1 1 220px;
    }
}

@media (max-width: 750px) {
    .player-layout {
        grid-template-columns: 1fr;
    }
    .profile-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .mini-heroes-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-block {
        width: 100%;
        grid-template-columns: repeat(2, 1fr);
    }
    .landing-card {
        padding: 24px 18px;
    }
    .landing-title {
        font-size: 24px;
    }
    .landing-features {
        grid-template-columns: 1fr;
    }
    .landing-logo {
        max-width: 280px;
    }
}