html, body { width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; background-color: #000; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: white; user-select: none; -webkit-tap-highlight-color: transparent; }

/* 3D Canvas */
#canvas-container { width: 100vw; height: 100dvh; position: absolute; top: 0; left: 0; z-index: 1; background: radial-gradient(circle at center, #0a0a20 0%, #000000 100%); touch-action: none; }

/* UI LAYER: Đẩy xuống dưới thanh Header cố định */
#ui-layer { 
    position: absolute; 
    top: 105px !important; 
    left: 24px; 
    pointer-events: none; 
    z-index: 20; 
    transition: all 0.3s ease; 
}

@media (max-width: 768px) {
    #ui-layer { 
        top: 80px !important; 
        left: 14px; 
        max-width: calc(100vw - 28px); 
    }
}
h1 { margin: 0; font-size: 2rem; text-transform: uppercase; letter-spacing: 2px; background: linear-gradient(to right, #fbb034, #ffdd00); -webkit-background-clip: text; -webkit-text-fill-color: transparent; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
h2 { margin: 5px 0 0 0; font-size: 1.2rem; color: #4af; text-transform: uppercase; }
#ui-layer p { margin: 5px 0 0 0; font-size: 0.9rem; color: #aaa; }

.control-group { position: absolute; top: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; pointer-events: none; }

.control-btn { pointer-events: auto; touch-action: manipulation; padding: 10px 20px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.3); color: white; font-weight: bold; cursor: pointer; border-radius: 30px; backdrop-filter: blur(5px); transition: all 0.3s; text-align: right; display: block; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.control-btn:hover { background: rgba(255, 255, 255, 0.3); transform: scale(1.05); }
#btn-2d-map { background: rgba(70, 150, 255, 0.2); border-color: #4af; }
#btn-earth-info { background: rgba(40, 200, 100, 0.2); border-color: #2e8; }
#btn-back { background: rgba(255, 70, 70, 0.2); border-color: #f44; }

/* LOADING SCREEN */
#loading { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 9999; display: flex; flex-direction: column; justify-content: center; align-items: center; color: #ffaa00; font-family: monospace; transition: opacity 0.5s ease; }
.spinner { width: 40px; height: 40px; border: 4px solid #333; border-top: 4px solid #ffaa00; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 20px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.instruction { position: absolute; bottom: 20px; width: 100%; text-align: center; color: #ccc; font-size: 0.9rem; pointer-events: none; text-shadow: 0 2px 4px black; z-index: 20; background: linear-gradient(to top, rgba(0,0,0,0.8), transparent); padding: 10px 0; }

/* MAP CONTAINERS */
#map-2d-container, #maikai-map-container, #maikai-2nd-map-container, #maikai-3rd-map-container { position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 10; display: none; background: #000; overflow-x: hidden; overflow-y: auto; }
#map-wrapper, #maikai-wrapper, #maikai-2nd-wrapper, #maikai-3rd-wrapper { position: relative; width: 100%; height: auto; margin: 0; padding: 0; display: block; }
#map-image, #maikai-image, #maikai-2nd-image, #maikai-3rd-image { display: block; width: 100%; height: auto; object-fit: cover; }

/* Hotspots */
.hotspot { position: absolute; width: 1.5vw; height: 1.5vw; max-width: 20px; max-height: 20px; min-width: 12px; min-height: 12px; background: radial-gradient(circle, #ffeb3b 30%, #f57f17 100%); border: 2px solid #fff; border-radius: 50%; transform: translate(-50%, -50%); cursor: pointer; z-index: 2; box-shadow: 0 0 10px rgba(255, 235, 59, 0.8); transition: transform 0.2s; }
.hotspot:hover { transform: translate(-50%, -50%) scale(1.5); z-index: 100; }
.hotspot::after { content: attr(data-name); position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.9); color: #fff; padding: 4px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.2s; border: 1px solid #f57f17; box-shadow: 0 2px 5px rgba(0,0,0,0.5); }
.hotspot:hover::after { opacity: 1; }

.hotspot.highlight {
    background: radial-gradient(circle, #00ffff 30%, #0088ff 100%);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.9);
    border: 2px solid #fff;
    width: 1.8vw; height: 1.8vw;
    animation: pulse 2s infinite;
    z-index: 3;
}
@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 10px rgba(0, 255, 255, 0.7); }
    50% { transform: translate(-50%, -50%) scale(1.2); box-shadow: 0 0 20px rgba(0, 255, 255, 1); }
    100% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 10px rgba(0, 255, 255, 0.7); }
}

/* Text Label cho 2D Map */
.map-label { position: absolute; transform: translateX(-50%); background: rgba(0, 0, 0, 0.7); color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 12px; font-weight: bold; border: 1px solid #aaa; white-space: nowrap; cursor: pointer; z-index: 2; }

/* 3D Labels */
.label { position: absolute; color: rgba(255, 255, 255, 0.9); font-size: 11px; font-weight: bold; text-shadow: 0 0 4px #000; background: rgba(0, 0, 0, 0.5); padding: 2px 6px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.1); pointer-events: none; white-space: nowrap; transform: translate(-50%, -50%); z-index: 5; display: none; transition: opacity 0.2s ease; }
.label.earth-label { background: rgba(20, 100, 255, 0.6); border: 1px solid #4af; }
.label.maikai-label { background: rgba(200, 0, 0, 0.6); border: 1px solid #f00; }
.clickable-label { pointer-events: auto !important; cursor: pointer; border: 1px solid rgba(255, 221, 0, 0.5); background: rgba(0, 0, 0, 0.7); }
.clickable-label:hover { background: rgba(50, 50, 50, 0.9); color: #ffdd00; transform: translate(-50%, -50%) scale(1.1); z-index: 10; }

/* ============================================================ */
/* CẤU HÌNH POPUP CHUẨN: 80% MÀN HÌNH TRÊN PC & HỖ TRỢ DARK/LIGHT */
/* ============================================================ */
#popup-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100dvh; 
    background: rgba(0, 0, 0, 0.75); 
    z-index: 1000; 
    display: none; 
    justify-content: center; 
    align-items: center; 
    backdrop-filter: blur(8px); 
}

/* Mặc định trên Mobile: chiếm 92% */
#popup-content { 
    background: #121218; 
    border: 1px solid #2e2839; 
    width: 92vw; 
    max-width: 92vw; 
    max-height: 85vh; 
    border-radius: 16px; 
    display: flex; 
    flex-direction: column; 
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); 
    animation: popIn 0.3s ease-out; 
    position: relative; 
    color: #e5e7eb;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* 👉 TRÊN PC: ÉP CHIẾM ĐÚNG 80% CHIỀU RỘNG MÀN HÌNH */
@media (min-width: 768px) {
    #popup-content {
        width: 80vw !important;
        max-width: 80vw !important;
    }
}

#popup-header { 
    padding: 16px 24px; 
    background: rgba(255, 255, 255, 0.03); 
    border-bottom: 1px solid #2e2839; 
    border-radius: 16px 16px 0 0; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}
#popup-title { 
    margin: 0; 
    font-size: 1.25rem; 
    color: #facc15; 
    text-transform: uppercase; 
    font-weight: 800; 
}
#popup-close { 
    background: none; 
    border: none; 
    color: #9ca3af; 
    font-size: 2rem; 
    cursor: pointer; 
    line-height: 1; 
    transition: color 0.2s; 
}
#popup-close:hover { color: #ffffff; }

#popup-body { 
    padding: 24px md:p-8; 
    overflow-y: auto; 
    font-size: 0.95rem; 
    line-height: 1.7; 
    color: #d1d5db; 
    -webkit-overflow-scrolling: touch; 
}
#popup-body img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid #374151; margin: 12px auto; display: block; }
#popup-body h3 { color: #38bdf8; margin-top: 18px; border-bottom: 1px solid #374151; padding-bottom: 6px; }
#popup-body p { margin-bottom: 12px; }

/* ============================================================ */
/* ĐỒNG BỘ CHẾ ĐỘ SÁNG (LIGHT MODE) THEO TOÀN TRANG             */
/* ============================================================ */
.light #popup-content {
    background: #ffffff !important;
    border-color: #e5e7eb !important;
    color: #1f2937 !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15) !important;
}
.light #popup-header {
    background: #f9fafb !important;
    border-bottom-color: #e5e7eb !important;
}
.light #popup-title {
    color: #ea580c !important; /* Đổi sang màu cam nổi bật ở nền trắng */
}
.light #popup-close {
    color: #6b7280 !important;
}
.light #popup-close:hover {
    color: #111827 !important;
}
.light #popup-body {
    color: #374151 !important;
}
.light #popup-body h3 {
    color: #2563eb !important;
    border-bottom-color: #e5e7eb !important;
}
.light #popup-body img {
    border-color: #e5e7eb !important;
}
.light #popup-body table {
    border-color: #e5e7eb !important;
}
.light #popup-body th, 
.light #popup-body td {
    border-color: #e5e7eb !important;
}

/* Mobile */
@media (max-width: 768px) {
    body { position: fixed; width: 100%; height: 100%; }
    .label { font-size: 10px; padding: 1px 4px; } 
    .label.earth-label { display: none !important; }
    .label.earth-label.mobile-visible { 
        display: block !important; 
        opacity: 1 !important; 
        pointer-events: auto !important; 
    }

    #ui-layer { top: 10px; left: 10px; max-width: 60%; }
    #ui-layer h1 { font-size: 1rem; margin-bottom: 2px; }
    #ui-layer h2 { font-size: 0.8rem; }
    #ui-layer p { display: none; } /* ✅ Chỉ ẩn mô tả góc 3D ngoài màn hình */
    .control-group { top: 10px; right: 10px; gap: 5px; }
    .control-btn { padding: 6px 10px; font-size: 10px; border-radius: 15px; }
    .instruction { font-size: 0.7rem; padding: 5px 0; bottom: 10px; }

    #map-2d-container, #maikai-map-container, #maikai-2nd-map-container, #maikai-3rd-map-container { width: 100vw; height: 100dvh; overflow: auto; -webkit-overflow-scrolling: touch; background: #000; }
    #map-wrapper, #maikai-wrapper, #maikai-2nd-wrapper, #maikai-3rd-wrapper { width: max-content; height: 100%; position: relative; }
    #map-image, #maikai-image, #maikai-2nd-image, #maikai-3rd-image { width: auto; height: 100dvh; max-width: none; display: block; }
    
    .hotspot { width: 35px; height: 35px; border: 2px solid #fff; background: radial-gradient(circle, rgba(255,235,59,0.9) 30%, rgba(245,127,23,0.9) 100%); }
    .hotspot.highlight { width: 40px; height: 40px; background: radial-gradient(circle, #00ffff 30%, #0088ff 100%); }
    
    .hotspot::after { display: none; }
    #popup-overlay { align-items: center; padding: 0; }
    #popup-content { width: 95%; max-height: 85vh; margin: 0 auto; }
    #popup-title { font-size: 1.1rem; }
}

/* ============================================================ */
/* TYPOGRAPHY POPUP: NÉT CĂNG ĐẬM ĐÀ CẢ LIGHT MODE VÀ DARK MODE */
/* ============================================================ */
#popup-content {
    user-select: text !important; /* Cho phép bôi đen copy chữ */
}

/* 1. MẶC ĐỊNH (DARK MODE) */
#popup-body {
    color: #e5e7eb !important;
    font-size: 1rem;
    line-height: 1.75;
}
#popup-body p {
    color: #d1d5db !important;
    font-size: 1rem !important;
    line-height: 1.75 !important;
    margin-bottom: 1rem !important;
}
#popup-body strong, 
#popup-body b {
    color: #ffffff !important;
    font-weight: 700 !important;
}
#popup-body h1, 
#popup-body h2, 
#popup-body h3, 
#popup-body h4 {
    color: #38bdf8 !important;
    font-weight: 700 !important;
    margin-top: 1.5rem !important;
    margin-bottom: 0.75rem !important;
}
#popup-body .wp-caption-text,
#popup-body figcaption {
    color: #9ca3af !important;
    font-size: 0.85rem !important;
    text-align: center;
    margin-top: 0.35rem;
}

/* 2. CHẾ ĐỘ SÁNG (LIGHT MODE) - ĐẬM ĐÀ, RÕ NÉT 100% NHƯ BÀI GỐC */
.light #popup-body {
    color: #111827 !important;
}
.light #popup-body p,
.light #popup-body span:not([class*="text-"]):not([style*="color"]),
.light #popup-body li,
.light #popup-body td {
    color: #1f2937 !important; /* Đen than chuẩn typography, nét căng trên nền trắng */
    font-size: 1rem !important;
    line-height: 1.75 !important;
}
.light #popup-body strong, 
.light #popup-body b {
    color: #000000 !important;
    font-weight: 700 !important;
}
.light #popup-body h1,
.light #popup-body h2,
.light #popup-body h3,
.light #popup-body h4 {
    color: #0f172a !important; /* Tiêu đề màu đen đậm */
    border-bottom: 2px solid #fdba74 !important; /* Gạch chân màu cam nhạt đặc trưng bài gốc */
    padding-bottom: 6px !important;
    font-weight: 800 !important;
}
.light #popup-body .wp-caption-text,
.light #popup-body figcaption {
    color: #4b5563 !important; /* Chú thích ảnh xám đậm dễ đọc */
    font-size: 0.85rem !important;
    text-align: center;
}
.light #popup-body a {
    color: #ea580c !important;
    text-decoration: underline;
}
.light #popup-body a:hover {
    color: #c2410c !important;
}

/* 1. CHỈ KẺ 1 ĐƯỜNG VIỀN NGOÀI CÙNG CHO KHUNG SPOILER */
.light #popup-body .su-spoiler,
.light #popup-body details,
.light #popup-body div[class*="spoiler"]:not([class*="-title"]):not([class*="-icon"]):not([class*="-content"]) {
    background-color: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    color: #0f172a !important;
    padding: 0 !important;
    overflow: hidden;
}

/* 2. XÓA BỎ HOÀN TOÀN CÁC VIỀN THỪA LỒNG NHAU Ở TIÊU ĐỀ VÀ DẤU (+) */
#popup-body [class*="spoiler"] [class*="title"],
#popup-body [class*="spoiler"] [class*="icon"],
#popup-body [class*="spoiler"] [class*="content"],
#popup-body .su-spoiler-title,
#popup-body .su-spoiler-icon,
#popup-body .su-spoiler-content {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

/* Căn chỉnh lại padding của tiêu đề cho gọn gàng */
#popup-body .su-spoiler-title,
#popup-body [class*="spoiler-title"] {
    padding: 10px 14px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer !important;
}

/* ============================================================ */
/* RESPONSIVE TOÀN DIỆN CHO POPUP: CHỐNG TRÀN ẢNH, VIDEO, BẢNG  */
/* ============================================================ */

/* 1. KHÓA KHUNG POPUP KHÔNG CHO TRÀN THEO CHIỀU NGANG */
#popup-content {
    box-sizing: border-box !important;
    overflow: hidden !important;
}

#popup-body {
    box-sizing: border-box !important;
    overflow-x: hidden !important; /* Chặn hoàn toàn cuộn ngang gây mất chữ */
    overflow-y: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    word-break: break-word !important; /* Tự xuống dòng nếu gặp từ hoặc link quá dài */
    overflow-wrap: break-word !important;
}

/* 2. ÉP TẤT CẢ KHUNG CHỨA ẢNH CỦA WORDPRESS CO GIÃN 100% */
#popup-body figure,
#popup-body .wp-caption,
#popup-body .wp-block-image,
#popup-body .image {
    max-width: 100% !important;
    width: 100% !important; /* Ghi đè style="width: ...px" cố định của WP */
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
    clear: both !important;
}

/* 3. ĐIỀU CHỈNH ẢNH CO GIÃN TỰ NHIÊN, KHÔNG VỠ HẠT */
#popup-body img {
    max-width: 100% !important;
    width: auto !important; /* Ảnh nhỏ giữ nguyên cỡ, ảnh to tự co lại vừa màn hình */
    height: auto !important;
    object-fit: contain !important;
    display: block !important;
    margin-left: auto !important;
    margin-right: auto !important;
    border-radius: 8px !important;
}

/* 4. CHỮ CHÚ THÍCH ẢNH (CAPTION) CĂN CHỈNH GỌN GÀNG */
#popup-body .wp-caption-text,
#popup-body figcaption {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    text-align: center !important;
    font-size: 13px !important;
    padding: 6px 10px !important;
    line-height: 1.4 !important;
}

/* 5. RESPONSIVE CHO VIDEO YOUTUBE, IFRAME, EMBED */
#popup-body iframe,
#popup-body video,
#popup-body embed,
#popup-body object {
    max-width: 100% !important;
    width: 100% !important;
    aspect-ratio: 16 / 9 !important; /* Giữ chuẩn tỉ lệ màn hình video 16:9 */
    height: auto !important;
    display: block !important;
    border-radius: 8px !important;
    margin: 14px auto !important;
}

/* 6. BẢNG BIỂU (TABLE) NẾU CÓ TRONG WIKI TỰ ĐỘNG CÓ THANH CUỘN NẰM TRONG */
#popup-body table {
    max-width: 100% !important;
    width: 100% !important;
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-collapse: collapse !important;
    margin: 14px 0 !important;
}

/* ÉP TOÀN BỘ CHỮ, ĐOẠN VĂN VÀ ẢNH TRONG POPUP LUÔN HIỆN TRÊN MOBILE */
#popup-body p {
    display: block !important;
}

#popup-body img {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-width: 100% !important;
    height: auto !important;
}

#popup-body figure,
#popup-body .wp-caption {
    display: block !important;
}