/* 위키 전용 레이아웃 */
.wiki-body {
    background-color: #f5f7fa; /* 연한 회색 배경 */
}

.wiki-header {
    background: #1b499c; /* 협회 블루 */
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.wiki-header a { color: white; text-decoration: none; font-size: 14px; }
.wiki-header h1 { margin-top: 10px; font-size: 24px; }
.wiki-header .badge { background: #ff4757; font-size: 12px; padding: 3px 8px; border-radius: 4px; vertical-align: middle; margin-left: 10px;}

.wiki-container {
    display: flex;
    margin-top: 30px;
    gap: 30px;
}

/* 사이드바 */
.wiki-sidebar {
    width: 250px;
    flex-shrink: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 20px;
    height: fit-content;
}
.profile-box {
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}
.wiki-nav ul { list-style: none; padding: 0; }
.wiki-nav li { margin-bottom: 5px; }
.wiki-nav a {
    display: block;
    padding: 12px;
    color: #333;
    text-decoration: none;
    border-radius: 6px;
    transition: 0.2s;
}
.wiki-nav a:hover, .wiki-nav li.active a {
    background: #eef4ff;
    color: #1b499c;
    font-weight: bold;
}
.wiki-nav i { margin-right: 10px; width: 20px; text-align: center; }

/* 메인 콘텐츠 */
.wiki-content {
    flex-grow: 1;
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.alert-box {
    background: #fff3cd;
    color: #856404;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 30px;
    border: 1px solid #ffeeba;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.wiki-card {
    display: block;
    border: 1px solid #eee;
    padding: 20px;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: 0.3s;
    text-align: center;
}
.wiki-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-color: #1b499c;
}
.wiki-card .icon {
    font-size: 30px;
    color: #1b499c;
    margin-bottom: 15px;
}

/* 필터 버튼 */
.filter-buttons {
    margin-bottom: 30px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.filter-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s;
}
.filter-btn:hover { background: #f1f2f6; }
.filter-btn.active {
    background: #1b499c;
    color: white;
    border-color: #1b499c;
}

/* 캐릭터 그리드 */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

/* 캐릭터 카드 디자인 */
.char-card {
    background: white;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    overflow: hidden;
    transition: 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}
.char-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.char-img {
    position: relative;
    width: 100%;
    height: 380px; /* 이미지 높이 고정 */
    overflow: hidden;
    background: #f0f0f0;
}
.char-img img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 비율 유지하며 꽉 채우기 */
    object-position: top center; /* 얼굴 위주로 */
}

/* 랭크 배지 스타일 (수정됨) */
.char-rank {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 800;
    color: white;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    z-index: 2;
}

/* S급: 금색 그라데이션 + 반짝임 효과 */
.char-rank.rank-S { 
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%); 
    color: #fff;
    border: 1px solid #fff;
}
/* A급: 보라색 */
.char-rank.rank-A { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
/* B급: 파란색 */
.char-rank.rank-B { background: linear-gradient(135deg, #3498db, #2980b9); }
/* C급: 초록색 */
.char-rank.rank-C { background: linear-gradient(135deg, #2ecc71, #27ae60); }
/* D급: 주황색/갈색 계열 */
.char-rank.rank-D { background: #e67e22; }
/* E급: 회색 */
.char-rank.rank-E { background: #95a5a6; }

/* 비각성자 / 일반인 (N 클래스) */
.char-rank.rank-N, .char-rank.rank-일 { 
    background: #34495e; /* 짙은 네이비 */
    color: #ecf0f1;
    font-weight: 500;
    border: 1px solid #7f8c8d;
}

/* ?? / 측정불가 (특수) */
.char-rank.rank-Unknown {
    background: #000;
    color: #ff0000;
    font-family: 'Courier New', monospace;
}

.char-info {
    padding: 20px;
}
.char-group {
    font-size: 12px;
    color: #666;
    background: #f1f2f6;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 5px;
}
.char-info h3 {
    margin: 5px 0;
    font-size: 18px;
    color: #2c3e50;
}
.char-info h3 small {
    display: block;
    font-size: 13px;
    color: #95a5a6;
    font-weight: normal;
    margin-top: 2px;
}
.char-meta {
    font-size: 13px;
    color: #1b499c;
    font-weight: 500;
    margin-bottom: 10px;
}
.char-desc {
    font-size: 14px;
    color: #555;
    line-height: 1.5;
    /* 3줄 이상 넘어가면 말줄임표 */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 아코디언 스타일 */
.accordion-box {
    margin-top: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}
.accordion-item { border-bottom: 1px solid #eee; }
.accordion-item:last-child { border-bottom: none; }
.accordion-header {
    width: 100%;
    padding: 18px 25px;
    background: white;
    border: none;
    text-align: left;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.2s;
}
.accordion-header:hover { background: #f9f9f9; color: #1b499c; }
.accordion-body {
    display: none;
    padding: 20px 25px;
    background: #fdfdfd;
    border-top: 1px solid #eee;
    color: #555;
    line-height: 1.6;
}
.accordion-item.active .accordion-body { display: block; }
.accordion-item.active .icon { transform: rotate(180deg); }

.text-danger { color: #d63031; font-weight: bold; }
.text-info { color: #0984e3; font-weight: bold; }
.page-title {
    border-bottom: 2px solid #1b499c;
    padding-bottom: 15px;
    margin-bottom: 25px;
    color: #2c3e50;
    font-size: 22px;
}

/* 세력 카드 스타일 */
.faction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}
.faction-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    transition: 0.3s;
}
.faction-card:hover { transform: translateY(-5px); }

.f-header {
    padding: 20px;
    color: white;
    position: relative;
}
.f-header h3 { margin: 0; font-size: 20px; }
.f-header span { font-size: 12px; opacity: 0.8; letter-spacing: 1px; text-transform: uppercase; }

.f-body { padding: 20px; color: #555; font-size: 14px; line-height: 1.6; }
.f-body strong { color: #333; }
.f-body .quote {
    margin-top: 15px;
    font-style: italic;
    color: #7f8c8d;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid #ccc;
}

/* 적대 세력 스타일 */
.faction-card.hostile { border: 1px solid #fab1a0; }
.faction-card.hostile .f-header { background: #d63031; } /* 빨간색 통일 */

/* 가이드 스텝 박스 */
.step-box { display: flex; gap: 20px; margin-top: 20px; }
.step { background: #f8f9fa; padding: 20px; border-radius: 8px; flex: 1; border-top: 4px solid #1b499c; }
.step-num { font-size: 24px; font-weight: bold; color: #1b499c; opacity: 0.3; }

/* 헌터 세대 표 */
.gen-table { display: flex; flex-direction: column; gap: 10px; }
.gen-item { background: white; border: 1px solid #eee; padding: 15px; border-radius: 6px; }
.gen-item.highlight { border: 2px solid #1b499c; background: #eef4ff; }

/* 경제 표 */
.wiki-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
.wiki-table th, .wiki-table td { padding: 12px; border: 1px solid #ddd; text-align: center; }
.wiki-table th { background: #f1f2f6; }

/* 통화 박스 */
.currency-box { display: flex; gap: 20px; margin-top: 15px; }
.c-item { flex: 1; padding: 20px; border-radius: 8px; background: #eee; }
.c-item.coin { background: #fff3cd; border: 1px solid #ffeeba; }

/* 아이템 등급 */
.item-ranks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-top: 15px; }
.rank-box { padding: 15px; border-radius: 6px; background: #f1f2f6; border-left: 5px solid #ccc; }
.rank-box.rare { border-left-color: #3498db; }
.rank-box.unique { border-left-color: #9b59b6; }
.rank-box.legendary { border-left-color: #f1c40f; }

/* 국가별 동향 스타일 */
.nation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.nation-card {
    background: white;
    border: 1px solid #e1e4e8;
    border-radius: 10px;
    padding: 20px;
    transition: 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}
.nation-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    border-color: #1b499c;
}
.n-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid #f1f2f6;
    padding-bottom: 10px;
}
.n-header .flag { font-size: 24px; }
.n-header h4 { margin: 0; font-size: 18px; color: #2c3e50; }

.n-body { font-size: 14px; color: #555; line-height: 1.6; }
.n-body p { margin-bottom: 8px; }
.n-body strong { color: #2c3e50; font-weight: 600; }

/* 국가별 포인트 컬러 (선택 사항) */
.nation-card.usa { border-top: 4px solid #3c6382; }
.nation-card.china { border-top: 4px solid #e55039; }
.nation-card.japan { border-top: 4px solid #e1b12c; }
.nation-card.uk { border-top: 4px solid #0c2461; }

/* 모달 스타일 */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: none; /* 기본 숨김 */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
}
.modal-overlay.show { display: flex; }

.modal-box {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: popUp 0.3s ease-out;
}
.modal-box.danger { border: 2px solid #d63031; background: #fff5f5; }

.modal-icon { font-size: 40px; margin-bottom: 15px; }
.modal-icon.warning { color: #f1c40f; }
.modal-icon.danger { color: #d63031; }

.modal-box h3 { margin-top: 0; margin-bottom: 10px; color: #333; }
.modal-box p { color: #555; line-height: 1.5; margin-bottom: 25px; font-size: 15px; }

.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: 0.2s;
}
.btn-cancel { background: #eee; color: #555; }
.btn-cancel:hover { background: #ddd; }
.btn-confirm { background: #1b499c; color: white; }
.btn-confirm:hover { background: #163a7a; }
.btn-danger { background: #d63031; color: white; }
.btn-danger:hover { background: #c0392b; box-shadow: 0 0 10px rgba(214, 48, 49, 0.4); }

@keyframes popUp {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* 단말기 매뉴얼 박스 */
.device-manual-box {
    display: flex;
    gap: 40px;
    background: white;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #eee;
    align-items: center;
}
.device-visual {
    flex-shrink: 0;
}

/* 폰 목업 (순수 CSS) */
.mockup-phone {
    width: 160px;
    height: 300px;
    background: #333;
    border-radius: 20px;
    padding: 10px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    position: relative;
}
.mockup-phone .screen {
    background: #1b499c; /* 협회 배경색 */
    width: 100%;
    height: 100%;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}
.app-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    padding: 30px 15px;
}
.app-icon {
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}
.app-icon.active { background: #fff; color: #1b499c; } /* 활성 앱 */

.status-bar {
    position: absolute;
    top: 5px;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 8px;
    opacity: 0.8;
}
.home-btn {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: #555;
    border-radius: 2px;
}

/* 스펙 리스트 */
.device-specs h3 { margin-top: 0; color: #2c3e50; border-bottom: 2px solid #eee; padding-bottom: 10px; }
.spec-list { list-style: none; padding: 0; font-size: 15px; line-height: 1.8; }
.spec-list li { margin-bottom: 15px; }
.spec-list ul { margin-top: 5px; padding-left: 20px; color: #555; list-style: disc; }
.warning-text {
    background: #fff5f5;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #fab1a0;
    color: #d63031;
}

/* 등급 비교 박스 스타일 */
.rank-list { list-style: none; padding: 0; margin-top: 15px; }
.rank-list li { margin-bottom: 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }

.tag {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    color: white;
}
/* 시스템 등급 색상 */
.tag.normal { background: #95a5a6; }
.tag.rare { background: #3498db; }
.tag.unique { background: #9b59b6; }
.tag.legendary { background: #f1c40f; color: #333; }

/* 협회 등급 색상 (기존 rank-S 등 활용) */
.tag.rank-S { background: linear-gradient(135deg, #FFD700, #FFA500); color: black; }
.tag.rank-E { background: #7f8c8d; }

.example-text {
    background: #fff;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #eee;
    font-size: 13px;
    color: #555;
    margin-top: 10px;
}

/* =========================================
   모바일 최적화 (반응형 미디어 쿼리)
   화면 너비 768px 이하 (태블릿/스마트폰)
   ========================================= */
   @media screen and (max-width: 768px) {

    /* 1. 전체 레이아웃: 사이드바와 본문을 수직으로 배치 */
    .wiki-container {
        flex-direction: column; /* 가로 배치 -> 세로 배치 */
        gap: 15px;
        margin-top: 15px;
        padding: 0 15px; /* 좌우 여백 확보 */
    }

    /* 2. 사이드바 (내비게이션) 변형 */
    .wiki-sidebar {
        width: 100%; /* 전체 너비 사용 */
        padding: 15px;
        position: sticky; /* 스크롤 내려도 상단에 붙게 (선택사항) */
        top: 0;
        z-index: 100;
        box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    }
    
    .profile-box {
        display: none; /* 모바일에서는 프로필 박스 숨김 (공간 절약) */
    }

    /* 내비게이션 메뉴를 가로 스크롤 형태로 변경 (앱 메뉴처럼) */
    .wiki-nav ul {
        display: flex;
        overflow-x: auto; /* 가로 스크롤 허용 */
        gap: 10px;
        padding-bottom: 5px;
        white-space: nowrap; /* 줄바꿈 방지 */
        -webkit-overflow-scrolling: touch; /* 부드러운 스크롤 */
    }
    .wiki-nav ul::-webkit-scrollbar {
        display: none; /* 스크롤바 숨김 (깔끔하게) */
    }
    .wiki-nav li {
        margin-bottom: 0;
        flex: 0 0 auto;
    }
    .wiki-nav a {
        padding: 8px 12px;
        font-size: 13px;
        border: 1px solid #eee;
    }

    /* 3. 메인 콘텐츠 영역 */
    .wiki-content {
        padding: 20px; /* 내부 여백 축소 */
    }
    
    .wiki-header h1 {
        font-size: 18px; /* 헤더 폰트 크기 축소 */
    }
    .wiki-header .badge {
        display: none; /* 모바일에서 뱃지는 숨김 */
    }

    /* 4. 그리드 시스템 (카드들을 1열로 변경) */
    .card-grid, 
    .faction-grid, 
    .nation-grid,
    .item-ranks {
        grid-template-columns: 1fr; /* 무조건 1열 */
        gap: 15px;
    }

    /* 인물 카드: 모바일에서는 2열로 보여주는 게 나을 수도 있음 (너무 길어짐 방지) */
    /* 사진을 좀 줄이고 2열로 하거나, 그냥 1열로 큼직하게 하거나 선택 */
    .char-grid {
        grid-template-columns: 1fr; 
    }
    .char-img {
        height: 300px; /* 이미지 높이 약간 축소 */
    }

    /* 5. 컴포넌트별 세부 조정 */
    
    /* 필터 버튼 (가로 스크롤) */
    .filter-buttons {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
    }
    .filter-btn {
        flex: 0 0 auto; /* 버튼 크기 유지 */
    }

    /* 가이드 페이지 (스텝 박스) */
    .step-box {
        flex-direction: column; /* 세로로 쌓기 */
    }
    
    /* 단말기 매뉴얼 박스 */
    .device-manual-box {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }
    .device-visual {
        margin: 0 auto; /* 목업 중앙 정렬 */
    }
    .device-specs {
        text-align: left; /* 텍스트는 다시 왼쪽 정렬 */
    }

    /* 아이템 비교 박스 */
    .grade-comparison {
        flex-direction: column; /* 세로 배치 */
    }
    .currency-box {
        flex-direction: column;
    }

    /* 테이블 (가로 스크롤) */
    .wiki-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap; /* 내용이 길면 줄바꿈 대신 스크롤 */
    }

    /* 모달 */
    .modal-box {
        width: 90%; /* 화면 꽉 차게 */
        padding: 20px;
    }
    .modal-icon {
        font-size: 30px;
    }
    
    /* 기밀 문서 폰트 크기 조정 */
    .page-title {
        font-size: 18px;
    }
}