/* ============================================================
   HỆ THỐNG VISUAL NOVEL - PHONG CÁCH UIT (XANH/TRẮNG)
   ============================================================ */
#vn-screen { 
    position: fixed; 
    top: 0; 
    left: 0;
    width: 100vw; 
    height: 100vh; 
    background-color: #f0cbcb; 
    overflow: hidden; 
    z-index: 999; /* Ép nổi lên trên cùng */
    /*CHỐNG BÔI ĐEN:*/
    -webkit-user-select: none; /* Chặn trên Safari/Chrome */
    -ms-user-select: none;     /* Chặn trên Edge/IE */
    user-select: none;         /* Lệnh chuẩn chung */
}
.vn-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover; background-position: center; transition: background-image 0.5s ease; }
#vn-sprite { 
    width: auto; 
    height: 85%; 
    bottom: 0; 
    top: auto; 
    left: 5%; /* Ép nhân vật đứng sát lề trái, cách lề 5% */
    object-fit: contain; 
    transition: opacity 0.3s ease; 
    filter: drop-shadow(0 0 20px rgba(0, 212, 255, 0.2)); 
}

/* ============================================================
   HỘP THOẠI CĂN TRÁI TUYỆT ĐỐI - CHUẨN ẢNH GỐC BÊN PHẢI
   ============================================================ */

/* 1. Khung thoại chính: Box rõ nét, đen sâu, ranh giới rành mạch */
.uit-dialogue-box, #uit-dialogue-box, .dialogue-box {
    position: absolute !important; 
    bottom: 0 !important; 
    left: 0 !important;
    width: 100vw !important; 
    height: 24vh !important; /* Chiều cao cố định */
    
    background: rgba(0, 0, 0, 0.2) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.15) !important;

    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    box-shadow: none !important; 
    border-radius: 0 !important; 
    transform: none !important; 
    margin: 0 !important;
    padding: 0 !important;
    z-index: 100 !important;
    display: block !important; /* Xóa flexbox gây lỗi đè chữ */

    transition: opacity 0.3s ease !important; /* Thêm hiệu ứng mờ dần */
}

.uit-name-tag {
    position: absolute !important;
    top: 0 !important; /* Chốt ở mép viền trên cùng */
    transform: translateY(-79%) !important; /* BÍ KÍP: Đẩy lên đúng 50% để đường viền cắt ngang giữa chữ */
    left: 15vw !important; 
    
    background: transparent !important; 
    color: #e2e8f0 !important; 
    padding: 0 !important; 
    border: none !important; 
    font-size: 1.5rem !important; 
    font-weight: bold !important; 
    letter-spacing: 1px !important;
    box-shadow: none !important;
    text-shadow: 2px 2px 4px rgba(0,0,0,1) !important;
    text-align: left !important;
    margin: 0 !important;
}

/* 3. Chữ thoại chính: Nằm gọn gàng bên trong hộp đen */
#dialogue-text, .dialogue-text, .narration-text {
    position: absolute !important;
    top: 30px !important; /* Đẩy xuống một xíu để chừa chỗ cho nửa dưới của Tên */
    left: 15vw !important; 
    width: 70vw !important; 
    
    text-align: left !important; 
    color: #ffffff !important; 
    font-size: 1.35rem !important; 
    line-height: 1.6 !important; 
    text-shadow: 2px 2px 4px rgba(0,0,0,1) !important;
    margin: 0 !important;
    padding: 0 !important;
    font-style: normal !important; 
    transform: none !important; 
}

/* 4. Mũi tên nháy (Góc phải dưới cùng) */
.uit-blink { 
    position: absolute !important; 
    bottom: 20px !important; 
    right: 5vw !important; 
    transform: none !important;
    color: #ffffff !important; 
    font-size: 1.2rem !important;
}

/* 5. Nhân vật (Sprite) - Giữ nguyên lề phải */
#vn-sprite {
    position: absolute !important;
    bottom: 0 !important;
    top: auto !important;
    left: 50% !important; /* Căn giữa từ lề trái */
    right: auto !important; /* Bỏ ép lề phải */
    height: 85vh !important; 
    object-fit: contain !important;
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
    
    /* BÍ KÍP CHUYỂN ĐỘNG: Thêm transition để mượt mà mọi thay đổi */
    transition: opacity 0.2s ease-out, transform 0.2s ease-out !important;
    transform: translateX(-50%) scale(1) !important; /* Kéo nhân vật lùi lại đúng tâm */
    opacity: 1; 
}

/* Class dùng để tạo hiệu ứng "bước ra ngoài" khi đổi nhân vật */
.sprite-changing {
    opacity: 0 !important;
    /* Dùng calc để giữ nguyên vị trí căn giữa (-50%) rồi mới lùi 30px tạo hiệu ứng */
    transform: translateX(calc(-50% + 30px)) scale(0.98) !important; 
}
/* Class ẩn hoàn toàn (lúc không có nhân vật) */
.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}
/* =========================================
   HIỆU ỨNG GLITCH RÁCH MÀN HÌNH (RGB SPLIT)
========================================= */
#cyber-glitch-overlay {
    position: fixed; inset: 0;
    z-index: 9998;
    display: none;
    /* Hiệu ứng sọc ngang của màn hình CRT hỏng */
    background: repeating-linear-gradient(
        0deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.15) 2px,
        transparent 2px, transparent 4px
    );
    pointer-events: none;
}

#cyber-glitch-overlay.active {
    display: block;
    /* Chớp tắt màu âm bản liên tục */
    animation: cyber-glitch-flash 0.15s infinite;
}

/* Các vệt xé màu RGB chạy loạn xạ */
.glitch-tear {
    position: absolute;
    width: 100%;
    left: 0;
    opacity: 0.8;
    mix-blend-mode: exclusion; /* Tạo hiệu ứng trộn màu dị thường */
}
.tear-1 { background: cyan; animation: tear-move-1 0.1s infinite; }
.tear-2 { background: red; animation: tear-move-2 0.15s infinite reverse; }
.tear-3 { background: lime; animation: tear-move-3 0.08s infinite; }

/* Các Animation tạo độ giật (Keyframes) */
@keyframes cyber-glitch-flash {
    0% { background-color: rgba(255,0,0,0.1); filter: invert(0); }
    25% { background-color: rgba(0,255,255,0.1); filter: invert(1) hue-rotate(90deg); }
    50% { background-color: rgba(0,255,0,0.1); filter: invert(0); }
    75% { background-color: rgba(255,0,255,0.1); filter: invert(1) blur(2px); }
    100% { background-color: rgba(10,25,47,0.1); filter: invert(0); }
}
@keyframes tear-move-1 {
    0% { top: 10%; height: 5vh; transform: skewX(10deg) translateX(-10px); }
    50% { top: 60%; height: 2vh; transform: skewX(-20deg) translateX(20px); }
    100% { top: 30%; height: 8vh; transform: skewX(5deg) translateX(-5px); }
}
@keyframes tear-move-2 {
    0% { top: 80%; height: 3vh; transform: translateX(-20px); }
    50% { top: 20%; height: 10vh; transform: translateX(30px); }
    100% { top: 50%; height: 4vh; transform: translateX(-10px); }
}
@keyframes tear-move-3 {
    0% { top: 40%; height: 1vh; transform: scaleY(2); }
    50% { top: 90%; height: 6vh; transform: scaleY(0.5); }
    100% { top: 15%; height: 2vh; transform: scaleY(1.5); }
}

/* Rung lắc cả màn hình game */
.screen-shake {
    animation: extremeShake 0.1s infinite;
}
@keyframes extremeShake {
    0% { transform: translate(8px, 8px) rotate(0deg); }
    25% { transform: translate(-8px, -5px) rotate(1deg); }
    50% { transform: translate(5px, -8px) rotate(-1deg); }
    75% { transform: translate(-5px, 8px) rotate(0deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* Kế thừa cục Flashbang trắng xóa */
#whiteout-overlay {
    position: fixed; inset: 0; background-color: white;
    z-index: 9999; opacity: 0; pointer-events: none; transition: opacity 0.1s;
}
.trigger-flashbang { opacity: 1 !important; }

/* ============================================================
   MENU ĐIỀU KHIỂN NHANH (NẰM SÁT ĐÁY DƯỚI CÙNG)
   ============================================================ */

/* Khung chứa các nút */
.vn-quick-menu {
    position: absolute !important; /* Neo vị trí bám theo khung hộp thoại */
    top: 12px !important;          /* Cách đường line ngang phía trên hộp thoại 12px */
    right: 3vw !important;         /* Căn lề lùi về góc phải */
    
    /* Gỡ bỏ các lệnh ghim góc dưới/trái cũ */
    bottom: auto !important; 
    left: auto !important; 
    transform: none !important; 
    
    display: flex !important; 
    gap: 20px !important;          /* Khoảng cách giữa các nút */
    z-index: 110 !important;
}

/* Style cho từng nút (Thanh mảnh, mộc mạc giống ảnh gốc) */
.vn-btn {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    
    color: rgba(255, 255, 255, 0.6) !important; /* Chữ mờ đi một chút */
    font-size: 1.0rem !important; /* Cỡ chữ nhỏ lại cho tinh tế */
    font-weight: 400 !important; /* Bỏ in đậm, giữ nét chữ thanh mảnh */
    letter-spacing: 0.5px !important;
    text-transform: none !important; /* Bỏ viết hoa toàn bộ, giữ nguyên gốc (Ví dụ: Log, Skip) */
    
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

/* Hiệu ứng khi rê chuột vào */
.vn-btn:hover {
    color: #ffffff !important; /* Sáng trắng lên */
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5) !important; /* Tỏa sáng nhẹ nhàng */
    transform: scale(1.05) !important; /* Hơi nhích to lên một tẹo */
}

/* Khi bấm chuột xuống */
.vn-btn:active {
    transform: scale(0.95) !important;
}

/* ============================================================
   MÀN HÌNH LỊCH SỬ (LOG) - STYLE TỐI GIẢN, SẮC NÉT
   ============================================================ */
#vn-log-screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.4); /* Lớp nền mờ mờ sau lưng bảng */
    z-index: 9999; 
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}

#vn-log-screen.active {
    opacity: 1; pointer-events: auto;
}

/* KHUNG CHỨA LOG (Giống ảnh gốc + Viền sắc nét) */
.log-container {
    width: 85%; height: 85%; /* To gần hết màn hình */
    background: rgba(15, 15, 15, 0.85); /* Đen mờ, nhìn thấu cảnh game phía sau */
    
    /* BÍ KÍP Ở ĐÂY: Viền mảnh 1px, màu trắng mờ, cực kỳ sắc nét và gọn */
    border: 1px solid rgba(255, 255, 255, 0.3); 
    border-radius: 4px; /* Hơi bo góc nhẹ xíu cho tinh tế */
    
    display: flex; flex-direction: column;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8); /* Bóng đổ cho bảng nổi bật lên */
}

/* ẨN TIÊU ĐỀ, CHỈ GIỮ LẠI NÚT TẮT NHỎ GÓC PHẢI */
.log-header {
    display: flex; 
    justify-content: space-between; /* Đẩy tiêu đề sang trái, nút tắt sang phải */
    align-items: center;
    padding: 20px 60px; /* Căn lề cho bằng với đoạn text bên dưới */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Đường kẻ phân cách siêu mảnh, mờ mờ */
}

.log-header h2 { 
    display: block !important; /* Lệnh ép hiện lại chữ */
    margin: 0;
    color: rgba(255, 255, 255, 0.7); /* Màu trắng ngà mờ nhẹ */
    font-size: 1rem;
    font-weight: 400; /* Nét chữ thanh mảnh, không in đậm */
    letter-spacing: 3px; /* Giãn chữ ra nhìn cho "điện ảnh" */
    text-transform: uppercase;
}

#close-log-btn {
    background: none; border: none; color: rgba(255, 255, 255, 0.4); 
    font-size: 1.5rem; cursor: pointer; transition: 0.2s; padding: 5px;
}

#close-log-btn:hover { 
    color: #fff; 
    transform: scale(1.2); 
}

/* KHU VỰC CHỨA CHỮ (Rộng rãi, thoáng đãng giống ảnh) */
#log-content-area {
    flex: 1; 
    padding: 40px 60px; /* Căn lề trái phải rộng ra */
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 25px; /* Khoảng cách giữa các đoạn thoại */
}

/* Thanh cuộn (Scrollbar) làm thanh mảnh lại cho hợp style */
#log-content-area::-webkit-scrollbar { width: 6px; }
#log-content-area::-webkit-scrollbar-track { background: transparent; }
#log-content-area::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 10px; }
#log-content-area::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }

/* STYLE CHO CHỮ TRONG LOG */
.log-item { display: flex; flex-direction: column; }

.log-name { 
    color: rgba(255, 255, 255, 0.4); /* Tên nhân vật mờ nhẹ */
    font-size: 0.95rem; margin-bottom: 4px; 
    text-transform: uppercase; letter-spacing: 1px;
}

.log-text, .log-narration { 
    color: #f0f0f0; /* Trắng ngà, không chói mắt */
    font-size: 1.25rem; 
    line-height: 1.8; /* Khoảng cách dòng rộng y chang ảnh */
    font-weight: 300; /* Nét chữ thanh mảnh */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* ============================================================
   MÀN HÌNH MENU CÀI ĐẶT
   ============================================================ */
#vn-menu-screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px);
    z-index: 9999; 
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}

#vn-menu-screen.active { opacity: 1; pointer-events: auto; }

.menu-container {
    width: 50%; height: auto; /* Menu không cần to như Log */
    min-height: 300px;
}

#menu-content-area {
    padding: 40px 60px;
    display: flex; flex-direction: column; gap: 30px;
}

.setting-row {
    display: flex; justify-content: space-between; align-items: center;
    color: #f0f0f0; font-size: 1.2rem;
}

.vn-slider {
    width: 55%; 
    cursor: pointer;
    accent-color: #00d2ff; /* Màu xanh công nghệ */
}

/* =========================================
   CHỐNG BÔI ĐEN CHO TOÀN BỘ GAME (TẤT CẢ CÁC TÒA)
   ========================================= */
#game-scene {
    -webkit-user-select: none; /* Chặn trên Safari/Chrome */
    -moz-user-select: none;    /* Chặn trên Firefox */
    -ms-user-select: none;     /* Chặn trên Edge/IE */
    user-select: none;         /* Lệnh chuẩn chung */
}

/* Đảm bảo các nút bấm cũng không bao giờ bị bôi đen lỗi */
button, .btn, .uit-btn, .action-btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}