/* หน้า Side Panel */
.side-panel {
    position: fixed;
    top: 0;
    width: 700px !important; /* ปรับความกว้างเป็น 700px */
    right: -700px !important; /* ซ่อนไว้ในระยะที่เท่ากับความกว้าง */
    height: 100%;
    background: #1a1c20; /* หรือสีเดิมของคุณ */
    box-shadow: -5px 0 15px rgba(0,0,0,0.3);
    transition: 0.4s ease;
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* เมื่อพาเนลเปิด (สำหรับ PC ที่ไม่ได้คุมผ่าน inline style) */
.side-panel.open {
    right: 0 !important;
}

/* Footer ยึดติดล่าง */
.side-panel-footer {
    padding: 15px;
    border-top: 1px solid #eee;
    background: #f9f9f9;
}

.btn-clear-all {
    width: 100%;
    padding: 10px;
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

/* เมื่อเปิด Panel ให้หดคลังการ์ดทางซ้ายลง (ถ้าต้องการ) */
body.panel-open #main-wrapper {
    padding-right: 720px !important;
}

/* ซ่อนปุ่ม "เพิ่มลงเด็ค" ในคลังการ์ดเป็นค่าเริ่มต้น */
.add-to-deck-btn {
    display: none;
    width: 100%;
    background: #007bff;
    color: white;
    border: none;
    padding: 5px;
    cursor: pointer;
    margin-top: 5px;
    border-radius: 4px;
}



/* โหมดจัดเด็ค ให้โชว์ปุ่มเพิ่มลงเด็คในการ์ดทุกใบ (ย่อพาเนลอยู่ก็ยังโชว์) */
body.mode-build .add-to-deck-btn {
    display: block;
}

/* โหมดดูการ์ด: ไม่มีพาเนลเด็คและปุ่มดึงพาเนล การ์ดเต็มจอ */
body.mode-browse .deck-toggle-handle {
    display: none;
}
body.mode-browse .side-panel {
    visibility: hidden;
}

/* การ์ดจำลองที่ใช้ทำแอนิเมชั่น */
.flying-card {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    /* เปลี่ยนจาก transition ธรรมดา เป็นการคุม transform และ opacity */
    transition: transform 0.8s cubic-bezier(0.19, 1, 0.22, 1), 
                opacity 0.8s ease-out, 
                width 0.8s ease, 
                height 0.8s ease;
    box-shadow: 0 12px 25px rgba(0,0,0,0.4);
    border-radius: 10px; /* ให้มนเท่ากับการ์ดจริง */
    object-fit: contain; /* เปลี่ยนเป็น contain เพื่อไม่ให้รูปโดนตัดตอนบิน */
    will-change: transform, opacity; /* ช่วยให้ Animation ลื่นไหลขึ้น */
    opacity: 1;
}

/* 1. ตัว Side Panel หลัก */

/* 2. ส่วนหัว (ล็อคอยู่กับที่) */
.side-panel-header {
    padding: 15px;
    background: #ffffff;
    opacity: 80;
    border-bottom: 2px solid #ffbf00;
}

.deck-name-field {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ffbf00;
    border-radius: 5px;
    font-family: 'Kanit', sans-serif;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}




/* 4. ส่วนท้ายที่มีปุ่ม (ล็อคอยู่กับที่ด้านล่าง) */
.deck-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    background: white;
    flex-shrink: 0; /* ป้องกันไม่ให้ส่วนท้ายโดนบีบหด */
}




/* ถ้าเป็นการ์ด Commander ให้เพิ่มประกายแสงสีทองตอน Hover */
.starter-zone .deck-item[data-commander="true"] img:hover {
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.8);
}



			/* ไอเทมการ์ดแต่ละใบในเด็ค */




/* 1. คอนเทนเนอร์หลักของแต่ละใบ */
.deck-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
    isolation: isolate; /* ป้องกันการขยายของรูปไปทับตำแหน่งปุ่มใบข้างๆ */
}


/* =========================================================
   GOLDEN QTY CONTROL - SIDE PANEL
   ========================================================= */

/* คอนเทนเนอร์ปุ่มควบคุม - ปรับเป็นสีดำเข้มขอบทอง */
.qty-control {
    display: flex;
    align-items: stretch;
    justify-content: center;
    margin-top: 5px;
    width: 100%;
    height: 28px; /* เพิ่มความสูงนิดนึงให้ดูเต็ม */
    border: 1px solid rgba(212, 175, 55, 0.4); /* ขอบทองจางๆ */
    border-radius: 4px;
    overflow: hidden;
    background: #1a1a1a; /* พื้นหลังดำสนิท */
    box-sizing: border-box;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

/* ปุ่มบวก/ลบ - ปรับเป็นโทนทองหม่น */
.qty-btn {
    width: 28px;
    flex-shrink: 0;
    padding: 0;
    font-size: 14px;
    font-weight: bold;
    border: none;
    background: #252525; /* พื้นหลังปุ่มเทาเข้ม */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

/* สีปุ่มลบ - แดงทอง */
.qty-btn.minus { 
    color: #e74c3c; 
    border-right: 1px solid rgba(212, 175, 55, 0.2); 
}

/* สีปุ่มบวก - เขียวทอง */
.qty-btn.plus { 
    color: #2ecc71; 
    border-left: 1px solid rgba(212, 175, 55, 0.2); 
}

/* Hover: ให้ปุ่มสว่างขึ้นและเป็นสีทอง */
.qty-btn:hover { 
    background: #d4af37; 
    color: #1a1a1a !important; /* เปลี่ยนตัวอักษรเป็นดำเมื่อ hover บนพื้นทอง */
}

/* ตัวเลขจำนวน - สีทองสว่าง */
.qty-number {
    flex-grow: 1;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent; /* ให้เห็นพื้นหลังสีดำของตัวแม่ */
    color: #f1c40f; /* สีทองสว่าง */
    text-shadow: 0 0 5px rgba(241, 196, 15, 0.3); /* แสงฟุ้งสีทอง */
}

/* 4. ปรับ Grid ให้มีพื้นที่หายใจ */
.deck-grid {
    display: grid;
    /* ลองลด min จาก 85px เหลือสัก 75px - 80px หากรูปดูเล็กไปในกรอบ */
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); 
    gap: 12px 8px; /* บน-ล่าง 12px, ซ้าย-ขวา 8px */
    padding: 10px;
    align-content: start;
}



					/* ป้ายกำกับแถบต่างๆ */
.deck-section-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    margin-top: 20px;
    margin-bottom: 10px;
    font-family: 'Kanit', sans-serif;
    letter-spacing: 1px; /* เพิ่มระยะห่างตัวอักษรให้ดูเป็นสากล */
}

/* ใส่กรอบสีทองให้คอมมานเดอร์ในหน้าเด็ค */
.starter-zone .deck-item[data-commander="true"] {
    border: 3px solid #f1c40f;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.5);
    border-radius: 8px;
}


/* แถบตัวนับตัวเลขข้างในให้ดูโปร่งแสงนิดๆ */
.deck-section-label {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}


.main-deck-label {
    background: linear-gradient(90deg, #2d3436 0%, #006ae3 50%, #2d3436 100%);
    border-bottom: 2px solid #ff8c00; /* ขอบทองด้านล่าง */
    color: #fff;
	}
	
.extra-deck-label {
    background: linear-gradient(90deg, #2d3436 0%, #6c5ce7 50%, #2d3436 100%);
    border-bottom: 2px solid #ffd700; /* ขอบทองด้านล่าง */
    color: #fff;
}



/* หัวข้อหมวดหมู่ในหน้าจัดเด็ค */
.deck-category-title {
    grid-column: 1 / -1; /* ให้ยืดเต็มแถวของ Grid */
    background: #444;
    color: #fff;
    padding: 5px 10px;
    font-size: 13px;
    border-radius: 4px;
    margin-top: 10px;
    margin-bottom: 5px;
    font-family: 'Kanit', sans-serif;
    display: flex;
    justify-content: space-between;
}

/* ปรับความห่างในหน้าจัดเด็คเล็กน้อย */
.deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); /* ปรับขนาดเล็กลงหน่อยเพื่อให้ดูเหมือน Master Duel */
    gap: 8px;
    align-content: start;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}



/* คุมภาพรวมของ Panel ให้เป็น Flex แนวตั้ง */
.side-panel {
    display: flex;
    flex-direction: column;
    height: 100vh; /* บังคับสูงเท่าจอพอดี */
    /* ... ค่าอื่นๆ ที่คุณมีอยู่แล้ว ... */
}

/* =========================================================
   DARK GOLD THEME - SIDE PANEL
   ========================================================= */

/* 1. Header: พื้นหลังเข้ม ตัดขอบล่างด้วยสีทองไล่เฉด */
.side-panel-header {
    flex-shrink: 0;
    padding: 20px;
    background: #252525; /* สีพื้นหลังส่วนหัว (สว่างกว่าตัวนิดนึงให้มีมิติ) */
    color: #fff;         /* สีตัวอักษรขาว */
    
    /* เทคนิคเส้นขอบสีทองไล่เฉด (Gold Gradient Border) */
    border-bottom: 3px solid transparent;
    border-image: linear-gradient(to right, #8a6e2f, #f9f295, #e0aa3e, #8a6e2f) 1;
    
    /* เงาเล็กน้อยให้ดูลอย */
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    z-index: 10; /* ให้เงาทับส่วน Body */
}

/* ปรับสีตัวอักษรหัวข้อข้างใน (ถ้ามี h2 หรือ h3) */
.side-panel-header h2, 
.side-panel-header h3 {
    color: #f1c40f; /* สีทองสว่าง */
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* 2. Body: พื้นหลังดำโปร่งแสงเล็กน้อย */
.deck-body {
    flex: 1 1 auto;
    overflow-y: auto !important;
    overflow-x: hidden;
    box-sizing: border-box;
    padding: 20px;

    /* สีพื้นหลังดำเทา แบบมีความโปร่งแสงนิดๆ (Glassmorphism Dark) */
    background-color: rgba(30, 30, 30, 0.95) !important; 
    backdrop-filter: blur(10px); /* เบลอฉากหลังที่ซ้อนอยู่ */
    
    scrollbar-width: thin;
    scrollbar-color: #d4af37 #1a1a1a; /* Firefox: ทอง / ดำ */
    -webkit-overflow-scrolling: touch;
    color: #e0e0e0; /* สีตัวอักษรในลิสต์ */
}

/* 3. Footer: พื้นหลังเข้ม ขอบบนทอง */
.side-panel-footer {
    flex-shrink: 0;
    padding: 20px;
    background: #252525;
    
    /* เส้นขอบบนสีทองไล่เฉด */
    border-top: 3px solid transparent;
    border-image: linear-gradient(to right, #8a6e2f, #f9f295, #e0aa3e, #8a6e2f) 1;
    
    box-shadow: 0 -4px 10px rgba(0,0,0,0.3);
}

/* =========================================================
   CUSTOM SCROLLBAR (GOLD STYLE)
   ========================================================= */

/* ความกว้าง Scrollbar */
.deck-body::-webkit-scrollbar {
    width: 8px; /* ปรับให้เล็กเรียบหรู */
    display: block !important;
}

/* ราง Scrollbar (Track) - สีดำ */
.deck-body::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-left: 1px solid #333;
}

/* ตัวเลื่อน (Thumb) - สีทองไล่ระดับ */
.deck-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #bf953f, #fcf6ba, #aa771c);
    border-radius: 4px;
    border: 1px solid #5e4b25; /* ขอบเข้มตัดให้ดูคม */
}

/* ตอนเอาเมาส์ชี้ */
.deck-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #d4af37, #fffacd, #b8860b);
}

/* =========================================================
   ADDITIONAL: ปรับการ์ดในลิสต์ให้เข้ากับธีมมืด
   ========================================================= */

/* ถ้าคุณมี Class สำหรับรายการการ์ด (สมมติชื่อ .deck-item) */
/* รายการการ์ดแต่ละใบในหน้าจัดเด็ค */
.deck-item {
    display: flex;
    align-items: center;
    background: rgba(40, 40, 40, 0.6); /* ดำเทาโปร่งแสง */
    border: 1px solid rgba(212, 175, 55, 0.3); /* ขอบทองจางๆ */
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 8px;
    box-sizing: border-box; /* กัน width:100% + padding/border ดันความกว้างล้นจอ */
    transition: all 0.3s ease;
    position: relative;
    overflow: visible; /* ยอมให้รูปภาพ Hover แล้วลอยทะลุออกมาได้ */
}

.deck-item:hover {
    background: rgba(50, 50, 50, 0.9);
    border-color: rgba(212, 175, 55, 0.8); /* ขอบทองสว่างขึ้นเมื่อชี้ */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* ส่วนของรูปภาพการ์ดใน Side Panel */
.deck-item img {
    width: 60px !important; /* ปรับขนาดให้พอดีกับแถว */
    aspect-ratio: 2 / 3; 
    object-fit: cover !important; 
    border-radius: 4px;
    display: block;
    margin: 0;
    padding: 0 !important;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* เพิ่มความนุ่มนวลเวลาเด้ง */
    
    /* เพิ่มขอบให้รูปภาพดูเหมือนการ์ดจริง */
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
}

/* Hover เฉพาะรูป ลอยขึ้นและขยาย */
.deck-item img:hover {
    transform: translateY(-5px) scale(1.3); /* ขยายใหญ่ขึ้นเพื่อให้เห็น Text บนการ์ดชัดเจน */
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.8);
    z-index: 100;
    border-color: #f1c40f; /* ขอบทองสว่างตอนซูม */
}

/* คอนเทนเนอร์ปุ่มดึง */
.deck-toggle-handle {
    position: absolute;
    left: -30px; /* ดึงปุ่มออกไปนอกหน้าต่างจัดเด็ค */
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 60px;
    background-color: #2d3436; /* สีเดียวกับ Main Deck Label */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px 0 0 8px; /* มนเฉพาะฝั่งซ้าย */
    box-shadow: -2px 0 5px rgba(0,0,0,0.2);
    transition:  0.3s;
    z-index: 9999;
}

.deck-toggle-handle:hover {
    background-color: #e7a900;
}


/* ไอคอนสามเหลี่ยม */
.triangle-icon {
    font-size: 12px;
    transition: transform 0.4s;
}

/* เมื่อหน้าจัดเด็คเปิดอยู่ ให้หมุนสามเหลี่ยมกลับทาง */
.side-panel.open .triangle-icon {
    transform: rotate(180deg);
}

/* การ์ดที่ถูก Disable (เช่น ใส่ครบแล้ว หรือเงื่อนไขไม่ผ่าน) */
.card.disabled-card {
    filter: grayscale(100%) brightness(0.7); /* ทำให้เป็นสีเทาและมืดลง */
    cursor: pointer; /* ยังคงให้เมาส์เป็นรูปมือเพื่อให้รู้ว่าคลิกได้ */
    transition: all 0.3s ease;
}

/* เมื่อเอาเมาส์ชี้การ์ดที่สีเทา ให้สว่างขึ้นนิดหน่อยเพื่อให้รู้ว่ายังมีปฏิสัมพันธ์ได้ */
.card.disabled-card:hover {
    filter: grayscale(50%) brightness(0.9);
    transform: translateY(-5px); /* ยังคงให้มีการ Hover เล็กน้อย */
}

/* ปรับปุ่มข้างล่างการ์ดที่เป็นสีเทาให้ดูจางลง */
.card.disabled-card .deck-item-controls button {
    background-color: #666 !important;
    cursor: not-allowed; /* ปุ่มเพิ่มลงเด็คให้เป็นรูปห้ามกด */
}



/*//*เซฟเด็ค/*//*
/* ปุ่มเซฟเด็ค (ทับอันเดิม) - สีน้ำเงิน/เขียวเข้ม */
.btn-save-main {
    background: #0bd65f !important; 
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
	    margin-left: 5px;
}

/* ปุ่มเซฟเป็นอันใหม่ - สีส้มทอง */
.btn-save-new {
    background: #0bd65f !important;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
	    margin-left: 5px;
}

.btn-save-main:hover, .btn-save-new:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}


/* ปุ่มเปิดโหมดเลือกปก */
.btn-select-cover {
    background: #2b113b !important;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 10px;
    margin-left: 5px;
}

/* Overlay ทับหน้าจอตอนเลือกปก */
#coverModeOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.2);
    z-index: 1004; /* อยู่ใต้ Side Panel นิดเดียว */
}



/* --- ส่วนที่แก้ไขเพื่อแก้บั๊คโหมดเลือกปก --- */

/* 1. ปรับระดับ Side Panel ให้ลอยเหนือ Overlay ทุกอย่างเมื่ออยู่ในโหมดเลือกปก */
.side-panel.selecting-cover-active {
    z-index: 1005 !important; /* ต้องสูงกว่า #coverModeOverlay (1004) */
}

/* 2. เมื่ออยู่ในโหมดเลือกปก ให้ภาพการ์ดในเด็คโดดเด่นและกดได้ */
.selecting-cover-active .deck-item img {
    cursor: crosshair !important;
    filter: brightness(0.7); /* ทำให้มืดลงเพื่อรอการเลือก */
    transition: all 0.3s ease;
    position: relative;
    z-index: 1006;
    pointer-events: auto; /* มั่นใจว่ารูปภาพรับการคลิกได้ */
}

/* 3. เอฟเฟกต์ตอน Hover การ์ดที่จะเลือก */
.selecting-cover-active .deck-item img:hover {
    filter: brightness(1.2) !important;
    border: 3px solid #6c5ce7 !important;
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.8) !important;
    transform: scale(1.05) translateY(-5px);
}

/* 4. ปิดการทำงานของปุ่มอื่นๆ ในเด็คชั่วคราวขณะเลือกปก เพื่อป้องกัน Event ตีกัน */
.selecting-cover-active .qty-control,
.selecting-cover-active .btn-remove,
.selecting-cover-active .deck-toggle-handle,
.selecting-cover-active .side-panel-footer {
    pointer-events: none; /* ห้ามคลิกปุ่มบวกลบหรือปุ่มเซฟขณะเลือกปก */
    opacity: 0.6;
}

/* 5. ไฮไลท์การ์ดที่เป็นปกปัจจุบัน */
.deck-item.is-cover-now img {
    border: 3px solid #f1c40f !important;
    box-shadow: 0 0 15px #f1c40f !important;
    filter: brightness(1.1);
}

/* 6. เพิ่มป้ายบอกว่าเป็น Cover (Optional: ช่วยให้ UX ชัดเจนขึ้น) */
.deck-item.is-cover-now::before {
    content: "⭐ COVER";
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: #f1c40f;
    color: #000;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 1007;
    pointer-events: none;
}

/* 7. Overlay ทับหน้าจอ (แก้ให้รับคลิกเฉพาะนอก Side Panel) */
#coverModeOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.4); /* ทำให้จอมืดลงเห็นชัดขึ้น */
    z-index: 1004; /* อยู่ใต้ Side Panel ที่เป็น 1005 */
    cursor: pointer;
}

/* --- คงไว้ซึ่งฟังก์ชันเดิม (ห้ามเปลี่ยน) --- */
.side-panel {
    /* ... ค่าเดิมของคุณ ... */
    z-index: 999; 
}


/*ปุ่มลบคอมมานเดอร์ มาสเตอร์*/

/* คอนเทนเนอร์ใหม่ ป้องกันการชนกับชื่อเดิม */
/* คอนเทนเนอร์สำหรับปุ่ม (แสดงตลอดเวลา) */
/* คอนเทนเนอร์ปุ่มด้านล่างการ์ด */
.deck-item-bottom-controls {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 5px;   /* ดันปุ่มลงมาจากส่วน Qty Control */
    padding-bottom: 5px;
}

/* ปรับแต่งปุ่ม (ให้ดูเป็นปุ่มกดเต็มตัวมากขึ้น) */
.btn-custom-action {
    all: unset;
    cursor: pointer;
    padding: 4px 15px; /* เพิ่มพื้นที่กดให้กว้างขึ้น */
    border-radius: 6px;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn-custom-action:hover {
    transform: translateY(-2px); /* ให้ความรู้สึกเหมือนปุ่มลอยขึ้นเวลาชี้ */
    filter: brightness(1.1);
}

.btn-custom-action:active {
    transform: translateY(0);
}

/* สีปุ่ม ปลด (Commander) */
.btn-detach-cmd {
    background: #ffc107;
    color: #212529;
    border-bottom: 3px solid #b7950b; /* เพิ่มมิติให้เหมือนปุ่มกด */
}

/* สีปุ่ม เอาออก (Master) */
.btn-eject-master {
    background: #007bff;
    color: #ffffff;
    border-bottom: 3px solid #0056b3;
}



/*กราฟแื่ง*/
/* 1. ตัว Panel หลัก (กล่องหุ้ม) */
#typeHistogramPanel {
    display: block !important; /* บังคับให้เป็น block เพื่อใช้ transition ได้ */
    max-height: 0;             /* เริ่มต้นที่ความสูง 0 */
    opacity: 0;                /* เริ่มต้นแบบโปร่งใส */
    overflow: hidden;          /* ซ่อนเนื้อหาที่เกินออกไป */
    transform: translateY(-10px); /* เลื่อนขึ้นไปด้านบนนิดหน่อย */
    transition: 
        max-height 0.4s ease-out, 
        opacity 0.3s ease, 
        transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        margin 0.3s ease;
    margin-bottom: 0;
    pointer-events: none;      /* กันไม่ให้คลิกโดนตอนที่ยังไม่เปิด */
}

/* 2. เมื่อมีการเติม Class 'open' (กดเปิด) */
#typeHistogramPanel.open {
    max-height: 500px;         /* ปรับให้พอดีกับเนื้อหา (หรือใช้ 1000px เผื่อไว้) */
    opacity: 1;                /* แสดงตัวตน */
    transform: translateY(0);  /* เลื่อนกลับมาตำแหน่งปกติ */
    margin-bottom: 20px;       /* เว้นระยะห่างด้านล่าง */
    pointer-events: auto;      /* กลับมาคลิกได้ปกติ */
    padding: 15px;             /* ใส่ Padding ตอนเปิด */
}

/* 3. ตกแต่งภายใน Container ของกราฟ */
.histogram-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 5px;
}

/* 4. สไตล์ของแถบกราฟ (เพื่อให้ดูเป็น Dinomaster มากขึ้น) */
.hist-row {
    width: 100%;
}

.hist-bar-bg {
    background: rgba(255, 255, 255, 0.1);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.hist-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1); /* แอนิเมชันตอนกราฟวิ่ง */
}

/* บังคับให้หน้าต่าง Modal อยู่หน้าสุดเสมอ แม้จะเปิดจากโหมด Showcase */
#imageModal {
    z-index: 100000 !important; /* ค่านี้ต้องสูงกว่า z-index ของโหมด Showcase */
}



/*ปุ่มเซฟมีเอฟเฟค*/

.btn-save-main.unsaved {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%) !important;
    animation: pulse-orange 1.5s infinite !important;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
}

@keyframes pulse-orange {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}

/* Success Toast ✅ บันทึกสำเร็จ */
.save-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(11, 214, 95, 0.95); /* สีเขียวเดียวกับปุ่มคุณ */
    color: white;
    padding: 12px 25px;
    border-radius: 50px;
    z-index: 10000;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    animation: toast-pop 1.5s ease-in-out forwards;
}

@keyframes toast-pop {
    0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -70%); }
}

/*ส่วนปรับปรุงการเซฟรูป*/

/* คอนเทนเนอร์หลักสำหรับการ Export */
.export-container {
    width: 1000px;
    background: #1a1c20;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    position: absolute;
    left: -9999px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.export-section-title {
    color: #f1c40f;
    font-size: 22px;
    font-weight: bold;
    border-bottom: 2px solid #34495e;
    padding-bottom: 8px;
    margin-bottom: 15px;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
}

.export-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr); /* แถวละ 8 ใบกำลังสวยสำหรับรูปสรุป */
    gap: 15px;
}

.export-card-item {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
}

.export-badge {
    position: absolute;
    bottom: 8px;          /* ระยะห่างจากขอบล่าง */
    left: 50%;            /* กึ่งกลางซ้าย */
    transform: translateX(-50%); /* ดึงกลับให้กึ่งกลางเป๊ะ */
    background: #ff0000bb;  /* สีแดงตามโจทย์ */
    color: white;
    padding: 2px 10px;    /* ทรงสี่เหลี่ยมมุมมน */
    border-radius: 6px;   /* มุมมน */
    font-size: 20px;      /* ขนาดตัวอักษร */
    font-weight: bold;
    border: 2.5px solid rgba(255,255,255,0.9);
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6);
    white-space: nowrap;
}

.export-card-img {
    width: 100%;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

/* ไฟล์: responsive.css หรือ deck_builder.css */

/* 1. ป้องกันการกดแช่แล้วขึ้นเมนู Save รูป (สำคัญมากสำหรับมือถือ) */
.card-img-btn {
    -webkit-touch-callout: none !important; /* iOS Safari */
    -webkit-user-select: none !important;   /* Safari */
    -khtml-user-select: none !important;    /* Konqueror HTML */
    -moz-user-select: none !important;      /* Old Firefox */
    -ms-user-select: none !important;       /* Internet Explorer/Edge */
    user-select: none !important;           /* Non-prefixed version */
}

/* 2. สไตล์ของ Badge (ค่าเริ่มต้นสำหรับ PC) */
.status-badge {
    position: absolute;
            width: 95px !important;
        height: 80px !important;
    top: -5px;      /* ขยับให้อยู่มุมสวยๆ */
    right: -5px;
    z-index: 800;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* Fallback กรณีรูปไม่โหลด */
.status-badge-fallback {
    display: none;
    position: absolute;
    top: 0; right: 0;
    width: 40px; height: 40px;
    z-index: 800;
    pointer-events: none;
    color: white;
    font-weight: bold;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
    border: 2px solid white;
}
.status-badge-fallback.ban { background: rgba(255,0,0,0.9); }
.status-badge-fallback.limit { background: rgba(218, 165, 32, 0.9); }

