/* --- BỐ CỤC NHÀ MÁY SẢN XUẤT --- */
.factory-arena {
    height: 180px;
    background: linear-gradient(180deg, #9e9e9e 0%, #616161 100%);
    box-shadow: inset 0 0 15px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
    border: 4px solid #424242;
    border-radius: 12px;
}

/* --- CẬP NHẬT CSS BÀI 71 --- */

/* 1. Kéo dài băng chuyền sát đuôi xe */
.conveyor-belt {
    position: absolute;
    bottom: 20%;
    left: 0;
    width: 78%; /* Tăng từ 60% lên 78% để chạm đuôi xe */
    height: 15px;
    background: repeating-linear-gradient(90deg, #424242, #424242 10px, #212121 10px, #212121 20px);
    border-radius: 5px;
    z-index: 2;
    animation: roll-belt 2s linear infinite;
}

/* 2. Mở rộng khoảng cách 2 chân đỡ cho cân đối */
.conveyor-legs {
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 60%; /* Tăng từ 40% lên 60% */
    height: 20%;
    border-left: 8px solid #ffb300;
    border-right: 8px solid #ffb300;
    z-index: 1;
}

/* 3. Sửa lại hiệu ứng bốc hàng (Chạy dọc băng chuyền rồi mới rớt vào thùng) */
.load-to-truck {
    animation: box-fly 1s ease-in forwards; /* Tăng thời gian lên 1s cho mượt */
}
@keyframes box-fly {
    0% { left: 10%; bottom: calc(20% + 15px); transform: rotate(0) scale(1); }
    60% { left: 70%; bottom: calc(20% + 15px); transform: rotate(0) scale(1); } /* Hộp trượt dọc băng chuyền */
    100% { left: 82%; bottom: 15%; transform: rotate(45deg) scale(0.5); opacity: 0; } /* Rơi tọt vào thùng xe */
}

/* 4. Sửa lại hiệu ứng rớt hàng khi tính sai (Rớt ở cuối băng chuyền) */
.fall-off {
    animation: box-drop 0.8s ease-in forwards;
}

@keyframes box-drop {
    0% { left: 10%; bottom: calc(20% + 15px); transform: rotate(0); }
    70% { left: 78%; bottom: calc(20% + 15px); transform: rotate(0); } /* Trượt đến mép */
    100% { left: 80%; bottom: -20px; transform: rotate(90deg); opacity: 0; } /* Rơi tuột xuống đất */
}

/* Thùng hàng (Box) */
.box-item {
    position: absolute;
    left: 10%;
    bottom: calc(20% + 15px);
    font-size: 3.5rem;
    z-index: 3;
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.on-conveyor {
    animation: box-bump 0.5s infinite alternate;
}
@keyframes box-bump {
    0% { transform: translateY(0); }
    100% { transform: translateY(-3px); }
}

/* Xe tải giao hàng */
.truck-item {
    position: absolute;
    right: 5%;
    bottom: 10%;
    font-size: 5rem;
    z-index: 4;
    transition: all 1s ease;
    filter: drop-shadow(-3px 3px 5px rgba(0,0,0,0.5));
}
.idle {
    animation: engine-vibrate 0.1s infinite;
}
@keyframes engine-vibrate {
    0% { transform: translateY(0); }
    100% { transform: translateY(1px); }
}

/* Hoạt ảnh bốc hàng lên xe */
.load-to-truck {
    animation: box-fly 0.6s ease-in forwards;
}

/* Xe tải nháy đèn báo nhận hàng */
.flash-lights {
    filter: drop-shadow(0 0 15px #ffd54f);
}

/* Hoạt ảnh thùng rớt */
.fall-off {
    animation: box-drop 0.5s ease-in forwards;
}


/* Lỗi hệ thống rung lắc */
.shake-error { animation: factory-alarm 0.4s infinite; filter: sepia(1) hue-rotate(-50deg) saturate(3); }
@keyframes factory-alarm {
    0% { transform: translate(0) rotate(0); }
    25% { transform: translate(-3px, 3px) rotate(-1deg); }
    50% { transform: translate(3px, -3px) rotate(1deg); }
    75% { transform: translate(-3px, -3px) rotate(-1deg); }
    100% { transform: translate(0) rotate(0); }
}

/* Xe tải rời đi khi thắng game */
.drive-away {
    animation: truck-leave 2s ease-in forwards;
}
@keyframes truck-leave {
    0% { right: 5%; }
    100% { right: -100%; opacity: 0; }
}

.min-h-75 { min-height: 90px; }