.gallery-wrapper {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.top-display-container {
    position: relative;
    width: 100%;
}

/* 1. KHUNG 3 ẢNH DỌC HIỂN THỊ BAN ĐẦU */
.top-portrait-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    transition: all 0.3s ease;
}

.portrait-slot {
    position: relative;
    height: 250px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(0, 240, 255, 0.4);
    background: #030c1a;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.slot-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(3, 14, 30, 0.85);
    color: #00f0ff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 8.5px;
    padding: 2px 5px;
    border-radius: 3px;
    border: 1px solid rgba(0, 240, 255, 0.5);
    z-index: 5;
}

/* 2. KHUNG 1 ẢNH DUY NHẤT (MẶC ĐỊNH LÀ KHUNG DỌC CHUẨN TỶ LỆ) */
.top-single-box {
    display: none;
    position: relative;
    width: 100%;
    max-width: 270px; /* Khóa chiều ngang để chuẩn khung DỌC */
    height: 360px;     /* Chiều cao dọc thanh thoát, không bị biến thành ảnh ngang */
    margin: 0 auto;    /* Căn giữa thiệp */
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #00f0ff;
    background: #020b18;
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.45);
    animation: techFadeIn 0.35s ease;
    transition: all 0.3s ease;
}

/* Tự động thích ứng nếu ảnh được bấm thực sự là ảnh ngang */
.top-single-box.is-landscape {
    max-width: 100%;
    height: 260px;
}

@keyframes techFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

/* Nút quay lại 3 ảnh */
.btn-reset-3photos {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 15;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    background: rgba(3, 14, 30, 0.9);
    border: 1px solid #00f0ff;
    color: #00f0ff;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.2s;
}

.btn-reset-3photos:hover {
    background: #00f0ff;
    color: #000;
    box-shadow: 0 0 10px #00f0ff;
}

/* 4 góc ngắm HUD */
.hud-bracket { 
    position: absolute; 
    font-size: 22px; 
    color: #00f0ff; 
    font-family: monospace; 
    z-index: 8; 
    pointer-events: none; 
}
.hud-tl { top: 4px; left: 6px; }
.hud-tr { top: 4px; right: 6px; }
.hud-bl { bottom: 4px; left: 6px; }
.hud-br { bottom: 4px; right: 6px; }

/* Tia quét laser */
.scanner-laser {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #00f0ff, transparent);
    box-shadow: 0 0 10px #00f0ff;
    z-index: 10;
    animation: scanAnimation 3.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes scanAnimation {
    0% { top: 0%; opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { top: 98%; opacity: 0; }
}

.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: opacity 0.3s ease;
}

/* Dòng gợi ý click nguyên bản ban đầu, xoay ngược 180 độ */
.click-hint {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #00f0ff;
    text-align: center;
    opacity: 0.9;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.click-hint i {
    display: inline-block;
    transform: rotate(180deg); /* Xoay ngược lại 180 độ */
    animation: bounce 1.2s infinite;
}

@keyframes bounce {
    0%, 100% { 
        transform: rotate(180deg) translateY(0); 
    }
    50% { 
        transform: rotate(180deg) translateY(-3px); 
    }
}

/* 3. HÀNG 3 ẢNH NGANG BÊN DƯỚI */
.bottom-landscape-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.landscape-slot {
    position: relative;
    height: 75px;
    border-radius: 8px;
    overflow: hidden;
    border: 1.5px solid rgba(0, 240, 255, 0.4);
    background: #020914;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.25s ease;
}

.landscape-slot:hover {
    transform: translateY(-3px);
    border-color: #00f0ff;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.8);
}

.landscape-slot.active {
    border-color: #00f0ff;
    box-shadow: 0 0 15px #00f0ff;
}

.landscape-slot:hover .gallery-img {
    transform: scale(1.08);
}

.landscape-tag {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(2, 10, 22, 0.88);
    color: #00f0ff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 700;
    text-align: center;
    padding: 3px 0;
    border-top: 1px solid rgba(0, 240, 255, 0.35);
    z-index: 4;
}

/* ====================================================
   BẢNG ĐIỀU KHIỂN CĂN CHỈNH ẢNH (HUD ADJUSTER)
   ==================================================== */
.adjuster-hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(1, 9, 20, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 25px;
    z-index: 9999;
    animation: fadeInHud 0.2s ease;
}

.hud-box {
    background: #061933;
    border: 1.5px solid #00f0ff;
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.4);
    border-radius: 12px;
    width: 90%;
    max-width: 360px;
    padding: 16px;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
}

.hud-title {
    color: #00f0ff;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 12px;
    text-align: center;
}

.hud-control {
    margin-bottom: 12px;
}

.hud-control label {
    display: block;
    font-size: 11px;
    color: #a5c2e2;
    margin-bottom: 5px;
}

.hud-control input[type="range"] {
    width: 100%;
    accent-color: #00f0ff;
    cursor: pointer;
}

.hud-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.hud-btn {
    flex: 1;
    padding: 8px 0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.2s;
}

.hud-btn.save {
    background: #00f0ff;
    color: #020914;
}

.hud-btn.close {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

@keyframes fadeInHud {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* =========================================
   LIGHTBOX FULLSCREEN PINCH & ZOOM
   ========================================= */
.image-lightbox {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(2, 9, 20, 0.94);
    backdrop-filter: blur(10px);
    z-index: 99999;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    touch-action: none;
}
.image-lightbox.active { display: flex; }

.lightbox-topbar {
    width: 100%;
    padding: 12px 20px;
    background: rgba(4, 18, 38, 0.9);
    border-bottom: 1px solid rgba(0, 240, 255, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}
.lightbox-title {
    color: #00f0ff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 700;
}
.lightbox-tools { display: flex; gap: 8px; }
.lb-btn {
    background: rgba(0, 240, 255, 0.15);
    border: 1px solid #00f0ff;
    color: #00f0ff;
    width: 36px; height: 36px;
    border-radius: 6px;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}
.lb-btn:hover { background: #00f0ff; color: #020914; }
.lb-btn.lb-close { color: #ff5f56; border-color: #ff5f56; font-size: 20px; }
.lb-btn.lb-close:hover { background: #ff5f56; color: #fff; }

.lightbox-viewport {
    flex: 1;
    width: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    position: relative;
}
.lightbox-viewport:active { cursor: grabbing; }

#lbImg {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    transition: transform 0.08s ease-out;
    transform-origin: center center;
    will-change: transform;
}

.lightbox-footer-hint {
    padding: 10px 15px;
    color: #8baece;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    background: rgba(3, 14, 30, 0.85);
    border-top: 1px solid rgba(0, 240, 255, 0.2);
    width: 100%;
    text-align: center;
}

/* Thêm hiệu ứng kính lúp khi hover vào ảnh to trên thiệp */
.top-single-box img#imgSingleMain {
    cursor: zoom-in;
}

/* Hiệu ứng trỏ chuột kính lúp cho 3 ảnh dọc */
.portrait-slot {
    cursor: zoom-in;
}
.portrait-slot .scanner-laser,
.portrait-slot .slot-badge {
    pointer-events: none; /* Tránh cản trở thao tác chạm/click vào ảnh */
}