.mig-countdown-wrapper {
    background-color: #314353; /* สีพื้นหลังตามภาพ */
    padding: 30px 15px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    border-radius: 8px;
    color: #ffffff;
}

/* ส่วน Header ที่มีเส้นประ 2 ข้าง */
.mig-countdown-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}
.mig-countdown-header .mig-line {
    flex-grow: 1;
    height: 1px;
    border-top: 1px dashed rgba(255, 255, 255, 0.3);
    max-width: 150px;
}
.mig-countdown-title {
    font-size: clamp(20px, 5vw, 26px);
    font-weight: 700;
    letter-spacing: 1px;
    margin: 0;
}

/* จัด Layout กล่องเวลา */
.mig-countdown-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: clamp(4px, 1.5vw, 15px);
}
.mig-unit-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.mig-cards {
    display: flex;
    gap: 4px; /* ระยะห่างระหว่างหลักสิบและหลักหน่วย */
}

.mig-colon {
    font-size: clamp(30px, 8vw, 45px);
    font-weight: 700;
    line-height: clamp(48px, 12vw, 75px); /* ให้ตรงกับความสูงกล่อง */
    color: rgba(255, 255, 255, 0.4);
}
.mig-unit-label {
    font-size: clamp(10px, 2.5vw, 12px);
    font-weight: 600;
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
}

/* --- ระบบ Flip Card ของจริง --- */
.mig-digit {
    --w: clamp(32px, 8vw, 55px);
    --h: clamp(48px, 12vw, 75px);
    --f: clamp(30px, 7vw, 45px);
    width: var(--w);
    height: var(--h);
    position: relative;
    border-radius: 6px;
    perspective: 800px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    background-color: var(--c-bg);
}

/* รอยตัดตรงกลาง */
.mig-digit::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(0, 0, 0, 0.4);
    z-index: 5;
}

.mig-top, .mig-bottom, .mig-flip-top, .mig-flip-bottom {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    color: #ffffff;
    font-size: var(--f);
    font-weight: 700;
}

.mig-top, .mig-flip-top {
    top: 0;
    align-items: flex-end; /* ดันข้อความลงไปชิดรอยตัด */
    transform-origin: bottom;
    background-color: var(--c-bg-dark); /* ครึ่งบนสีเข้มกว่านิดหน่อย */
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}
.mig-bottom, .mig-flip-bottom {
    bottom: 0;
    align-items: flex-start; /* ดันข้อความขึ้นมาชิดรอยตัด */
    transform-origin: top;
    background-color: var(--c-bg);
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.mig-top span, .mig-flip-top span { transform: translateY(50%); }
.mig-bottom span, .mig-flip-bottom span { transform: translateY(-50%); }

/* สีตามแผ่น */
.mig-color-orange { --c-bg: #ed9b40; --c-bg-dark: #dc8a2f; }
.mig-color-green  { --c-bg: #82be55; --c-bg-dark: #71ad44; }
.mig-color-red    { --c-bg: #c95656; --c-bg-dark: #b84545; }
.mig-color-purple { --c-bg: #a672b5; --c-bg-dark: #9561a4; }

/* Animation Classes */
.mig-flip-top { z-index: 2; }
.mig-flip-bottom { z-index: 1; transform: rotateX(90deg); }

.mig-flip-top.mig-animate {
    transform: rotateX(-90deg);
    transition: transform 0.25s ease-in;
}
.mig-flip-bottom.mig-animate {
    transform: rotateX(0deg);
    transition: transform 0.25s ease-out 0.25s;
}
/* --- บังคับหดตัวบน Mobile ขยายขนาดเต็มพิกัดจอ iPhone --- */
@media screen and (max-width: 480px) {
    .mig-countdown-header .mig-line {
        display: none !important; 
    }
    .mig-countdown-wrapper {
        padding: 20px 8px !important; /* ลด padding ขอบซ้ายขวาลงอีก เพื่อขอพื้นที่ตรงกลางเพิ่ม */
    }
    .mig-countdown-container {
        gap: 6px !important; /* ถ่างช่องว่างระหว่าง วัน-ชั่วโมง-นาที ออกอีกนิด */
    }
    .mig-cards {
        gap: 3px !important; 
    }
    .mig-digit {
        --w: 34px !important; /* ดันความกว้างขึ้น (เดิม 28px) */
        --h: 52px !important; /* ดันความสูงขึ้น (เดิม 42px) */
        --f: 30px !important; /* ดันฟอนต์ให้ตัวเบ้อเริ่ม (เดิม 24px) */
        border-radius: 5px !important;
    }
    .mig-colon {
        font-size: 26px !important;
        line-height: 52px !important;
        margin: 0 -2px !important; 
    }
    .mig-unit-label {
        font-size: 10px !important;
        margin-top: 6px !important;
        letter-spacing: 0.5px !important;
    }
}