/* ==========================================
   1. GLOBAL RESET & BASE STYLES
   ========================================== */

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
    
    /* [추가] 모바일 기기 롱터치 팝업 및 텍스트/이미지 선택 완벽 차단 */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
body, html { 
    margin: 0; padding: 0; width: 100%; height: 100%; 
    overflow: hidden; background: #000; 
    font-family: 'Segoe UI', 'Pretendard', -apple-system, sans-serif; 
}

#viewer-container { width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 1; }

#interface-zone { 
    position: absolute; z-index: 10; 
    color: #fff; display: flex; flex-direction: column; 
}

#scene-info-overlay { 
    position: absolute; top: 3.5vh; left: 2.5vh; z-index: 5; color: #fff; 
    font-size: 2.2vh; font-weight: bold; text-shadow: 2px 2px 4px #000; 
    pointer-events: none;
}

/* ==========================================
   2. LANDSCAPE LAYOUT (DESKTOP - 안정화)
   ========================================== */
@media (orientation: landscape) {
    #interface-zone { 
        top: 0; right: 0; 
        width: 35.56vh; height: 100vh; 
        padding: 4vh 2.5vh; 
        background: rgba(15, 15, 15, 0.95); 
        border-left: 1px solid rgba(255, 255, 255, 0.08);
        overflow: hidden;
        transition: background 0.3s ease;
    }
    
    #scene-info-overlay { display: block; }
    
    /* [핵심 수정] 가로형 화면에서 모바일 전용 인터페이스 완벽 차단 */
    .mobile-only-interface { display: none !important; }
    
    .desktop-fixed-container { 
        flex: 1; display: flex; flex-direction: column; 
        justify-content: space-between; 
        overflow: hidden; 
    }

    .logo-area { flex: 0 0 auto; text-align: center; }
    .main-logo { width: 22vh; height: auto; }

    .control-group { flex: 0 0 auto; width: 100%; }

    .btn-grid-2col, 
    .room-grid-2col { 
        display: grid; 
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 0.8vh; 
        width: 100% !important; 
        margin: 0 auto;
    }

    button { 
        width: 100% !important;
        background: #1c1c1c; color: #bbb; border: 1px solid #333;
        padding: 1.1vh 5px; border-radius: 4px; 
        font-size: 1.4vh; font-weight: bold;
        cursor: pointer; transition: 0.2s;
        display: flex; align-items: center; justify-content: center; text-align: center;
    }

    button:hover { background: #2b2b2b; }
    
    button.active { 
        background: #c5a059; 
        color: #000 !important; 
        border-color: rgba(0,0,0,0) !important;
    }
    
    button:disabled {
        opacity: 0.2 !important; cursor: not-allowed !important;
        pointer-events: none; border-color: #222 !important; color: #444 !important;
        background: #111 !important;
    }

    .room-section { flex: 0 0 auto; width: 100% !important; }
    
    .F-area { flex: 0 0 auto; width: 100%; }
}

/* ==========================================
   3. PORTRAIT LAYOUT (MOBILE - 안정화)
   ========================================== */
@media (orientation: portrait) {
    #interface-zone { 
        top: auto; bottom: 0; left: 0; width: 100%; height: auto; 
        padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); 
        background: rgba(15, 15, 15, 0.98);
        border-top: 1px solid rgba(255, 255, 255, 0.1); 
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6);
        transition: background 0.3s ease;
    }
    
    /* 세로형 화면에서 데스크톱 인터페이스 완벽 차단 */
    .desktop-fixed-container, #scene-info-overlay { display: none !important; }
    
    .mobile-only-interface { display: block; width: 100%; }
    
    #scene-info-overlay-m {
        position: fixed; top: 3.5vh; left: 16px; z-index: 99;
        color: #fff; font-size: 13px; font-weight: bold;
        text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9);
        pointer-events: none;
        transition: border-color 0.3s ease;
    }

    .mobile-only-interface .logo-area { 
        width: 100%; text-align: center; margin-bottom: 12px; padding-bottom: 8px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }
    .mobile-only-interface .main-logo { height: 22px; width: auto; object-fit: contain; }

    .main-btn-grid { 
        display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 100%; 
    }
    
    .main-btn-grid button { 
        background: #161616; color: #bbb; border: 1px solid #2d2d2d; border-radius: 8px; 
        font-weight: 600; font-size: 13px; padding: 12px 8px; width: 100%;
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.02); transition: all 0.2s ease;
    }
    
    .main-btn-grid button.active { 
        background: #c5a059; 
        color: #000 !important; 
        border-color: rgba(0,0,0,0) !important; 
        font-weight: bold;
    }
    
    .main-btn-grid button:disabled {
        opacity: 0.2 !important; cursor: not-allowed !important; pointer-events: none;
        border-color: #202020 !important; color: #444 !important; background: #111 !important;
    }
    
    .mobile-only-interface .minimap-area { 
        position: fixed; top: 3.5vh; right: 16px; 
        width: 85px; height: 85px; z-index: 99;
        border: 1px solid #c5a059; border-radius: 8px; overflow: hidden; 
        background: rgba(15, 15, 15, 0.75); backdrop-filter: blur(5px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.4);
        transition: border-color 0.3s ease;
    }
    
    #minimap-container-m { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
    #minimap-img-m { width: 100%; height: auto; max-height: 100%; object-fit: contain; }
}

/* ==========================================
   4. COMMON COMPONENTS (MINIMAP & POPUP)
   ========================================== */
#minimap-container { 
    position: relative; width: 100%; 
    background: transparent; 
    border-radius: 4px; overflow: hidden; 
}
#minimap-img { width: 100%; display: block; }

#popup-overlay { 
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0, 0, 0, 0.85); z-index: 100; align-items: center; justify-content: center; 
}
#popup-content { 
    background: #0f0f0f; width: 85%; max-width: 360px; border-radius: 15px; padding: 20px; 
    border: 1px solid #c5a059; 
    transition: border-color 0.3s ease;
}
#popup-header { text-align: center; color: #c5a059; margin-bottom: 20px; font-weight: bold; font-size: 16px; transition: color 0.3s ease;}
.btn-grid-popup { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-height: 50vh; overflow-y: auto; }
.btn-grid-popup button { background: #1a1a1a; color: #ccc; padding: 12px; border-radius: 6px; font-size: 13px; border: 1px solid #2d2d2d; }
.btn-grid-popup button.active { background: #c5a059; color: #000; border-color: rgba(0,0,0,0); font-weight: bold; }
.btn-grid-popup button:disabled { opacity: 0.2; cursor: not-allowed; pointer-events: none; color: #444; border-color: #202020; }
.close-btn { width: 100%; margin-top: 20px; background: #2a2a2a; color: #fff; border: none; padding: 12px; border-radius: 5px; font-size: 13px; }

/* ==========================================
   5. HOTSPOT & DEBUG UI (NEW)
   ========================================== */
/* 핫스팟 컨테이너 */
#hotspot-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 4; overflow: hidden;
}

/* [수정] 개별 핫스팟 (흰색 투명 박스 적용) */
.hotspot-element {
    position: absolute;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.25); /* 텍스트 흰색 투명박스 처리 */
    backdrop-filter: blur(2px); /* 배경을 살짝 흐리게 하여 고급스러움 추가 */
    border: none;
    color: #ffffff; /* 텍스트는 선명한 흰색 */
    padding: 8px 18px;
    border-radius: 10px; /* 부드러운 알약 형태 */
    font-size: 15px;                 
    font-weight: bold;
    cursor: pointer;
    pointer-events: auto;
    white-space: nowrap;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.8); /* 흰색 배경 위에서 글씨가 잘 보이도록 그림자 강화 */
    transition: background 0.2s, transform 0.2s; 
    animation: hotspotFadeIn 0.5s ease forwards; 
}

@keyframes hotspotFadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.hotspot-element:hover {
    background: rgba(255, 255, 255, 0.45); /* 호버 시 박스가 살짝 더 뚜렷해짐 */
    color: #ffffff; 
    transform: translate(-50%, -50%) scale(1.05); 
}

/* 디버그 모드 크로스헤어 */
#debug-crosshair {
    position: absolute; top: 50%; left: 50%;
    width: 20px; height: 20px;
    transform: translate(-50%, -50%);
    pointer-events: none; z-index: 9999;
}
#debug-crosshair::before, #debug-crosshair::after {
    content: ''; position: absolute; background: red;
}
#debug-crosshair::before { top: 9px; left: 0; width: 20px; height: 2px; }
#debug-crosshair::after { top: 0; left: 9px; width: 2px; height: 20px; }

/* 디버그 모드 UI 패널 */
#debug-panel {
    position: absolute; bottom: 20px; left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #0f0; font-family: monospace; font-size: 14px;
    padding: 15px; border: 1px solid #0f0; border-radius: 8px;
    z-index: 9999; text-align: center;
}
#debug-panel button {
    margin-top: 10px; background: #0f0; color: #000;
    border: none; padding: 5px 10px; cursor: pointer; font-weight: bold;
}

/* ==========================================
   6. MINIMAP HOTSPOT & DEBUG UI 확장
   ========================================== */
/* [수정] 미니맵 이동 아이콘 (포인트) */
.minimap-dot {
    position: absolute;
    border-radius: 50%;
    border: none; /* 흰색 외곽선 완전 삭제 */
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); /* 뒤에 그림자 음영만 살짝 */
    transition: transform 0.2s ease;
    aspect-ratio: 1 / 1; 
    padding-bottom: 0 !important; 
}

/* 마우스 오버 시 강조 */
.minimap-dot:hover {
    transform: translate(-50%, -50%) scale(1.4) !important;
    filter: saturate(100%) opacity(100%) !important;
    z-index: 20 !important;
}

/* 디버그 패널 텍스트 확장 (미니맵 좌표 포함용) */
#debug-panel {
    text-align: center;
    line-height: 1.6;
}
.debug-hint {
    font-size: 11px;
    color: #aaa;
    display: block;
    margin-top: 4px;
}

/* ==========================================
   미니맵 호버 툴팁 스타일 (신규)
   ========================================== */
#minimap-tooltip {
    position: fixed;
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    pointer-events: none; /* 툴팁 위로 마우스가 올라가도 간섭 없게 처리 */
    z-index: 10000;
    opacity: 10;
    transition: opacity 0.2s ease;
    transform: translateX(-50%); /* 정확히 도트 중앙 아래 위치 */
    white-space: nowrap;
}

/* ==========================================
   7. INTRO / SCREENSAVER VIDEO
   ========================================== */
#intro-video-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 99999; /* 모든 UI 위로 올라오도록 최상단 배치 */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

#intro-video-container.hidden {
    opacity: 0;
    pointer-events: none; /* 숨겨졌을 때 클릭 방지 */
}

#intro-video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 화면 비율에 맞춰 꽉 채우기 (여백 없이) */
}

/* 비디오 화면 중앙 안내 문구 스타일 */
.video-overlay-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    
    /* 기기 화면 크기에 맞춘 반응형 폰트 사이즈 (가로/세로 비율 고려) */
    font-size: 2.6vh; 
    font-weight: bold;
    text-align: center;
    line-height: 1.5;
    letter-spacing: -0.03em;
    
    /* 어두운 영상이나 밝은 영상 모두에서 글씨가 잘 보이도록 그림자 강화 */
    text-shadow: 2px 2px 12px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 0.5);
    
    /* 중요: 문구 자체를 터치해도 뒤의 컨테이너 클릭 이벤트(영상 종료)가 정상 작동하도록 설정 */
    pointer-events: none; 
    z-index: 100000;
}

/* 세로형 모바일 화면에서 글씨가 너무 작아지지 않도록 보정 */
@media (orientation: portrait) {
    .video-overlay-text {
        font-size: 18px;
        line-height: 1.6;
    }
}

/* 은은하게 맥박치듯 깜빡이는 애니메이션 효과 */
@keyframes textPulse {
    0% { opacity: 0.3; transform: translate(-50%, -50%) scale(0.97); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.03); }
    100% { opacity: 0.3; transform: translate(-50%, -50%) scale(0.97); }
}