/* ==========================================================================
   1. GLOBAL & LAYOUT (ค่าพื้นฐานและโครงสร้างหลัก)
   ========================================================================== */
/* ⭐️ เพิ่มคำสั่งนี้บรรทัดแรก: ป้องกันกล่องบวมทุกกรณี */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Kanit', sans-serif;
    background-color: #FDFBFA;
    color: #333;
    margin: 0;
    padding: 0;
    
    /* ⭐️ ป้องกันสกรอลล์แนวนอน (แก้มือถือล้น) */
    overflow-x: hidden;
    width: 100%;
    
    /* Sticky Footer Setup */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==========================================================================
   ⭐️ FIX FONT: บังคับทุกปุ่มและช่องข้อความให้เป็น Kanit
   (วางไว้บนสุดของไฟล์ หรือต่อจาก body)
   ========================================================================== */

button, 
input, 
select, 
textarea,
optgroup {
    font-family: 'Kanit', sans-serif !important;
}

/* แถม: แก้ฟอนต์ใน Placeholder (ข้อความจางๆ ในช่อง) ให้เป็น Kanit ด้วย */
::placeholder {
    font-family: 'Kanit', sans-serif !important;
    opacity: 0.7;
}

/* 🟢 บังคับความกว้าง 1100px เท่ากันทุกหน้า */
.container {
    max-width: 1100px; 
    margin: 20px auto;
    padding: 0 20px;
    width: 100%; /* เพิ่ม width 100% กันเหนียว */
}

/* Fix for footer pushing */
main.container {
    flex-grow: 1; 
}

/* ⭐️ เพิ่มคำสั่งคุมรูปภาพทั้งเว็บ ไม่ให้ดันจนจอล้น */
img {
    max-width: 100%;
    height: auto;
}

/* Links Global */
.category-link, .post-card-link { 
    text-decoration: none; 
    color: inherit; 
}

/* Hide line breaks on desktop */
.mobile-only-break { 
    display: none; 
}

/* ==========================================================================
   2. HEADER & NAVIGATION (ส่วนหัวและเมนู)
   ========================================================================== */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background-color: #fff;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.logo {
    font-weight: 700;
    font-size: 24px;
    color: #036666;
}

/* 🟢 สไตล์สำหรับเมนูหลัก (นำทาง) */
.main-nav a {
    text-decoration: none;
    color: #555; 
    padding: 5px 10px; /* 👈 แก้ตรงนี้! ลดระยะห่างซ้ายขวาลงให้กระชับขึ้น */
    margin: 0 2px; /* 👈 เพิ่มตรงนี้! ขยับปุ่มแต่ละอันให้มาอยู่ชิดกันอีกนิด */
    border-radius: 15px; /* ลดความมนลงหน่อยให้ดูโมเดิร์น */
    transition: 0.3s;
    font-weight: 500;
    font-size: 0.95rem; /* ปรับขนาดฟอนต์ให้พอดี ไม่เทอะทะ */
    white-space: nowrap; /* บังคับไม่ให้คำยาวๆ โดนตัดตกบรรทัด */
}

.main-nav a:hover {
    background-color: #f1f3f4; 
    color: #333;
}

/* 🟢 พระเอกของเรา! สไตล์ตอนที่เมนูนั้นถูกใส่ class="active" */
.main-nav a.active {
    color: #036666; 
    font-weight: bold; 
    background-color: #e0f2f1; 
}

.search-icon img {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

/* Hamburger Menu (Mobile Trigger) */
.mobile-menu-button { 
    display: none; 
}

/* ==========================================================================
   3. HERO & CONTENT MODULES (Hero, Categories, News Lists)
   ========================================================================== */
/* --- Hero Banner --- */
.hero {
    display: flex;
    align-items: center;
    background-color: #fff;
    border-radius: 20px;
    padding: 40px;
    margin-top: 20px;
}
.hero-text { flex: 1; }
.hero-text h1 { font-size: 48px; color: #036666; margin: 0; }
.hero-text p { font-size: 18px; color: #666; }
.hero-button {
    background-color: #FF7B54;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 25px;
    font-family: 'Kanit', sans-serif;
    font-size: 16px;
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
}
.hero-image img { max-width: 250px; border-radius: 15px; }

/* --- Categories Grid --- */
.categories { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    margin-top: 40px; 
    gap: 20px; 
}
.category-card { 
    background-color: #fff; 
    border-radius: 15px; 
    padding: 20px; 
    text-align: center; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.category-card img { 
    width: 70px;
    height: 70px;
    object-fit: contain;
    margin-bottom: 10px; 
}
.category-card span { font-weight: 500; color: #333; }
.category-link:hover .category-card {
    /* 1. เปลี่ยนเงาให้ใหญ่ขึ้น ฟุ้งขึ้น และเข้มขึ้นเล็กน้อย */
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);

    /* 2. ดันการ์ดลอยขึ้นข้างบน 7 pixels */
    transform: translateY(-7px);
}

/* --- News Big List (Layout: Left Image | Right Text) --- */
.news-big-item {
    display: flex;          
    align-items: flex-start; 
    gap: 25px;              
    background: #fff;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    margin-bottom: 25px;
    border: 1px solid #eee;
    transition: transform 0.2s;
}
.news-big-item:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.1); }

.news-big-left { flex: 0 0 260px; width: 260px; }
.news-big-img {
    width: 100%;
    height: 200px;          
    object-fit: cover;
    border-radius: 10px;
    display: block;         
}

.news-big-right {
    flex: 1;                
    display: flex;
    flex-direction: column;
}

.news-big-title {
    font-size: 20px;        
    font-weight: 700;
    color: #036666;
    line-height: 1.4;
    margin: 0 0 10px 0;     
}
.news-big-title:hover { color: #FF7B54; }

.news-big-desc {
    font-size: 16px;
    color: #555;
    line-height: 1.6;
    margin: 0 0 15px 0;     
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.read-more-btn {
    align-self: flex-start; 
    color: #FF7B54;
    font-weight: 600;
    text-decoration: none;
    font-size: 14px;
    border: 1px solid #FF7B54;
    padding: 6px 18px;
    border-radius: 50px;
    transition: all 0.2s;
}
.read-more-btn:hover { background-color: #FF7B54; color: white; }

/* Mobile News List */
@media (max-width: 768px) {
    .news-big-item { padding: 15px; gap: 15px; }
    .news-big-left { flex: 0 0 130px; width: 130px; }
    .news-big-img { height: 130px; }
    .news-big-title { font-size: 15px; margin-bottom: 5px; }
    .news-big-desc { font-size: 13px; -webkit-line-clamp: 3; }
    .read-more-btn { font-size: 12px; padding: 4px 12px; margin-top: 5px; }
}

/* ==========================================================================
   4. POST COMPONENTS (Cards, Meta, Single Post)
   ========================================================================== */
.recent-posts { margin-top: 40px; }
.recent-posts h2, .category-title { font-size: 28px; color: #036666; text-align: center; }

/* Grid Layout แบบยืดหยุ่น */
.posts-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); /* ปรับ Auto ตามหน้าจอ */
    gap: 25px; 
    margin-top: 20px;
}

/* ตัวการ์ดบทความ */
.post-card { 
    background-color: #fff; 
    border-radius: 15px; 
    overflow: hidden; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    display: flex;
    flex-direction: column; /* เรียงแนวตั้ง: รูป -> เนื้อหา */
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%; /* ให้สูงเท่ากันทั้งแถว */
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

/* ส่วนรูปภาพ */
.card-image {
    width: 100%;
    height: 180px;
    overflow: hidden;
}

.card-image img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    transition: transform 0.5s ease;
}

.post-card:hover .card-image img {
    transform: scale(1.05); /* ซูมรูปนิดนึงตอนชี้ */
}

/* ส่วนเนื้อหาในการ์ด */
.card-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* ดันให้เต็มพื้นที่ */
}

/* ป้าย Tag (เช่น หลักภาษา, วรรณคดี) */
.card-tag {
    background-color: #FFF2D7;
    color: #D57149;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-block;
    align-self: flex-start;
    margin-bottom: 10px;
}

/* หัวข้อบทความ */
.card-title { 
    font-size: 1.15rem; 
    font-weight: 700;
    color: #333;
    margin: 0 0 10px 0;
    line-height: 1.4;
    
    /* ตัดคำถ้าเกิน 2 บรรทัด */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ส่วนท้ายการ์ด (วันที่) */
.card-footer {
    margin-top: auto; /* ดันไปล่างสุดเสมอ */
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
    font-size: 0.85rem;
    color: #888;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* --- (คงเดิม) Post Meta & Tags สำหรับหน้าอ่านบทความ --- */
.post-meta-grid, .post-meta {
    display: flex; align-items: center; justify-content: space-between; 
    gap: 8px; padding: 0 15px 15px 15px; flex-wrap: wrap; width: 100%; box-sizing: border-box; 
}
.post-date, .post-date-small {
    display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: #555; 
    background-color: #f0f4f8; border: 1px solid #e1e8ed; padding: 4px 10px; border-radius: 50px; font-weight: 500;
}
.post-tag, .post-row-tag { 
    display: inline-block; background-color: #FFF2D7; color: #D57149; padding: 5px 12px; 
    border-radius: 50px; font-size: 12px; font-weight: 700; margin: 0 !important; flex-shrink: 0; 
}

/* --- Filter Tabs & Single Post --- */
.post-filter-tabs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.filter-tab {
    padding: 8px 15px; font-size: 0.9rem; font-weight: 500; font-family: 'Kanit', sans-serif;
    border: 1px solid #ddd; background-color: #f9f9f9; border-radius: 20px; cursor: pointer; color: #444; transition: all 0.3s ease;
}
.filter-tab:hover { background-color: #eee; }
.filter-tab.active { background-color: #1a73e8; color: white; border-color: #1a73e8; }

.post-image-wrapper { width: 100%; margin-bottom: 30px; border-radius: 20px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.post-image-wrapper img { width: 100%; height: auto; display: block; }


/* ==========================================================================
   5. INTERACTIVE UI (Popup Modal, Search, Chatbot)
   ========================================================================== */
/* --- Pop-up Modal (ฉบับอัปเดต: ปุ่มปิดอยู่นอกกล่อง) --- */

/* 1. ฉากหลัง (Overlay) */
.modal-overlay {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    /* พื้นหลังสีดำจางๆ + เบลอฉากหลัง */
    background-color: rgba(0, 0, 0, 0.75); /* ปรับให้เข้มขึ้นนิดนึงเพื่อให้ปุ่มขาวเด่น */
    backdrop-filter: blur(8px); 
    display: flex; 
    justify-content: center; 
    align-items: center;
    z-index: 9999; 
    visibility: hidden; 
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.4s;
}

.modal-overlay.show { 
    visibility: visible; 
    opacity: 1; 
}

/* 2. ตัวกล่องป็อปอัพ (Content Box) */
.modal-content {
    background-color: #ffffff; 
    padding: 40px 30px; 
    border-radius: 20px; 
    
    /* เงา */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    max-width: 450px; /* ปรับความกว้างให้กระชับขึ้นนิดหน่อย */
    width: 90%; 
    position: relative;
    
    /* Animation */
    transform: scale(0.9) translateY(20px); 
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); 
    
    /* ⚠️ สำคัญมาก: ต้องเป็น visible เพื่อให้ปุ่มที่ลอยอยู่ข้างบนไม่โดนตัด */
    overflow: visible !important; 
    
    /* ลบ max-height/overflow-y เดิมออก เพื่อไม่ให้ปุ่มโดนตัด */
    /* ถ้าเนื้อหายาวมาก ให้ไปจัดการที่ขนาดรูปภาพแทน */
    text-align: center;
}

.modal-overlay.show .modal-content { 
    transform: scale(1) translateY(0); 
}

/* หัวข้อและเนื้อหา */
.modal-content h2 { 
    color: #036666; 
    font-size: 24px;
    margin-top: 5px; 
    margin-bottom: 10px; 
    font-weight: 700;
}

.modal-content p { 
    color: #666;
    margin-bottom: 20px; 
    font-size: 16px;
    line-height: 1.6;
}

/* รูปภาพในป็อปอัพ */
.modal-image {
    max-width: 100%; 
    max-height: 55vh; /* เพิ่มความสูงรูปได้อีกนิด */
    width: auto;
    border-radius: 12px; 
    margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); 
    display: block; 
    margin-left: auto; 
    margin-right: auto;
}

/* 3. ปุ่มปิด (Close Button) - 🚀 ย้ายไปอยู่นอกกล่องด้านบนขวา */
.modal-close {
    position: absolute; 
    
    /* ดันขึ้นไปเหนือกล่อง 50px */
    top: -50px; 
    right: 0;   /* ชิดขวา */
    
    width: 40px;  /* ขยายใหญ่ขึ้นนิดนึงให้กดง่ายในมือถือ */
    height: 40px;
    
    /* เปลี่ยนเป็นสีขาว เพื่อให้เห็นชัดบนพื้นหลังมืด */
    background-color: #ffffff; 
    color: #333; 
    border-radius: 50%;
    
    border: none; 
    font-size: 24px; /* ขยายไอคอน X */
    font-weight: bold; 
    cursor: pointer;
    
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    
    /* เพิ่มเงาให้ปุ่มดูมีมิติ */
    box-shadow: 0 2px 10px rgba(255, 255, 255, 0.2);
}

.modal-close:hover { 
    background-color: #e03131; /* สีแดงเมื่อเอาเมาส์ชี้ */
    color: white;
    transform: rotate(90deg); 
}

/* 4. ปุ่ม Action (Link PDF) */
.modal-button {
    display: inline-block; 
    background: linear-gradient(135deg, #FF7B54 0%, #FFB26B 100%); 
    color: white;
    padding: 10px 30px; 
    border-radius: 50px; 
    text-decoration: none;
    font-weight: 600; 
    font-family: 'Kanit', sans-serif;
    font-size: 16px;
    margin-top: 5px; 
    box-shadow: 0 4px 15px rgba(255, 123, 84, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.modal-button:hover { 
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 123, 84, 0.4);
}

/* --- Search Overlay --- */
.search-overlay {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    justify-content: center;
    padding-top: 80px;
    backdrop-filter: blur(5px);
}
.search-overlay.active { display: flex; }
.search-container { width: 90%; max-width: 600px; }
.search-header {
    display: flex; align-items: center;
    border-bottom: 2px solid rgba(255,255,255,0.3);
    padding-bottom: 10px; margin-bottom: 20px;
}
#search-input {
    width: 100%; background: transparent; border: none;
    font-size: 1.5rem; color: white; font-family: 'Kanit', sans-serif; outline: none;
}
#search-input::placeholder { color: rgba(255,255,255,0.5); }
#close-search-btn {
    background: none; border: none; color: white;
    font-size: 2rem; cursor: pointer; padding: 0 10px;
}
.search-result-item {
    background: white; padding: 15px; border-radius: 10px;
    margin-bottom: 10px; display: flex; align-items: center; gap: 15px;
    text-decoration: none; color: #333; transition: transform 0.2s;
}
.search-result-item:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
.search-result-item img { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; }
.search-result-info h4 { margin: 0 0 5px 0; font-size: 1.1rem; }
.search-result-info span { font-size: 0.9rem; color: #1a73e8; background: #e8f0fe; padding: 2px 8px; border-radius: 4px; }

/* --- Chatbot Widget --- */
#chatbot-container, #chatbot-container * { font-family: 'Kanit', sans-serif !important; }
#chatbot-container {
    display: none; 
    flex-direction: column;
    position: fixed; bottom: 20px; right: 20px;
    width: 350px; height: 500px; max-height: 80vh;
    background: white; border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    z-index: 10000; overflow: hidden;
}
#chatbot-header {
    background: #036666; color: white; padding: 15px;
    display: flex; justify-content: space-between; align-items: center;
}
.chatbot-title { display: flex; align-items: center; gap: 10px; font-weight: bold; }
.chatbot-title img { width: 30px; height: 30px; border-radius: 50%; background: white; }
#chatbot-close { background: none; border: none; color: white; font-size: 24px; cursor: pointer; }
#chatbot-messages {
    flex: 1; padding: 15px; overflow-y: auto; background: #f9f9f9;
    display: flex; flex-direction: column; gap: 10px;
}
.chat-message { padding: 10px 15px; border-radius: 15px; max-width: 80%; font-size: 0.95rem; line-height: 1.5; }
.chat-message.user { align-self: flex-end; background: #FF7B54; color: white; border-bottom-right-radius: 2px; }
.chat-message.bot { align-self: flex-start; background: white; border: 1px solid #eee; color: #333; border-bottom-left-radius: 2px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.chat-message.loading { font-style: italic; color: #888; background: transparent; border: none; box-shadow: none; }
#chatbot-input-area { padding: 10px; background: white; border-top: 1px solid #eee; display: flex; gap: 10px; }
#chatbot-input { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 20px; outline: none; }
#chatbot-send { background: #036666; color: white; border: none; padding: 0 20px; border-radius: 20px; cursor: pointer; font-weight: bold; }
#chatbot-toggle-btn {
    position: fixed; bottom: 20px; right: 20px;
    background: #036666; color: white; border: none;
    padding: 15px 25px; border-radius: 50px;
    font-size: 16px; font-weight: bold; cursor: pointer;
    box-shadow: 0 4px 15px rgba(3, 102, 102, 0.4);
    z-index: 9999; transition: transform 0.2s;
    font-family: 'Kanit', sans-serif;
}
#chatbot-toggle-btn:hover { transform: scale(1.05); background: #024d4d; }

/* Mobile Chatbot */
@media (max-width: 480px) {
    #chatbot-container, #chatbot-container * { font-family: 'Kanit', sans-serif !important; }
    #chatbot-container {
        width: 92%; height: 85dvh; bottom: 20px; right: 4%; left: 4%;
        border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
        overflow: hidden; z-index: 9999;
    }
    #chatbot-close { font-size: 26px; padding: 8px; }
    #chatbot-input { font-size: 16px !important; }
}

/* ==========================================================================
   6. PAGE: QUIZ SYSTEM & EXAMS
   ========================================================================== */
.quiz-form-container {
    background-color: #fff;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    max-width: 800px; 
    margin: 40px auto; 
}
.quiz-form-container label { font-weight: 500; color: #036666; margin-bottom: 5px; display: block; }
.quiz-form-container input[type="text"],
.quiz-form-container input[type="number"],
.quiz-form-container select {
    width: 100%; box-sizing: border-box; padding: 12px;
    border: 1px solid #ddd; border-radius: 8px;
    font-size: 16px; font-family: 'Kanit', sans-serif;
}
.quiz-form-container button {
    display: block; width: 100%; max-width: 320px; margin: 30px auto 0 auto;
    background-color: #FF7B54; color: white; border: none;
    border-radius: 50px; padding: 15px 20px;
    font-size: 18px; font-weight: 600; font-family: 'Kanit', sans-serif;
    cursor: pointer; white-space: nowrap; transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 123, 84, 0.3);
}
.quiz-form-container button:hover { background-color: #E06C4A; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255, 123, 84, 0.4); }
.quiz-form-container button:active { transform: translateY(0); box-shadow: 0 2px 10px rgba(255, 123, 84, 0.3); }

@media (max-width: 480px) {
    .quiz-form-container button { font-size: 16px; width: 90%; }
}

/* Quiz Questions & Display */
.quiz-question {
    background-color: #fff; border-radius: 15px; padding: 20px; margin-top: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    max-width: 800px; margin-left: auto; margin-right: auto;
}
.quiz-question h3 { margin-top: 0; color: #036666; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; }
.quiz-option { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; border: 1px solid #eee; cursor: pointer; }
.quiz-option:hover { background-color: #f9f9f9; }
.quiz-option input[type="radio"] { width: auto; }
.quiz-option label { margin-bottom: 0; font-weight: 400; color: #333; flex: 1; }

#submit-quiz-btn {
    display: block; margin: 20px auto 0 auto; font-size: 18px; padding: 15px 30px;
    background-color: #FF7B54; color: white; border: none; border-radius: 10px;
    cursor: pointer; font-weight: 500; font-family: 'Kanit', sans-serif;
}

#quiz-results {
    background-color: #e6ffed; border: 1px solid #4CAF50; border-radius: 15px;
    padding: 20px; margin-top: 30px; text-align: center;
    max-width: 800px; margin-left: auto; margin-right: auto;
    display: none; 
}
#quiz-results h2 { color: #036666; margin-top: 0; }

.spinner {
    border: 4px solid #f3f3f3; border-top: 4px solid #FF7B54;
    border-radius: 50%; width: 30px; height: 30px;
    animation: spin 1s linear infinite; margin: 20px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Quiz Feedback Styling */
.quiz-option.correct-answer { background-color: #e6ffed; border: 1px solid #4CAF50; }
.quiz-option.correct-answer label { font-weight: 700; color: #1e5631 !important; }
.quiz-option.incorrect-answer { background-color: #ffefef; border: 1px solid #D9534F; opacity: 0.8; }
.quiz-option.incorrect-answer label { color: #a94442 !important; text-decoration: line-through; }
.quiz-option.faded-option { opacity: 0.5; }
input[type="radio"]:disabled + label { color: #999; cursor: not-allowed; }
input[type="radio"]:disabled { cursor: not-allowed; }

/* T-GAT Passage Layout */
.quiz-passage {
    background-color: #f9f9f9; border-left: 4px solid #036666;
    padding: 15px; margin-bottom: 20px; border-radius: 4px;
    font-size: 16px; line-height: 1.6; white-space: pre-wrap; 
}
.quiz-explanation {
    display: none; background-color: #FFF8E1; border: 1px solid #FFECB3;
    border-radius: 8px; padding: 15px; margin-top: 20px;
}
.quiz-explanation h4 { margin: 0 0 10px 0; color: #6D4C41; }
.quiz-explanation p { margin: 0; line-height: 1.6; }

/* Leaderboard */
#leaderboard-container {
    background-color: #fff;
    border: 1px solid #eee; border-radius: 15px;
    padding: 20px 30px; margin: 30px auto; max-width: 800px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
.leaderboard-title { color: #036666; margin: 0 0 15px 0; text-align: center; font-size: 22px; }
#leaderboard-list { padding-left: 30px; margin: 0; }
#leaderboard-list li { font-size: 16px; color: #555; padding: 8px 0; border-bottom: 1px solid #f0f0f0; }
#leaderboard-list li:last-child { border-bottom: none; }
#leaderboard-list li strong { color: #FF7B54; font-size: 18px; }

/* ==========================================================================
   7. PAGE: DONATE & SUPPORT
   ========================================================================== */
.donate-wrapper {
    display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
    gap: 50px; margin-top: 40px; margin-bottom: 40px;
}
.donate-text { flex: 1; min-width: 300px; max-width: 500px; }
.donate-text h1 { color: #036666; font-size: 32px; margin-bottom: 10px; }
.donate-text .subtitle { font-size: 18px; color: #FF7B54; font-weight: 500; margin-bottom: 20px; }
.donate-text p { line-height: 1.8; color: #555; margin-bottom: 15px; }
.donate-perks { list-style: none; padding: 0; margin-top: 20px; }
.donate-perks li { margin-bottom: 10px; font-size: 16px; color: #333; }

.donate-card {
    background: white; padding: 40px; border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1); text-align: center;
    max-width: 350px; border: 2px solid #f0f0f0;
}
.donate-card h3 { color: #333; margin-top: 0; margin-bottom: 20px; }
.donate-qr { width: 100%; max-width: 250px; border-radius: 10px; margin-bottom: 20px; border: 1px solid #ddd; }
.bank-details p { margin: 5px 0; }
.bank-name { font-size: 14px; color: #888; }
.account-number { font-size: 24px; font-weight: 700; color: #036666; margin: 10px 0 !important; letter-spacing: 1px; }
.account-name { font-size: 16px; font-weight: 500; }
.promptpay-label { font-size: 13px; color: #FF7B54; margin-top: 10px !important; }

/* Mobile Donate */
@media (max-width: 768px) {
    .donate-wrapper { flex-direction: column; text-align: center; gap: 30px; }
    .donate-text h1 { font-size: 28px; }
}

/* Donate CTA (Button) */
.donate-cta-container { margin-top: 40px; margin-bottom: 40px; display: flex; justify-content: center; }
.donate-cta-box {
    background-color: #fff8f5; border: 1px dashed #ffccbc;
    border-radius: 15px; padding: 30px; text-align: center;
    max-width: 600px; width: 100%;
}
.donate-cta-box h3 { color: #d84315; margin-top: 0; margin-bottom: 10px; font-size: 1.4rem; }
.donate-cta-box p { color: #555; margin-bottom: 25px; font-size: 1rem; }
.donate-button {
    display: inline-block; background-color: #FF7B54; color: white;
    padding: 12px 35px; border-radius: 50px; text-decoration: none;
    font-weight: 600; font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(255, 123, 84, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}
.donate-button:hover { transform: translateY(-3px); box-shadow: 0 6px 15px rgba(255, 123, 84, 0.4); background-color: #f4511e; }

/* ==========================================================================
   8. PAGE: ADMIN PANEL (✨ ฉบับสมบูรณ์: ปุ่มสวย พรีเมียม คุมโทน หน้าข่าวสาร)
   ========================================================================== */

/* --- 1. Admin Tabs (แท็บเมนู) --- */
.admin-tabs { 
    display: flex; 
    gap: 15px; 
    margin-bottom: 30px; 
    border-bottom: 2px solid #f0f0f0; 
    padding-bottom: 0;
}

.tab-button {
    padding: 15px 25px; 
    font-size: 1.1rem; 
    font-weight: 500; 
    font-family: 'Kanit', sans-serif;
    border: none; 
    background-color: transparent; 
    cursor: pointer; 
    color: #999;
    border-bottom: 3px solid transparent; 
    transition: all 0.3s ease;
    margin-bottom: -2px; /* ทับเส้นขอบล่าง */
}

.tab-button:hover { color: #036666; background-color: rgba(3, 102, 102, 0.02); }

/* แท็บที่ถูกเลือก */
.tab-button.active { 
    color: #036666; 
    border-bottom: 3px solid #036666; 
    font-weight: 700;
}

.tab-content { display: none; animation: fadeIn 0.4s ease; }
.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 2. Admin Cards (กรอบฟอร์มทั้งหมด: โพสต์, ป็อปอัพ, ผลงาน) --- */
.add-post-section,
.popup-settings {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05); /* เงานุ่มๆ */
    border: 1px solid #f0f0f0;
    margin-bottom: 40px;
    max-width: 900px; /* บีบความกว้างให้อ่านง่าย */
    margin-left: auto;
    margin-right: auto;
}

/* หัวข้อในฟอร์ม */
#form-title,
.popup-settings h2 {
    color: #036666;
    border-bottom: 2px solid #e0f2f1;
    padding-bottom: 20px;
    margin-top: 0;
    margin-bottom: 30px;
    font-size: 26px;
    font-weight: 700;
}

/* จัดระยะห่างระหว่างบรรทัด */
.add-post-section form > div,
.popup-settings form > div {
    margin-bottom: 25px;
}

/* Label (ป้ายกำกับ) */
.add-post-section label,
.popup-settings label {
    font-weight: 600;
    color: #444;
    display: block;
    margin-bottom: 10px;
    font-size: 16px;
}

/* --- 3. Inputs & Textareas (ช่องกรอกข้อมูล) --- */
/* ปรับแต่งช่อง "หัวข้อ" (Title) ให้เด่นเป็นพิเศษ */
#title-input,
#popup-title {
    width: 100%;
    padding: 15px 20px;
    font-size: 20px;         /* ตัวใหญ่ */
    font-weight: 600;
    color: #333;
    background-color: #fcfcfc;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    transition: all 0.3s ease;
}

#title-input:focus,
#popup-title:focus {
    border-color: #036666;
    background-color: #fff;
    box-shadow: 0 0 0 5px rgba(3, 102, 102, 0.1);
    outline: none;
}

/* ช่องกรอกทั่วไป (Dropdown, File, Textarea) */
#tag-select, 
#image-input, 
#pdf-input, 
#detail-input,
#popup-image-file,
#popup-pdf-file,
.popup-settings input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-family: 'Kanit', sans-serif;
    font-size: 16px;
    background-color: #fff;
    transition: border-color 0.2s;
}

#tag-select:focus,
#detail-input:focus,
.popup-settings input:focus {
    border-color: #036666;
    outline: none;
}

/* --- 4. Buttons (ปุ่มกดหลัก - บันทึก) --- */
.form-buttons {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 15px;
}

/* ปุ่มบันทึก (ทุกปุ่มที่เป็น submit) */
#submit-button,
#save-popup-button,
#save-portfolio-button {
    background: linear-gradient(135deg, #036666 0%, #024d4d 100%);
    color: white;
    font-size: 18px;
    font-weight: 600;
    padding: 15px 40px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(3, 102, 102, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%; 
}

/* เฉพาะปุ่มบันทึกหน้าโพสต์ ให้ยืดหยุ่น */
#add-post-form #submit-button {
    width: auto;
    flex-grow: 1;
}

#submit-button:hover,
#save-popup-button:hover,
#save-portfolio-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(3, 102, 102, 0.4);
}

/* ปุ่มยกเลิก */
.cancel-edit-button {
    background-color: #f8f9fa;
    color: #666;
    font-size: 16px;
    font-weight: 500;
    padding: 15px 30px;
    border: 1px solid #dee2e6;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
}
.cancel-edit-button:hover { background-color: #e2e6ea; color: #333; }

/* Progress Bar */
.progress-bar {
    height: 8px;
    background-color: #f1f1f1;
    border-radius: 20px;
    overflow: hidden;
    margin-top: 15px;
    margin-bottom: 15px;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #FF7B54, #FFB26B);
    width: 0%;
    transition: width 0.3s ease;
}

/* --- 5. Admin Post List (รายการบทความด้านล่าง) --- */
.post-list-container { margin-top: 50px; }
.post-list-container h2 { text-align: center; color: #036666; font-size: 24px; margin-bottom: 20px; }

.post-item {
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    padding: 20px; 
    background-color: #fff;
    border: 1px solid #f0f0f0; 
    border-radius: 15px; 
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    transition: transform 0.2s, border-color 0.2s;
}

.post-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    border-color: #036666;
}

.post-item img {
    width: 70px; 
    height: 70px; 
    object-fit: cover; 
    border-radius: 10px;
    margin-right: 20px; 
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.post-item p {
    margin: 0; 
    flex-grow: 1; 
    padding-right: 20px;
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
    min-width: 0; 
    text-align: left;
    font-size: 18px;
    font-weight: 500;
    color: #333;
}

/* --- ⭐️ 6. Action Buttons (ปุ่มแก้ไข/ลบ - ปรับใหม่!) --- */
.action-buttons { 
    display: flex; 
    flex-shrink: 0; 
    gap: 10px; 
}

.action-buttons button { 
    font-size: 14px; 
    padding: 8px 20px; /* เพิ่มความกว้าง */
    border-radius: 50px; /* ปุ่มมนกลม Pill Shape */
    border: none;
    color: white;
    cursor: pointer;
    font-family: 'Kanit', sans-serif;
    font-weight: 500;
    transition: all 0.2s ease; /* Animation นุ่มๆ */
    display: flex; 
    align-items: center; 
    gap: 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); /* เงาพื้นฐาน */
}

/* ปุ่มแก้ไข (สีฟ้า Gradient) */
.edit-button { 
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); 
}
.edit-button:hover { 
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(37, 99, 235, 0.3); /* เงาสีฟ้า */
}

/* ปุ่มลบ (สีแดง Gradient) */
.delete-button { 
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); 
}
.delete-button:hover { 
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(220, 38, 38, 0.3); /* เงาสีแดง */
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .add-post-section, .popup-settings { padding: 25px; }
    
    .form-buttons { flex-direction: column; }
    #submit-button, .cancel-edit-button { width: 100%; }

    .post-item { flex-direction: column; align-items: flex-start; gap: 15px; }
    .post-item img { width: 100%; height: 180px; margin-right: 0; }
    .post-item p { white-space: normal; padding-right: 0; font-size: 16px; }
    
    /* ปรับปุ่มในมือถือให้เต็มความกว้าง */
    .action-buttons { width: 100%; justify-content: space-between; gap: 10px; }
    .action-buttons button { flex: 1; justify-content: center; padding: 12px; }
}

/* ปุ่ม "ดูทั้งหมด" (อยู่ขวามือของหัวข้อ ทันโลกภาษาไทย) */
.see-all-link {
    font-size: 1rem;
    color: #036666; /* สีเขียวหลัก */
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border: 1px solid #036666; /* กรอบบางๆ */
    padding: 6px 16px;
    border-radius: 20px; /* ขอบมน */
    background-color: transparent;
}

.see-all-link:hover {
    background-color: #036666;
    color: white;
    box-shadow: 0 4px 10px rgba(3, 102, 102, 0.2);
    transform: translateY(-2px); /* ลอยขึ้นนิดนึงตอนชี้ */
}

/* ป้าย Tag สีส้ม (เฉพาะข่าวสาร) */
.post-tag.news-tag {
    background-color: #FF7B54 !important; /* บังคับให้เป็นสีส้ม */
    color: white;
}

/* =========================================
   สไตล์สำหรับการ์ดข่าว (News Item)
   ========================================= */
.news-item {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden; /* ตัดขอบรูปที่เกิน */
    box-shadow: 0 4px 15px rgba(0,0,0,0.08); /* เงาฟุ้งๆ */
    border: 1px solid #eee;
    display: flex;
    flex-direction: column; /* เรียงจากบนลงล่าง */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%; /* สูงเต็มพื้นที่ */
}

.news-item:hover {
    transform: translateY(-5px); /* ลอยขึ้นตอนชี้ */
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

/* 1. ส่วนภาพ */
.news-item img {
    width: 100%;
    height: 200px; /* ความสูงรูป */
    object-fit: cover; /* ให้รูปเต็มกรอบสวย ไม่เบี้ยว */
    border-bottom: 1px solid #f0f0f0;
}

/* กล่องเนื้อหาข้างใน */
.news-content-box {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* ยืดให้เต็มพื้นที่ที่เหลือ */
}

/* 2. ส่วนหัวข้อ */
.news-item h3 {
    font-size: 1.2rem;
    color: #036666; /* สีเขียว */
    margin: 0 0 10px 0;
    line-height: 1.4;
    font-weight: 700;
    
    /* ตัดคำถ้าเกิน 2 บรรทัด */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 3. ส่วนคำโปรย */
.news-item p {
    font-size: 0.95rem;
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
    flex-grow: 1; /* ดันปุ่มอ่านต่อไปไว้ล่างสุด */
    
    /* ตัดคำถ้าเกิน 3 บรรทัด */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 4. ปุ่มอ่านต่อ */
.news-read-more {
    display: inline-block;
    color: #FF7B54; /* สีส้ม */
    font-weight: 600;
    text-decoration: none;
    font-size: 0.9rem;
    align-self: flex-start; /* ชิดซ้าย */
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.news-read-more:hover {
    color: #d35400;
    border-bottom-color: #d35400; /* ขีดเส้นใต้ตอนชี้ */
}

/* ==========================================================================
   9. FOOTER SECTION (ส่วนท้ายเว็บ)
   ========================================================================== */
.main-footer {
    background-color: #f8f8f8; color: #333; padding: 25px 40px;
    border-top: 1px solid #eee; font-family: 'Kanit', sans-serif;
    display: flex; flex-direction: column; gap: 20px; 
    margin-top: 60px;
}

.footer-container {
    max-width: 1100px; /* 🟢 แก้ไข: เปลี่ยนจาก 1200px เป็น 1100px ให้เท่า Header */
    margin: 0 auto;
    display: flex; flex-wrap: wrap; justify-content: space-between;
    align-items: flex-start; gap: 30px;
}

.footer-content {
    display: flex; justify-content: space-between; align-items: center; width: 100%;
}

.about-me { display: flex; align-items: center; gap: 15px; }
.about-me h4, .contact-form h4 { font-size: 16px; margin-top: 0; margin-bottom: 8px; }
.about-me p { font-size: 14px; margin: 0; }
.profile-pic { width: 60px; height: 60px; border-radius: 50%; }

.contact-form input { border: 1px solid #ccc; border-radius: 8px; padding: 10px; margin-right: 10px; font-family: 'Kanit', sans-serif; }
.contact-form button { background-color: #036666; color: white; border: none; border-radius: 8px; padding: 10px 20px; cursor: pointer; font-family: 'Kanit', sans-serif; }

.footer-logo {
    width: 73px; height: 73px; object-fit: contain;
    margin-right: 2px; margin-bottom: 0;
}

.footer-copyright {
    text-align: center; font-size: 14px; color: #888;
    padding-top: 20px; border-top: 1px solid #f0f0f0; width: 100%;
}

/* 🕵️‍♀️ ทางลับแอดมิน (วางตรงนี้ครับ ต่อจาก footer-copyright) */
.secret-link {
    cursor: default; /* ชี้แล้วเมาส์ยังเป็นลูกศรปกติ */
    display: inline-block;
    text-decoration: none;
    color: inherit; /* ให้สีกลมกลืนกับตัวหนังสือเดิม */
    border: none;
    outline: none;
}

/* ป้องกันกรอบสีเวลาคลิก */
.secret-link:focus, .secret-link:active {
    outline: none;
    border: none;
    box-shadow: none; /* เพิ่มอันนี้ให้ชัวร์ */
    background: transparent; /* ป้องกันพื้นหลังเปลี่ยนสี */
}

/* Footer Sections placeholders (from provided fragments) */
.footer-section.footer-brand { flex: 2; min-width: 250px; }
.footer-section.footer-contact { flex: 1; min-width: 220px; }

/* ==========================================================================
   10. UTILITIES: CTA BANNERS (แบนเนอร์คั่นหน้า)
   ========================================================================== */
.cta-banner {
    background: linear-gradient(135deg, #FF7B54 0%, #FFB26B 100%);
    border-radius: 20px; padding: 30px 40px; margin: 40px 0;
    display: flex; align-items: center; justify-content: space-between;
    color: white; box-shadow: 0 10px 25px rgba(255, 123, 84, 0.3);
    position: relative; overflow: hidden;
}
.cta-banner::after {
    content: ""; position: absolute; right: -20px; bottom: -50px;
    width: 150px; height: 150px; background: rgba(255, 255, 255, 0.15);
    border-radius: 50%; pointer-events: none;
}
.cta-text h3 { margin: 0 0 5px 0; font-size: 1.5rem; font-weight: 700; }
.cta-text p { margin: 0; font-size: 1rem; opacity: 0.95; }
.cta-button {
    background-color: white; color: #FF7B54; padding: 10px 25px;
    border-radius: 50px; font-weight: 600; font-size: 1rem;
    transition: transform 0.2s, box-shadow 0.2s; white-space: nowrap;
    z-index: 1; text-decoration: none;
}
.cta-button:hover {
    transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    background-color: #fff; opacity: 0.95;
}

/* Color Themes */
.cta-banner.quiz { background: linear-gradient(135deg, #036666 0%, #2A9D8F 100%); box-shadow: 0 10px 25px rgba(3, 102, 102, 0.3); }
.cta-banner.quiz .cta-button { color: #036666; }

.cta-banner.download { background: linear-gradient(135deg, #264653 0%, #2a9d8f 100%); box-shadow: 0 10px 25px rgba(38, 70, 83, 0.3); }
.cta-banner.download .cta-button { color: #264653; }

.cta-banner.course { background: linear-gradient(135deg, #E76F51 0%, #F4A261 100%); box-shadow: 0 10px 25px rgba(231, 111, 81, 0.3); }
.cta-banner.course .cta-button { color: #E76F51; }

.cta-banner.line { background: linear-gradient(135deg, #06C755 0%, #00B900 100%); box-shadow: 0 10px 25px rgba(6, 199, 85, 0.3); }
.cta-banner.line .cta-button { color: #06C755; }

.cta-banner.video { background: linear-gradient(135deg, #FF4B2B 0%, #FF416C 100%); box-shadow: 0 10px 25px rgba(255, 65, 108, 0.3); }
.cta-banner.video .cta-button { color: #FF416C; }

.cta-banner.general { background: linear-gradient(135deg, #00C6FF 0%, #0072FF 100%); box-shadow: 0 10px 25px rgba(0, 114, 255, 0.3); }
.cta-banner.general .cta-button { color: #0072FF; }

.cta-banner.important { background: linear-gradient(135deg, #F39C12 0%, #D35400 100%); box-shadow: 0 10px 25px rgba(243, 156, 18, 0.3); }
.cta-banner.important .cta-button { color: #D35400; }

.cta-banner.podcast { background: linear-gradient(135deg, #8E44AD 0%, #9B59B6 100%); box-shadow: 0 10px 25px rgba(142, 68, 173, 0.3); }
.cta-banner.podcast .cta-button { color: #8E44AD; }

.cta-banner.feedback { background: linear-gradient(135deg, #00b09b 0%, #96c93d 100%); box-shadow: 0 10px 25px rgba(0, 176, 155, 0.3); }
.cta-banner.feedback .cta-button { color: #00b09b; }

.cta-banner.game { background: linear-gradient(135deg, #3F51B5 0%, #9C27B0 100%); box-shadow: 0 10px 25px rgba(63, 81, 181, 0.3); }
.cta-banner.game .cta-button { color: #3F51B5; }

/* --- ✅ ใหม่: สำหรับ Mini Quiz เก็บแต้ม (สีน้ำเงิน-ชมพู โรงเรียน) --- */
.cta-banner.mini-quiz {
    /* ไล่สีจากน้ำเงินเข้ม ไปหา ชมพูสด */
    background: linear-gradient(135deg, #004e92 0%, #d91d6f 100%);

    /* เงาสีออกโทนม่วงแดง เพื่อให้เข้ากับพื้นหลัง */
    box-shadow: 0 10px 25px rgba(217, 29, 111, 0.4);
}

.cta-banner.mini-quiz .cta-button {
    /* สีตัวอักษรในปุ่ม ใช้สีชมพูเข้มเพื่อให้เด่นและเข้าธีม */
    color: #d91d6f;
}

/* ===================================================
   📱 Mobile Redesign: Compact CTA Banners (ฉบับกะทัดรัด)
   =================================================== */

@media (max-width: 768px) {
    
    /* ปรับกล่องแบนเนอร์ให้เป็น "การ์ดแนวนอน" ที่กระชับขึ้น */
    .cta-banner {
        display: flex;
        flex-direction: column; /* เรียงลงมาเหมือนเดิมแต่ชิดกันขึ้น */
        justify-content: center;
        align-items: center;
        text-align: center;
        
        /* ✅ ลดขอบในสุดๆ ให้เหลือพื้นที่พอดี */
        padding: 15px 15px !important; 
        
        /* ระยะห่างระหว่างแบนเนอร์ */
        margin: 15px 0 !important;
        
        /* ลดความโค้งให้ดูทันสมัยขึ้นในจอเล็ก */
        border-radius: 10px !important;
        
        /* ตัดเงาฟุ้งๆ ออก เพื่อลดความรก */
        box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    }

    /* ส่วนข้อความ */
    .cta-banner .cta-text {
        margin-right: 0 !important;
        margin-bottom: 10px !important; /* เว้นห่างจากปุ่มนิดเดียว */
        width: 100%;
    }

    /* 🟢 หัวข้อ: ปรับให้เล็กลงแต่ยังหนา */
    .cta-banner h3 {
        font-size: 1.1rem !important; /* เล็กลงชัดเจน */
        margin-bottom: 2px !important;
        line-height: 1.2 !important;
        font-weight: 700;
    }

    /* 🟢 คำอธิบาย: ย่อให้เล็ก หรือตัดถ้ายาวเกิน */
    .cta-banner p {
        font-size: 0.85rem !important; /* ตัวหนังสือเล็กอ่านสบาย */
        line-height: 1.4 !important;
        margin-bottom: 0 !important;
        opacity: 0.9; /* จางลงนิดนึงเพื่อไม่แย่งซีนหัวข้อ */
        
        /* ถ้าข้อความยาวมาก ให้ตัดเหลือ 2 บรรทัด */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* 🔘 ปุ่มกด: เปลี่ยนเป็นแถบยาว กดง่าย แต่มินิมอล */
    .cta-banner .cta-button {
        width: 100% !important;
        display: block !important;
        
        /* ลดความหนาปุ่มลง */
        padding: 8px 0 !important; 
        
        font-size: 0.9rem !important;
        border-radius: 6px !important; /* มุมมนน้อยลงเข้ากับกล่อง */
        margin-top: 5px !important;
    }
    
    /* (เฉพาะแบนเนอร์ลานประลอง) ปรับไอคอนพื้นหลังให้ไม่กวนสายตา */
    .cta-banner.showcase::before {
        display: none !important; /* ซ่อนไอคอนพื้นหลังไปเลยในมือถือ จะได้สะอาด */
    }
    
    .challenge-banner {
        padding: 20px 15px !important;
        margin: 20px 0 !important;
    }
    
    /* ปรับปุ่มส่งงานในแบนเนอร์โจทย์ */
    .submit-work-btn {
        width: 100%;
        padding: 10px 0 !important;
        font-size: 1rem !important;
        text-align: center;
        justify-content: center;
    }
}

/* ==========================================================================
   11. MOBILE RESPONSIVE (GLOBAL OVERRIDES) - ฉบับแก้ไขเฉพาะปุ่มสมูท
   ========================================================================== */
@media (max-width: 992px) {
    
    .container { margin: 10px auto; padding: 0 20px; }

    /* --- Header & Nav --- */
    .main-header { flex-direction: row; padding: 15px 20px; }
    .main-header .container {
        padding-left: 30px !important;  
        padding-right: 30px !important; 
        display: flex; align-items: center; width: 100%; box-sizing: border-box;
    }
    .logo { order: 1; font-size: 20px; }
    
    .search-icon { 
        display: block !important; order: 2; margin-left: auto; margin-right: 15px; 
    }
    .search-icon img { width: 24px; height: 24px; vertical-align: middle; }

    /* 🟢 ปุ่มหลัก (โครงสร้างเดิมแกเป๊ะๆ) */
    .mobile-menu-button { 
        display: flex; flex-direction: column; justify-content: space-around;
        width: 30px; height: 24px; background: transparent; border: none;
        cursor: pointer; padding: 0; z-index: 1001; order: 3; margin-left: 0;
    }

    /* 🟢 เติมความสมูท (transition) ให้เส้นแฮมเบอร์เกอร์ */
    .hamburger-bar { 
        width: 30px; height: 3px; background-color: #333; border-radius: 5px; 
        transition: all 0.3s ease-in-out; /* ทำให้ขยับสมูท */
    }

    /* 🟢 คำสั่งแปลงร่างเป็นกากบาท (X) เมื่อกด */
    .mobile-menu-button.open .hamburger-bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }
    .mobile-menu-button.open .hamburger-bar:nth-child(2) {
        opacity: 0;
        transform: translateX(10px);
    }
    .mobile-menu-button.open .hamburger-bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }
    
    .main-nav { display: none; flex-direction: column; position: absolute; top: 100%; left: 0; width: 100%; background-color: white; box-shadow: 0 4px 8px rgba(0,0,0,0.1); padding: 10px 0; z-index: 1000; }
    .main-nav.active { display: flex; }
    .main-nav a { text-align: center; padding: 15px; border-bottom: 1px solid #f0f0f0; margin: 0; }

    /* --- Content Sections --- */
    .hero { flex-direction: row; text-align: left; gap: 15px; padding: 20px; align-items: center; }
    .hero-text h1 { font-size: 24px; }
    .hero-text p { font-size: 14px; }
    .hero-button { padding: 8px 18px; font-size: 14px; }
    .hero-image img { max-width: 120px; }

    .categories { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 30px; }
    .category-card { padding: 15px; }
    .category-card img { width: 48px; height: 48px; }
    .category-card span { font-size: 14px; }

    /* ... โค้ดส่วนที่เหลือของแกชั้นคงไว้ให้ครบทั้งหมดครับ ... */
    
    .categories { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 30px; }
    .category-card { padding: 15px; }
    .category-card img { width: 48px; height: 48px; }
    .category-card span { font-size: 14px; }

    .posts-grid { 
        display: flex !important; 
        flex-direction: column; 
        gap: 15px; 
    }

    .post-card { 
        display: flex; 
        flex-direction: row; 
        align-items: center; 
        background: #fff; 
        border: 1px solid #eee; 
        border-radius: 12px; 
        overflow: hidden; 
        min-height: 100px; 
        height: auto; 
    }

    .card-image {
        width: 110px;
        height: 110px; 
        flex-shrink: 0; 
    }

    .card-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .card-content {
        padding: 10px 15px;
        justify-content: center;
    }

    .card-tag {
        font-size: 0.7rem; 
        padding: 2px 8px;
        margin-bottom: 5px;
    }

    .card-title {
        font-size: 1rem;
        margin-bottom: 5px;
        -webkit-line-clamp: 2; 
    }

    .card-footer {
        padding-top: 5px;
        border-top: none; 
        font-size: 0.75rem;
    }

    .post-card .card-tag {
        display: none !important;
    }

    .post-card .card-title {
        -webkit-line-clamp: 3 !important; 
        margin-bottom: 0 !important; 
    }
    
    .post-card .card-image {
        width: 120px; 
        height: 120px;
    }
    
    .post-tag, .post-row-tag { display: none; }
    .post-date, .post-date-small { font-size: 10px !important; padding: 2px 8px !important; gap: 3px; }
    .post-meta-grid, .post-meta { padding: 0 10px 10px 10px !important; gap: 5px !important; }

    .footer-content { flex-direction: column; align-items: center; text-align: center; gap: 30px; }
    .about-me { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 10px; max-width: 100%; }
    .secret-link {
        width: 73px;
        height: 73px;
        display: flex;          
        align-items: center;
        justify-content: center;
        flex-shrink: 0;         
    }
    .footer-logo { 
        width: 100%;
        height: 100%; 
        object-fit: contain; 
        margin: 0 !important;
    }
    .profile-pic { 
        width: 60px; 
        height: 60px; 
        object-fit: cover;
        margin: 0; 
        flex-shrink: 0;         
        border-radius: 50%;     
    }
    .about-me > div { text-align: left; }
    .about-me h4 { display: block; margin-bottom: 3px; font-size: 16px; }
    .about-me p { display: block; font-size: 14px; line-height: 1.4; }
    
    .contact-form { width: 100%; text-align: left; }
    .contact-form h4 { text-align: left; padding-left: 5%; font-size: 1rem; margin-bottom: 10px; }
    .contact-form input, .contact-form button { display: block; width: 90%; max-width: 450px; margin: 10px auto; padding: 12px; box-sizing: border-box; font-size: 0.95rem; }

    .donate-wrapper { flex-direction: column; gap: 30px; margin-top: 20px; }
    .donate-text { width: 100%; text-align: center; }
    .donate-perks { display: inline-block; text-align: left; }
    .bank-info { flex-direction: column; text-align: center; gap: 20px; padding: 20px; }
    .bank-details { text-align: center; width: 100%; }
    .donate-qr { max-width: 150px; margin: 0 auto; }

    .post-item { flex-direction: column; align-items: flex-start; }
    .post-item p { white-space: normal; margin-top: 10px; margin-bottom: 10px; }
    .action-buttons { width: 100%; justify-content: flex-end; }
    .modal-image { max-height: 40vh; }
    .mobile-only-break { display: block; }

    #post-date { font-size: 0.75rem; padding: 3px 12px; gap: 4px; margin: 10px auto; }
}

/* ==========================================================================
   12. PAGE: ABOUT & PORTFOLIO STYLES (สำหรับหน้าผลงานและเกี่ยวกับครู)
   ========================================================================== */

/* คุมความกว้างคอนเทนเนอร์หน้าเกี่ยวกับครู */
.about-page-container {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* ดีไซน์กรอบ "ผลงานและความภูมิใจ" (เฉพาะกรอบนอก) */
.awards-content {
    background-color: #FFFFFF; 
    border: 2px solid #036666;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(3, 102, 102, 0.1);
    margin-top: 30px;
    margin-bottom: 30px;
    width: 100%; 
    box-sizing: border-box; 
    overflow: hidden; 
    text-align: center; /* จัดเนื้อหากลาง */
}

/* ปรับแต่งกรอบผลงานในมือถือ */
@media (max-width: 768px) {
    .awards-content {
        padding: 20px; 
        border-radius: 15px;
    }
}

/* ==========================================================================
   13. DYNAMIC CONTENT THEME (รวมทุกหน้า: โพสต์, ผลงาน, เกี่ยวกับครู)
   ========================================================================== */

/* 👇 จุดสังเกต: ผมเพิ่มชื่อ class ต่อท้ายเข้าไปด้วยคอมม่า (,) 
   เพื่อให้สไตล์นี้มีผลกับทั้งหน้าโพสต์และหน้าผลงานครับ 
*/
#post-content, 
.portfolio-content, 
.about-text {
    font-family: 'Kanit', sans-serif;
    font-size: 16px;
    color: #333;
    line-height: 1.6;
    word-wrap: break-word;
}

/* 2. หัวข้อ (H1-H6) */
#post-content h1, .portfolio-content h1, .about-text h1,
#post-content h2, .portfolio-content h2, .about-text h2,
#post-content h3, .portfolio-content h3, .about-text h3,
#post-content h4, .portfolio-content h4, .about-text h4,
#post-content h5, .portfolio-content h5, .about-text h5,
#post-content h6, .portfolio-content h6, .about-text h6 {
    color: #036666;
    font-weight: 700;
    margin-top: 25px;
    margin-bottom: 15px;
    line-height: 1.3;
}

/* 3. ย่อหน้า */
#post-content p, 
.portfolio-content p, 
.about-text p {
    margin-bottom: 16px;
    margin-top: 0;
}

/* 4. ลิงก์ */
#post-content a, 
.portfolio-content a, 
.about-text a {
    color: #FF7B54;
    text-decoration: underline;
}
#post-content a:hover, 
.portfolio-content a:hover, 
.about-text a:hover {
    color: #d35400;
}

/* 5. รูปภาพ (Images) - แก้ไขให้วางเรียงข้างกันได้ */
#post-content img, 
.portfolio-content img, 
.about-text img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    
    /* ✅ เปลี่ยนจาก block เป็น inline-block เพื่อให้วางข้างกันได้ */
    display: inline-block !important; 
    
    /* เว้นระยะห่างรอบๆ รูปนิดหน่อย */
    margin: 10px !important; 
    
    /* จัดตำแหน่งให้เสมอขอบบน (กรณีรูปสูงไม่เท่ากัน) */
    vertical-align: top;
}

/* 6. รายการ (List) */
#post-content ul, .portfolio-content ul, .about-text ul,
#post-content ol, .portfolio-content ol, .about-text ol {
    margin-bottom: 16px;
    padding-left: 40px;
}
#post-content li, .portfolio-content li, .about-text li {
    margin-bottom: 8px;
}

/* 7. ตาราง (Table) */
#post-content table, 
.portfolio-content table, 
.about-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 20px 0;
    font-size: 16px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
}

/* หัวตาราง */
#post-content th, .portfolio-content th, .about-text th,
#post-content thead tr, .portfolio-content thead tr, .about-text thead tr {
    background-color: #036666 !important;
    color: #ffffff !important;
    text-align: center !important;
    vertical-align: middle !important;
    padding: 8px 10px !important;
    font-weight: 500;
    border: none;
}

/* เนื้อหาในตาราง */
#post-content td, 
.portfolio-content td, 
.about-text td {
    padding: 8px 10px !important;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

/* สลับสีแถว */
#post-content tr:nth-of-type(even), 
.portfolio-content tr:nth-of-type(even), 
.about-text tr:nth-of-type(even) {
    background-color: #fcfcfc;
}
#post-content tr:hover, 
.portfolio-content tr:hover, 
.about-text tr:hover {
    background-color: #f0fdfd;
}

/* --- 📱 Mobile Responsive --- */
@media screen and (max-width: 768px) {
    #post-content, .portfolio-content, .about-text {
        font-size: 15px;
        padding: 0 5px;
    }
    
    #post-content table, .portfolio-content table, .about-text table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    #post-content img, .portfolio-content img, .about-text img {
        display: block !important;       /* กลับมาเป็น block */
        margin: 15px auto !important;    /* จัดกึ่งกลาง */
        width: 100% !important;          /* ขยายเต็มจอ */
    }
}

/* ===================================================
   14. PAGE SPECIFIC: Showcase (Teen & Pop Style) 🎨
   =================================================== */

/* กล่องลานประลองหลัก */
.challenge-banner {
    background-color: #ffffff;
    /* เพิ่มลายจุดจางๆ ให้ดูมีลูกเล่น ไม่เรียบเกินไป */
    background-image: radial-gradient(#036666 1px, transparent 1px);
    background-size: 20px 20px;
    
    border-radius: 24px; /* มุมมนโค้งกว่าเดิม */
    padding: 50px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
    
    /* กรอบและเงาแบบลอยตัว (Pop-up style) */
    border: 2px solid #036666;
    box-shadow: 10px 10px 0px rgba(3, 102, 102, 0.15); /* เงาแข็งแบบกราฟิก */
    
    margin: 50px 0;
}

/* ไอคอนตกแต่งพื้นหลัง (ขยับให้ดูสนุกขึ้น) */
.challenge-banner::before {
    content: '✨'; 
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 3rem;
    opacity: 0.5;
    animation: float 3s ease-in-out infinite;
}
.challenge-banner::after {
    content: '✍️';
    position: absolute;
    left: 20px;
    bottom: 20px;
    font-size: 4rem;
    opacity: 0.1;
    transform: rotate(-15deg);
}

/* Animation ลอยไปมา */
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

/* หัวข้อหลัก */
.challenge-banner h1 { 
    margin: 0 0 10px 0;
    font-size: 2.2rem; 
    font-weight: 800;
    color: #036666;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    letter-spacing: -0.5px;
}

.challenge-banner p {
    color: #555;
    font-size: 1.1rem;
    margin-bottom: 30px;
    font-weight: 500;
}

/* 🏷️ กล่องโจทย์ (พระเอกของงาน - สไตล์ Sticker) */
.challenge-topic {
    /* พื้นหลังสีส้มสดใส ไล่เฉดให้ดูทันสมัย */
    background: linear-gradient(135deg, #FF7B54 0%, #ff5722 100%);
    color: white;
    
    padding: 15px 40px;
    border-radius: 50px;
    display: inline-block;
    
    font-weight: 700;
    font-size: 1.5rem; /* ตัวใหญ่สะใจ */
    text-shadow: 1px 1px 0px rgba(0,0,0,0.1);
    
    /* เงาฟุ้ง + ขอบขาวตัดให้เด้ง */
    border: 4px solid white;
    box-shadow: 0 10px 20px rgba(255, 87, 34, 0.4);
    
    margin-bottom: 25px;
    position: relative;
    z-index: 2;
    
    /* เอียงนิดนึงให้ดูขี้เล่น */
    transform: rotate(-2deg); 
    transition: transform 0.3s;
}

.challenge-topic:hover {
    transform: rotate(0deg) scale(1.05); /* ชี้แล้วเด้งกลับ */
}

/* กล่องรายละเอียดกติกา (สไตล์กระดาษโน้ต) */
#display-detail {
    background-color: #fff;
    padding: 25px;
    border-radius: 16px;
    
    /* เส้นประสีเขียว ดูเป็นกันเองเหมือนงานประดิษฐ์ */
    border: 2px dashed #036666;
    
    text-align: left;
    font-size: 1.05rem;
    color: #333;
    line-height: 1.8;
    max-width: 800px;
    margin: 0 auto 25px auto;
    position: relative;
    z-index: 1;
}

/* วันหมดเขต (Badge เล็กๆ) */
#display-deadline {
    color: #c62828;
    background: #ffcdd2;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
}

/* 🚀 ปุ่มส่งผลงาน (ต้องน่ากดที่สุด) */
.submit-work-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    
    background-color: #036666;
    color: white !important;
    text-decoration: none !important;
    padding: 14px 45px;
    border-radius: 50px;
    
    font-weight: 700;
    font-size: 1.2rem;
    
    transition: all 0.2s;
    border-bottom: 5px solid #014040; /* ปุ่มแบบมีมิติ */
}

.submit-work-btn:hover { 
    transform: translateY(2px); /* กดลง */
    border-bottom: 2px solid #014040; /* ขอบบางลงเหมือนถูกกด */
    background-color: #025252;
}

/* ลิงก์ดูทำเนียบด้านล่าง */
.hall-of-fame-link {
    display: inline-block;
    margin-top: 25px;
    font-size: 1rem;
    color: #555;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 2px solid #FF7B54; /* ขีดเส้นใต้สีส้ม */
    padding-bottom: 2px;
    transition: 0.2s;
}
.hall-of-fame-link:hover {
    color: #FF7B54;
    letter-spacing: 0.5px;
}

/* โครงสร้าง Grid หลัก */
#showcase-grid {
    display: grid;
    /* แถวปกติ: ให้เรียงกัน (สำหรับที่ 2, 3, ชมเชย) */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 40px; /* ระยะห่างระหว่างการ์ด */
    padding-bottom: 40px;
    align-items: start;
}

/* --- การ์ดผู้ชนะทั่วไป (Basis) --- */
.prestige-card {
    background: #fff;
    border-radius: 20px;
    position: relative;
    padding-top: 60px; /* เว้นที่ให้ไอคอนลอย */
    margin-top: 40px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #f0f0f0;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}
.prestige-card:hover { transform: translateY(-8px); box-shadow: 0 20px 40px rgba(0,0,0,0.1); }

/* --- 🥇 ไฮไลท์: ที่ 1 ต้องเด่นสุด (The King Layout) --- */
.prestige-card.card-rank-1 {
    /* 1. สั่งให้กินพื้นที่เต็มแถวบนสุด */
    grid-column: 1 / -1; 
    
    /* 2. จัดขนาดและตำแหน่ง */
    max-width: 500px;   /* ไม่ให้กว้างเกินไป เดี๋ยวไม่สวย */
    width: 100%;
    margin-left: auto;  /* จัดกึ่งกลางแนวนอน */
    margin-right: auto;
    
    /* 3. ขยายขนาดให้ดูใหญ่กว่าเพื่อน */
    transform: scale(1.1); 
    z-index: 10; /* ลอยอยู่บนสุด */
    
    /* 4. แต่งสีทองให้สมฐานะ */
    border: 3px solid #FFD700;
    background: linear-gradient(to bottom, #fff, #fffdf0);
    box-shadow: 0 20px 50px rgba(255, 215, 0, 0.25); /* เงาทองฟุ้งๆ */
}

/* แก้บั๊ก: ตอน hover ที่ 1 ไม่ให้เด้งไปมากกว่านี้ (เพราะ scale 1.1 แล้ว) */
.prestige-card.card-rank-1:hover {
    transform: scale(1.12) translateY(-5px);
    box-shadow: 0 25px 60px rgba(255, 215, 0, 0.35);
}

/* ปรับไอคอนที่ 1 ให้ใหญ่ยักษ์ */
.prestige-card.card-rank-1 .rank-icon-box {
    width: 100px; height: 100px; top: -50px; font-size: 4rem;
    background: linear-gradient(135deg, #FFD700, #ffca28);
    border: 5px solid #fff;
    box-shadow: 0 10px 30px rgba(255, 193, 7, 0.4);
}
.prestige-card.card-rank-1 .winner-name { font-size: 1.8rem; color: #b38600; }

/* ===================================================
   📱 Mobile Redesign: Compact Hall of Fame (ทำเนียบฉบับพกพา)
   =================================================== */

@media (max-width: 768px) {
    /* 0. จัดการหัวข้อ (ให้แยกบรรทัด) */
    h2 span.english-title {
        display: block; /* สั่งให้ขึ้นบรรทัดใหม่ */
        font-size: 0.9rem; /* ลดขนาดลงหน่อย */
        color: #FF7B54; /* เปลี่ยนสีให้ดูมีลูกเล่น */
        margin-top: 5px;
    }
    
    /* 1. ปรับตาราง Grid ให้ชิดกันขึ้น */
    #showcase-grid {
        display: flex !important; /* เปลี่ยนเป็น Flex แนวตั้ง */
        flex-direction: column;
        gap: 15px !important; /* ลดระยะห่างระหว่างการ์ด */
        padding-bottom: 20px;
    }

    /* 2. แปลงร่างการ์ดเป็น "แนวนอน" */
    .prestige-card {
        margin-top: 0 !important; /* ลบระยะหัวที่เผื่อไว้ให้ไอคอนลอย */
        padding-top: 0 !important; /* ลบพื้นที่ว่างด้านบน */
        
        display: flex !important;
        flex-direction: row !important; /* เรียงซ้ายขวา */
        align-items: center;
        
        padding: 15px !important;
        border-radius: 12px !important;
        
        /* เงาบางลง */
        box-shadow: 0 4px 10px rgba(0,0,0,0.05) !important;
        
        /* ความสูงยืดหยุ่น */
        height: auto !important; 
        min-height: auto !important;
    }

    /* 3. จัดการไอคอนยศ (ดึงกลับเข้ามาอยู่ในการ์ดด้านซ้าย) */
    .rank-icon-box {
        position: static !important; /* ยกเลิกการลอย */
        transform: none !important;
        
        width: 50px !important;  /* เล็กลง */
        height: 50px !important;
        font-size: 1.8rem !important;
        
        margin-right: 15px; /* เว้นระยะห่างจากชื่อ */
        flex-shrink: 0; /* ห้ามโดนบีบ */
        
        box-shadow: none !important; /* เอาเงาออก */
        border: 2px solid rgba(0,0,0,0.05) !important;
    }

    /* 4. ซ่อนป้ายชื่อรางวัล (Winner/2nd Place) เพื่อประหยัดที่ */
    .rank-label {
        display: none !important;
    }

    /* 5. จัดเนื้อหาชื่อและโรงเรียน */
    .winner-content {
        padding: 0 !important;
        text-align: left !important; /* ชิดซ้าย */
        width: 100%;
    }

    .winner-name {
        font-size: 1.1rem !important;
        margin: 0 0 2px 0 !important;
    }

    .winner-school {
        font-size: 0.85rem !important;
        margin-bottom: 5px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis; /* ถ้าชื่อโรงเรียนยาวไปให้ ... */
        max-width: 200px;
    }

    /* 6. เส้นคั่น (ซ่อนไปเลย) */
    .divider {
        display: none !important;
    }

    /* 7. ปุ่มดาวน์โหลด (เปลี่ยนเป็นปุ่มเล็กๆ) */
    .cert-link {
        display: inline-block !important;
        font-size: 0.75rem !important;
        padding: 4px 10px !important;
        margin-top: 5px;
        background-color: transparent !important;
        border: 1px solid #ddd !important;
        color: #666 !important;
    }
    
    /* ไอคอนในปุ่ม */
    .cert-link .icon { font-size: 0.8rem; }

    /* --- ✨ พิเศษ: ปรับแต่งตามอันดับในมือถือ --- */

    /* 🥇 ที่ 1: ยังคงความเด่น (พื้นหลังทองจางๆ) */
    .prestige-card.card-rank-1 {
        background: linear-gradient(to right, #fffdf0, #ffffff) !important;
        border: 2px solid #FFD700 !important;
        transform: scale(1) !important; /* ไม่ต้องขยายใหญ่เดี๋ยวล้น */
    }
    .prestige-card.card-rank-1 .winner-name {
        color: #b38600 !important;
        font-size: 1.2rem !important;
    }
    .prestige-card.card-rank-1 .cert-link {
        background-color: #FFD700 !important;
        color: #fff !important;
        border: none !important;
    }

    /* 🥈 ที่ 2: ขอบเงินซ้าย */
    .prestige-card.card-rank-2 {
        border: 1px solid #eee !important;
        border-left: 5px solid #C0C0C0 !important;
    }

    /* 🥉 ที่ 3: ขอบทองแดงซ้าย */
    .prestige-card.card-rank-3 {
        border: 1px solid #eee !important;
        border-left: 5px solid #CD7F32 !important;
    }
    
    /* 🏅 ชมเชย: ขอบเขียวซ้าย */
    .prestige-card.card-rank-other {
        border: 1px solid #eee !important;
        border-left: 5px solid #036666 !important;
    }

/* 📱 แก้ปัญหาปุ่ม AI บัง Footer เฉพาะในมือถือ */
    .main-footer {
        /* เพิ่มพื้นที่ด้านล่างขึ้นมา 120px เพื่อให้เลื่อนหนีปุ่ม AI ได้ */
        padding-bottom: 120px !important; 
    }
}

/* --- อันดับรองลงมา (2, 3) --- */
.prestige-card.card-rank-2 { border-top: 5px solid #C0C0C0; }
.prestige-card.card-rank-2 .rank-icon-box { background: linear-gradient(135deg, #e0e0e0, #bdbdbd); }

.prestige-card.card-rank-3 { border-top: 5px solid #CD7F32; }
.prestige-card.card-rank-3 .rank-icon-box { background: linear-gradient(135deg, #d7ccc8, #a1887f); }

/* --- ชมเชย (Honorable) --- */
.prestige-card.card-rank-other .rank-icon-box { 
    background: #f0fdfd; border: 2px solid #036666; font-size: 2.5rem; 
}

/* (CSS ส่วนประกอบย่อยอื่นๆ เหมือนเดิม) */
.rank-icon-box { position: absolute; top: -40px; left: 50%; transform: translateX(-50%); width: 80px; height: 80px; background: #fff; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 3rem; box-shadow: 0 10px 20px rgba(0,0,0,0.1); z-index: 2; border: 4px solid #fff; }
.rank-label { text-align: center; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; margin-top: 10px; margin-bottom: 5px; color: #999; }
.winner-content { padding: 10px 25px 30px; text-align: center; }
.winner-name { font-size: 1.3rem; font-weight: 700; color: #333; margin: 5px 0; line-height: 1.3; }
.winner-school { color: #666; font-size: 0.95rem; font-weight: 300; margin-bottom: 15px; }
.divider { height: 1px; background: linear-gradient(to right, transparent, #eee, transparent); margin: 15px 0; }
.cert-link { display: inline-flex; align-items: center; gap: 8px; color: #036666; text-decoration: none; font-weight: 500; font-size: 0.9rem; padding: 8px 16px; border-radius: 50px; transition: all 0.2s; background-color: #f4fdfd; border: 1px solid transparent; }
.cert-link:hover { background-color: #036666; color: white; border-color: #036666; }
.cert-pending { font-size: 0.85rem; color: #aaa; font-style: italic; }

/* 📱 Mobile Responsive: ปรับลานประลองให้เล็กลงในมือถือ */
@media (max-width: 768px) {
    
    /* 1. ลดขนาดกล่องและระยะห่าง */
    .challenge-banner {
        padding: 30px 15px !important; /* ลดขอบใน */
        margin: 30px 0 !important;     /* ลดระยะห่างบนล่าง */
        border-radius: 16px !important;
        background-size: 15px 15px !important; /* จุดเล็กลง */
    }

    /* 2. ลดขนาดหัวข้อ */
    .challenge-banner h1 {
        font-size: 1.6rem !important; /* จาก 2.2 เหลือ 1.6 */
        gap: 5px !important;
    }
    .challenge-banner h1::before {
        font-size: 1.6rem !important; /* ไอคอนถ้วยเล็กลง */
    }

    /* 3. ลดขนาดคำอธิบาย */
    .challenge-banner p {
        font-size: 0.95rem !important;
        margin-bottom: 20px !important;
    }

    /* 4. ปรับกล่องโจทย์ (Sticker) ให้เล็กลง */
    .challenge-topic {
        font-size: 1.1rem !important; /* ตัวหนังสือเล็กลง */
        padding: 10px 20px !important; /* กล่องผอมลง */
        width: 100%; /* ให้กว้างเกือบเต็มจอจะได้ไม่ล้น */
        box-sizing: border-box;
    }

    /* 5. ปรับกล่องกติกา */
    #display-detail {
        padding: 15px !important;
        font-size: 0.9rem !important;
    }

    /* 6. ปุ่มส่งงาน (ให้เต็มจอ กดยง่าย) */
    .submit-work-btn {
        width: 100% !important;
        justify-content: center;
        padding: 12px 0 !important;
        font-size: 1rem !important;
    }
    
    /* ไอคอนตกแต่งพื้นหลัง */
    .challenge-banner::before, 
    .challenge-banner::after {
        opacity: 0.3 !important; /* จางลงอีกนิดในมือถือ */
        transform: scale(0.7);   /* ย่อขนาดลง */
    }
}