/* ============================================
   Player Detail Page - 게임 통계 툴 스타일
   ============================================ */

:root {
    /* 베이스 컬러 (90% 영역) */
    --player-bg-primary: #FFFFFF;
    --player-bg-surface: #F8FAFC;
    --player-border: #E5E7EB;
    --player-border-strong: #CBD5E1;
    --player-text-primary: #0F172A;
    --player-text-secondary: #475569;
    --player-text-muted: #94A3B8;
    
    /* 브랜드 / 인터랙션 컬러 (절제) - 전역 변수 사용 */
    --player-accent: var(--color-accent, #1E293B);
    --player-accent-hover: rgba(30, 41, 59, 0.06);
    
    /* 상태 컬러 (의미 전용) - 전역 변수 사용 */
    --player-success: var(--color-success, #16A34A);
    --player-danger: var(--color-danger, #D97706);
    --player-win-bg: rgba(22, 163, 74, 0.12);
    --player-lose-bg: rgba(217, 119, 6, 0.12);
    
    /* 팀 색상 - 전역 변수 사용 */
    --player-team-blue: var(--team-blue, #4299E1);
    --player-team-red: var(--team-red, #F56565);
}

body {
    background-color: var(--player-bg-primary);
}

/* ============================================
   페이지 전체 컨테이너 (통일된 최대 너비)
   ============================================ */
.player-detail-container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ============================================
   상단 플레이어 요약 영역
   ============================================ */
.profile-header {
    background-color: var(--player-bg-primary);
    border-bottom: 1px solid var(--player-border);
    padding: 2.5rem 0;
}

.profile-header .player-detail-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.profile-info {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
}

.profile-avatar {
    width: 96px;
    height: 96px;
    background-color: var(--player-bg-surface);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--player-text-muted);
    border: 1px solid var(--player-border);
    overflow: hidden;
    flex-shrink: 0;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-details {
    flex: 1;
    min-width: 0;
}

.profile-details h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--player-text-primary);
    line-height: 1.2;
    word-break: break-word;
    margin-bottom: 0;
}

.profile-stats {
    font-size: 16px;
    color: var(--player-text-primary);
}

.profile-winrate {
    display: inline-block;
    font-weight: 500;
}

.profile-winrate-percent {
    font-weight: 600;
    margin-left: 0.25rem;
}

.titles-container {
    margin-top: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.title-badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

/* 포지션 점수 리스트 + 그래프 레이아웃 */
.profile-scores-layout {
    display: flex;
    gap: 2rem;
    align-items: stretch;
}

@media (max-width: 768px) {
    .profile-scores-layout {
        flex-direction: column;
        gap: 1.5rem;
        align-items: stretch;
    }
    
    .profile-scores-summary {
        flex: 1;
        width: 100%;
    }
    
    .profile-score-graph {
        flex: 1;
        width: 100%;
    }
    
    .score-history-chart-wrapper {
        height: 200px;
    }
    
    .profile-scores-summary {
        min-width: 100%;
        width: 100%;
        height: 280px;
    }
    
    .profile-score-graph {
        height: 280px;
    }
    
    .score-history {
        height: 100%;
    }
}

/* 포지션 점수 요약 영역 (왼쪽) */
.profile-scores-summary {
    flex: 0 0 auto;
    min-width: 280px;
    width: 280px;
    display: flex;
    flex-direction: column;
    height: 280px;
}

/* 점수 변화 그래프 영역 (오른쪽) */
.profile-score-graph {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 280px;
}

/* ============================================
   포지션 점수 리스트 (정제된 스타일)
   ============================================ */
.play-scores-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 13px;
    height: 100%;
    display: table;
}

.play-scores-table tbody {
    display: table-row-group;
    height: 100%;
}

.score-row-table {
    background: var(--player-bg-primary);
    border-bottom: 1px solid var(--player-border);
    cursor: pointer;
}

/* 주/부 포지션: 색상으로 구분 */
.score-row-table.main {
    background: var(--player-bg-surface);
}

.score-row-table.main .score-role-label-table,
.score-row-table.main .score-value-table {
    color: #FF4081;
    font-weight: 600;
}

.score-row-table.sub {
    background: var(--player-bg-surface);
}

.score-row-table.sub .score-role-label-table,
.score-row-table.sub .score-value-table {
    color: #FF6B9D;
    font-weight: 600;
}

.score-row-table.highlight {
    background: var(--player-accent-hover) !important;
}

.score-role-label-table {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    min-width: 80px;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    color: var(--player-text-primary);
    height: calc(280px / var(--row-count, 5));
    vertical-align: middle;
}

.score-value-table {
    min-width: 60px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: right;
    padding: 0 0.5rem 0 0.75rem;
    color: var(--player-text-primary);
    height: calc(280px / var(--row-count, 5));
    vertical-align: middle;
}

.score-diff-table {
    min-width: 70px;
    font-size: 12px;
    text-align: right;
    font-weight: 400;
    padding: 0 0.75rem 0 0.25rem;
    color: var(--player-text-secondary);
    height: calc(280px / var(--row-count, 5));
    vertical-align: middle;
}

/* 점수 변동량 색상 규칙 (텍스트 색상만) */
.score-diff-table.positive {
    color: var(--player-success);
}

.score-diff-table.negative {
    color: var(--player-danger);
}

.score-diff-table.neutral {
    color: var(--player-text-secondary);
}

/* ============================================
   칭호 영역
   ============================================ */
.titles-container {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.title-badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

/* ============================================
   포지션별 점수 그래프
   ============================================ */
/* snapshots 섹션은 이제 사용하지 않음 (그래프가 profile-header로 이동) */
.snapshots {
    display: none;
}

.score-history {
    margin-top: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #2A2A2A;
    border-radius: 8px;
    padding: 1.25rem;
}

.score-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.score-history-title {
    font-size: 16px;
    font-weight: 600;
    color: #E5E5E5;
    position: relative;
    padding-left: 0.5rem;
    margin: 0;
    flex: 1;
}

.score-history-title::before {
    content: '';
    position: absolute;
    left: -0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--player-accent);
}

.score-history-chart-wrapper {
    flex: 1;
    min-height: 0;
    position: relative;
    margin-top: 0;
    background: #2A2A2A;
}

.score-history-chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

.score-history-period-tabs {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
}

.score-period-tab {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 0.375rem 0.75rem;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.score-period-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.score-period-tab.active {
    background: rgba(255, 107, 157, 0.3);
    border-color: #FF6B9D;
    color: #E5E5E5;
}

.score-role-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.score-role-tab {
    border: none;
    border-radius: 0;
    padding: 0.375rem 0.75rem;
    font-size: 13px;
    background: transparent;
    color: var(--player-text-muted);
    cursor: pointer;
    line-height: 1.4;
    transition: all 0.2s;
    font-weight: 400;
    position: relative;
    height: 32px;
    display: flex;
    align-items: center;
}

.score-role-tab:hover {
    color: var(--player-text-secondary);
}

.score-role-tab.active {
    background: transparent;
    color: var(--player-text-primary);
    font-weight: 500;
}

.score-role-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--player-accent);
}

.score-history-chart-wrapper {
    flex: 1;
    min-height: 0;
    position: relative;
    margin-top: 1rem;
    display: flex;
    align-items: stretch;
    overflow: visible;
}

.score-history-chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================
   챔피언별 전적 테이블 (games-section과 동일한 구조)
   ============================================ */
.section-body {
    padding: 0;
}

/* games-section과 동일한 스타일 적용 */
.games-section {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    padding: 0;
    margin: 0;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--player-text-primary);
    margin: 0 0 1rem 0;
    position: relative;
    padding-left: 0.5rem;
}

.section-title::before {
    content: '';
    position: absolute;
    left: -0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--player-accent);
}

.wr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.wr-table th,
.wr-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--player-border);
    text-align: center;
}

.wr-table thead th {
    background: transparent;
    color: var(--player-text-secondary);
    font-weight: 600;
    font-size: 12px;
}

.wr-table tbody tr:hover {
    background: var(--player-bg-surface);
}

.wr-table tbody td.wr-left {
    text-align: left !important;
}

.wr-table tbody td.wr-left .wr-chip {
    justify-content: flex-start;
}

.wr-left {
    text-align: left;
}

.wr-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-start;
}

.wr-icon-img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid var(--player-border);
    object-fit: cover;
    display: inline-block;
    vertical-align: middle;
}

.wr-name {
    color: var(--player-text-primary);
    font-weight: 500;
}

.wr-win-black { color: #111; font-weight: 600; }
.wr-win-blue { color: #1a73e8; font-weight: 600; }
.wr-win-red { color: #d93025; font-weight: 600; }

.wr-kda { font-weight: 600; }
.wr-kda-black { color: #111; }
.wr-kda-green { color: #1b8f3a; }
.wr-kda-blue { color: #1a73e8; }
.wr-kda-red { color: #d93025; }
.wr-kda-red-bright { color: #c41e3a; font-weight: 700; }

.wr-more-btn {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--color-accent, #1E293B);
    border: 1px solid var(--color-accent, #1E293B);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1rem;
    text-align: center;
}

.wr-more-btn:hover {
    background: var(--color-accent-hover, #0F172A);
    border-color: var(--color-accent-hover, #0F172A);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(30, 41, 59, 0.2);
}

.wr-more-btn:active {
    transform: translateY(0);
}

.hidden-row {
    display: none;
}

/* ============================================
   최근 게임 리스트
   ============================================ */
.main-content {
    padding: 2rem 0;
}

.games-section {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
}

.section-header {
    padding: 0 0 0.75rem 0;
    border-bottom: 1px solid var(--player-border);
    background: transparent;
    margin-bottom: 1rem;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--player-text-primary);
    margin: 0 0 1rem 0;
    position: relative;
    padding-left: 0.5rem;
}

.section-title::before {
    content: '';
    position: absolute;
    left: -0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--player-accent);
}

.recent-role-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-top: 0;
}

.recent-role-tab {
    border: none;
    background: transparent;
    color: var(--player-text-secondary);
    border-radius: 0;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    border-bottom: 2px solid transparent;
    margin-right: 0.5rem;
}

.recent-role-tab:hover {
    color: var(--player-text-primary);
}

.recent-role-tab.active {
    background: transparent;
    color: var(--player-text-primary);
    font-weight: 600;
    border-bottom-color: var(--player-accent);
}

.champion-role-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-top: 0;
}

.champion-role-tab {
    border: none;
    background: transparent;
    color: var(--player-text-secondary);
    border-radius: 0;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    border-bottom: 2px solid transparent;
    margin-right: 0.5rem;
}

.champion-role-tab:hover {
    color: var(--player-text-primary);
}

.champion-role-tab.active {
    background: transparent;
    color: var(--player-text-primary);
    font-weight: 600;
    border-bottom-color: var(--player-accent);
}

.game-item {
    border-bottom: 1px solid var(--player-border);
}

.game-item:last-child {
    border-bottom: none;
}

.game-summary {
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: background-color 0.2s;
}

.game-summary:hover {
    background-color: var(--player-bg-hover);
}

/* 승/패 색상 충돌 해결: 배경은 매우 연하게, 상태는 텍스트/아이콘에서 표현 */
.game-item.win .game-summary {
    background-color: rgba(22, 163, 74, 0.04);
    border-left: 3px solid var(--player-success);
}

.game-item.win .game-summary:hover {
    background-color: rgba(22, 163, 74, 0.08);
}

.game-item.lose .game-summary {
    background-color: rgba(217, 119, 6, 0.04);
    border-left: 3px solid var(--player-danger);
}

.game-item.lose .game-summary:hover {
    background-color: rgba(217, 119, 6, 0.08);
}

.game-basic-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}

.champion-icon {
    width: 48px;
    height: 48px;
    background-color: var(--player-bg-surface);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--player-border);
    overflow: hidden;
}

.champion-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.game-info {
    flex-grow: 1;
    min-width: 0;
}

.game-result {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
    font-size: 12px;
    margin-bottom: 0.375rem;
    display: inline-block;
}

.game-result.win {
    background-color: var(--player-win-bg);
    color: var(--player-success);
    border: none;
}

.game-result.lose {
    background-color: var(--player-lose-bg);
    color: var(--player-danger);
    border: none;
}

.game-result:not(.win):not(.lose) {
    background-color: transparent;
    color: var(--player-text-muted);
    border: none;
}

.game-result.team-blue-result .team-name-text {
    color: var(--team-blue-text, #4299E1);
    font-weight: 600;
}

.game-result.team-red-result .team-name-text {
    color: var(--team-red-text, #F56565);
    font-weight: 600;
}

.game-meta {
    font-size: 12px;
    color: var(--player-text-muted);
}

.game-stats {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.stat-group {
    display: flex;
    flex-direction: column;
    min-width: 60px;
    align-items: flex-start;
}

.stat-main {
    font-weight: 400;
    color: var(--player-text-primary);
    font-size: 13px;
}

.kda-rating {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 0.125rem;
    line-height: 1.2;
}

.wr-kda-black.kda-rating { color: var(--player-text-primary); }
.wr-kda-green.kda-rating { color: var(--player-success); }
.wr-kda-blue.kda-rating { color: var(--player-team-blue); }
.wr-kda-red.kda-rating { color: var(--player-danger); }
.wr-kda-red-bright.kda-rating { color: #c41e3a; font-weight: 700; }
.kda-muted { color: var(--player-text-muted); font-weight: 400; }

.expand-icon {
    color: var(--player-text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.expand-icon.rotated {
    transform: rotate(180deg);
}

/* ============================================
   게임 상세 영역 (요약과 구분)
   ============================================ */
.game-details {
    background-color: var(--player-bg-surface);
    border-top: 1px solid var(--player-border);
    padding: 1.5rem;
    margin: 0;
}

.detail-link {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--player-border);
}

.detail-link a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--player-accent);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.detail-link a:hover {
    background: #1D4ED8;
    text-decoration: none;
    color: white;
}

/* ============================================
   Game Card 스타일 오버라이드 (game_cards.css와 호환)
   ============================================ */
/* player_detail 페이지의 game-card는 game_cards.css 스타일 사용 */
/* CSS 변수는 home.css의 변수를 사용하도록 game_cards.css에서 정의됨 */

/* game_cards.css의 변수를 player_detail 변수로 매핑 */
.game-details .game-card {
    --bg-primary: var(--player-bg-primary, #FFFFFF);
    --border: var(--player-border, #E5E7EB);
    --text-primary: var(--player-text-primary, #0F172A);
    --text-secondary: var(--player-text-secondary, #475569);
    --text-muted: var(--player-text-muted, #94A3B8);
    --accent-primary: var(--color-accent, #1E293B);
    --accent-primary-hover: var(--color-accent-hover, #0F172A);
    --accent-secondary: var(--color-success, #16A34A);
    --team-blue: var(--team-blue, #4299E1);
    --team-red: var(--team-red, #F56565);
    --bg-surface: var(--player-bg-surface, #F8FAFC);
    --bg-hover: var(--player-bg-hover, rgba(37, 99, 235, 0.06));
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
}

.shots-wrap {
    margin-top: 1.5rem;
}

.shots-title {
    font-size: 0.875rem;
    color: var(--player-text-primary);
    margin: 0 0 0.75rem;
    font-weight: 600;
}

.shots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.shot {
    position: relative;
    background: var(--player-bg-surface);
    border: 1px solid var(--player-border);
    border-radius: 4px;
    overflow: hidden;
}

.shot img {
    display: block;
    width: 100%;
    height: 100px;
    object-fit: cover;
}

.shot a {
    display: block;
}

.shot:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.shots-empty {
    color: var(--player-text-muted);
    font-size: 13px;
}

.shot-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    z-index: 2000;
}

.shot-modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.shot-modal img {
    max-width: 92vw;
    max-height: 90vh;
    object-fit: contain;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.shot-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    color: #fff;
    cursor: pointer;
}

.shot-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 30px;
    color: #fff;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.35);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    user-select: none;
}

.shot-prev {
    left: 16px;
}

.shot-next {
    right: 16px;
}

.shot-count {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: #ddd;
    font-size: 0.9rem;
}

.recent-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--player-text-muted);
    font-size: 13px;
}

.recent-more {
    margin: 0 1.5rem 1.2rem;
}

/* ============================================
   반응형
   ============================================ */
@media (max-width: 768px) {
    .player-detail-container {
        padding: 0 1rem;
    }
    
    .profile-header .player-detail-container {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .profile-info {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .profile-details h1 {
        font-size: 1.5rem;
        text-align: center;
    }

    .titles-container {
        justify-content: center;
    }
    
    .profile-scores-summary {
        flex: 1 1 100%;
        width: 100%;
    }

    .game-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    /* game_cards.css의 반응형 스타일 사용 */

    .wr-hide-sm {
        display: none;
    }

    .wr-name {
        display: inline-block;
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
