/**
 * 마이랭킹 2026 - AI 라이벌 매치 예측 + 자동 매칭 스타일
 */

/* ── 키프레임 ── */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulseVs {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes gradientFlow {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}
@keyframes barGrow {
    from { width: 0; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes overlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes pulseRing {
    0%   { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}
@keyframes badgePop {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ── 도움말 버튼 ── */
.rival-help-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
    vertical-align: middle;
    color: #9aa0a6;
    transition: color 0.2s;
    line-height: 1;
}
.rival-help-btn:hover { color: #1a73e8; }
.rival-help-btn .material-symbols-outlined { font-size: 20px; }

.rival-help-bubble {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: #1f2937;
    color: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
    width: 300px;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    animation: fadeSlideUp 0.2s ease;
}
.rival-help-bubble::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 20px;
    border: 6px solid transparent;
    border-bottom-color: #1f2937;
}
.rival-help-bubble p { margin: 0; }
.rival-help-bubble.show { display: block; }

h1 { position: relative; }

/* ── 모드 탭 ── */
.rival-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: #f0f0f0;
    border-radius: 12px;
    padding: 4px;
}

.rival-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.25s;
}

.rival-tab .material-symbols-outlined {
    font-size: 18px;
}

.rival-tab.active {
    background: #fff;
    color: #1a73e8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.rival-tab:not(.active):hover {
    color: #333;
    background: rgba(255,255,255,0.5);
}

/* ── 입력 카드 ── */
.rival-input-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.rival-input-row .inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.rival-input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
    background: #fafafa;
}

.rival-input:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
    background: #fff;
}

.rival-vs-text {
    font-weight: 800;
    font-size: 15px;
    color: #fff;
    flex-shrink: 0;
    background: linear-gradient(135deg, #1a73e8, #ea4335);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulseVs 2s ease-in-out infinite;
    letter-spacing: 1px;
}

.rival-target-date {
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    width: 150px;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.rival-target-date:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.rival-input-row .cateBtns {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── 안내 메시지 ── */
.rival-guide {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px;
    color: #666;
    font-size: 14px;
    text-align: center;
    justify-content: center;
}

.rival-guide .material-symbols-outlined {
    font-size: 20px;
    color: #999;
}

/* ── 매칭 애니메이션 오버레이 ── */
.matching-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.matching-overlay.visible {
    opacity: 1;
}

.matching-content {
    text-align: center;
    color: #fff;
}

.matching-spinner {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: #4a9af5;
    border-right-color: #ea4335;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: relative;
}

.matching-spinner::after {
    content: '';
    position: absolute;
    top: -8px; left: -8px; right: -8px; bottom: -8px;
    border: 2px solid rgba(26, 115, 232, 0.3);
    border-radius: 50%;
    animation: pulseRing 1.5s ease-out infinite;
}

.matching-text {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.matching-subtext {
    font-size: 13px;
    opacity: 0.7;
}

/* ── 필터 ── */
.rival-filter { margin-bottom: 16px; }
.rival-filter .filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rival-filter .filter-label { font-size: 13px; color: #666; font-weight: 500; }
.rival-filter .filter-selects { display: flex; gap: 8px; }
.rival-filter .filter-select {
    padding: 6px 10px; border: 1px solid #ddd; border-radius: 6px;
    font-size: 13px; outline: none; background: #fff; cursor: pointer; transition: border-color 0.2s;
}
.rival-filter .filter-select:hover { border-color: #1a73e8; }

/* ── 매치 헤더 ── */
.rival-match-header {
    background: linear-gradient(135deg, #0d47a1, #1a73e8, #4a9af5, #1a73e8, #0d47a1);
    background-size: 300% 300%;
    animation: gradientFlow 6s ease infinite;
    border-radius: 14px;
    padding: 28px 20px;
    color: #fff;
    text-align: center;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.rival-match-header::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.08) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
    pointer-events: none;
}

.rival-match-header .match-badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
    animation: badgePop 0.5s ease-out;
}

.rival-match-header .match-badge #matchScoreVal {
    font-weight: 800;
}

.rival-match-header .match-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 6px;
    letter-spacing: 1px;
    position: relative;
    z-index: 1;
}

.rival-match-header .match-subtitle {
    font-size: 13px;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* ── 라이벌 선택 탭 ── */
.rival-selector {
    display: flex; gap: 6px; justify-content: center;
    margin-top: 12px; flex-wrap: wrap;
    position: relative; z-index: 1;
}
.rival-sel-btn {
    padding: 6px 16px; border-radius: 20px; border: 1.5px solid rgba(255,255,255,0.4);
    background: transparent; color: rgba(255,255,255,0.8); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
.rival-sel-btn:hover { background: rgba(255,255,255,0.1); }
.rival-sel-btn.active {
    background: #fff; color: #1a73e8; border-color: #fff;
}
.rival-sel-score { font-weight: 400; font-size: 11px; opacity: 0.8; margin-left: 4px; }

/* ── 동명이인 팀 필터 ── */
.team-filter {
    position: relative;
    z-index: 1;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.team-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    padding: 6px 16px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0 auto;
}

.team-filter-toggle:hover {
    background: rgba(255,255,255,0.2);
}

.team-filter-toggle .material-symbols-outlined {
    font-size: 16px;
}

.team-filter-toggle .toggle-arrow {
    transition: transform 0.25s;
}

.team-filter-toggle.open .toggle-arrow {
    transform: rotate(180deg);
}

.team-filter-body {
    margin-top: 10px;
}

.team-filter-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 10px;
}

.team-filter-btn {
    padding: 5px 14px;
    border: 1.5px solid rgba(255,255,255,0.5);
    border-radius: 20px;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.team-filter-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.7);
}

.team-filter-btn.active {
    background: #fff;
    color: #1a73e8;
    border-color: #fff;
}

.team-filter-apply {
    padding: 6px 24px;
    border: none;
    border-radius: 20px;
    background: rgba(255,255,255,0.95);
    color: #1a73e8;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.team-filter-apply:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ── 2x2 그리드 ── */
.rival-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.rival-grid > .card {
    display: flex;
    flex-direction: column;
    transition: transform 0.25s, box-shadow 0.25s;
    opacity: 0;
    animation: fadeSlideUp 0.5s ease-out forwards;
}

.rival-grid > .card:nth-child(1) { animation-delay: 0.05s; }
.rival-grid > .card:nth-child(2) { animation-delay: 0.15s; }
.rival-grid > .card:nth-child(3) { animation-delay: 0.25s; }
.rival-grid > .card:nth-child(4) { animation-delay: 0.35s; }

.rival-grid > .card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.rival-grid > .card > .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ── 승률 게이지 ── */
.rival-gauge-card { margin-bottom: 0; }
.rival-gauge-card .card-body { padding: 20px; }

.gauge-labels { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.gauge-labels .label-a { color: #1a73e8; }
.gauge-labels .label-b { color: #ea4335; }

.gauge-numbers { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.gauge-number { font-size: 36px; font-weight: 800; line-height: 1; }
.gauge-number.a { color: #1a73e8; }
.gauge-number.b { color: #ea4335; }
.gauge-number .unit { font-size: 18px; font-weight: 600; opacity: 0.7; }

.gauge-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: #eee; margin-bottom: 10px; gap: 2px; }
.gauge-fill-a { background: linear-gradient(90deg, #1a73e8, #4a9af5); border-radius: 7px 0 0 7px; transition: width 1s cubic-bezier(0.22,0.61,0.36,1); min-width: 8px; }
.gauge-fill-b { background: linear-gradient(90deg, #f56a5a, #ea4335); border-radius: 0 7px 7px 0; transition: width 1s cubic-bezier(0.22,0.61,0.36,1); min-width: 8px; }
.gauge-fill-a.winner { box-shadow: 0 0 10px rgba(26,115,232,0.5); }
.gauge-fill-b.winner { box-shadow: 0 0 10px rgba(234,67,53,0.5); }
.gauge-verdict { text-align: center; font-size: 13px; color: #888; font-weight: 500; }

/* ── 카드 공통 헤더 ── */
.rival-gauge-card h3,
.rival-radar-card h3,
.rival-stats-card h3,
.rival-comment-card h3,
.rival-history-card h3 {
    font-size: 14px; font-weight: 700; margin-bottom: 14px;
    display: flex; align-items: center; gap: 6px;
    color: #444; text-transform: uppercase; letter-spacing: 0.3px;
}

.rival-gauge-card h3 .material-symbols-outlined,
.rival-radar-card h3 .material-symbols-outlined,
.rival-stats-card h3 .material-symbols-outlined,
.rival-comment-card h3 .material-symbols-outlined,
.rival-history-card h3 .material-symbols-outlined {
    font-size: 18px; color: #1a73e8;
}

/* ── 레이더 ── */
.rival-radar-card { margin-bottom: 0; }
.rival-radar-card .card-body { padding: 16px; }
.rival-radar-container { height: 300px; position: relative; }
.rival-radar-legend { display: flex; justify-content: center; gap: 24px; margin-top: 10px; font-size: 12px; font-weight: 600; color: #666; }
.rival-radar-legend .legend-item { display: flex; align-items: center; gap: 6px; }
.rival-radar-legend .legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-dot.a { background: #1a73e8; }
.legend-dot.b { background: #ea4335; }

/* ── 상세 비교 테이블 ── */
.rival-stats-card { margin-bottom: 0; }
.rival-stats-card .card-body { padding: 16px; }

.rival-stats-table { width: 100%; border-collapse: separate; border-spacing: 0 4px; }
.rival-stats-table th { padding: 8px; text-align: center; font-size: 12px; font-weight: 700; color: #999; text-transform: uppercase; letter-spacing: 0.5px; border: none; }
.rival-stats-table th:first-child { color: #1a73e8; }
.rival-stats-table th:last-child { color: #ea4335; }

.rival-stats-table tbody tr {
    transition: transform 0.2s, background-color 0.2s;
    cursor: default; opacity: 0; animation: fadeSlideUp 0.35s ease-out forwards;
}
.rival-stats-table tbody tr:nth-child(1) { animation-delay: 0.4s; }
.rival-stats-table tbody tr:nth-child(2) { animation-delay: 0.5s; }
.rival-stats-table tbody tr:nth-child(3) { animation-delay: 0.6s; }
.rival-stats-table tbody tr:nth-child(4) { animation-delay: 0.7s; }
.rival-stats-table tbody tr:nth-child(5) { animation-delay: 0.8s; }
.rival-stats-table tbody tr:hover { background-color: #f5f8ff; transform: scale(1.01); }

.rival-stats-table td { padding: 10px 8px; text-align: center; font-size: 14px; border: none; vertical-align: middle; }
.rival-stats-table td:first-child, .rival-stats-table td:last-child { font-weight: 600; font-size: 15px; }
.rival-stats-table td:nth-child(2) { font-weight: 500; color: #888; font-size: 12px; white-space: nowrap; }
.rival-stats-table .stat-winner { color: #34a853; font-weight: 700; }

.stat-bar-wrapper { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stat-bar-wrapper .stat-value { font-size: 15px; font-weight: 600; }
.stat-bar-track { width: 100%; height: 4px; background: #eee; border-radius: 2px; overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 2px; animation: barGrow 0.8s ease-out forwards; }
.stat-bar-fill.a { background: linear-gradient(90deg, #1a73e8, #4a9af5); }
.stat-bar-fill.b { background: linear-gradient(90deg, #ea4335, #f56a5a); }
.stat-bar-fill.winner { background: linear-gradient(90deg, #34a853, #5bc974); }

/* ── AI 코멘트 ── */
.rival-comment-card { margin-bottom: 0; }
.rival-comment-card .card-body { padding: 20px; }
.rival-comment-card h3 { color: #1a73e8; }
.rival-comment-text { font-size: 14px; line-height: 1.8; color: #333; min-height: 40px; }
.rival-comment-text .comment-block { margin: 0; }
.rival-comment-text .comment-block:last-child { margin-top: 12px; padding: 10px 14px; background: #f0f7ff; border-radius: 8px; border-left: 3px solid #1a73e8; }
.rival-comment-text .typing-cursor {
    display: inline-block; width: 2px; height: 16px; background: #1a73e8;
    margin-left: 2px; vertical-align: text-bottom; animation: blink 0.7s step-end infinite;
}
.rival-disclaimer { margin-top: 14px; font-size: 11px; color: #aaa; padding-top: 10px; border-top: 1px dashed #e0e0e0; }

/* ── 기록 히스토리 카드 ── */
.rival-history-card {
    margin-bottom: 16px;
    opacity: 0;
    animation: fadeSlideUp 0.5s ease-out 0.45s forwards;
}

.rival-history-card .card-body {
    padding: 20px;
}

.rival-history-container {
    height: 320px;
    position: relative;
    margin-bottom: 16px;
}

/* ── 맞대결 이력 ── */
.encounter-title {
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    color: #444;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.encounter-title .material-symbols-outlined {
    font-size: 18px;
    color: #ff9800;
}

.encounter-title #encounterSummary {
    font-weight: 500;
    font-size: 12px;
    color: #888;
}

.encounter-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.encounter-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #f8f9fa;
    font-size: 13px;
    transition: transform 0.2s;
}

.encounter-item:hover {
    transform: translateX(4px);
}

.encounter-item.enc-win-a {
    border-left: 3px solid #1a73e8;
}

.encounter-item.enc-win-b {
    border-left: 3px solid #ea4335;
}

.encounter-item.enc-draw {
    border-left: 3px solid #999;
}

.enc-date {
    font-weight: 600;
    color: #555;
    white-space: nowrap;
    min-width: 80px;
}

.enc-comp {
    flex: 1;
    color: #777;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.enc-records {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    white-space: nowrap;
}

.enc-rec-a { color: #1a73e8; }
.enc-rec-b { color: #ea4335; }
.enc-vs { color: #ccc; font-size: 11px; font-weight: 400; }

.enc-result {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* ── 반응형: 768px ── */
@media (max-width: 768px) {
    .rival-grid { grid-template-columns: 1fr; }
    .rival-input-row { flex-direction: row; }
    .rival-input-row .inputs { width: 50%; }
    .rival-target-date { width: 100%; }
    .rival-input-row .cateBtns { width: 100%; justify-content: center; }
    .rival-match-header .match-title { font-size: 18px; }
    .rival-radar-container { height: 260px; }
    .gauge-number { font-size: 30px; }
    .rival-stats-table td, .rival-stats-table th { padding: 8px 4px; font-size: 13px; }
    .rival-stats-table td:first-child, .rival-stats-table td:last-child { font-size: 14px; }
    .rival-history-container { height: 260px; }

    .rival-target-date {
        display: none;
        width: 100%;
    }

    .rival-input-row .cateBtns {
        width: 50%; gap: 0px;
        justify-content: center;
    }
    .rival-input-row .cateBtns button {
        width: 50%; padding: 10px 14px;
    }
    .rival-input-row .cateBtns button:first-child {
        border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-right: 0px;
    }
    .rival-input-row .cateBtns button:last-child {
        border-top-left-radius: 0px; border-bottom-left-radius: 0px; border-left: 0px;
    }

    #manualInputCard .rival-input-row { flex-direction: column; }
    #manualInputCard .rival-input-row .inputs { width: 100%; }
    #manualInputCard .rival-input-row .cateBtns {
        width: 100%; gap: 0px;
        justify-content: center;
    }
    #manualInputCard .rival-input-row .cateBtns button {
        width: 40%; padding: 10px 14px;
    }
    .rival-filter .filter-row {
        flex-direction: row;
    }
    .rival-filter .filter-label {
        width: 30%; 
        margin: 0px; padding: 0px;
        border-bottom: 0px; 
    }
    .rival-filter .filter-selects {
        width: 60%;
    }
    .rival-filter .filter-selects select{
        width: 40%;
    }

    .encounter-item {
        flex-wrap: wrap;
        gap: 6px;
    }
    .enc-comp { order: 4; flex-basis: 100%; }
}

/* ── 반응형: 480px ── */
@media (max-width: 480px) {
    .rival-tabs { font-size: 13px; }
    .rival-tab { padding: 8px 10px; font-size: 13px; }
    .rival-match-header { padding: 20px 14px; }
    .rival-match-header .match-title { font-size: 16px; }
    .rival-match-header .match-subtitle { font-size: 12px; }
    .gauge-number { font-size: 26px; }
    .gauge-number .unit { font-size: 14px; }
    .gauge-bar { height: 10px; }
    .rival-radar-container { height: 220px; }
    .rival-stats-table td, .rival-stats-table th { padding: 6px 2px; font-size: 12px; }
    .rival-stats-table td:first-child, .rival-stats-table td:last-child { font-size: 13px; }
    .rival-comment-text { font-size: 13px; }
    .rival-history-container { height: 220px; }
}
