:root {
    --bg-dark: #050505;
    --card-dark: #141414;
    --text-main: #e0e0e0;
    --text-sub: #a0a0a0;
    
    /* 카드 색상 (고정) */
    --neon-green: #00e676;  
    --neon-red: #ff1744;   
    
    /* 기본 강조색 (서울 기준) */
    --accent-color: #2979ff; 
    
    --border-color: #333333;
    --shadow-color: rgba(0,0,0,0.9);
}

/* 🌟 지역별 테마 색상 (확실하게 적용) */
[data-theme="seoul"] { --accent-color: #2979ff; } /* 서울: 블루 */
[data-theme="busan"] { --accent-color: #76ff03; } /* 부산: 라임/연두 */
[data-theme="jeju"]  { --accent-color: #ff9100; } /* 제주: 오렌지 */

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Noto Sans KR', sans-serif;
    margin: 0; padding: 0;
    line-height: 1.6;
    transition: background-color 0.3s;
}

.container {
    max-width: 640px; margin: 0 auto; min-height: 100vh;
    background-color: #000000; box-shadow: 0 0 50px var(--shadow-color);
    position: relative; padding-bottom: 20px;
}

/* 헤더 */
header {
    background-image: url('background_only.png');
    background-size: cover; background-position: center; background-repeat: no-repeat;
    background-color: rgba(0, 0, 0, 0.85); background-blend-mode: multiply; 
    text-align: center; padding: 70px 20px 30px 20px;
    border-bottom: 1px solid var(--border-color);
}
header h1 {
    font-size: 2.4rem; margin: 0; font-weight: 900; letter-spacing: -1px; color: #fff;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.neon-text {
    color: #fff; text-shadow: 0 0 15px rgba(255, 255, 255, 0.4); font-style: italic;
}
header p {
    color: var(--text-sub); font-size: 0.95rem; margin-top: 10px; font-weight: 300; letter-spacing: 1px;
}

/* 요일 선택 */
.day-selector { display: flex; gap: 10px; padding: 20px; background: #000; }
.day-btn {
    flex: 1; padding: 12px 5px; background: #121212;
    border: 1px solid #333; color: #777; border-radius: 8px;
    cursor: pointer; font-weight: bold; font-size: 1rem; transition: 0.3s; line-height: 1.2;
}
.day-btn span { font-size: 0.75rem; font-weight: normal; }

/* 활성화된 요일 버튼 (테마색 적용) */
.day-btn.active {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-color);
}

/* 스티키 헤더 */
#sticky-header {
    position: sticky; top: 0; z-index: 1000;
    background: rgba(10, 10, 10, 0.95); backdrop-filter: blur(8px);
    border-bottom: 1px solid #333;
}
.sub-nav { display: flex; justify-content: center; gap: 15px; padding: 15px 0 5px 0; }
.loc-btn {
    padding: 8px 20px; background: #1f1f1f; color: #aaa;
    border: 1px solid #444; border-radius: 20px;
    font-size: 0.9rem; font-weight: bold; cursor: pointer; transition: 0.2s;
}

/* 활성화된 지역 버튼 (테마색 적용) */
.loc-btn.active {
    background: var(--accent-color);
    color: #000; 
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
}

#race-selector {
    display: flex; gap: 10px; overflow-x: auto; padding: 15px 20px; scrollbar-width: none;
}
#race-selector::-webkit-scrollbar { display: none; }
.race-btn {
    flex: 0 0 auto; width: 50px; height: 50px;
    border-radius: 50%; background: #1a1a1a; border: 1px solid #333; color: #888;
    font-weight: bold; font-size: 1.1rem; cursor: pointer;
    transition: 0.2s; display: flex; align-items: center; justify-content: center;
}

/* 활성화된 경주 버튼 (테마색 적용) */
.race-btn.active {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
    transform: scale(1.1); box-shadow: 0 0 10px var(--accent-color);
}

/* 결과 영역 */
#result-area { padding: 20px; }
.race-info-box {
    margin-bottom: 30px; padding: 15px; background: rgba(255,255,255,0.03);
    border-radius: 12px; border: 1px solid #333;
    /* 왼쪽 테두리에 지역 테마색 적용 */
    border-left: 4px solid var(--accent-color); 
}
.race-header-row {
    display: flex; justify-content: space-between; align-items: flex-start;
    flex-wrap: wrap; gap: 10px;
}
/* [수정] 제목 스타일 (거리 뱃지와 간격 추가) */
#race-title { 
    font-size: 1.6rem; margin: 0; color: #fff; line-height: 1.2; 
    margin-right: 10px; /* 🌟 옆에 거리 뱃지가 붙으므로 간격 확보 */
}

/* 🌟 [NEW] 거리 표시 뱃지 (기존 badge-chaos 대체) */
.badge-dist {
    display: inline-block;
    padding: 2px 10px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    color: #ddd;
    background: rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

/* (아래는 기존과 동일하지만 같이 복사해서 덮어쓰세요) */
.info-desc { font-size: 0.8rem; color: #666; margin: 10px 0 0 0; }

.util-btn-group { display: flex; gap: 8px; }
.util-btn {
    padding: 6px 12px; border-radius: 6px; font-size: 0.85rem; font-weight: bold;
    cursor: pointer; border: none; color: #fff; background: #333; transition: 0.2s;
}
.util-btn:hover { background: #444; }
.util-btn.share { background: #fee500; color: #000; }

/* 카드 디자인 */
.cards-container { display: flex; flex-direction: column; gap: 25px; }
.card {
    background: var(--card-dark); border-radius: 16px; overflow: hidden;
    position: relative; border: 1px solid #333;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); transition: transform 0.2s;
}
.card:hover { transform: translateY(-2px); }
.game-changer { border-color: var(--neon-green); }
.game-changer .card-header { 
    background: linear-gradient(90deg, rgba(0, 230, 118, 0.1), transparent);
    color: var(--neon-green); border-bottom: 1px solid rgba(0, 230, 118, 0.2);
}
.game-changer .horse-no { color: var(--neon-green); }
.nuclear { border-color: var(--neon-red); }
.nuclear .card-header { 
    background: linear-gradient(90deg, rgba(255, 23, 68, 0.15), transparent);
    color: var(--neon-red); border-bottom: 1px solid rgba(255, 23, 68, 0.3);
}
.nuclear .horse-no { color: var(--neon-red); }
.card-header {
    padding: 12px 20px; font-weight: 900; font-size: 1.1rem;
    letter-spacing: 1px; display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 25px 20px; display: flex; flex-direction: column; gap: 15px; }
.horse-info { display: flex; align-items: center; gap: 15px; }
.horse-no {
    font-size: 3rem; font-weight: 900; line-height: 1;
    text-shadow: 0 0 15px rgba(0,0,0,0.8); font-family: 'Roboto', sans-serif;
}
.horse-name { font-size: 1.5rem; font-weight: bold; color: #fff; }
.ai-comment {
    background: rgba(255,255,255,0.05); padding: 15px; border-radius: 10px;
    font-size: 0.95rem; color: #ccc; border: 1px solid rgba(255,255,255,0.05);
}
.ai-comment .label {
    display: block; font-size: 0.7rem; color: #666; margin-bottom: 6px;
    font-weight: 900; text-transform: uppercase; letter-spacing: 1px;
}
.ai-comment p { margin: 0; line-height: 1.5; }

/* 링크 섹션 */
.cross-link-area {
    margin-top: 40px; margin-bottom: 40px; text-align: center; padding: 30px 20px;
    background: #111; border-radius: 16px; border: 1px solid #222;
}
.basic-link-btn {
    display: inline-block; padding: 15px 30px; background: #fff; color: #000;
    text-decoration: none; font-weight: 900; border-radius: 30px;
    transition: 0.3s; font-size: 1.1rem; box-shadow: 0 0 20px rgba(255,255,255,0.15);
}
.basic-link-btn:hover { background: #f0f0f0; box-shadow: 0 0 30px rgba(255,255,255,0.4); transform: translateY(-3px); }

/* 인트로 박스 */
.intro-box {
    margin: 20px; padding: 25px; background: #121212; border-radius: 12px;
    text-align: center; border: 1px solid #333; word-break: keep-all;
}
.intro-box h3 { color: #fff; margin-top: 0; font-size: 1.1rem; font-weight: 800; }
.intro-box p { color: #888; font-size: 0.85rem; line-height: 1.7; margin-bottom: 10px; }
.engine-tag {
    margin-top: 20px; font-family: 'Roboto Mono', monospace;
    color: #555; font-size: 0.75rem; letter-spacing: 1px;
}
.neon-engine { color: var(--neon-green); font-weight: bold; }

/* 푸터 */
footer { text-align: center; padding: 40px 20px; color: #444; font-size: 0.8rem; margin-top: 20px; }
.warning-text { color: rgba(0, 255, 128, 0.7); text-shadow: 0 0 5px rgba(0, 255, 128, 0.2); font-weight: 500; margin: 5px 0; }
.copyright { color: #333; margin-top: 20px; letter-spacing: 1px; }

.hidden { display: none !important; }
#loading, #error-msg { text-align: center; padding: 80px 20px; color: #555; font-weight: bold; }

/* 🌟 [NEW] 포털 섹션 (항상 노출) */
.portal-section {
    padding: 20px 20px 0 20px; /* 위치 조정 */
}

/* 포털 버튼 디자인 */
.portal-card-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1a1a1a, #0d0d0d);
    border: 1px solid #333;
    padding: 20px;
    border-radius: 16px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

/* 버튼 내부 텍스트 */
.portal-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.portal-content .sub-text {
    font-size: 0.8rem;
    color: #888;
    font-weight: 500;
}

.portal-content .main-text {
    font-size: 1.1rem;
    color: #fff;
    font-weight: bold;
}

.portal-content .main-text strong {
    /* 기존 블루(#2979ff) -> 골드(#ffd700) 변경 */
    color: #ffd700; 
    font-weight: 900;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
}

/* 화살표 아이콘 */
.portal-icon {
    font-size: 1.5rem;
    color: #444;
    transition: all 0.3s ease;
    font-weight: bold;
}

/* ✨ 마우스 올렸을 때 효과 (골드빛으로 믓지게!) */
.portal-card-btn:hover {
    /* 테두리: 골드 */
    border-color: #ffd700; 
    /* 그림자: 골드 네온 글로우 */
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.25); 
    transform: translateY(-3px);
}

.portal-card-btn:hover .portal-icon {
    /* 아이콘: 골드 */
    color: #ffd700; 
    transform: translateX(5px); /* 화살표가 오른쪽으로 이동 */
}

.portal-card-btn:active {
    transform: scale(0.98);
}

/* =========================================
   📱 모바일 최적화 (Mobile Responsive)
   ========================================= */

/* 기본 헤더 스타일 (PC/태블릿) */
header h1 {
    font-size: 2.2rem;
    line-height: 1.3; /* 줄간격 조정 */
    margin-bottom: 10px;
}

header h1 .neon-text {
    display: inline-block; /* 블록 요소로 변경하여 줄바꿈 효과 강화 */
    margin-top: 5px;       /* 위쪽 텍스트와 간격 벌리기 */
    font-size: 2.6rem;     /* THE BLACK을 더 크게 강조 */
}

/* 📱 스마트폰 화면 (480px 이하) */
@media (max-width: 480px) {
    .container {
        padding-bottom: 80px; /* 하단 여백 확보 */
    }

    header { 
        padding: 40px 15px 20px 15px; /* 상단 패딩 조정 */
    } 

    header h1 { 
        font-size: 1.6rem; /* 모바일에서 제목 크기 살짝 축소 */
    }

    /* THE BLACK 부분 모바일 스타일 */
    header h1 .neon-text { 
        display: block;    /* 강제 줄바꿈 (확실하게) */
        font-size: 2.0rem; /* 모바일에서도 충분히 크게 */
        margin-top: 2px;
    }

    header p { 
        font-size: 0.9rem; 
        word-break: keep-all; /* 단어 단위 줄바꿈 */
        padding: 0 10px;
    }

    /* 요일 선택 버튼 최적화 */
    .day-selector { 
        margin: 0 10px 20px; 
        gap: 8px;
    }
    
    .day-btn {
        font-size: 0.9rem;
        padding: 10px 5px;
    }
    
    .day-btn span {
        font-size: 0.7rem;
    }

    /* 결과 카드 영역 패딩 */
    #result-area { 
        padding: 0 10px; 
    }

    /* 카드 내부 폰트 조정 */
    .horse-name {
        font-size: 1.4rem;
    }
    
    .ai-comment p {
        font-size: 0.95rem;
    }

    /* 푸터 여백 */
    footer { 
        margin-left: 15px; 
        margin-right: 15px; 
        font-size: 0.75rem;
    }
}

/* --- 🏆 명예의 전당 (Hall of Fame) 버튼 스타일 : 로얄 퍼플 테마 --- */
.fame-btn {
    width: 100%;
    cursor: pointer;
    text-align: left;
    /* 아주 어두운 보라빛이 감도는 블랙 배경 */
    background: linear-gradient(135deg, #050505, #120024); 
    border: 1px solid #4a148c; /* 딥 퍼플 테두리 */
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    transition: all 0.3s ease;
}

.fame-btn:hover {
    border-color: #d500f9; /* 밝은 네온 퍼플 */
    box-shadow: 0 0 20px rgba(213, 0, 249, 0.25); /* 보라색 후광 */
    transform: translateY(-2px);
}

.fame-btn .sub-text {
    color: #b388ff; /* 연한 라벤더색 */
}

.fame-btn .main-text strong {
    color: #ea80fc; /* 화사한 퍼플 핑크 */
    text-shadow: 0 0 10px rgba(234, 128, 252, 0.4);
    font-family: 'Roboto', sans-serif;
    font-weight: 900;
}

.fame-btn .portal-icon {
    color: #d500f9; /* 아이콘도 퍼플 */
}

/* --- 팝업창(모달) 스타일 --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9); z-index: 9999;
    backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center;
    padding: 20px; box-sizing: border-box;
}

.modal-window {
    width: 100%; max-width: 480px;
    background: #0a0a0a; border: 1px solid #333;
    border-radius: 16px; overflow: hidden;
    /* 보라색 은은한 그림자 */
    box-shadow: 0 0 40px rgba(124, 77, 255, 0.15);
    animation: slideUp 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    display: flex; flex-direction: column;
    max-height: 80vh;
}

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 20px; background: #120024; /* 헤더도 아주 어두운 보라색 */
    border-bottom: 1px solid #333;
}

.modal-header h3 { 
    margin: 0; 
    color: #ea80fc; /* 제목: 퍼플 핑크 */
    font-size: 0.9rem; 
    letter-spacing: 2px; font-weight: 900;
}
.close-btn { background: none; border: none; color: #888; font-size: 1.5rem; cursor: pointer; transition: 0.2s;}
.close-btn:hover { color: #fff; }

.modal-body {
    overflow-y: auto; padding: 20px;
    scrollbar-width: thin; scrollbar-color: #333 #111;
}
.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* --- 적중 내역 리스트 아이템 --- */
.hit-item {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 12px; padding: 15px;
    border-radius: 8px; border: 1px solid #2a2a2a;
    transition: 0.2s;
}
.hit-info-group { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.hit-meta { font-size: 0.75rem; color: #666; display: flex; align-items: center; gap: 8px; }
.hit-date { font-family: 'Roboto Mono', monospace; color: #888; }
.hit-race { color: #ccc; font-weight: bold; }

.hit-desc { font-size: 0.95rem; color: #e0e0e0; font-weight: 500; margin: 0; line-height: 1.4; }

.hit-tags-area { display: flex; gap: 5px; margin-top: 4px; }
.hit-tag {
    font-size: 0.65rem; padding: 2px 6px; 
    border: 1px solid; border-radius: 4px;
    font-weight: bold; background: rgba(0,0,0,0.3);
}

/* 배당 뱃지 */
.hit-odds-badge {
    font-size: 1.1rem; font-weight: 900;
    padding: 10px 0; width: 70px; text-align: center;
    border-radius: 8px; color: #fff; background: #222;
    font-family: 'Roboto', sans-serif; margin-left: 15px;
    border: 1px solid #333;
}

/* 🔥 고배당 (30배~) - 붉은색 */
.odds-high {
    background: linear-gradient(135deg, #b71c1c, #5f0000);
    border-color: #ff5252; color: #ff8a80;
    box-shadow: 0 0 10px rgba(255, 82, 82, 0.2);
}
/* 💎 전설 (100배~) - 보라색 (테마와 일체감) */
.odds-legendary {
    background: linear-gradient(135deg, #6200ea, #311b92);
    border-color: #b388ff; color: #fff;
    box-shadow: 0 0 15px rgba(124, 77, 255, 0.4);
    animation: pulse 2s infinite;
}