:root {
    --bg-dark: #020617;
    --primary-btn: #6366f1;
    --accent: #fbbf24;
    --modal-bg: rgba(15, 23, 42, 0.95);
    --vote-red: linear-gradient(135deg, #ff416c, #ff4b2b);
    --neon-blue: #38bdf8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --gold: #fbbf24;
    --primary-blue: #6366f1;
    --deep-bg: #020617;
    --glass: rgba(255, 255, 255, 0.05);
}

* {
    box-sizing: border-box;
    font-family: 'Kanit', sans-serif;
    /* ป้องกันการเกิดสีไฮไลท์เวลาแตะบนมือถือ */
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    /* --- จุดสำคัญ: ห้ามเลื่อนซ้ายขวาเด็ดขาด --- */
    overflow-x: hidden;
    position: relative;
    /* ยอมให้เลื่อนขึ้นลงได้ปกติ */
    overflow-y: auto;
    /* พื้นหลังแบบลุ่มลึก */
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(251, 191, 36, 0.1) 0px, transparent 50%);
    color: white;
    overflow: hidden;
    height: 100vh;
    min-height: 100vh;
    font-family: 'Kanit', sans-serif;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--deep-bg);
}

* {
    box-sizing: border-box;
    /* ป้องกันไม่ให้ Element ใดๆ ทะลุขอบจอออกไปด้านข้าง */
    max-width: 100vw;
}

/* เพิ่มความลื่นไหลในการเลื่อนหน้าจอ */
html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden;
    height: 100dvh;
}

.page {
    display: none;
    /* เปลี่ยนจาก height: 100vh เป็น min-height เพื่อให้ยืดตามเนื้อหา */
    min-height: 100vh;
    width: 100vw;
    position: relative;
    /* เปลี่ยนจาก absolute เพื่อให้ Flow ของหน้าจอปกติ */
    flex-direction: column;
    align-items: center;
    padding: 80px 20px 100px 20px;
    /* เว้นที่บนให้ปุ่ม Back และล่างให้พื้นว่าง */
}

.active {
    display: flex;
}

.hero-section {
    margin-bottom: 40px;
}

.badge {
    display: inline-block;
    padding: 5px 15px;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid var(--primary-blue);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--primary-blue);
    letter-spacing: 3px;
    margin-bottom: 15px;
    font-weight: bold;
}

/* --- หน้าแรก (Home Page) --- */
#home-page {
    background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
    position: relative;
    overflow-y: auto; 
    overflow-x: hidden;
}

/* Ambient Glow - แสงฟุ้งด้านหลัง */
#home-page::before {
    content: "";
    position: absolute;
    width: 40vmin;
    height: 40vmin;
    background: var(--primary-btn);
    filter: blur(100px);
    opacity: 0.15;
    top: 20%;
    left: 10%;
    pointer-events: none;
}

/* จัดการเนื้อหาหน้าแรกให้ดูเด่น */
.home-content {
    position: relative;
    /* ให้อยู่เหนือแสง Glow และ Star Field */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    z-index: 10;
    width: 100%;
    max-width: 900px;
    /* จำกัดความกว้างให้พอดีมือถือ */
}

.main-title {
    font-size: clamp(4rem, 12vw, 7rem);
    font-weight: 900;
    line-height: 0.9;
    background: linear-gradient(to bottom, #fff 50%, #64748b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.1));
}

.main-title span {
    color: var(--gold);
    -webkit-text-fill-color: var(--gold);
    text-shadow: 0 0 40px rgba(251, 191, 36, 0.3);
}

h1 {
    /* clamp ช่วยให้ตัวหนังสือใหญ่ในคอม และเล็กลงในมือถืออัตโนมัติ */
    font-size: clamp(2rem, 10vw, 4.5rem);
    font-weight: 500;
    background: linear-gradient(to bottom, #ffffff 30%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

.sub-text {
    font-size: 1.2rem;
    color: #94a3b8;
    margin-bottom: 3rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.8;
}

.btn-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
}

/* ปรับปุ่มให้เรียงแถวเดียวถ้าจอมือถือเล็กมาก */
@media (max-width: 350px) {
    .btn-container {
        grid-template-columns: 1fr;
    }
}

.hero-btn {
    padding: 25px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
    border-color: rgba(255, 255, 255, 0.3);
    font-size: 1.2rem;
}

.nav-btn {
    position: relative;
    padding: 20px;
    border-radius: 15px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    backdrop-filter: blur(15px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover,
.nav-btn:active {
    transform: translateY(-3px) scale(1.02);
    background: rgba(255, 255, 255, 0.1);
    border-color: #fbbf24;
    box-shadow: 0 10px 25px rgba(251, 191, 36, 0.2);
}

.nav-btn span {
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 2;
}

.nav-btn:hover span i {
    transform: scale(1.2);
    filter: drop-shadow(0 0 8px #fbbf24);
}

.nav-btn:first-child {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.2);
}

/* เอฟเฟกต์แสงวิ่งพาดผ่านปุ่ม (Shine Effect) */
.nav-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 15px;
    padding: 2px;
    /* ความหนาของเส้นขอบ */
    background: linear-gradient(90deg, transparent, #fbbf24, #ef4444, transparent);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.5;
    transition: 0.5s;
}

.nav-btn:hover::before {
    opacity: 1;
    background: linear-gradient(90deg, #fbbf24, #fff, #fbbf24);
}

.nav-btn:hover {
    transform: translateY(-5px) rotateX(10deg);
    background: rgba(255, 255, 255, 0.1);
    color: #fbbf24;
    box-shadow: 0 15px 30px rgba(251, 191, 36, 0.3);
}

.nav-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.2),
            transparent);
    transition: 0.6s;
}

.nav-btn:hover::after {
    left: 100%;
}

.nav-btn:active {
    transform: translateY(-2px) scale(0.98);
}

/* อนิเมชั่นปุ่มลอยขึ้นลงเบาๆ ให้ดูมีชีวิต */
@keyframes buttonFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* อนิเมชั่นตอนเปิดหน้า (เนียนขึ้น) */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
        filter: blur(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

.space-aura {
    position: absolute;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.15;
}

.aura-1 {
    background: var(--primary-blue);
    top: -20%;
    left: -20%;
}

.aura-2 {
    background: #7c3aed;
    bottom: -20%;
    right: -20%;
}

#member-page {
    background: radial-gradient(circle at center, #0f172a 0%, #020617 100%);
    justify-content: center;
    /* จัดให้อยู่กลางแนวตั้ง */
}

.star-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* สร้างดวงดาวด้วย Box Shadow แบบกระจายตัว */
/* เราจะสร้างก้อนเมฆดวงดาวขนาดใหญ่ 1 ก้อน แล้วก๊อปปี้ไปวางต่อกัน */
.stars-container {
    position: absolute;
    width: 100%;
    height: 200%;
    /* ให้สูงเป็น 2 เท่าของจอ */
    top: 0;
    left: 0;
    background: transparent;
    animation: starsInfinite 40s linear infinite;
    /* วนลูปต่อเนื่อง */
}

.stars-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    background: transparent;
    /* สร้างดาวดวงเล็กจิ๋วอีกชุด */
    box-shadow: 15vw 15vh #fff, 55vw 55vh #fff, 85vw 85vh #fff, 45vw 25vh #fff;
    /* แสงกระพริบ */
    animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
    from {
        opacity: 0.3;
    }

    to {
        opacity: 1;
    }
}

/* สร้างดาวด้วย shadow */
.stars-container::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 2px;
    background: white;
    box-shadow:
        /* แถวที่ 1 */
        10vw 20vh #fff, 35vw 45vh #fff, 80vw 10vh #fff, 20vw 90vh #fff,
        60vw 30vh #fff, 95vw 80vh #fff, 40vw 15vh #fff, 15vw 55vh #fff,
        /* แถวที่ 2 (ก๊อปปี้พิกัดเดิมแต่เพิ่มความสูงขึ้นไป 100vh เพื่อให้มันต่อกัน) */
        10vw 120vh #fff, 35vw 145vh #fff, 80vw 110vh #fff, 20vw 190vh #fff,
        60vw 130vh #fff, 95vw 180vh #fff, 40vw 115vh #fff, 15vw 155vh #fff;

    border-radius: 50%;
    opacity: 0.6;
}

/* อนิเมชั่นเลื่อนขึ้นทีละ 50% (คือเลื่อนขึ้นไป 1 จอพอดี) */
@keyframes starsInfinite {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-100vh);
        /* เมื่อเลื่อนขึ้น 1 จอ ชุดที่สองจะมาแทนที่จุดเดิมพอดี */
    }
}

.universe-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

/* วงโคจร: ให้เห็นเส้นแต่คลิกทะลุได้ (pointer-events: none) */
.orbit-layer {
    position: absolute;
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
    transform: translate(-50%, -50%);
    box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.05);
}

/* ตัวนักเรียน: ตั้งค่าให้คลิกได้ (pointer-events: auto) */
.student {
    position: absolute;
    width: 8vmin;
    /* ปรับขนาดตามความกว้างหน้าจอ */
    height: 8vmin;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.student:hover {
    transform: scale(1.5) !important;
    z-index: 500;
}

.student img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 1.5px solid rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

.student:hover img {
    border-color: #fff;
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.4);
}

/* ครูที่ปรึกษา */
.teacher {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 20vmin;
    height: 20vmin;
    z-index: 50;
    cursor: pointer;
}

.teacher img {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 50%;
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.4);
    border: 3px solid var(--accent);
    filter: drop-shadow(0 0 15px rgba(251, 191, 36, 0.6));
    animation: teacherPulse 4s infinite ease-in-out;
}

@keyframes teacherPulse {

    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 15px rgba(251, 191, 36, 0.6));
    }

    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 35px rgba(251, 191, 36, 0.9));
    }
}

.back-btn {
    position: fixed;
    top: 15px;
    left: 15px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    /* ทำให้เป็นวงกลม */
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2000;
    /* อยู่เหนือทุกอย่างรวมถึง Modal */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.back-btn:hover {
    background: var(--primary-btn);
    transform: scale(1.1) rotate(-10deg);
    /* ส่ายนิดๆ ให้ดูมีลูกเล่น */
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
    border-color: rgba(255, 255, 255, 0.5);
}

.back-btn:active {
    transform: scale(0.9);
}

/* เพิ่ม icon หรือตัวอักษรให้ดูดี */
.back-btn::before {
    content: '🏠';
    /* ใช้ลูกศรแทนคำพูด */
    font-size: 1.5rem;
    font-weight: bold;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
    transition: all 0.4s ease;
}

.modal-overlay.open {
    display: flex;
    backdrop-filter: blur(15px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    position: relative;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    padding: 40px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: scale(0.9);
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-overlay.open .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ซ่อน Scrollbar สำหรับ Chrome/Safari */
.modal-content::-webkit-scrollbar {
    display: none;
}

.image-wrapper {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto 20px;
}

.modal-img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto 20px auto;
    border: 3px solid var(--primary-btn);
    box-shadow: 0 0 25px rgba(99, 102, 241, 0.5);
    display: block;
    object-fit: cover;
    animation: imageFloat 4s infinite ease-in-out;
    /* รูปลอยขึ้นลงเบาๆ */
}

@keyframes imageFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ปรับปุ่ม Instagram ให้ดูเพรียวขึ้น */
.ig-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    color: white;
    padding: 10px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.9rem;
    width: 100%;
    transition: transform 0.2s;
}

.ig-btn:active {
    transform: scale(0.95);
}

.fb-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    color: white;
    padding: 10px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.9rem;
    width: 100%;
    transition: transform 0.2s;
}

.fb-btn:active {
    transform: scale(0.95);
}

.modal-name {
    font-size: 1.8rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 1px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.3));
}

.modal-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    margin-bottom: 25px;
}

/* --- Social Buttons --- */
.social-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
    perspective: 500px;
    /* เพิ่มมิติความลึกเวลา Hover */
}

.social-btn {
    position: relative;
    padding: 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-decoration: none;
    text-transform: uppercase;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.social-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    transform: scale(0);
    transition: 0.6s ease-out;
    pointer-events: none;
}

.social-btn:hover::before {
    transform: scale(1);
}

.social-btn.ig {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    box-shadow: 0 4px 15px rgba(220, 39, 67, 0.3);
    color: white;
}

.social-btn.fb {
    background: linear-gradient(135deg, #1877f2 0%, #0a58ca 100%);
    box-shadow: 0 4px 15px rgba(24, 119, 242, 0.3);
    color: white;
}

.social-btn:hover {
    transform: translateY(-5px) translateZ(20px);
    /* ลอยออกมาหาผู้ใช้ */
    filter: brightness(1.1);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.4);
}

.social-btn:hover i {
    animation: iconBounce 0.5s infinite alternate;
}

@keyframes iconBounce {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.3);
    }
}

/* --- Animations --- */
@keyframes pulseAura {
    0% {
        transform: scale(1);
        opacity: 0.3;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 0.3;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#ranking-list {
    margin: 10px 0;
    padding-right: 8px;
    /* เว้นที่ให้ scrollbar */
}

/* ปรับแต่ง Scrollbar ให้ดูหรู */
#ranking-list::-webkit-scrollbar {
    width: 5px;
}

#ranking-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

#ranking-list::-webkit-scrollbar-thumb {
    background: rgba(251, 191, 36, 0.3);
    border-radius: 10px;
}

.modal-sub {
    font-size: 1rem;
    color: var(--neon-blue);
    /* สีฟ้าสดใสจากเครื่องมือก่อนหน้า */
    letter-spacing: 1px;
    margin-bottom: 25px;
    text-align: center;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    transition: 0.3s;
}

.close-modal:hover {
    color: #fff;
    transform: rotate(90deg);
}

.modal-content .nav-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    padding: 14px;
    border-radius: 15px;
    font-weight: 600;
    letter-spacing: 1px;
    transition: all 0.3s;
}

.modal-content .nav-btn:hover {
    background: #ef4444;
    /* เปลี่ยนเป็นสีแดงตอน Hover ให้รู้ว่าเป็นปุ่มปิด */
    color: white;
    border-color: #ef4444;
}


/* --- อนิเมชั่น --- */
@keyframes rotate-cw {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes rotate-ccw {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(-360deg);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
    }

    50% {
        box-shadow: 0 0 40px rgba(251, 191, 36, 0.6);
    }
}

.counter-spin {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;600&display=swap');

h1 {
    font-weight: 600;
    font-size: 2.8rem;
    margin: 30px 0;
    background: var(--primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(255, 65, 108, 0.5));
    animation: pulseGlow 2s infinite alternate;
}

@keyframes pulseGlow {
    from {
        filter: drop-shadow(0 0 10px rgba(255, 65, 108, 0.5));
    }

    to {
        filter: drop-shadow(0 0 20px rgba(255, 65, 108, 0.8));
        transform: scale(1.02);
    }
}

.vote-grid {
    display: grid;
    /* ปรับขนาดขั้นต่ำเป็น 150px เพื่อให้ดูไม่เบียดกันเกินไปในมือถือจอเล็ก */
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 800px;
    /* ขยายให้กว้างขึ้นเล็กน้อยเพื่อความสวยงามในแท็บเล็ต */
    margin: 0 auto;
    padding: 30px 20px 150px 20px;
    /* เว้นที่ด้านล่างเพิ่มให้ปุ่ม Sticky */
    perspective: 1000px;
    /* เพิ่มมิติสำหรับการทำ 3D Hover */
}

.vote-card {
    position: relative;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    /* มนขึ้นเพื่อให้ดูซอฟต์ */
    padding: 25px 15px;
    text-align: center;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    backdrop-filter: blur(5px);
}

.vote-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
    transform: translateY(-12px) scale(1.02);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(251, 191, 36, 0.2);
}

/* เอฟเฟกต์แสงวิ่งพาดผ่านการ์ดตอน Hover */
.vote-card::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -150%;
    width: 100%;
    height: 200%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.1),
            transparent);
    transform: rotate(45deg);
    transition: 0.8s;
}

.vote-card:hover::after {
    left: 150%;
}

.profile-img {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 15px;
    /* ทำขอบสองชั้น (Double Border Effect) */
    border: 3px solid transparent;
    background: linear-gradient(var(--bg-dark), var(--bg-dark)) padding-box,
        var(--vote-red) border-box;
    padding: 2px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.4s ease;
}

.vote-card:hover .profile-img {
    transform: scale(1.1) rotate(5deg);
}

.name-label {
    font-size: 1.1rem;
    color: #f8fafc;
    font-weight: 600;
    margin-bottom: 18px;
    letter-spacing: 0.5px;
}

.btn-vote {
    background: var(--vote-red);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 15px;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 4px 15px rgba(255, 65, 108, 0.3);
    transition: all 0.3s ease;
}

.btn-vote:hover {
    filter: brightness(1.1);
    box-shadow: 0 8px 25px rgba(255, 65, 108, 0.5);
    transform: translateY(-2px);
}

.btn-result {
    display: flex;
    margin: 40px auto;
    width: 85%;
    max-width: 280px;
    padding: 16px;
    font-size: 1.1rem;
    animation: floatingGlow 3s infinite ease-in-out;
}

.btn-result:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 15px 35px rgba(255, 65, 108, 0.6);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(20px);
}

.modal-title {
    text-align: center;
    margin-bottom: 25px;
    color: #ffcc00;
}

@keyframes modalPop {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.ranking-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    /* พื้นหลังจางๆ แบบในรูป */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    /* ขอบมนสวยงาม */
    padding: 15px 20px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.ranking-item:hover {
    transform: scale(1.02);
    background: rgba(255, 255, 255, 0.06);
}

.rank-badge {
    width: 30px;
    height: 30px;
    background: var(--vote-red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    margin-right: 12px;
}

.rank-img {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fbbf24;
    /* ขอบสีทองตามอันดับ */
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.3);
    margin-right: 20px;
}

.rank-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: #ffffff;
    flex-grow: 1;
    /* ดันส่วนคะแนนไปทางขวา */
}

.rank-score-container {
    text-align: right;
}

.rank-info {
    display: flex;
    align-items: center;
    font-size: 1.1rem;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rank-number {
    font-size: 1.5rem;
    font-weight: 900;
    color: #fbbf24;
    /* สีทองสำหรับอันดับ */
    min-width: 40px;
    text-align: center;
    margin-right: 15px;
    font-family: 'Inter', sans-serif;
}

.score-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    color: #10b981;
    /* สีเขียวสว่างตามรูปตัวอย่าง */
    line-height: 1;
}

.score-label {
    font-size: 0.8rem;
    color: #94a3b8;
    text-transform: uppercase;
    margin-top: 5px;
    display: block;
}

.close-btn {
    width: 100%;
    margin-top: 25px;
    padding: 15px;
    border-radius: 18px;
    background: #21262d;
    color: white;
    border: 1px solid #30363d;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
}

* {
    box-sizing: border-box;
    font-family: 'Kanit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* --- การจัดการหน้า --- */
.page {
    display: none;
    height: 100vh;
    width: 100vw;
    position: absolute;
    top: 0;
    left: 0;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.active {
    display: flex;
}

#vote-page {
    display: none;
    padding-top: 0 !important;
    /* ล้าง padding ด้านบน */
    padding-left: 0 !important;
    padding-right: 0 !important;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 100vh;
    width: 100vw;
    background: radial-gradient(circle at 50% -20%, #1e293b 0%, #020617 80%);
    background-attachment: fixed;
    flex-direction: column;
    align-items: stretch;
    /* ให้ลูกๆ ขยายเต็มหน้าจอ */
}

#vote-page::-webkit-scrollbar {
    display: none;
}

#vote-page.active {
    display: block;
    animation: zoomOutFade 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.vote-header {
    position: sticky;
    /* หรือ fixed ถ้าต้องการให้ล็อคถาวร */
    top: 0;
    left: 0;
    width: 100%;
    margin: 0;
    /* ลบ margin ที่อาจทำให้นูนออกมา */
    padding: 20px 0;
    /* ปรับระยะห่างภายในตามความเหมาะสม */

    background: rgba(15, 23, 42, 0.9);
    /* สีพื้นหลังเข้มตามภาพ */
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;

    display: flex;
    justify-content: center;
    align-items: center;
}

.vote-title {
    font-size: clamp(1.8rem, 8vw, 2.5rem);
    font-weight: 800;
    margin: 0;
    background: linear-gradient(135deg, #fbbf24, #ff4b2b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.3));
}

/* --- 3. เพิ่มอนิเมชั่นให้การ์ดค่อยๆ ลอยขึ้นมาทีละใบ (Stagger) --- */
#vote-page.active .vote-card {
    animation: cardEntrance 0.6s ease-out backwards;
}

/* ใส่ Delay ให้แต่ละใบ (ถ้าใช้ JS Generate ให้ใส่สไตล์ delay เพิ่ม) */
#vote-page.active .vote-card:nth-child(1) {
    animation-delay: 0.1s;
}

#vote-page.active .vote-card:nth-child(2) {
    animation-delay: 0.2s;
}

#vote-page.active .vote-card:nth-child(3) {
    animation-delay: 0.3s;
}

/* --- 4. Keyframes ใหม่ให้ดู Smooth --- */

@keyframes zoomOutFade {
    from {
        opacity: 0;
        transform: scale(1.1);
        /* เริ่มจากซูมเข้ามาหาตัว */
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.vote-card:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.1);
}

.vote-card img {
    width: 75px;
    height: 75px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
    border: 3px solid transparent;
    background-image: linear-gradient(var(--bg-dark), var(--bg-dark)), var(--vote-red);
    background-origin: border-box;
    background-clip: content-box, border-box;
    padding: 3px;
    transition: transform 0.3s;
}

.vote-card:hover img {
    border-color: #fbbf24;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
}

.vote-card .name-label {
    font-size: 0.95rem;
    display: block;
    margin-bottom: 10px;
    color: #e2e8f0;
}

.btn-vote {
    background: var(--vote-red);
    color: white;
    border: none;
    padding: 8px 0;
    border-radius: 12px;
    width: 100%;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: 0 4px 10px rgba(255, 75, 43, 0.3);
}

.btn-result-sticky {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    /* จัดกลาง */
    width: 220px;
    padding: 14px 25px;
    font-size: 1rem;
    z-index: 1000;
    animation: floatingGlow 3s infinite ease-in-out;
}

.btn-result::before,
.btn-result-sticky::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.3),
            transparent);
    transition: 0.6s;
}

/* ปุ่ม Leaderboard แบบใหม่ที่ดูแพงขึ้น */
.btn-result,
.btn-result-sticky {
    background: var(--vote-red);
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    overflow: hidden;
    /* จำเป็นสำหรับแสงวิ่งข้ามปุ่ม */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 0 20px rgba(255, 65, 108, 0.4);
    z-index: 10;
}

.btn-result-sticky:hover {
    /* รักษาค่าจัดกลาง (translateX) ไว้พร้อมกับยกตัวขึ้น */
    transform: translate(-50%, -8px) scale(1.05);
    box-shadow: 0 15px 35px rgba(255, 65, 108, 0.6);
}

/* เมื่อ Hover ให้แสงวิ่งผ่าน */
.btn-result:hover::before,
.btn-result-sticky:hover::before {
    left: 100%;
}

@keyframes floatingGlow {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(255, 65, 108, 0.3), 0 0 5px rgba(255, 65, 108, 0.2);
    }

    50% {
        box-shadow: 0 0 35px rgba(255, 65, 108, 0.7), 0 0 15px rgba(255, 65, 108, 0.4);
    }
}

#vote-page .vote-header {
    position: sticky;
    /* ล็อคให้อยู่กับที่เวลาเลื่อน */
    top: 0;
    left: 0;
    width: 100%;
    margin: 0 !important;
    /* ล้าง margin top ที่เคยตั้งไว้ 50px */
    padding: 30px 20px;
    /* เพิ่มพื้นที่หายใจด้านบน-ล่างให้หัวข้อ */
    background: rgba(15, 23, 42, 0.9);
    /* สีพื้นหลังเข้มตามรูป */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

#vote-page .vote-title {
    font-size: clamp(2.5rem, 10vw, 4rem);
    font-weight: 900;
    text-transform: uppercase;
    background: linear-gradient(135deg, #fbbf24, #ff4b2b);
    /* สีทองไปแดง */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(251, 191, 36, 0.4));
    margin: 0;
}

#vote-page .vote-subtitle {
    color: #94a3b8;
    font-size: 1.1rem;
    margin-top: 10px;
}

/* แอนิเมชันให้ Modal หรือ Card ดูเหมือนลอยอยู่ในอวกาศ */
@keyframes float {
    0% {
        transform: translateY(0px) rotate(0deg);
    }

    50% {
        transform: translateY(-15px) rotate(1deg);
    }

    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

/* เอฟเฟกต์ Glassmorphism ขั้นสูง */
.modal-content,
.nav-btn {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.1) inset,
        0 20px 50px rgba(0, 0, 0, 0.5);
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
        box-shadow 0.5s ease,
        background 0.3s ease;
}

/* เอฟเฟกต์แสงนีออนวิ่งรอบปุ่ม/Modal (Border Beam) */
@keyframes borderBeam {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.hero-btn {
    background-size: 200% 200%;
    animation: borderBeam 5s linear infinite;
    border: 2px solid transparent;
    background-image: linear-gradient(#020617, #020617),
        linear-gradient(90deg, #fbbf24, #6366f1, #fbbf24);
    background-origin: border-box;
    background-clip: padding-box, border-box;
}

/* มิติความลึกของตัวอักษร */
.main-title {
    perspective: 1000px;
    transform-style: preserve-3d;
}

/* สร้างจุดเล็กๆ ลอยไปมา */
.star-field::after {
    content: "";
    position: absolute;
    inset: -100px;
    background-image: radial-gradient(1px 1px at 20px 30px, #fff, rgba(0, 0, 0, 0)),
        radial-gradient(1.5px 1.5px at 100px 150px, #fff, rgba(0, 0, 0, 0));
    background-size: 300px 300px;
    opacity: 0.2;
    animation: drift 60s linear infinite;
}

@keyframes drift {
    from {
        transform: rotate(0deg) translateY(0);
    }

    to {
        transform: rotate(5deg) translateY(-100px);
    }
}