/* 개선된 대회 결과 화면 CSS 스타일 */

/* 게임 카드 기본 스타일 - 컴팩트 */
.improved-game-card {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 0.5rem; /* 0.8rem에서 0.5rem으로 더 줄임 */
    margin-bottom: 0.5rem; /* 0.8rem에서 0.5rem으로 더 줄임 */
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.improved-game-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

/* 순위별 카드 스타일 */
.rank-card-1 {
    background: linear-gradient(135deg, #fff8e1, #fffde7);
    border-left: 4px solid #ffd700;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.2);
}

.rank-card-2 {
    background: linear-gradient(135deg, #f5f5f5, #fafafa);
    border-left: 4px solid #c0c0c0;
    box-shadow: 0 4px 20px rgba(192, 192, 192, 0.15);
}

.rank-card-3 {
    background: linear-gradient(135deg, #fdf4e3, #fff8f0);
    border-left: 4px solid #cd7f32;
    box-shadow: 0 4px 20px rgba(205, 127, 50, 0.15);
}

.rank-card-4 {
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-left: 4px solid #8e8e93;
}

/* 종족 아이콘 스타일 */
.race-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    transition: transform 0.2s ease;
    margin-bottom: 0.5rem;
}

.race-icon:hover {
    transform: scale(1.1);
}

.race-orc { background: linear-gradient(135deg, #dc2626, #ef4444); }
.race-undead { background: linear-gradient(135deg, #6b21a8, #9333ea); }
.race-nightelf { background: linear-gradient(135deg, #059669, #10b981); }
.race-human { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.race-terran { background: linear-gradient(135deg, #ff6b35, #f7931e); }
.race-protoss { background: linear-gradient(135deg, #00d4ff, #0099cc); }
.race-zerg { background: linear-gradient(135deg, #9d4edd, #c77dff); }

/* 로딩 애니메이션 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(102, 126, 234, 0.2);
    border-left: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 버튼 개선 */
.btn-game-control {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary-gradient {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary-gradient:hover {
    background: linear-gradient(135deg, #5a67d8, #6b46c1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-load-more {
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-load-more:hover {
    background: linear-gradient(135deg, #5a67d8, #6b46c1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* 게임 타입 배지 */
.game-type-badge {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* 에러 및 빈 상태 스타일 */
.error-state {
    text-align: center;
    padding: 3rem;
    color: #dc3545;
    background: linear-gradient(135deg, #fff5f5, #fed7d7);
    border-radius: 12px;
    border: 1px solid #fc8181;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #888;
    background: linear-gradient(135deg, #f7fafc, #edf2f7);
    border-radius: 12px;
    border: 2px dashed #cbd5e0;
}

.loading-state {
    text-align: center;
    padding: 3rem;
    color: #888;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: 12px;
}

/* 종족 배지 스타일 - 가독성 개선 */
.race-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.race-badge-orc { 
    background: rgba(220, 38, 38, 0.2); 
    color: #8b0000 !important;
    border-color: #dc2626;
}
.race-badge-undead { 
    background: rgba(107, 33, 168, 0.2); 
    color: #4c1d95 !important;
    border-color: #6b21a8;
}
.race-badge-nightelf { 
    background: rgba(5, 150, 105, 0.2); 
    color: #064e3b !important;
    border-color: #059669;
}
.race-badge-human { 
    background: rgba(37, 99, 235, 0.2); 
    color: #1e3a8a !important;
    border-color: #2563eb;
}
.race-badge-terran { 
    background: rgba(255, 107, 53, 0.2); 
    color: #c2410c !important;
    border-color: #ff6b35;
}
.race-badge-protoss { 
    background: rgba(0, 212, 255, 0.2); 
    color: #0369a1 !important;
    border-color: #00d4ff;
}
.race-badge-zerg { 
    background: rgba(157, 78, 221, 0.2); 
    color: #6b21a8 !important;
    border-color: #9d4edd;
}

/* 특성 배지 스타일 - 가독성 개선 */
.trait-badge {
    background: rgba(16, 185, 129, 0.25);
    color: #064e3b !important;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid #10b981;
}

/* === 등수 아이콘 및 텍스트 수정 - 핵심 수정 부분 === */

/* 순위 이모지 스타일 - 항상 표시되도록 수정 */
.rank-emoji {
    position: relative !important; /* absolute에서 relative로 변경 */
    font-size: 1.8rem !important; /* 2rem에서 1.8rem으로 줄임 */
    margin-bottom: 0.2rem !important; /* 0.3rem에서 0.2rem으로 줄임 */
    margin-right: 0.4rem !important; /* 0.5rem에서 0.4rem으로 줄임 */
    opacity: 1 !important; /* 항상 완전히 보이도록 */
    z-index: 1;
    display: inline-block !important; /* 인라인 블록으로 표시 */
    vertical-align: middle !important;
    line-height: 1 !important;
    flex-shrink: 0; /* 축소되지 않도록 */
}

/* 플레이어 이름 스타일 - 강제 검정색 및 크기 조정 */
.player-name {
    font-weight: 700 !important;
    color: #000000 !important;
    font-size: 1rem !important; /* 크기 약간 줄임 */
    margin-bottom: 0.3rem !important;
    line-height: 1.2 !important;
    text-align: center !important;
    text-shadow: none !important; /* 그림자 제거 */
    background-color: rgba(255, 255, 255, 0.9) !important;
    padding: 0.25rem 0.5rem !important; /* 패딩 줄임 */
    border-radius: 6px !important;
    display: inline-block !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important; /* 테두리 얇게 */
    box-shadow: none !important; /* 그림자 제거 */
    max-width: none !important; /* 최대 너비 제한 제거 */
    white-space: nowrap !important; /* 줄바꿈 방지 */
}

/* 모든 플레이어 이름 관련 요소들 강제 검정색 */
.result-card .player-name,
.improved-game-card .player-name,
.player-info .player-name,
div[class*="player-name"],
*[class*="player-name"],
.player-name span,
.player-info div:has(.player-name),
.player-details .player-name {
    color: #000000 !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    border-radius: 6px !important;
    padding: 0.25rem 0.5rem !important;
    display: inline-block !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    font-size: 1rem !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

/* 인라인 스타일도 덮어쓰기 */
.player-name[style],
*[style*="color"] .player-name {
    color: #000000 !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
}

/* 게임 헤더 스타일 - 컴팩트 */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem; /* 0.8rem에서 0.5rem으로 더 줄임 */
    padding-bottom: 0.4rem; /* 0.6rem에서 0.4rem으로 더 줄임 */
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.game-title {
    margin: 0;
    color: #333;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.game-title i {
    color: #ffd700;
    font-size: 1rem;
}

.game-date {
    margin: 0.2rem 0 0;
    color: #666;
    font-size: 0.85rem;
}

/* 세로형 리스트 레이아웃 - 최종 최적화 버전 */
.results-list-vertical {
    display: flex;
    flex-direction: column;
    gap: 0.3rem; /* 0.4rem에서 0.3rem으로 더 줄임 */
    padding: 0.4rem; /* 0.6rem에서 0.4rem으로 더 줄임 */
}

/* 결과 행 스타일 - 최종 최적화 버전 */
.result-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.6rem; /* 0.6rem 0.8rem에서 더 줄임 */
    border-radius: 10px;
    border-left: 4px solid;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    min-height: 55px; /* 60px에서 55px로 더 줄임 */
}

.result-row:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* 순위별 행 스타일 - 최종 최적화 버전 */
.rank-row-1 {
    border-left-color: #ffd700;
    background: linear-gradient(135deg, #fff8e1, #fffde7);
    box-shadow: 0 3px 12px rgba(255, 215, 0, 0.2);
}

.rank-row-2 {
    border-left-color: #c0c0c0;
    background: linear-gradient(135deg, #f5f5f5, #fafafa);
    box-shadow: 0 3px 12px rgba(192, 192, 192, 0.15);
}

.rank-row-3 {
    border-left-color: #cd7f32;
    background: linear-gradient(135deg, #fdf4e3, #fff8f0);
    box-shadow: 0 3px 12px rgba(205, 127, 50, 0.15);
}

.rank-row-4 {
    border-left-color: #8e8e93;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
}

/* 순위 섹션 - 최종 최적화 버전 */
.rank-section {
    display: flex;
    flex-direction: row !important; /* 가로 배치로 변경 */
    align-items: center !important;
    justify-content: flex-start !important; /* 왼쪽 정렬 */
    min-width: 65px !important; /* 70px에서 65px로 더 줄임 */
    margin-right: 0.6rem; /* 0.8rem에서 0.6rem으로 더 줄임 */
    flex-shrink: 0; /* 축소 방지 */
}



/* 순위 번호 스타일 - 크기 조정 */
.rank-number {
    font-size: 0.9rem !important;
    font-weight: 700 !important;
    color: #000000 !important;
    background-color: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(0, 0, 0, 0.3) !important; /* 테두리 얇게 */
    border-radius: 4px !important; /* 모서리 약간 줄임 */
    padding: 0.2rem 0.4rem !important; /* 패딩 줄임 */
    text-shadow: none !important;
    box-shadow: none !important; /* 그림자 제거 */
    min-width: 35px !important; /* 최소 너비 줄임 */
    text-align: center !important;
    white-space: nowrap !important;
    flex-shrink: 0; /* 축소 방지 */
}

/* 플레이어 섹션 - 최종 최적화 버전 */
.player-section {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 0.5rem; /* 0.6rem에서 0.5rem으로 더 줄임 */
}

.player-info-compact {
    display: flex;
    flex-direction: column;
    gap: 0.15rem; /* 0.2rem에서 0.15rem으로 더 줄임 */
}

.player-info-compact .player-name {
    font-size: 1rem !important; /* 크기 조정 */
    margin: 0;
    font-weight: 700;
}

.player-info-compact .player-details {
    display: flex;
    gap: 0.15rem; /* 0.2rem에서 0.15rem으로 더 줄임 */
    align-items: center;
    flex-wrap: wrap;
}

/* 종족 아이콘 세로형 레이아웃용 - 최종 최적화 버전 */
.player-section .race-icon {
    width: 40px; /* 45px에서 40px로 줄임 */
    height: 40px; /* 45px에서 40px로 줄임 */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem; /* 1.3rem에서 1.2rem으로 줄임 */
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.player-section .race-icon:hover {
    transform: scale(1.05);
}

/* 순위 텍스트 스타일 - 강제 검정색 및 크기 조정 */
.rank-text {
    font-size: 0.9rem !important; /* 크기 줄임 */
    font-weight: 700 !important;
    line-height: 1 !important;
    color: #000000 !important;
    text-shadow: none !important; /* 그림자 제거 */
    background-color: rgba(255, 255, 255, 0.9) !important;
    padding: 0.2rem 0.4rem !important; /* 패딩 줄임 */
    border-radius: 4px !important; /* 모서리 줄임 */
    display: inline-block !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important; /* 테두리 얇게 */
    box-shadow: none !important; /* 그림자 제거 */
    white-space: nowrap !important;
}

/* 모든 순위 텍스트 관련 요소들 강제 검정색 */
.result-card .rank-text,
.improved-game-card .rank-text,
.rank-info .rank-text,
div[class*="rank-text"],
*[class*="rank-text"],
.rank-text span {
    color: #000000 !important;
    text-shadow: none !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    border-radius: 4px !important;
    padding: 0.2rem 0.4rem !important;
    display: inline-block !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    box-shadow: none !important;
}

/* 인라인 스타일도 덮어쓰기 */
.rank-text[style],
*[style*="color"] .rank-text {
    color: #000000 !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
}

/* 대기 상태 스타일 */
.waiting-state {
    text-align: center;
    color: #666;
    padding: 2rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    border: 2px dashed #dee2e6;
}

.waiting-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.waiting-state h4 {
    margin: 0 0 0.5rem 0;
    color: #495057;
}

.waiting-state p {
    margin: 0;
    font-size: 0.9rem;
}

/* === 강화된 반응형 미디어 쿼리 (세로형 레이아웃용) - 개선된 버전 === */

/* 대형 태블릿 (1024px ~ 1200px) */
@media (max-width: 1200px) {
    .results-list-vertical {
        gap: 0.5rem;
        padding: 0.7rem;
    }
    
    .result-row {
        min-height: 70px;
        padding: 0.7rem 0.9rem;
    }
    
    .rank-section {
        min-width: 70px;
        margin-right: 1rem;
    }
    
    .rank-emoji {
        font-size: 1.6rem;
    }
    
    .player-section .race-icon {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}

/* 태블릿 (768px ~ 1024px) */
@media (max-width: 1024px) {
    .results-list-vertical {
        gap: 0.5rem;
        padding: 0.6rem;
    }
    
    .result-row {
        min-height: 65px;
        padding: 0.6rem 0.8rem;
    }
    
    .rank-section {
        min-width: 65px;
        margin-right: 0.9rem;
    }
    
    .rank-emoji {
        font-size: 1.5rem;
        margin-bottom: 0.3rem;
    }
    
    .rank-number {
        font-size: 0.9rem;
        padding: 0.25rem 0.5rem !important;
    }
    
    .player-section {
        gap: 0.9rem;
    }
    
    .player-section .race-icon {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }
    
    .player-info-compact .player-name {
        font-size: 1.1rem;
    }
}

/* 모바일 (768px 이하) */
@media (max-width: 768px) {
    .results-list-vertical {
        gap: 0.4rem;
        padding: 0.5rem;
    }
    
    .result-row {
        min-height: 60px;
        padding: 0.5rem 0.7rem;
        flex-direction: row;
    }
    
    .rank-section {
        min-width: 55px;
        margin-right: 0.7rem;
    }
    
    .rank-emoji {
        font-size: 1.3rem;
        margin-bottom: 0.2rem;
    }
    
    .rank-number {
        font-size: 0.85rem;
        padding: 0.2rem 0.4rem !important;
    }
    
    .player-section {
        gap: 0.7rem;
    }
    
    .player-section .race-icon {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }
    
    .player-info-compact .player-name {
        font-size: 1rem;
    }
    
    .player-info-compact .player-details {
        gap: 0.3rem;
    }
    
    .race-badge {
        font-size: 0.75rem;
        padding: 0.15rem 0.5rem;
    }
    
    .trait-badge {
        font-size: 0.7rem;
        padding: 0.15rem 0.4rem;
    }
}

/* 작은 모바일 (480px 이하) */
@media (max-width: 480px) {
    .results-list-vertical {
        gap: 0.3rem;
        padding: 0.4rem;
    }
    
    .result-row {
        min-height: 55px;
        padding: 0.4rem 0.6rem;
        border-radius: 8px;
    }
    
    .rank-section {
        min-width: 50px;
        margin-right: 0.6rem;
    }
    
    .rank-emoji {
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
    }
    
    .rank-number {
        font-size: 0.8rem;
        padding: 0.15rem 0.35rem !important;
        min-width: 40px;
    }
    
    .player-section {
        gap: 0.6rem;
    }
    
    .player-section .race-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .player-info-compact .player-name {
        font-size: 0.95rem;
    }
    
    .player-info-compact .player-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }
    
    .race-badge {
        font-size: 0.7rem;
        padding: 0.1rem 0.4rem;
    }
    
    .trait-badge {
        font-size: 0.65rem;
        padding: 0.1rem 0.3rem;
    }
}

/* 초소형 화면 (360px 이하) */
@media (max-width: 360px) {
    .results-list-vertical {
        gap: 0.25rem;
        padding: 0.3rem;
    }
    
    .result-row {
        min-height: 50px;
        padding: 0.35rem 0.5rem;
    }
    
    .rank-section {
        min-width: 45px;
        margin-right: 0.5rem;
    }
    
    .rank-emoji {
        font-size: 1.1rem;
        margin-bottom: 0.1rem;
    }
    
    .rank-number {
        font-size: 0.75rem;
        padding: 0.1rem 0.3rem !important;
        min-width: 35px;
    }
    
    .player-section .race-icon {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
    
    .player-info-compact .player-name {
        font-size: 0.9rem;
    }
}

/* 다크 모드 지원 (필요시) */
@media (prefers-color-scheme: dark) {
    .improved-game-card {
        background: linear-gradient(145deg, #2a2a4a, #3a3a6a);
        color: #ffffff;
    }
    
    .player-name {
        color: #ffffff !important;
        background-color: rgba(0, 0, 0, 0.7) !important;
        border-color: rgba(255, 255, 255, 0.3) !important;
    }
    
    .game-title {
        color: #ffffff;
    }
}

/* 애니메이션 효과 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* 스케일 애니메이션 */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scale-in {
    animation: scaleIn 0.4s ease-out;
}

/* === 추가 수정: 등수 아이콘 표시 강제 === */

/* 등수 아이콘이 항상 표시되도록 강제 */
.rank-emoji,
*[class*="rank-emoji"],
.rank-section .rank-emoji {
    visibility: visible !important;
    opacity: 1 !important;
    display: inline-block !important;
    position: relative !important;
}

/* 호버 효과 제거 - 항상 표시 */
.rank-section:hover .rank-emoji,
.result-row:hover .rank-emoji {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* JavaScript로 숨겨진 요소들도 강제 표시 */
.rank-emoji[style*="display: none"],
.rank-emoji[style*="visibility: hidden"],
.rank-emoji[style*="opacity: 0"] {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* 등수별 이모지 확실히 표시 */
.rank-emoji::before {
    content: '';
}

.rank-emoji.rank-1::before,
.rank-emoji[data-rank="1"]::before {
    content: '🥇';
}

.rank-emoji.rank-2::before,
.rank-emoji[data-rank="2"]::before {
    content: '🥈';
}

.rank-emoji.rank-3::before,
.rank-emoji[data-rank="3"]::before {
    content: '🥉';
}

.rank-emoji.rank-4::before,
.rank-emoji[data-rank="4"]::before {
    content: '😢';
}

/* 텍스트 크기 문제 해결을 위한 최종 조정 */
.rank-section,
.player-section {
    max-width: 100% !important;
    overflow: visible !important;
}

.result-row {
    overflow: visible !important;
    white-space: normal !important;
}

/* 텍스트가 잘리지 않도록 보장 */
.player-name,
.rank-number,
.rank-text {
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
}
