/* 사서 기록 칼럼 스타일 */
    .record-column { 
        border: 1px solid #ffffff00; border-radius: 4px; background: #3e526800; 
        font-size: 12px; /* 🚩 [추가] '기록 없음' 텍스트 크기 조정 */
        padding: 1px; /* 🚩 [추가] 내부 여백 추가 */
    }
    .record-column h2 { border-bottom: 1px solid #000000; }
    .record-item {
        background: rgba(255,255,255,0.05);
        color: #d8cfc4;
        border: 1px solid rgba(255,255,255,0.10);
        border-left: 3px solid rgba(180,140,80,0.55);
        border-radius: 4px;
        padding: 8px 10px;
        margin-bottom: 5px;
        font-size: 12px;
        white-space: pre-wrap;
        line-height: 1.6;
        font-family: 'Noto Serif KR', serif;
    }
    .record-item.foreign { 
        border-left-color: rgba(100,160,200,0.55);
    } 
    .record-item.true_history { border-left-color: rgba(46,204,113,0.7); }
    


    /* 🚩 [수정] 폼 입력 필드 스타일 개선 (다크 테마 적용) */
    #castleForm input, #historyForm input, #countryForm input, #kingForm input, #eventForm input, #drawingForm input,
    #castleForm select, #historyForm select, #countryForm select, #kingForm select, #eventForm select, #drawingForm select, #castleForm textarea,
    #historyForm textarea {
        margin: 4px 0; 
        padding: 8px; 
        width: 100%; 
        box-sizing: border-box; 
        background-color: #1c2833;
        color: #ecf0f1;
        border: 1px solid #5d7185;
        border-radius: 4px;
    }
    #castleForm input:focus, #historyForm input:focus, #countryForm input:focus, #kingForm input:focus, #eventForm input:focus, #drawingForm input:focus,
    #castleForm select:focus, #historyForm select:focus, #countryForm select:focus, #kingForm select:focus, #eventForm select:focus, #drawingForm select:focus, #castleForm textarea:focus,
    #historyForm textarea:focus {
        outline: none;
        border-color: #00aaff;
        box-shadow: 0 0 5px rgba(0, 170, 255, 0.5);
    }
    .record-item button {
        float: right; margin-left: 10px; background-color: #1a6fa8; color: #fff; border: 1px solid #3498db; padding: 3px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; font-weight: bold; transition: background 0.15s;
    }
    .record-item button:hover { background-color: #2980b9; }

    /* 경로 데이터 섹션 스타일 */
    .path-point-row {
      display: flex;
      gap: 5px;
      margin-bottom: 5px;
      align-items: center;
      padding: 5px;
      border: 1px solid #5d7185;
      border-radius: 3px;
    }
    .path-point-row input {
      flex-grow: 1;
      width: auto; /* flex-grow 때문에 width: 100% 무시 */
      min-width: 0;
    }
    .path-point-row .path-time-input {
      width: 50px;
    }
    .path-point-row button {
      width: 30px;
      padding: 5px;
      margin: 0;
      background-color: #e74c3c;
    }
    #pathDataSection h4 {
      white-space: nowrap; /* 제목 줄바꿈 방지 */
    }

    /* 🚩 [추가] 폼 레이아웃 개선 */
    .form-row {
      display: flex;
      align-items: center;
      margin-bottom: 8px;
      gap: 10px;
    }
    .form-row label {
      width: 100px; /* 레이블 너비 고정 */
      flex-shrink: 0; /* 레이블 너비가 줄어들지 않도록 설정 */
      text-align: right;
      padding-right: 5px;
    }
    .form-row input, .form-row select, .form-row textarea, .form-row .input-group {
      flex-grow: 1; /* 입력 필드가 남은 공간을 모두 차지하도록 설정 */
    }
    .submission-form-header {
      padding: 18px 20px 14px;
      border-bottom: 1px solid rgba(230,126,34,0.28);
      background:
        linear-gradient(135deg, rgba(230,126,34,0.16), transparent 45%),
        rgba(255,255,255,0.025);
    }
    .submission-form-header h3 {
      margin: 0;
      color: #f0c987;
      font-size: 20px;
    }
    .submission-form-header p {
      margin: 6px 0 0;
      color: #aebdcc;
      font-size: 12px;
      line-height: 1.5;
    }
    .submission-form-body {
      padding: 18px 20px 8px;
    }
    #contributionForm .form-row {
      align-items: flex-start;
      margin-bottom: 11px;
    }
    #contributionForm .form-row > label:first-child {
      color: #c9d3dc;
      font-size: 12px;
      font-weight: 700;
      padding-top: 7px;
    }
    #contributionForm input,
    #contributionForm select,
    #contributionForm textarea {
      min-height: 34px;
      box-sizing: border-box;
      border: 1px solid rgba(140,165,185,0.35);
      border-radius: 5px;
      background: rgba(7,12,18,0.55);
      color: #ecf0f1;
      padding: 7px 9px;
    }
    #contributionForm textarea {
      min-height: 108px;
      resize: vertical;
    }
    #contribSubmissionType {
      border-color: rgba(230,126,34,0.48) !important;
      background: rgba(230,126,34,0.12) !important;
      color: #f7dfbf !important;
      font-weight: 700;
    }
    .submission-form-actions {
      position: sticky;
      bottom: 0;
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      padding: 12px 20px 16px;
      background: rgba(17,26,36,0.96);
      border-top: 1px solid rgba(230,126,34,0.22);
      text-align: right;
    }
    .input-group {
      display: flex;
      gap: 5px;
    }
    /* 재생/정지 버튼 컨테이너 */
    .playback-button-container {
        position: relative;
        width: auto; /* 🚩 [수정] 너비를 자동으로 조절하도록 변경 */
        height: auto; /* 🚩 [수정] 높이를 자동으로 조절하도록 변경 */
        align-self: center; /* flex 아이템 스스로 수직 중앙 정렬 */
    }

    /* 🚩 [추가] 마커 타입 선택 버튼 그룹 스타일 */
    .marker-type-selector {
      display: flex;
      border: 1px solid #5d7185;
      border-radius: 5px;
      overflow: hidden;
    }
    /* 🚩 [핵심 수정] 레이어 토글 버튼이 기본 버튼 스타일을 상속받도록 수정 */
    .marker-type-selector button {
      flex-grow: 1;
      /* 기본 버튼 스타일을 상속받으므로 아래 속성들은 제거 또는 수정됩니다. */
      /* all: unset; */
      /* text-align: center; */
      /* padding: 6px 5px; */
      /* cursor: pointer; */
      transition: all 0.2s ease; /* 🚩 [수정] 기본 버튼과 동일한 전환 효과 적용 */
      opacity: 0.5; /* 비활성 상태일 때 반투명 처리 */
      border-radius: 0; /* 🚩 [추가] 버튼 그룹의 중간 버튼들은 각진 모서리로 */
      border-right: none; /* 🚩 [추가] 오른쪽 테두리 제거하여 버튼들이 붙어보이게 함 */
    }
    .marker-type-selector button.active {
      background-color: #008cff; /* 🚩 [수정] 활성 색상을 다른 버튼과 통일 */
      opacity: 1; /* 활성 상태일 때 완전 불투명 */
      font-weight: bold;
    }
    .marker-type-selector button:hover:not(.active) {
      background-color: #36434f; /* 🚩 [수정] 호버 색상을 다른 버튼과 통일 */
      opacity: 0.8; /* 🚩 [추가] 비활성 버튼 호버 시 약간 더 진하게 */
    }

    /* 🚩 [수정] 버튼 스타일 통합 및 역할별 클래스 정의 */
    button, .button-style, input[type="button"], input[type="submit"] {
        all: unset; /* 모든 기본 스타일 초기화 */
        display: inline-block;
        box-sizing: border-box;
        background-color: #3e4a56; /* 더 어두운 기본 배경색 */
        color: #f0f0f0; /* 🚩 [수정] 더 밝은 텍스트 색상 */
        border: 1px solid #5d7185; /* 🚩 [수정] 테두리 색상 밝게 조정 */
        padding: 5px 5px; /* 🚩 [수정] 패딩 조정 */
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.2s ease; /* 🚩 [수정] 모든 속성에 전환 효과 적용 */
        font-size: 12px; /* 🚩 [수정] 폰트 크기 조정 */
        text-shadow: 1px 1px 2px rgba(0,0,0,0.5); /* 🚩 [추가] 텍스트 그림자로 가독성 향상 */
    }
    
    /* 🚩 [추가] PC 버전 시간 컨트롤 스타일 */
    #time-controls-map {
        flex-wrap: wrap;
        max-width: calc(100% - 180px);
    }
    
    #time-controls-map #timeLabelDisplay {
        min-width: 180px;
    }
    
    #time-controls-map #timeLabelDisplay #yearLabel {
        min-width: 65px;
    }
    
    #time-controls-map #timeLabelDisplay #monthLabel {
        min-width: 20px;
    }
    
    #time-controls-map #timeLabelDisplay #ganjiLabel {
        min-width: 40px;
    }

    /* Compact style used while user is dragging the timeline slider */
    #time-controls-map #timeLabelDisplay.compact,
    #timeLabelDisplay-pc.compact {
        font-size: 11px !important;
        padding: 2px 6px !important;
        height: 22px !important;
        line-height: 16px !important;
        transition: font-size 0.12s ease, padding 0.12s ease;
        opacity: 0.6;
    }
    /* 슬라이더 드래그 중 연도 표시 크게 */
    #current-year-display.compact {
        font-size: 20px !important;
        font-weight: 700 !important;
        opacity: 1 !important;
        transition: font-size 0.12s ease;
    }

    button:hover, .button-style:hover, input[type="button"]:hover, input[type="submit"]:hover {
        background-color: #36434f; /* 어두운 호버 색상 */
        border-color: #5d7185;
    }

    button.primary, button.active, .button-style.active, button:active, input[type="submit"] {
        background-color: #008cff; /* 🚩 [수정] 활성/주요 색상을 더 밝은 파란색으로 변경 */
        border-color: #008cff;
    }

    button.primary:hover, input[type="submit"]:hover {
        background-color: #006bb3; /* 🚩 [수정] primary 버튼 호버 시 더 어두운 파란색 */
        border-color: #006bb3;
    }

    button.danger {
        background-color: #c0392b; /* 톤 다운된 위험 색상 */
        border-color: #c0392b;
    }
    button.danger:hover {
        background-color: #e74c3c;
    }

        /* 자연 지물 마커 스타일 (NEW) */
    .natural-feature-marker {
        font-size: 20px; /* 아이콘 크기 */
        font-weight: bold;
        text-shadow: 1px 1px 2px #000;
        text-align: center;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px; /* 아이콘 ↔ 텍스트 간격 통일 */
        line-height: 1;
        padding: 0;
        box-sizing: border-box;
        background: none !important;
        border: none !important;
    }
    /* 🚩 자연 지물 마커: transform 없음 - zoom마다 마커 재생성으로 크기 조절 */
    .natural-feature-marker {
        overflow: visible;
    }
    .natural-feature-marker .feature-name {
        font-size: 10px;
        font-family: 'Nanum Myeongjo', serif;
        font-weight: 300;
        color: #d8cdb8;
        background: none;
        padding: 0;
        border-radius: 0;
        display: inline-block;
        white-space: nowrap;
        margin-top: 0;
        text-shadow: 0px 0px 2px rgba(0,0,0,0.9), 0px 0px 4px rgba(0,0,0,0.8);
        border: none;
    }
    /* 특정 타입에 따른 색상 */
    .feature-mountain { color: #2ecc71; background-color: transparent; } /* 산/숲 */
    .feature-sea { color: #3498db; background-color: transparent; } /* 바다/호수 */
    .feature-river { color: #1abc9c; background-color: transparent; } /* 강/내륙 */
    .feature-mudflat { color: #f1c40f; background-color: transparent; } /* 뻘/늪 */
    .feature-hunting { color: #e67e22; background-color: transparent; } /* 사냥터 */
    .feature-construction { color: #95a5a6; background-color: transparent; } /* 건설 */
    .feature-other { color: #ecf0f1; background-color: transparent; } /* 기타 */
    .feature-tomb { font-size: 13px; } /* 고분 아이콘 크기 */

    /* ====================================================================
       🦸 HERO SYSTEM — Teardrop Marker + Sidebar + Admin Panel CSS
       ==================================================================== */

    /* ── 영웅 물방울 핀 (SVG teardrop) ── */
    .hero-pin-wrapper {
        position: relative;
        width: 34px;
        height: 41px;
        cursor: pointer;
        overflow: visible;
    }
    .hero-pin-inner {
        position: absolute;
        left: 0;
        top: 0;
        width: 40px;
        height: 52px;
        transform-origin: top left;
        transform: scale(0.845);
        transition: transform .18s ease;
        filter: drop-shadow(0 3px 8px rgba(0,0,0,.8));
    }
    .hero-pin-wrapper:hover .hero-pin-inner { transform: translateY(-4px) scale(0.9); }
    .ml3d-hero-marker .hero-pin-wrapper {
        height: 41px;
    }
    .ml3d-hero-marker .hero-pin-name {
        bottom: auto;
        top: 42px;
    }

    /* SVG 물방울 — teardrop 배경 */
    .hero-pin-svg {
        position: absolute;
        inset: 0;
        width: 40px;
        height: 52px;
        pointer-events: none;
        z-index: 1;
    }

    /* 아바타: clip-path 제거, border-radius + overflow:hidden 방식으로 수정 */
    .hero-pin-avatar {
        position: absolute;
        top: 3px;
        left: 50%;
        transform: translateX(-50%);
        width: 34px;
        height: 34px;
        border-radius: 50%;
        overflow: hidden;
        object-fit: cover;
        object-position: top center;
        background: #2c1f0a;
        display: block;
        border: 2px solid rgba(255,255,255,.8);
        z-index: 2;
        /* clip-path 제거 — img 태그에서 border-radius만으로 충분 */
    }
    .hero-pin-name {
        position: absolute;
        bottom: -16px;
        left: 50%;
        transform: translateX(-50%);
        white-space: nowrap;
        font-size: 10px;
        font-family: 'Nanum Myeongjo', serif;
        color: #f5e6b0;
        text-shadow: 0 1px 3px #000, 0 0 6px rgba(0,0,0,.95);
        pointer-events: none;
        letter-spacing: .3px;
    }

    /* ── 전신 일러스트 독립 패널 (왼쪽에서 슬라이드) ── */
    .hero-illust-panel {
        --hero-illust-panel-width: clamp(400px, 30vw, 600px);
        position: fixed;
        top: 0;
        left: 0;
        transform: translateX(calc(-100% - 20px));
        width: var(--hero-illust-panel-width);
        height: 100vh;
        height: 100dvh;
        background: transparent;
        border-right: none;
        box-shadow: none;
        z-index: 149900 !important;
        transition: transform .38s cubic-bezier(.4,.0,.2,1);
        overflow: hidden;
        /* 인물 상세에서는 독립 일러스트 패널을 사용하지 않는다. */
        display: none !important;
        cursor: pointer;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end;
    }
    .hero-illust-panel.open { transform: translateX(0); }

    /* ── 인물 상세 사이드바 ── */
    #heroSidebar {
        position: fixed;
        top: 0; right: -520px;
        width: min(480px, 98vw);
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        background: #0e0b04;
        border-left: 1.5px solid #7a5a1a;
        box-shadow: -8px 0 40px rgba(0,0,0,.9);
        z-index: 150000 !important;
        transition: right .38s cubic-bezier(.4,.0,.2,1);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    #heroSidebar.open { right: 0; }
    /* 이미지 하단 페이드아웃 — 지도 배경으로 자연스럽게 */
    .hero-illust-panel::after {
        content: '';
        position: absolute;
        bottom: 0; left: 0; right: 0;
        height: 180px;
        background: linear-gradient(transparent, rgba(0,0,0,0.7));
        pointer-events: none;
    }
    .hero-illust-panel img#heroIllustImg {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: top center;
    }
    .hero-illustration-placeholder {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 90px;
        background: transparent;
        color: rgba(122,90,26,0.4);
    }
    /* 일러스트 패널 하단 국가 배지 — 사이드바 상단과 수평 정렬 */
    .hero-faction-badge {
        position: absolute;
        bottom: 20px; left: 50%;
        transform: translateX(-50%);
        z-index: 2;
        padding: 4px 14px;
        border-radius: 20px;
        font-size: 11px;
        font-family: 'Nanum Myeongjo', serif;
        letter-spacing: 1.5px;
        white-space: nowrap;
        border: 1px solid rgba(255,255,255,.3);
        background: rgba(0,0,0,.55);
        color: #fff;
        backdrop-filter: blur(4px);
    }

    /* 오른쪽: 상세 정보 스크롤 패널 */
    .hero-detail-panel {
        flex: 1;
        min-height: 0;
        max-height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 16px 22px 32px;
        display: flex;
        flex-direction: column;
        scrollbar-width: thin;
        scrollbar-color: #7a5a1a #0e0b04;
        background: linear-gradient(180deg, #18120a 0%, #0e0b04 100%);
    }
    .hero-detail-panel::-webkit-scrollbar { width: 5px; }
    .hero-detail-panel::-webkit-scrollbar-track { background: #0e0b04; }
    .hero-detail-panel::-webkit-scrollbar-thumb { background: #7a5a1a; border-radius: 3px; }

    /* 이름 위 대표 아바타 — 성·도시 상세의 대표 이미지와 같은 배너 구성 */
    .hero-detail-avatar-banner {
        position: relative;
        flex: 0 0 auto;
        height: 190px;
        margin: -16px -22px 18px;
        overflow: hidden;
        background: linear-gradient(135deg, #2a2114, #0e0b04);
        border-bottom: 1px solid rgba(201,153,58,.32);
    }
    .hero-detail-avatar-banner img {
        position: absolute;
        inset: 8px 12px;
        width: calc(100% - 24px);
        height: calc(100% - 16px);
        display: none;
        object-fit: contain;
        object-position: center top;
        background: rgba(8,6,3,.72);
    }
    .hero-detail-avatar-placeholder {
        position: absolute;
        inset: 0;
        display: grid;
        place-items: center;
        color: rgba(219,181,96,.32);
        font-size: 58px;
    }
    .hero-detail-avatar-gradient {
        position: absolute;
        inset: 0;
        pointer-events: none;
        background: linear-gradient(180deg, transparent 42%, rgba(14,11,4,.9) 100%);
    }
    @media (max-width: 967px) {
        .hero-detail-avatar-banner { height: 180px; }
    }
    body.force-mobile .hero-detail-avatar-banner { height: 180px; }

    /* 영웅 사이드바 헤더 */
    .hero-sidebar-header {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 13px 58px 12px 18px;
        border-bottom: 1px solid #7a5a1a;
        background: rgba(14,11,4,0.98);
    }
    .hero-sidebar-header-title {
        font-family: 'Nanum Myeongjo', serif;
        font-size: 14px;
        color: #f5c842;
        letter-spacing: 1.5px;
    }
    .hero-close-btn {
        position: absolute !important;
        top: 10px !important;
        right: 12px !important;
        background: none;
        border: none;
        color: #7a5a1a;
        width: 28px;
        height: 28px;
        border-radius: 4px;
        cursor: pointer;
        font-size: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background .15s, color .15s;
        padding: 0;
        line-height: 1;
        z-index: 150010 !important;
    }
    .hero-close-btn:hover { background: rgba(122,90,26,.35); color: #f5c842; }

    /* admin 수정 버튼 */
    .hero-admin-edit-btn {
        display: none;
        align-items: center;
        gap: 6px;
        margin-bottom: 14px;
        padding: 7px 14px;
        background: rgba(197,150,30,.12);
        border: 1px solid #c5961e;
        border-radius: 5px;
        color: #f5c842;
        font-size: 12px;
        cursor: pointer;
        font-family: 'Nanum Myeongjo', serif;
        transition: background .15s;
        width: 100%;
        justify-content: center;
    }
    .hero-admin-edit-btn:hover { background: rgba(197,150,30,.28); }
    .hero-admin-edit-btn.visible { display: flex; }

    .hero-info-block {
        position: relative;
        z-index: 1;
    }
    .hero-name-zh {
        font-size: 13px;
        color: #b8960a;
        font-family: 'Nanum Myeongjo', serif;
        letter-spacing: 3px;
        margin-bottom: 2px;
    }
    .hero-name-ko {
        font-size: 32px;
        font-weight: bold;
        color: #f5e6b0;
        font-family: 'Nanum Myeongjo', serif;
        letter-spacing: 1px;
        line-height: 1;
        margin-bottom: 4px;
    }
    .hero-title-badge {
        display: inline-block;
        padding: 3px 10px;
        background: rgba(197,150,30,.18);
        border: 1px solid #c5961e;
        border-radius: 3px;
        font-size: 12px;
        color: #f5c842;
        margin-bottom: 12px;
        font-family: 'Nanum Myeongjo', serif;
    }
    .hero-meta-row {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin: 0 0 10px;
    }
    .hero-meta-pill {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        min-height: 22px;
        padding: 3px 9px;
        border: 1px solid rgba(197,150,30,.45);
        border-radius: 4px;
        background: rgba(197,150,30,.10);
        color: #d8c28a;
        font-size: 11px;
        line-height: 1.2;
    }
    button.hero-faction-link {
        font-family: inherit;
        cursor: pointer;
        text-decoration: underline dotted;
        text-underline-offset: 3px;
    }
    button.hero-faction-link:hover,
    button.hero-faction-link:focus-visible {
        border-color: rgba(126,184,232,.72);
        color: #9dcdf1;
        background: rgba(126,184,232,.12);
        outline: none;
    }
    button.hero-faction-link:disabled {
        cursor: default;
        text-decoration: none;
        opacity: .75;
    }
    .hero-years {
        font-size: 11px;
        color: #8a7a5a;
        margin-bottom: 14px;
    }
    .hero-divider {
        border: none;
        border-top: 1px solid rgba(122,90,26,.4);
        margin: 12px 0;
    }
    .hero-desc {
        font-size: 13px;
        color: #c8ba9a;
        line-height: 1.75;
        font-family: 'Nanum Myeongjo', serif;
        white-space: pre-wrap;
    }
    .hero-desc img {
        display: block;
        max-width: 100%;
        height: auto;
        margin: 8px 0;
        border-radius: 5px;
    }
    .hero-desc p { margin: 0 0 8px; }
    .hero-desc ul, .hero-desc ol { margin: 6px 0; padding-left: 22px; }
    #haDescEditor[data-placeholder]:empty::before {
        content: attr(data-placeholder);
        color: #6a5a3a;
        pointer-events: none;
    }
    #haDescEditor img { display:block; max-width:100%; height:auto; margin:4px 0; border-radius:4px; }

    .hero-positions-title {
        font-size: 12px;
        color: #b8960a;
        letter-spacing: 1px;
        text-transform: uppercase;
        margin: 16px 0 8px;
    }
    .hero-position-item {
        display: flex;
        gap: 10px;
        align-items: flex-start;
        margin-bottom: 8px;
    }
    #heroCareerPhaseList .hero-pos-year { min-width: 92px; }
    .hero-career-current {
        margin-left: -8px;
        padding: 6px 8px;
        border-left: 2px solid #f5c842;
        background: rgba(245, 200, 66, 0.07);
        border-radius: 3px;
    }
    .hero-pos-year {
        min-width: 42px;
        font-size: 11px;
        color: #f5c842;
        font-weight: bold;
        padding-top: 1px;
    }
    .hero-pos-detail {
        font-size: 12px;
        color: #c8ba9a;
        line-height: 1.5;
    }
    .hero-pos-location {
        font-size: 11px;
        color: #7a6a4a;
    }
    .hero-recorded-by {
        display: flex;
        align-items: center;
        gap: 7px;
        margin: 12px 0 4px;
        padding: 9px 11px;
        border: 1px solid rgba(197,150,30,.28);
        border-radius: 5px;
        background: rgba(197,150,30,.07);
        color: #9c8a62;
        font-size: 11px;
        line-height: 1.45;
    }
    .hero-recorded-by[hidden] { display: none; }
    .hero-recorded-by strong {
        color: #d8c28a;
        font-weight: 600;
    }

    .hero-vote-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 18px 0 12px;
        padding: 10px 18px;
        background: rgba(197,150,30,.12);
        border: 1px solid #c5961e;
        border-radius: 6px;
        color: #f5c842;
        font-size: 14px;
        cursor: pointer;
        font-family: 'Nanum Myeongjo', serif;
        transition: background .15s;
        width: 100%;
        justify-content: center;
    }
    .hero-vote-btn:hover { background: rgba(197,150,30,.28); }
    .hero-vote-btn.voted { background: rgba(46,204,113,.15); border-color: #2ecc71; color: #2ecc71; cursor: default; }
    .hero-vote-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin: 18px 0 12px;
    }
    .hero-vote-actions .hero-vote-btn { margin: 0; padding: 10px 8px; }
    .hero-vote-btn.villain {
        background: rgba(155,55,55,.12);
        border-color: #9d4c4c;
        color: #e49a91;
    }
    .hero-vote-btn.villain:hover { background: rgba(155,55,55,.26); }
    .hero-vote-btn.villain.voted {
        background: rgba(190,70,70,.18);
        border-color: #d06a62;
        color: #efaaa3;
        cursor: default;
    }

    .hero-comments-title {
        font-size: 12px;
        color: #b8960a;
        letter-spacing: 1px;
        margin: 16px 0 8px;
    }
    .hero-comment-form {
        display: grid;
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 10px;
        border: 1px solid rgba(122,90,26,.55);
        border-radius: 7px;
        background: rgba(255,255,255,.025);
        margin-bottom: 12px;
    }
    .hero-comment-input {
        display: block;
        width: 100%;
        min-height: 76px;
        box-sizing: border-box;
        padding: 8px 10px;
        background: rgba(255,255,255,.06);
        border: 1px solid #7a5a1a;
        border-radius: 5px;
        color: #f5e6b0;
        font-size: 12px;
        font-family: 'Nanum Myeongjo', serif;
        resize: none;
    }
    .hero-comment-form-actions {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
        min-height: 34px;
    }
    .hero-comment-form-limit {
        color: #7f8c8d;
        font-size: 10px;
    }
    .hero-comment-submit {
        padding: 8px 14px;
        background: rgba(197,150,30,.2);
        border: 1px solid #c5961e;
        border-radius: 5px;
        color: #f5c842;
        font-size: 12px;
        cursor: pointer;
        transition: background .15s;
        min-height: 34px;
    }
    .hero-comment-submit:hover { background: rgba(197,150,30,.4); }
    .hero-comment-item {
        position: relative;
        width: fit-content;
        max-width: 84%;
        padding: 8px 11px;
        margin-bottom: 8px;
        border: 1px solid rgba(255,255,255,.08);
        border-radius: 13px;
    }
    .hero-comment-item.hero {
        margin-right: auto;
        background: #17334b;
        border-color: rgba(91,153,205,.38);
    }
    .hero-comment-item.villain {
        margin-left: auto;
        background: #562724;
        border-color: rgba(205,91,83,.42);
    }
    .hero-comment-item.neutral {
        margin-right: auto;
        margin-left: auto;
        background: #303840;
    }
    .hero-comment-item.hero::before {
        content: "";
        position: absolute;
        left: -7px;
        bottom: 8px;
        border-width: 7px 8px 0 0;
        border-style: solid;
        border-color: #17334b transparent transparent transparent;
    }
    .hero-comment-item.villain::after {
        content: "";
        position: absolute;
        right: -7px;
        bottom: 8px;
        border-width: 7px 0 0 8px;
        border-style: solid;
        border-color: #562724 transparent transparent transparent;
    }
    .hero-comment-author { font-size: 11px; color: #b8960a; font-weight: bold; }
    .hero-comment-date   { font-size: 10px; color: #6a5a3a; margin-left: 6px; }
    .hero-comment-text   { font-size: 12px; color: #c8ba9a; margin-top: 4px; line-height: 1.5; }
    .hero-comment-stance-selector {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .hero-comment-stance-selector label {
        position: relative;
        padding: 7px 9px;
        border: 1px solid rgba(150,140,120,.35);
        border-radius: 7px;
        color: #9e9278;
        text-align: center;
        font-size: 11px;
        font-weight: bold;
        cursor: pointer;
    }
    .hero-comment-stance-selector input {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }
    .hero-comment-stance-selector label:has(input[value="hero"]:checked) {
        border-color: #5b99cd;
        background: rgba(45,105,155,.35);
        color: #d9efff;
    }
    .hero-comment-stance-selector label:has(input[value="villain"]:checked) {
        border-color: #cd5b53;
        background: rgba(155,55,48,.35);
        color: #ffe0dc;
    }
    .hero-comment-gauge { margin: 2px 0 12px; }
    .hero-vote-gauge { margin: 14px 0 10px; }
    .hero-comment-gauge-labels {
        display: flex;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 5px;
        font-size: 11px;
        font-weight: bold;
    }
    .hero-comment-gauge-labels .hero-side { color: #78b8e9; }
    .hero-comment-gauge-labels .villain-side { color: #e77b72; }
    .hero-comment-gauge-track {
        position: relative;
        display: flex;
        height: 11px;
        overflow: hidden;
        border-radius: 999px;
        background: #303840;
    }
    .hero-comment-gauge-hero { background: linear-gradient(90deg,#326f9e,#69addf); }
    .hero-comment-gauge-villain { background: linear-gradient(90deg,#d3675f,#8e342f); }
    .hero-comment-gauge-vs {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%);
        padding: 1px 5px;
        border-radius: 999px;
        background: #111820;
        color: #f0e2c0;
        font-size: 8px;
        font-weight: bold;
    }
    .hero-comment-actions {
        display: flex;
        justify-content: flex-end;
        gap: 5px;
        margin-top: 5px;
    }
    .hero-comment-action {
        padding: 2px 6px;
        border: 0;
        border-radius: 4px;
        background: rgba(255,255,255,.09);
        color: #bdc8d0;
        font-size: 10px;
        cursor: pointer;
    }
    .hero-comment-action.delete { color: #ffaaa3; }

    /* ── 영웅 관리자 패널 ── */
    /* 영웅 관리자 패널 — 왼쪽 슬라이드 사이드바 */
    #heroAdminPanel {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: min(520px, 96vw);
        height: 100vh;
        overflow: hidden;
        background: rgba(12,9,3,0.98);
        border-right: 1.5px solid #7a5a1a;
        padding: 0;
        z-index: 10200;
        box-shadow: 6px 0 32px rgba(0,0,0,.9);
        color: #c8ba9a;
        font-size: 13px;
        flex-direction: column;
    }
    #heroAdminPanel.show { display: flex; }
    #heroAdminPanel h3 {
        font-family: 'Nanum Myeongjo', serif;
        flex-shrink: 0;
        color: #f5c842;
        font-size: 15px;
        margin: 0;
        padding: 14px 20px 12px;
        border-bottom: 1px solid #7a5a1a;
        background: rgba(12,9,3,0.98);
        z-index: 2;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    #heroAdminPanelBody {
        flex: 1;
        min-height: 0;
        overflow-y: scroll;
        overflow-x: hidden;
        padding: 16px 20px 60px;
        box-sizing: border-box;
        scrollbar-width: thin;
        scrollbar-color: #7a5a1a #0c0903;
    }
    #heroAdminPanelBody::-webkit-scrollbar { width: 6px; }
    #heroAdminPanelBody::-webkit-scrollbar-track { background: #0c0903; }
    #heroAdminPanelBody::-webkit-scrollbar-thumb { background: #7a5a1a; border-radius: 3px; }
    #heroAdminCloseBtn {
        background: none;
        border: none;
        color: #7a5a1a;
        font-size: 18px;
        cursor: pointer;
        padding: 0 4px;
        line-height: 1;
        transition: color .15s;
    }
    #heroAdminCloseBtn:hover { color: #f5c842; }
    .hero-admin-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px 14px;
    }
    .hero-admin-grid .full-col { grid-column: 1 / -1; }
    .hero-admin-label {
        font-size: 11px;
        color: #8a7a5a;
        margin-bottom: 3px;
        display: block;
    }
    .hero-admin-input,
    .hero-admin-textarea {
        width: 100%;
        box-sizing: border-box;
        padding: 7px 10px;
        background: rgba(255,255,255,.05);
        border: 1px solid #7a5a1a;
        border-radius: 5px;
        color: #f5e6b0;
        font-size: 12px;
        font-family: 'Nanum Myeongjo', serif;
    }
    .hero-admin-textarea { resize: vertical; min-height: 70px; }
    .hero-admin-file-label {
        display: block;
        padding: 8px 12px;
        background: rgba(197,150,30,.1);
        border: 1px dashed #7a5a1a;
        border-radius: 5px;
        cursor: pointer;
        font-size: 11px;
        color: #b8960a;
        text-align: center;
        transition: background .15s;
    }
    .hero-admin-file-label:hover { background: rgba(197,150,30,.22); }
    .hero-admin-file-label input[type=file] { display: none; }
    .hero-admin-btn-row {
        display: flex;
        gap: 8px;
        margin-top: 16px;
        justify-content: flex-end;
    }
    .hero-admin-btn {
        padding: 9px 18px;
        border-radius: 5px;
        font-size: 13px;
        cursor: pointer;
        font-family: 'Nanum Myeongjo', serif;
        transition: background .15s;
        border: 1px solid;
    }
    .hero-admin-btn.save   { background: rgba(46,204,113,.18); border-color: #2ecc71; color: #2ecc71; }
    .hero-admin-btn.cancel { background: rgba(93,113,133,.18); border-color: #5d7185; color: #aab8c2; }
    .hero-admin-btn.danger { background: rgba(231,76,60,.18);  border-color: #e74c3c; color: #e74c3c; }
    .hero-admin-btn:hover.save   { background: rgba(46,204,113,.35); }
    .hero-admin-btn:hover.cancel { background: rgba(93,113,133,.35); }
    .hero-admin-btn:hover.danger { background: rgba(231,76,60,.35); }

    .hero-admin-table {
        width: 100%;
        border-collapse: collapse;
        margin-top: 12px;
        font-size: 12px;
    }
    .hero-admin-table th {
        background: rgba(122,90,26,.2);
        color: #f5c842;
        padding: 6px 10px;
        text-align: left;
        font-weight: normal;
        border-bottom: 1px solid #7a5a1a;
    }
    .hero-admin-table td {
        padding: 6px 10px;
        border-bottom: 1px solid rgba(122,90,26,.2);
        color: #c8ba9a;
        vertical-align: middle;
    }
    .hero-admin-table tr:hover td { background: rgba(255,255,255,.03); }

    /* 위치 관리 서브패널 */
    #heroPosPanel {
        display: none;
        background: rgba(255,255,255,.04);
        border: 1px solid #7a5a1a;
        border-radius: 6px;
        padding: 12px;
        margin-top: 10px;
    }

    /* ── 영웅 마커 레이어 토글 버튼 ── */
    #heroLayerToggleBtn {
        background: rgba(197,150,30,.15);
        border: 1px solid #c5961e;
        color: #f5c842;
    }
    #heroLayerToggleBtn.active {
        background: rgba(197,150,30,.4);
    }
    #layer-toggles .layer-toggle-btn {
        padding: 6px 8px; /* 🚩 [수정] 다른 버튼과 높이 맞춤 (축소) */
        font-size: 11px;
    }

    /* 🚩 [신규] 편집 컨트롤 PC 기본 스타일 */
    #edit-controls {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
        height: 26px;
    }
    #edit-controls #mainEditBtn {
        height: 100%;
        padding: 4px 10px;
        font-size: 13px;
        line-height: 1.2;
        box-sizing: border-box;
    }
    #edit-dropdown-container {
        position: relative;
        display: none;
        height: 100%;
    }
    #edit-dropdown-container #mainEditBtn {
        white-space: nowrap;
    }

    /* 폼 내부 버튼 스타일 */
    #castleForm .form-actions button, #historyForm .form-actions button, 
    #countryForm .form-actions button, #kingForm .form-actions button,
    #eventForm .form-actions button, #drawingForm .form-actions button {
        width: 80px;
    }

    /* 🚩 [추가] 그리기 스타일: 성곽 배경/전경 스타일 */
    .wall-background, .wall-foreground {
        /* 클릭 이벤트가 전경 레이어에만 발생하도록 설정 */
        pointer-events: none;
    }
    .wall-foreground { pointer-events: auto; }

    /* 왕 목록 스타일 */
    .king-item {
        font-size: 12px; /* 폰트 크기 줄임 */
        line-height: 1.5;
        margin-bottom: 4px;
        white-space: nowrap;
    }

    /* 🚩 한줄평 말풍선 아이콘 */
    .king-summary-badge {
        display: inline-block;
        font-size: 11px;
        cursor: pointer;
        opacity: 0.55;
        transition: opacity 0.15s, transform 0.15s;
        margin-left: 3px;
        vertical-align: middle;
        position: relative;
        user-select: none;
    }
    .king-summary-badge:hover {
        opacity: 1;
        transform: scale(1.3);
    }

    /* 🚩 한줄평 클릭 팝업 */
    #king-summary-popup {
        display: none;
        position: fixed;
        z-index: 99999;
        background: #1e2a38;
        color: #e8eaf0;
        border: 1px solid #4a90d9;
        border-radius: 8px;
        padding: 9px 13px;
        font-size: 12.5px;
        line-height: 1.6;
        max-width: 260px;
        box-shadow: 0 4px 18px rgba(0,0,0,0.55);
        pointer-events: none;
    }
    #king-summary-popup.visible {
        display: block;
    }

    /* 🚩 [추가] 검색창 컨테이너 스타일 */
    #searchInput {
        display: flex;
        align-items: center;
        all: unset;
        box-sizing: border-box;
        padding: 6px 10px; /* 🚩 [수정] 버튼과 높이를 맞추기 위해 패딩 조정 */
        border: 1px solid #4e5d6c;
        border-radius: 4px 0 0 4px; /* 왼쪽만 둥글게 */
        background-color: #f0f0f0;
        color: black;
        font-size: 12px;
        line-height: 1.2;
        width: 180px; /* 🚩 [수정] 검색창 너비 확대 */
    }

    /* ------------------- 4. 반응형 레이아웃 CSS (NEW) ------------------- */
    /* 화면 너비가 1200px 이하일 때 적용 */
    @media (max-width: 1200px) {
        #top-controls-container {
            flex-direction: column; /* 수직으로 쌓기 */
            align-items: flex-start; /* 왼쪽 정렬 */
            gap: 15px;
        }
        .time-controls, .right-controls {
            width: 100%; /* 너비를 100%로 설정 */
            flex-wrap: wrap; /* 내부 요소들이 다음 줄로 넘어가도록 설정 */
            justify-content: flex-start; /* 왼쪽부터 정렬 */
            gap: 10px; /* 요소 간 간격 추가 */
        }
        .right-controls {
            justify-content: flex-start; /* 오른쪽 컨트롤도 왼쪽부터 정렬 */
        }
    }
    /* 🚩 [추가] 모바일 컨트롤 패널 닫기 버튼 */
    #closeControlsBtn {
        display: none; /* 기본적으로 숨김 */
        position: absolute;
        top: 15px;
        right: 15px;
        z-index: 1003;
        /* 🚩 [수정] 배경과 테두리 제거 */
        background: none;
        border: none;
        /* 🚩 [수정] 크기와 색상 조정 */
        font-size: 22px;
        color: #dbdbdb;
    }

    /* 🚩 [추가] 줌 레벨에 따라 크기가 조절될 마커들의 공통 스타일 */
    /* 커스텀 아이콘 마커: overflow 해제로 이름 텍스트 잘림 방지 */
    /* 🚩 Leaflet divIcon wrapper: 깃발이 iconSize 위로 튀어나와도 잘리지 않도록 */
    .leaflet-div-icon {
        overflow: visible !important;
        background: none !important;
        border: none !important;
    }

    .custom-icon-marker {
        background: none !important;
        border: none !important;
        overflow: visible !important;
        display: flex !important;
        align-items: flex-start;
        justify-content: center;
        padding: 0;
    }

    /* 🚩 [추가] 도시 마커: voice 이퀄라이저 잘림 방지 */
    .custom-city-marker {
        background: none !important;
        border: none !important;
        overflow: visible !important;
    }

    /* 🚩 [삭제됨] 고대 지도 보기 버튼 컨테이너 스타일 (탑바로 이동됨) */
    /* #ancient-map-button-container {
        display: none; 
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-top: auto;
        padding: 12px;
        justify-content: center;
        align-items: stretch;
        background: rgba(30, 42, 56, 0.85);
        backdrop-filter: blur(15px);
        border: 1px solid rgba(255,255,255,0.1);
        border-radius: 12px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    } */

    /* 드롭다운 화살표 스타일 */
    .dropdown-arrow {
        display: inline-block;
        margin-left: 5px;
        transition: transform 0.3s ease;
        font-size: 10px;
    }
    /* 🚩 [추가] 성곽 그림자 효과를 위한 SVG 필터 */
    .svg-shadow-filter {

        /* 참고: 일부 브라우저 호환성을 위해 -webkit- 접두사 포함 */
    }

    /* ------------------- 5. 모바일 반응형 슬라이드 패널 (NEW) ------------------- */
    @media (max-width: 967px) { /* 🚩 [수정] 강제 모바일 뷰 클래스 제거 */
        /* 기본적으로 body 스크롤을 막습니다. */
        html, body {
            /* 🚩 [추가] 모바일 기본 글씨 크기 키워서 가독성 향상 */
            font-size: 15px;
            overflow: hidden;
        }

        /* 메인 컨테이너를 화면 전체로 확장합니다. */
        #mainContainer {
            flex-direction: column !important; /* 모바일에서는 수직으로 쌓습니다. */
            height: 100%;
            padding: 0;
        }

        /* 지도가 항상 전체 화면을 차지하도록 설정합니다. */
        #leftColumn {
            flex-basis: 100% !important;
        }

        /* 오른쪽 패널만 화면 밖으로 이동시킵니다. */
        #rightPanel {
            position: fixed !important;
            z-index: 1002; /* 폼보다 위에, 이벤트 오버레이보다 위에 */
            background-color: #1e2a38e0; /* 반투명 배경 */
            display: block !important;
            transition: transform 0.3s ease-in-out;
            box-shadow: 0 0 20px rgba(0,0,0,0.5);
        }

        /* 상단 메뉴는 항상 보이고 이동하지 않음 */
        #controls-wrapper {
            position: static !important;
            top: auto !important;
            left: auto !important;
            width: 100% !important;
            transform: none !important;
            display: block !important;
            visibility: visible !important;
            opacity: 1 !important;
            border-bottom: 2px solid #00aaff;
        }

        /* 오른쪽 패널 초기 위치 (화면 오른쪽) */
        #rightPanel {
            /* 🚩 [수정] 패널이 오른쪽에서 나오도록 복원 */
            top: 0;
            right: 0;
            width: 85%; /* 화면의 85% 너비 */
            max-width: 400px;
            height: 100%;
            transform: translateX(100%);
            border-left: 2px solid #00aaff;
            border-top: none; /* 상단 테두리 제거 */
        }

        /* 오른쪽 패널은 토글됨 */
        #rightPanel.visible {
            transform: translateX(0);
        }

        /* 가로/세로 리사이저는 모바일에서 숨깁니다. */
        #resizer, #vertical-resizer {
            display: none;
        }

        /* 오른쪽 패널 토글 버튼 위치 조정 */
        #rightPanelToggleBtn {
            /* 🚩 [수정] 버튼을 오른쪽 하단으로 이동 */
            top: auto;
            bottom: 15px;
            left: auto; /* 오른쪽 정렬을 위해 left는 auto로 둡니다. */
            right: 15px;
            z-index: 1003; /* 🚩 [추가] 패널(z-index: 1002)보다 위에 오도록 설정 */
            /* 🚩 [수정] 모바일용 디자인 변경 */
            writing-mode: horizontal-tb; /* 세로쓰기 해제 */
            width: 40px; /* 🚩 [수정] 버튼 크기 축소 */
            height: 40px; /* 🚩 [수정] 버튼 크기 축소 */
            border-radius: 50%; /* 원형 버튼 */
            font-size: 20px; /* 🚩 [수정] 아이콘 크기 축소 */
            line-height: 40px; /* 🚩 [수정] 아이콘 세로 중앙 정렬 */
            padding: 0;
        }
        /* 🚩 [추가] 패널이 열렸을 때 닫기 버튼 위치 조정 */
        #rightPanel.visible + #rightPanelToggleBtn {
            /* 🚩 [수정] 패널이 열렸을 때 버튼 위치를 패널의 왼쪽 상단으로 이동 */
            right: auto;
            left: 10px;
        }


        /* 🚩 [추가] 모바일에서 오른쪽 패널 내부 글씨 크기 조정 */
        #rightPanel .king-item,
        #rightPanel .record-item {
            font-size: 14px;
        }

        /* 🚩 [추가] 모바일에서 상단 컨트롤 레이아웃: 4줄로 분리 */
        #top-controls-container {
            flex-direction: column !important;
            width: 100% !important;
            gap: 5px !important;
            justify-content: flex-start !important;
        }
        
        /* 1줄: 시간 및 속도 컨트롤 */
        .time-controls {
            width: 100% !important;
            flex-wrap: wrap !important;
            order: 1;
            flex-basis: 100% !important;
            margin-bottom: 0 !important;
        }
        /* 🚩 [추가] 지도 내 시간 컨트롤 모바일 스타일 */
        #time-controls-map {
            position: fixed !important;
            top: 10px !important;
            left: 10px !important;
            right: auto !important;
            max-width: calc(100% - 20px) !important;
            font-size: 11px !important;
            padding: 6px !important;
            flex-wrap: wrap !important;
        }
        #time-controls-map input[type="number"] {
            width: 60px !important;
            font-size: 11px !important;
            padding: 2px !important;
        }
        #time-controls-map button {
            font-size: 11px !important;
            padding: 3px 6px !important;
        }
        #time-controls-map #playbackSpeedSlider {
            width: 50px !important;
        }
        
        /* 🚩 [신규] 모바일에서 편집 컨트롤 정렬 - 오른쪽 상단 */
        #edit-controls {
            position: fixed !important;
            top: 10px !important;
            right: 10px !important;
            bottom: auto !important;
            left: auto !important;
            margin-left: 0 !important;
            gap: 5px !important;
            height: auto !important;
            flex-wrap: wrap !important;
        }
        #edit-controls #mainEditBtn {
            height: 26px !important;
            padding: 4px 6px !important;
            font-size: 12px !important;
            white-space: nowrap !important;
        }
        #edit-dropdown-container {
            flex-shrink: 0 !important;
        }
        #edit-dropdown-menu {
            position: absolute !important;
            top: 100% !important;
            left: 0 !important;
            background-color: #1e2a38 !important;
            border: 1px solid #00aaff !important;
            border-radius: 4px !important;
            z-index: 1000 !important;
            min-width: 120px !important;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
            display: none !important;
        }
        #edit-dropdown-menu.show {
            display: flex !important;
            flex-direction: column !important;
        }
        #edit-dropdown-menu .dropdown-item {
            display: block !important;
            width: 100% !important;
            padding: 6px 10px !important;
            text-align: left !important;
            background: none !important;
            border: none !important;
            cursor: pointer !important;
            font-size: 12px !important;
            color: #f0f0f0 !important;
            transition: background-color 0.2s !important;
        }
        #edit-dropdown-menu .dropdown-item:hover {
            background-color: #00aaff !important;
            color: #1e2a38 !important;
        }
        
        /* 2줄: 필터 및 검색 (국가필터, 민족필터, 검색을 한 줄에) */
        .right-controls {
            width: 100% !important;
            display: flex !important;
            flex-direction: row !important;
            flex-wrap: wrap !important;
            order: 2;
            justify-content: flex-start !important;
            gap: 5px !important;
            align-items: center !important;
            margin-top: 0 !important;
            flex-basis: 100% !important;
        }
        /* 국가필터 - 고정 크기 */
        #country-filter-container {
            flex-shrink: 0 !important;
            display: flex !important;
            align-items: center !important;
            height: 26px !important;
            gap: 3px !important;
            order: 1 !important;
        }
        #country-filter-container label {
            display: none !important;
        }
        #countryFilterSelect {
            width: 90px !important;
            font-size: 13px !important;
            padding: 5px 4px !important;
            height: 100% !important;
            box-sizing: border-box !important;
            line-height: 1.8 !important;
        }
        /* select option 글씨 크기 */
        #countryFilterSelect option {
            font-size: 16px !important;
            padding: 12px 6px !important;
            line-height: 2 !important;
            background-color: #3e4a56 !important;
            color: #ffffff !important;
        }
        /* 민족필터 - 고정 크기 */
        #dynastyTimelineFilterPanel {
            flex-shrink: 0 !important;
            display: flex !important;
            align-items: center !important;
            gap: 2px !important;
            height: 26px !important;
            order: 2 !important;
        }
        #ethnicityFilterContainer {
            font-size: 13px !important;
            display: flex !important;
            align-items: center !important;
            gap: 2px !important;
            height: 100% !important;
        }
        /* 민족필터 select 요소 - 높이 및 글씨 크기 통일 */
        #ethnicityFilterContainer select {
            font-size: 13px !important;
            padding: 5px 4px !important;
            height: 100% !important;
            box-sizing: border-box !important;
            line-height: 1.8 !important;
        }
        /* 민족필터 select option 글씨 크기 */
        #ethnicityFilterContainer select option {
            font-size: 20px !important;
            padding: 12px 6px !important;
            line-height: 2 !important;
            background-color: #3e4a56 !important;
            color: #ffffff !important;
        }
        /* 검색 입력 및 버튼 - 남은 공간 차지하지 않고 고정 크기 */
        .right-controls > div:last-child {
            display: flex !important;
            align-items: center !important;
            position: relative !important;
            height: 26px !important;
            gap: 0 !important;
            flex: 0 0 auto !important;
            width: auto !important;
            order: 3 !important;
        }
        #searchInput {
            height: 100% !important;
            padding: 4px 6px !important;
            flex: 0 0 120px !important;
            font-size: 13px !important;
            min-width: 120px !important;
            box-sizing: border-box !important;
        }
        #searchBtn {
            height: 100% !important;
            flex-shrink: 0 !important;
            padding: 4px 10px !important;
            font-size: 13px !important;
            border-radius: 0 4px 4px 0 !important;
            border-left: none !important;
            box-sizing: border-box !important;
        }
        
        /* 레이어 토글 버튼 - 시간 컨트롤 내부로 이동 (모바일에서 줄바꿈) */
        #time-controls-map {
            position: fixed !important;
            top: 10px !important;
            left: 10px !important;
            right: 10px !important;
            max-width: calc(100% - 20px) !important;
            flex-wrap: wrap !important;
        }
        
        #time-controls-map > div {
            border-left: none !important;
            padding-left: 0 !important;
            margin-left: 0 !important;
            width: 100% !important;
            margin-top: 8px !important;
            padding-top: 8px !important;
            border-top: 1px solid rgba(255,255,255,0.2) !important;
        }
        
        .layer-toggle-btn {
            flex: 0 0 calc(25% - 4px) !important;
            font-size: 10px !important;
            padding: 3px 2px !important;
            margin: 2px !important;
        }
        #country-filter-container {
            flex: 0 0 auto !important;
            min-width: 85px !important;
            margin: 0 !important;
        }
        #country-filter-container label {
            display: none !important;
        }
        #countryFilterSelect {
            width: 85px !important;
            font-size: 11px !important;
            padding: 3px !important;
        }
        #dynastyTimelineFilterPanel {
            flex: 0 0 auto !important;
            min-width: auto !important;
            order: 2;
            margin: 0 !important;
        }
        #dynastyTimelineFilterPanel > div {
            display: flex !important;
            flex-direction: row !important;
            gap: 2px !important;
            font-size: 11px !important;
        }
        /* 검색 박스 - 남은 공간 사용 */
        .right-controls > div:last-child {
            flex: 1 1 auto !important;
            min-width: 100px !important;
            margin: 0 !important;
            display: flex !important;
            align-items: center !important;
            position: relative !important;
        }
        #searchInput {
            width: 100% !important;
            font-size: 11px !important;
            padding: 4px !important;
        }
        #searchBtn {
            padding: 4px 6px !important;
            font-size: 11px !important;
            flex-shrink: 0 !important;
        }
        
        /* 4줄: 슬라이더와 연대표 */
        #timeline-control {
            position: fixed !important;
            bottom: 0 !important; /* 🚩 [수정] 화면 최하단으로 이동 */
            left: 15% !important; /* 좌측 버튼 컨테이너와 겹치지 않게 조정 */
            right: 2.5% !important;
            width: auto !important;
            z-index: 9999 !important;
            background: transparent !important;
            padding: 10px !important;
            border-radius: 0 !important;
            backdrop-filter: none !important;
        }
        
        #timeline-container {
            height: 35px !important;
        }
        
        #timeline-fade-left,
        #timeline-fade-right {
            width: 80px !important;
        }
        
        /* 🚩 [추가] 모바일에서 레이어 토글 버튼 스타일 */
        #controls-wrapper .layer-toggle-btn {
            font-size: 11px !important;
            padding: 4px 2px !important;
        }
        /* 🚩 [추가] 모바일에서 편집 드롭다운 메뉴 스타일 조정 */
        #edit-dropdown-menu {
            min-width: 150px; /* 모바일에서 메뉴 너비 확보 */
        }
        
        /* 🚩 [추가] 지도 내부 컨트롤들 모바일 스타일 */
        #time-controls-map {
            position: fixed !important;
            top: 55px !important;
            left: 10px !important;
            right: 10px !important;
            width: auto !important;
            max-width: calc(100vw - 90px) !important;
            z-index: 500 !important;
            flex-wrap: wrap !important;
            padding: 6px !important;
        }
        
        #time-controls-map #timeLabelDisplay {
            font-size: 10px !important;
            min-width: 160px !important;
        }
        
        #time-controls-map #yearLabel {
            display: inline-block !important;
            min-width: 60px !important;
            text-align: right !important;
        }
        
        #time-controls-map #monthLabel {
            display: inline-block !important;
            min-width: 18px !important;
            text-align: right !important;
        }
        
        #time-controls-map #ganjiLabel {
            display: inline-block !important;
            min-width: 35px !important;
        }
        
        #time-controls-map #yearInput {
            width: 55px !important;
            min-height: 32px !important;
            font-size: 13px !important;
            padding: 4px !important;
        }
        
        #time-controls-map #monthInput {
            width: 38px !important;
            min-height: 32px !important;
            font-size: 13px !important;
            padding: 4px !important;
        }
        
        #time-controls-map .time-control-btn,
        #time-controls-map #playBtn,
        #time-controls-map #pauseBtn {
            min-height: 28px !important;
            font-size: 11px !important;
            padding: 3px 6px !important;
        }
        
        #time-controls-map input[type="range"] {
            min-height: 32px !important;
        }
        
        #time-controls-map label,
        #time-controls-map #speedDisplay {
            font-size: 11px !important;
        }
        
        #layer-toggles {
            width: 100% !important;
            margin-top: 8px !important;
            flex-wrap: wrap !important;
        }
        
        #layer-toggles .layer-toggle-btn {
            flex: 0 0 calc(33.333% - 6px) !important;
            min-height: 26px !important;
            font-size: 9px !important;
            padding: 3px 4px !important;
            margin: 2px !important;
        }
        
        #edit-controls {
            position: fixed !important;
            top: 55px !important;
            right: 10px !important;
            z-index: 500 !important;
        }
        
        #edit-controls button {
            min-height: 32px !important;
            padding: 6px 10px !important;
            font-size: 12px !important;
        }
        
        #map-search-filter {
            display: none !important; /* 🚩 [수정] 햄버거/탑바로 기능 이전 — 타일 리렌더 시 좌상단 노출 버그 방지 */
        }

        /* 각 필터 필 바 */
        .filter-pill {
            display: flex;
            align-items: center;
            height: 34px;
            background: #0e1a26;
            border: 1px solid #2a3a4a;
            border-radius: 17px;
            overflow: hidden;
            box-shadow: 0 2px 10px rgba(0,0,0,0.4);
            flex-shrink: 0;
        }

        /* 필 바 라벨 */
        .filter-pill-label {
            font-size: 9px;
            font-weight: 800;
            letter-spacing: 1.2px;
            text-transform: uppercase;
            color: #00aaff;
            padding: 0 10px;
            border-right: 1px solid #2a3a4a;
            height: 100%;
            display: flex;
            align-items: center;
            white-space: nowrap;
            flex-shrink: 0;
            background: rgba(0,170,255,0.06);
        }

        /* 필 바 내부 select */
        .filter-pill select {
            height: 100%;
            background: transparent;
            border: none;
            outline: none;
            color: #c0d4e8;
            font-size: 11px;
            padding: 0 24px 0 10px;
            min-width: 80px;
            appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234a7a9a'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 8px center;
            cursor: pointer;
        }

        /* 필 바 내부 input */
        .filter-pill input[type="number"],
        .filter-pill input[type="text"] {
            height: 100%;
            background: transparent;
            border: none;
            outline: none;
            color: #c0d4e8;
            font-size: 11px;
            padding: 0 10px;
            min-width: 0;
            text-align: center;
            -moz-appearance: textfield;
        }
        .filter-pill input[type="number"]::-webkit-inner-spin-button,
        .filter-pill input[type="number"]::-webkit-outer-spin-button {
            -webkit-appearance: none;
        }

        /* 필 바 내부 구분선 */
        .filter-pill-divider {
            width: 1px;
            height: 16px;
            background: #2a3a4a;
            flex-shrink: 0;
        }

        /* 필 바 내부 버튼 */
        .filter-pill button {
            height: 100%;
            padding: 0 12px;
            background: rgba(0,170,255,0.1);
            border: none;
            border-left: 1px solid #1a4060;
            cursor: pointer;
            color: #00aaff;
            font-size: 11px;
            font-weight: 700;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.2s;
            flex-shrink: 0;
            white-space: nowrap;
        }
        .filter-pill button:hover { background: rgba(0,170,255,0.22); }

        /* 아이콘 전용 버튼 */
        .filter-pill button.icon-only { padding: 0; width: 36px; }
        
        /* 모든 편집 폼 모바일 스타일 — 비활성 시 화면 밖으로 숨김 */
        #castleForm, #historyForm, #editForm, #battleForm,
        #cityForm, #labelForm, #naturalForm, #armyForm, #eventForm, #editBattleForm {
            position: fixed !important;
            top: -200vh !important;
            left: -200vw !important;
            transform: none !important;
            width: 90vw !important;
            max-width: 500px !important;
            max-height: 85vh !important;
            overflow-y: auto !important;
            z-index: 10000 !important;
            padding: 15px !important;
        }
        /* active 상태일 때만 화면 중앙에 표시 */
        #castleForm.active, #historyForm.active, #editForm.active, #battleForm.active,
        #cityForm.active, #labelForm.active, #naturalForm.active, #armyForm.active,
        #eventForm.active, #editBattleForm.active {
            top: 50% !important;
            left: 50% !important;
            transform: translate(-50%, -50%) !important;
        }
        
        #castleForm input, #historyForm input, #editForm input, #battleForm input,
        #cityForm input, #labelForm input, #naturalForm input, #armyForm input,
        #eventForm input, #editBattleForm input,
        #castleForm select, #historyForm select, #editForm select, #battleForm select,
        #cityForm select, #labelForm select, #naturalForm select, #armyForm select,
        #eventForm select, #editBattleForm select,
        #castleForm textarea, #historyForm textarea, #editForm textarea, #battleForm textarea,
        #cityForm textarea, #labelForm textarea, #naturalForm textarea, #armyForm textarea,
        #eventForm textarea, #editBattleForm textarea {
            min-height: 44px !important;
            font-size: 14px !important;
            padding: 10px !important;
            margin-bottom: 8px !important;
        }
        
        #castleForm button, #historyForm button, #editForm button, #battleForm button,
        #cityForm button, #labelForm button, #naturalForm button, #armyForm button,
        #eventForm button, #editBattleForm button {
            min-height: 44px !important;
            font-size: 14px !important;
            padding: 10px !important;
            margin: 5px !important;
        }
    }

    /* 🚩 [추가] 편집 드롭다운 메뉴 스타일 */
        #edit-dropdown-menu {
                display: none;
                position: absolute;
                right: 0;
                top: 100%;
                background-color: #ecf0f1;
                border: 1px solid #5d7185;
                border-radius: 4px;
                z-index: 1010;
                min-width: 120px;
                box-shadow: 0 4px 8px rgba(0,0,0,0.3);
                max-height: 60vh;
                overflow-y: auto;
        }
        /* (max-width: 967px) 미디어 쿼리 내 모바일 스타일은 force-mobile와 동일하게 맞추거나 삭제 */
    #edit-dropdown-menu.show {
        display: block;
    }
    /* 🚩 [추가] 드롭다운 메뉴 아이템 스타일 */
    .dropdown-item {
        width: 100%;
        text-align: left;
        padding: 8px 12px;
        border: none;
        background: none;
    }
    .dropdown-item.danger {
        color: #ff7675;
        font-weight: 600;
    }
    .dropdown-item.danger:hover {
        background-color: #c0392b;
        color: #fff;
    }
  