/* ===== Navbar: Page Loader ===== */
        /* =====================================================================
           Page Loader (เขียนแบบ "ห้ามหน่วง ห้ามค้าง")
           - ไม่ใช้ไลบรารีใดๆ
           - ตัวโหลดจะ "เริ่มปรากฏ" หลังผ่านไป 0.35 วิเท่านั้น ถ้าหน้าเว็บโหลดเร็วกว่านั้น
             ผู้ใช้จะไม่เห็นอะไรเลย (ไม่มีอาการกระพริบ และไม่ถ่วงเวลาแสดงผล)
           - กันค้าง 3 ชั้น: JS ปิดเมื่อโหลดเสร็จ / CSS บังคับซ่อนเองที่ 6 วิแม้ JS พัง /
             <noscript> ซ่อนทิ้งทันทีเมื่อผู้ใช้ปิด JavaScript
           ===================================================================== */
        .tn-loader {
            position: fixed; inset: 0; z-index: 99990;
            display: flex; align-items: center; justify-content: center;
            background: #101215;
            opacity: 0; visibility: hidden;
            animation: tnLoaderShow .25s ease .35s forwards, tnLoaderFailsafe 0s linear 6s forwards;
        }
        @keyframes tnLoaderShow { to { opacity: 1; visibility: visible; } }
        @keyframes tnLoaderFailsafe { to { opacity: 0; visibility: hidden; } }

        .tn-loader.tn-loader-out {
            animation: none;
            opacity: 0; visibility: hidden;
            transition: opacity .28s ease, visibility 0s linear .28s;
            pointer-events: none;
        }
        .tn-loader.tn-loader-visible { animation: none; opacity: 1; visibility: visible; }

        .tn-loader-box { display: flex; flex-direction: column; align-items: center; gap: 18px; }
        .tn-loader-logo { width: 190px; max-width: 55vw; height: auto; animation: tnLogoPulse 1.6s ease-in-out infinite; }
        @keyframes tnLogoPulse { 0%, 100% { opacity: .85; transform: scale(1); } 50% { opacity: 1; transform: scale(1.03); } }

        .tn-loader-bar { width: 180px; max-width: 50vw; height: 3px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; }
        .tn-loader-bar span { display: block; width: 40%; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #13C579, #38bdf8); animation: tnBarSlide 1.1s ease-in-out infinite; }
        @keyframes tnBarSlide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

        /* ผู้ใช้ที่ตั้งค่าระบบว่าไม่ต้องการแอนิเมชัน: ตัดการเคลื่อนไหวทั้งหมด */
        @media (prefers-reduced-motion: reduce) {
            .tn-loader { animation: none !important; opacity: 0 !important; visibility: hidden !important; }
            .tn-loader-logo, .tn-loader-bar span { animation: none !important; }
        }

/* ===== Navbar: Layout ===== */
        /* ================= ตัวแปรสีและค่าพื้นฐาน ================= */
        :root {
            --bg-dark: #121212;
            --bg-card: rgba(30, 30, 30, 0.7);
            --accent-primary: #13C579; 
            --accent-hover: #38bdf8;
            --text-main: #ffffff;
            --text-muted: #a1a1aa;
        }

        * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Prompt', sans-serif; }
        body { 
            background-color: var(--bg-dark); color: var(--text-main);
            background-image: linear-gradient(to bottom, rgba(18,18,18,0.7) 0%, rgba(18,18,18,1) 100%), url('../image/bg.webp');
            background-size: cover; background-position: center; background-attachment: fixed;
            min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden;
        }
        a { text-decoration: none; color: inherit; }

        /* ================= Navbar ด้านบน ================= */
        .navbar { 
            position: fixed; top: 0; left: 0; width: 100%; display: flex; justify-content: space-between; align-items: center;
            padding: 15px 5%; background: transparent; z-index: 1000; transition: all 0.3s ease; 
        }
        .navbar.scrolled {
            background: rgba(15, 20, 25, 0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
            padding: 10px 5%; border-bottom: 1px solid rgba(255, 255, 255, 0.05); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        }

        .nav-brand { 
            display: flex;
            align-items: center;
            z-index: 2; 
        }

        .nav-logo-img {
            height: 65px;
            width: auto;
            object-fit: contain;
            filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
            transition: transform 0.3s ease;
        }

        .nav-brand:hover .nav-logo-img {
            transform: scale(1.05); 
        }
        .nav-brand span { color: var(--accent-primary); }

        /* ================= เมนูกลาง (Top Navigation) ================= */
        .nav-center {
            display: flex;
            align-items: center;
            gap: 8px;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            z-index: 1;
        }

        .nav-link {
            display: flex; align-items: center; gap: 8px;
            padding: 10px 18px; border-radius: 14px;
            font-size: 14px; font-weight: 600; color: var(--text-muted);
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            cursor: pointer; text-decoration: none;
        }

        .nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }

        /* สถานะ Active */
        .nav-link.active {
            background: var(--accent-primary);
            color: #17103d; 
            box-shadow: none; 
        }

        /* กล่องเขียวที่เลื่อนตามเมนูที่ชี้ (ทำงานเมื่อ JS ใส่ .has-indicator เท่านั้น ไม่งั้นใช้ .active แบบเดิม)
           ความกว้างฐาน 100px แล้วใช้ scaleX ปรับให้เท่าเมนูแต่ละอัน เพื่อให้เคลื่อนไหวด้วย transform อย่างเดียว */
        .nav-indicator {
            position: absolute; left: 0; top: 0; width: 100px; height: 0; z-index: 0;
            border-radius: 14px; background: var(--accent-primary);
            transform-origin: left center; pointer-events: none; opacity: 0;
            transition: transform .35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity .2s ease;
        }
        .nav-indicator.no-anim { transition: none; }
        .nav-center.has-indicator .nav-link { position: relative; z-index: 1; }
        .nav-center.has-indicator .nav-link.active,
        .nav-center.has-indicator .nav-link:hover { background: transparent; }
        .nav-center.has-indicator .nav-link.active { color: var(--text-muted); }
        .nav-center.has-indicator .nav-link.tn-ind-on { color: #17103d; }
        @media (prefers-reduced-motion: reduce) {
            .nav-indicator { transition: none; }
        }

        /* Dropdown ร้านค้าตรงกลาง */
        .nav-item-dropdown { position: relative; display: inline-block; }
        .nav-item-dropdown::after { content: ''; position: absolute; width: 100%; height: 20px; bottom: -20px; left: 0; }
        
        .nav-dropdown-menu {
            position: absolute; top: calc(100% + 15px); left: 50%; transform: translateX(-50%) translateY(-15px);
            width: 200px; background: rgba(20, 20, 20, 0.95); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
            border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px; padding: 10px;
            box-shadow: 0 15px 40px rgba(0,0,0,0.7); opacity: 0; visibility: hidden;
            transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); z-index: 1001;
        }
        
        .nav-item-dropdown:hover .nav-dropdown-menu { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
        
        .dropdown-item {
            display: flex; align-items: center; gap: 10px; padding: 12px 15px;
            color: var(--text-muted); font-size: 14px; font-weight: 500;
            border-radius: 8px; transition: all 0.3s ease; text-decoration: none;
        }
        .dropdown-item i { font-size: 14px; text-align: center; width: 16px; transition: transform 0.3s; }
        .dropdown-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; transform: translateX(5px); }
        .dropdown-item.active { background: rgba(19, 197, 121, 0.1); color: var(--accent-primary); }

        /* ================= Navbar ด้านขวา ================= */
        .nav-right-actions { display: flex; align-items: center; gap: 15px; z-index: 2; }

        .server-badge-clean {
            display: flex; align-items: center; background: rgba(20, 20, 20, 0.65);
            border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px; overflow: hidden;
            cursor: pointer; transition: all 0.3s ease; backdrop-filter: blur(10px); height: 45px;
        }
        .server-badge-clean:hover { border-color: rgba(255, 255, 255, 0.3); transform: translateY(-2px); }
        .server-badge-ip { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 100%; }
        .pulse-dot-clean { width: 8px; height: 8px; background-color: #10b981; border-radius: 50%; box-shadow: none; animation: none; }
        .server-badge-ip span.ip-text { font-weight: 700; font-size: 14px; color: #fff; letter-spacing: 0.5px; }
        .server-badge-players { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, 0.05); color: #fff; padding: 0 16px; height: 100%; font-weight: 700; font-size: 13px; border-left: 1px solid rgba(255, 255, 255, 0.1); transition: all 0.3s ease; }
        .server-badge-clean:hover .server-badge-players { background: rgba(255, 255, 255, 0.15); color: #fff; }

        .drawer-toggle-btn {
            background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1);
            height: 45px; padding: 0 15px; border-radius: 14px; display: flex; align-items: center; gap: 10px;
            cursor: pointer; transition: all 0.3s ease; color: #fff; backdrop-filter: blur(10px);
        }
        .drawer-toggle-btn:hover { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.3); color: #fff; }
        .drawer-toggle-btn img { width: 28px; height: 28px; border-radius: 6px; }
        
        .cart-badge-nav {
            background: #ef4444; color: #fff; font-size: 11px; font-weight: 800;
            padding: 2px 6px; border-radius: 8px; margin-left: 5px; box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
            display: inline-block; 
        }

        /* ================= แถบเมนูด้านขวา (Right Drawer) ================= */
        .drawer-overlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
            background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px);
            z-index: 9998; opacity: 0; visibility: hidden; transition: all 0.3s ease;
            will-change: opacity, visibility; 
        }
        .drawer-overlay.active { opacity: 1; visibility: visible; }

        .right-drawer {
            position: fixed; top: 0; right: -350px; width: 320px; height: 100vh;
            background: rgba(20, 25, 30, 0.95); 
            backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); 
            border-left: 1px solid rgba(255, 255, 255, 0.08); box-shadow: -10px 0 40px rgba(0,0,0,0.5);
            z-index: 9999; transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            display: flex; flex-direction: column; overflow-y: auto;
            will-change: transform; 
        }
        .right-drawer.active { transform: translateX(-350px); }

        .drawer-profile-header {
            padding: 25px 20px 20px;
            background: linear-gradient(to bottom, rgba(255,255,255,0.03), transparent);
            border-bottom: 1px solid rgba(255,255,255,0.05);
        }
        
        .dp-user-info { display: flex; align-items: flex-start; gap: 15px; margin-bottom: 20px; }
        .dp-avatar { width: 55px; height: 55px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.5); }
        .dp-details { display: flex; flex-direction: column; }
        .dp-name { font-size: 18px; font-weight: 800; color: #fff; margin-bottom: 5px; display: flex; align-items: center; gap: 8px;}
        
        .dp-balance { font-size: 13px; color: var(--text-muted); display: flex; flex-direction: column; gap: 3px; font-weight: 500;}
        .dp-balance span.val-p { color: #fff; font-weight: 700; font-size: 14px;}
        .dp-balance span.val-rp { color: #fcd34d; font-weight: 700; font-size: 14px;}
        .dp-balance span.val-promo { color: #10b981; font-weight: 700; font-size: 14px;}

        .dp-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #10b981; font-weight: 600; margin-top: 10px; background: rgba(16, 185, 129, 0.1); padding: 4px 10px; border-radius: 20px; border: 1px solid rgba(16, 185, 129, 0.2);}
        .dp-status .dot { width: 6px; height: 6px; background: #10b981; border-radius: 50%; box-shadow: none;}

        .dp-actions { display: flex; gap: 10px; }
        .btn-drawer-action { 
            flex: 1; padding: 10px; border-radius: 10px; font-size: 13px; font-weight: 600; text-align: center;
            transition: all 0.3s ease; display: flex; justify-content: center; align-items: center; gap: 6px; border: none; cursor: pointer; text-decoration: none;
        }
        .btn-profile { background: rgba(255,255,255,0.1); color: #fff; }
        .btn-profile:hover { background: rgba(255,255,255,0.2); }
        .btn-logout-drawer { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
        .btn-logout-drawer:hover { background: #ef4444; color: #fff; }
        
        .btn-login-drawer { background: #3f3f46; color: #fff; width: 100%; border: 1px solid rgba(255,255,255,0.1); }
        .btn-login-drawer:hover { background: #52525b; }

        .drawer-menu-list { padding: 15px 15px 30px; display: flex; flex-direction: column; gap: 4px; }
        .drawer-menu-item {
            display: flex; align-items: center; padding: 12px 18px; color: var(--text-muted);
            font-size: 15px; font-weight: 500; text-decoration: none; border-radius: 12px;
            transition: all 0.25s ease; position: relative; overflow: hidden;
        }
        .drawer-menu-item i { width: 24px; font-size: 16px; text-align: center; margin-right: 12px; transition: 0.3s; }
        
        .drawer-menu-item:hover { background: rgba(255,255,255,0.05); color: #fff; transform: translateX(4px); }
        .drawer-menu-item:hover i { color: #fff; }
        
        .drawer-menu-item.active { 
            background: rgba(19, 197, 121, 0.1); 
            color: var(--accent-primary); 
            transform: translateX(4px); 
            font-weight: 600; 
        }
        .drawer-menu-item.active i { color: var(--accent-primary); }

        .drawer-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 8px 10px; }
        .menu-badge { margin-left: auto; background: #fff; color: #121212; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 10px; }

        /* ================= Toast Notification ================= */
        #toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px); background: #22c55e; color: white; padding: 10px 20px; border-radius: 8px; font-weight: 600; opacity: 0; transition: all 0.4s; z-index: 10000; box-shadow: 0 5px 15px rgba(34, 197, 94, 0.4); }
        #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

        /* ================= Floating Cart ขวามือ ================= */
        .floating-cart-wrapper {
            position: fixed; top: 50%; right: 0; transform: translateY(-50%); display: flex; align-items: center; z-index: 997; transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }
        .floating-cart-wrapper.hidden { transform: translateY(-50%) translateX(100%); }

        .fc-toggle {
            position: absolute; left: -24px; background: rgba(30, 30, 30, 0.9); border: 1px solid rgba(255, 255, 255, 0.1); border-right: none; color: var(--text-muted);
            width: 24px; height: 50px; border-radius: 8px 0 0 8px; display: flex; justify-content: center; align-items: center; cursor: pointer; backdrop-filter: blur(10px); box-shadow: -2px 0 5px rgba(0,0,0,0.2); transition: all 0.3s;
        }
        .fc-toggle:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }

        /* ป้ายแจ้งเตือนใหม่บนลูกศร (โชว์ตอนที่ตะกร้าถูกพับ) */
        .fc-toggle-badge {
            position: absolute;
            top: -6px;
            left: -6px;
            background: #ef4444;
            color: white;
            font-size: 10px;
            font-weight: 800;
            width: 20px;
            height: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            border-radius: 50%;
            box-shadow: 0 2px 5px rgba(239, 68, 68, 0.5);
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            pointer-events: none;
        }
        /* ตอนที่ตะกร้ากางอยู่ ให้ซ่อนป้ายบนลูกศร (เพราะมีอันใหญ่โชว์อยู่แล้ว) */
        .floating-cart-wrapper:not(.hidden) .fc-toggle-badge {
            opacity: 0;
            visibility: hidden;
            transform: scale(0);
        }
        /* ตอนที่ตะกร้าพับ ให้โชว์ป้ายบนลูกศร */
        .floating-cart-wrapper.hidden .fc-toggle-badge {
            opacity: 1;
            visibility: visible;
            transform: scale(1);
        }

        .fc-content {
            background: rgba(20, 20, 20, 0.85); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.1); border-right: none; padding: 18px 22px; border-radius: 16px 0 0 16px;
            display: flex; justify-content: center; align-items: center; text-decoration: none; color: #fff; box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5); transition: all 0.3s ease;
        }
        .fc-content:hover { background: rgba(255,255,255,0.1); transform: scale(1.05); transform-origin: right; border-color: rgba(255, 255, 255, 0.3); }

        .fc-icon { position: relative; font-size: 24px; display: flex; align-items: center; justify-content: center; }
        .fc-badge {
            position: absolute; top: -10px; right: -15px; background: #ef4444; color: white; font-size: 11px; font-weight: 800; width: 22px; height: 22px;
            display: flex; justify-content: center; align-items: center; border-radius: 50%; box-shadow: 0 2px 5px rgba(239, 68, 68, 0.5); transition: 0.3s;
        }
        .fc-content:hover .fc-badge { transform: scale(1.1); }

        /* SweetAlert in Navbar */
        .nav-swal-popup { background: rgba(20, 25, 30, 0.95) !important; backdrop-filter: blur(20px) !important; border: 1px solid rgba(255, 255, 255, 0.1) !important; border-radius: 24px !important; }
        .nav-cancel-btn { background: rgba(255, 255, 255, 0.05) !important; color: #fff !important; border: 1px solid transparent !important; }
        .nav-cancel-btn:hover { background: rgba(255, 255, 255, 0.1) !important; }

        /* Responsive */
        /* ต่ำกว่า 1600px เมนูกลางที่จัดกึ่งกลางจอแบบ absolute จะชนป้ายเซิร์ฟเวอร์ด้านขวา
           จึงให้อยู่ในช่องว่างระหว่างโลโก้กับปุ่มด้านขวาแทน แล้วค่อยๆ ย่อตามความกว้าง */
        @media (max-width: 1599px) {
            /* relative (ไม่ใช่ static) เพื่อให้ยังเป็นกรอบอ้างอิงของ .nav-indicator */
            .nav-center { position: relative; left: auto; transform: none; margin: 0 auto; gap: 4px; }
            .nav-link { padding: 10px 14px; }
        }
        @media (max-width: 1299px) {
            .nav-link { padding: 9px 11px; gap: 6px; }
            .server-badge-ip { display: none; }
            .server-badge-players { border-left: none; }
        }
        @media (max-width: 1050px) {
            .nav-center { display: none; }
            .server-badge-clean { display: none; }
            .right-drawer { width: 280px; right: -280px; }
            .right-drawer.active { transform: translateX(-280px); }
        }

        /* background-attachment: fixed บังคับ repaint ทุกเฟรมตอนสกรอลล์บนมือถือ ทำให้กระตุก
           ย้ายพื้นหลังไปไว้บน layer fixed แยกต่างหากซึ่ง GPU เลื่อนให้ได้โดยไม่ต้อง repaint */
        @media (max-width: 768px), (hover: none) {
            body { background-image: none; }
            body::before {
                content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
                background-image: linear-gradient(to bottom, rgba(18,18,18,0.7) 0%, rgba(18,18,18,1) 100%), url('../image/bg.webp');
                background-size: cover; background-position: center;
            }
        }

/* ===== Smooth Scroll ===== */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

/* ===== Scroll Reveal ===== */
/* ซ่อนเฉพาะเมื่อ JS ทำงาน (html.tn-js) ปิด JS แล้วการ์ดต้องยังเห็นตามปกติ
   ใช้ animation แบบ backwards ไม่ใช่ forwards/transition เพื่อไม่ค้าง transform ทับ hover ของการ์ด */
html.tn-js .tn-reveal { opacity: 0; }
html.tn-js .tn-reveal.is-visible {
    opacity: 1;
    animation: tnReveal .55s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
    animation-delay: var(--tn-reveal-delay, 0ms);
}
@keyframes tnReveal { from { opacity: 0; transform: translateY(24px); } }
@media (prefers-reduced-motion: reduce) {
    html.tn-js .tn-reveal { opacity: 1; animation: none !important; }
}

/* ===== Count Up ===== */
.tn-count { font-variant-numeric: tabular-nums; }
html.tn-js .tn-count:not(.is-counted) { opacity: 0; }

/* ===== Skeleton Shimmer =====
   ใส่ .tn-skel ที่กล่องรูปซึ่งมีขนาดตายตัวอยู่แล้ว สคริปต์ใน footer.php จะใส่ .tn-skel-done เมื่อรูปโหลดเสร็จ/โหลดพลาด
   ผูกกับ html.tn-js เสมอ ไม่งั้นปิด JS แล้วรูปจะถูกซ่อนตลอดไป */
html.tn-js .tn-skel { position: relative; }
html.tn-js .tn-skel:not(.tn-skel-done) { overflow: hidden; background-color: rgba(255, 255, 255, 0.04); }
html.tn-js .tn-skel:not(.tn-skel-done) img { opacity: 0; }
html.tn-js .tn-skel:not(.tn-skel-done)::after {
    content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.10) 50%, transparent 100%);
    transform: translateX(-100%);
    animation: tnShimmer 1.4s ease-in-out infinite;
}
@keyframes tnShimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
    html.tn-js .tn-skel:not(.tn-skel-done)::after { animation: none; transform: none; background: rgba(255, 255, 255, 0.03); }
}

/* ===== Cart Badge Bounce =====
   ไม่ใส่ fill-mode เพื่อให้ transform เดิมของ badge (เช่น scale(0) ตอนซ่อนของ .fc-toggle-badge) กลับมาเองเมื่อจบ */
.tn-bounce { animation: tnBadgeBounce .5s ease-out; }
@keyframes tnBadgeBounce {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.35); }
    55%  { transform: scale(0.9); }
    75%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .tn-bounce { animation: none; }
}

/* ===== Back To Top ===== */
/* z-index ต่ำกว่าตะกร้าลอย (997), drawer และ loader */
.tn-backtop {
    position: fixed; right: 24px; bottom: 24px; z-index: 996;
    width: 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(20, 25, 30, 0.85); color: #13C579; font-size: 16px;
    border: 1px solid rgba(19, 197, 121, 0.35); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(14px);
    transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
}
.tn-backtop.is-shown {
    opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0);
    transition: opacity .25s ease, transform .25s ease, visibility 0s;
}
.tn-backtop.is-shown:hover { transform: translateY(-3px); background: #13C579; color: #121212; }
.tn-backtop:focus-visible { outline: 2px solid #38bdf8; outline-offset: 3px; }
@media (max-width: 768px) {
    .tn-backtop { right: 16px; bottom: 20px; width: 42px; height: 42px; }
}
@media (prefers-reduced-motion: reduce) {
    .tn-backtop, .tn-backtop.is-shown { transition: none; transform: none; }
}

/* ===== Footer ===== */
    /* ================= CSS สำหรับ Footer (อิงตาม Layout รูปภาพตัวอย่างเป๊ะๆ) ================= */
    .tn-footer {
        background-color: #0a0a0a; /* สีพื้นหลังดำทึบแบบในภาพ */
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        padding: 30px 5%;
        margin-top: auto; /* บังคับให้อยู่ล่างสุดเสมอ */
        font-family: 'Prompt', sans-serif;
        width: 100%;
        position: relative;
        z-index: 10;
    }

    .tn-footer-container {
        max-width: 1300px;
        margin: 0 auto;
        display: flex;
        justify-content: space-between; /* ดันกลุ่มซ้าย และ กลุ่มขวา ให้อยู่คนละฝั่ง */
        align-items: center; /* ให้อยู่กึ่งกลางแนวตั้ง */
        flex-wrap: wrap;
        gap: 20px;
    }

    /* กลุ่มซ้าย (โลโก้ + ข้อมูล) */
    .tn-footer-left {
        display: flex;
        align-items: center; /* ให้โลโก้กับข้อความอยู่กึ่งกลางกันแนวนอน */
        gap: 25px;
        flex-wrap: wrap;
    }

    .tn-logo {
        height: 45px; 
        width: auto;
        object-fit: contain;
        filter: drop-shadow(0 2px 5px rgba(0,0,0,0.3));
    }

    /* กล่องข้อมูล (ป้าย Badge ด้านบน, ลิขสิทธิ์ด้านล่าง) */
    .tn-footer-info {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .tn-badges {
        display: flex;
        gap: 10px;
    }

    .tn-badge {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        padding: 6px 12px;
        border-radius: 6px;
        font-size: 13px;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 6px;
        text-decoration: none; /* เอาขีดเส้นใต้ออกกรณีใช้ <a> */
        border: 1px solid transparent;
        transition: all 0.3s ease;
    }

    /* เอฟเฟกต์สำหรับป้ายที่กดได้ */
    a.tn-badge:hover {
        transform: translateY(-2px);
        background: rgba(255, 255, 255, 0.15);
    }
    a.tn-badge.discord-badge:hover {
        border-color: #5865F2;
        color: #5865F2;
        box-shadow: 0 4px 10px rgba(88, 101, 242, 0.2);
    }
    a.tn-badge.ip-badge:hover {
        border-color: var(--accent-primary, #13C579);
        color: var(--accent-primary, #13C579);
        box-shadow: 0 4px 10px rgba(19, 197, 121, 0.2);
    }

    .tn-copyright {
        color: var(--text-muted, #a1a1aa);
        font-size: 12px;
        line-height: 1.5;
    }

    /* กลุ่มขวา (ไอคอนโซเชียล) */
    .tn-footer-right {
        display: flex;
        align-items: center;
        gap: 15px;
    }

    .tn-social-link {
        color: var(--text-muted, #a1a1aa);
        font-size: 22px;
        transition: all 0.3s ease;
        text-decoration: none;
    }

    .tn-social-link:hover {
        color: #fff;
        transform: scale(1.1);
    }
    .tn-social-link.tiktok-link:hover {
        color: #fff;
        filter: drop-shadow(2px 2px 0px #EE1D52) drop-shadow(-2px -2px 0px #69C9D0);
    }
    .tn-social-link.discord-link:hover {
        color: #5865F2;
    }
    .tn-social-link.facebook-link:hover {
        color: #1877F2;
    }
    .tn-social-link.youtube-link:hover {
        color: #FF0000;
    }
    .tn-social-link.instagram-link:hover {
        color: #E4405F;
    }

    /* ================= CSS สำหรับ Toast Notification ================= */
    #toast { 
        position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px); 
        background: #22c55e; color: white; padding: 10px 20px; border-radius: 8px; font-weight: 600; 
        opacity: 0; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 10000; 
        box-shadow: 0 5px 15px rgba(34, 197, 94, 0.4); 
    }
    #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

    /* Responsive สำหรับมือถือ */
    @media (max-width: 768px) {
        .tn-footer-container {
            flex-direction: column;
            align-items: center;
            text-align: center;
        }
        .tn-footer-left {
            flex-direction: column;
            text-align: center;
        }
        .tn-badges {
            justify-content: center;
        }
    }
