/* =========================================
   1. โครงสร้างหลัก (Main Structure)
   ========================================= */
body.bg-dark-green {
    background: radial-gradient(circle at center, #004d00 0%, #001a00 100%); /* ไล่สีพื้นหลังให้ดูมีมิติ */
    color: white;
    font-family: 'Sarabun', sans-serif;
    margin: 0;
}

.title {
    color: #ffeb3b;
    text-shadow: 0 4px 10px rgba(0,0,0,0.8);
    font-size: clamp(2rem, 5vw, 3.5rem); /* ย่อขยายขนาดฟอนต์ตามจออัตโนมัติ */
    font-weight: bold;
    letter-spacing: 2px;
}

/* =========================================
   2. วงล้อเซียมซี (Responsive Wheel)
   ========================================= */
.wheel-container {
    position: relative;
    /* ปรับลดขนาดลง 10% จากเดิม (ใช้ 80vw และ 65vh แทน) */
    width: min(80vw, 65vh);
    height: min(80vw, 65vh);
    max-width: 720px; /* ลดเพดานขนาดสูงสุดลงให้สมดุล */
    max-height: 720px;
}

.wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 8px solid #ffa500;
    box-shadow: 0 0 30px rgba(255, 165, 0, 0.4), inset 0 0 20px rgba(0,0,0,0.5); /* เพิ่มแสงเรืองขอบวงล้อ */
    background: conic-gradient(
        #ffffff 0deg 15deg, #008000 15deg 30deg,
        #ffffff 30deg 45deg, #008000 45deg 60deg,
        #ffffff 60deg 75deg, #008000 75deg 90deg,
        #ffffff 90deg 105deg, #008000 105deg 120deg,
        #ffffff 120deg 135deg, #008000 135deg 150deg,
        #ffffff 150deg 165deg, #008000 165deg 180deg,
        #ffffff 180deg 195deg, #008000 195deg 210deg,
        #ffffff 210deg 225deg, #008000 225deg 240deg,
        #ffffff 240deg 255deg, #008000 255deg 270deg,
        #ffffff 270deg 285deg, #008000 285deg 300deg,
        #ffffff 300deg 315deg, #008000 315deg 330deg,
        #ffffff 330deg 345deg, #008000 345deg 360deg
    );
    transition: transform 4s cubic-bezier(0.17, 0.67, 0.1, 1);
    position: relative; 
}

/* ชุดคำสั่งจัดวางตัวเลข 1-24 ไม่ให้ตกกรอบ */
.wheel-number {
    position: absolute;
    top: 0;
    left: 50%;
    width: 50px;
    height: 50%; /* ให้จุดหมุนอยู่กึ่งกลางพอดี */
    margin-left: -25px; /* ดึงกลับครึ่งนึงของ width ให้อยู่กึ่งกลางเป๊ะ */
    transform-origin: bottom center;
    transform: rotate(calc((var(--i) - 1) * 15deg + 7.5deg));
    
    display: flex;
    justify-content: center;
    padding-top: 7%; /* ปรับดันตัวอักษรลงมาด้านในให้พอดีกับวงล้อที่เล็กลง */
    font-size: clamp(14px, 3.2vw, 30px); /* ปรับขนาดฟอนต์ให้สมดุลกับวงล้อใหม่ */
    font-weight: 900;
    z-index: 2;
}

.wheel-number:nth-child(odd) span { color: #004d00; }
.wheel-number:nth-child(even) span { color: #ffffff; }

.pointer {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-size: clamp(2rem, 5vw, 3.5rem);
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6));
}

.spin-btn {
    background: linear-gradient(to bottom, #f3d994, #cba153);
    border: 3px solid #ffeb3b;
    border-radius: 50px;
    padding: 15px 50px;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    font-weight: bold;
    color: #002200;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.spin-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(255, 235, 59, 0.6);
}

/* =========================================
   3. Modal Pop-up (Glassmorphism สุดเท่)
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 10, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.hidden {
    display: none !important;
}

/* เอฟเฟกต์กระจกใส */
.glass-effect {
    background: rgba(26, 51, 34, 0.6); /* พื้นหลังโปร่งแสง */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(203, 161, 83, 0.4);
    box-shadow: 0 20px 50px rgba(0,0,0,0.8), 0 0 20px rgba(203, 161, 83, 0.2);
    border-radius: 20px;
    width: 90%;
    max-width: 550px;
    padding: 50px 30px 40px 30px;
    position: relative;
    text-align: center;
    animation: popIn 0.5s cubic-bezier(0.17, 0.89, 0.32, 1.28);
}

.number-badge {
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #112215 0%, #001100 100%);
    border: 3px solid #cba153;
    border-radius: 15px;
    padding: 10px 40px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 20px rgba(0,0,0,0.6), inset 0 0 10px rgba(203, 161, 83, 0.3);
}

.badge-title {
    font-size: 1rem;
    color: #e2cba0;
    letter-spacing: 2px;
}

.badge-number {
    font-size: 3.5rem;
    font-weight: 900;
    color: #ffd700;
    line-height: 1;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.modal-body {
    margin: 20px 0;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#resultMeaning {
    color: #e8f5e9;
    font-size: clamp(1.1rem, 3vw, 1.3rem); /* ปรับขนาดฟอนต์กลอนให้อ่านง่ายบนมือถือ */
    line-height: 1.9;
    white-space: pre-line;
    margin: 0;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

.close-btn {
    background: linear-gradient(to right, #cba153, #e2cba0, #cba153);
    color: #001100;
    border: none;
    padding: 12px 50px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(203, 161, 83, 0.4);
}

.close-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(203, 161, 83, 0.6);
}

@keyframes popIn {
    0% { transform: scale(0.8) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* =========================================
   4. สถิติการใช้งาน (Visitor Stats) - อัปเดตใหม่
   ========================================= */
.visitor-stats {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(17, 34, 21, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(203, 161, 83, 0.4);
    border-radius: 15px;
    padding: 12px 20px;
    font-size: 0.85rem;
    color: #e2cba0;
    z-index: 100;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: transform 0.3s;
}

.stat-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.stat-item b {
    color: #ffd700;
    font-size: 1.05rem;
    margin-left: 3px;
}

.stat-divider {
    color: rgba(203, 161, 83, 0.3);
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #00ff00;
    border-radius: 50%;
    margin-right: 5px;
    box-shadow: 0 0 8px #00ff00;
    animation: pulse 1.5s infinite;
}

@media (max-width: 576px) {
    .visitor-stats {
        bottom: 15px;
        right: 50%;
        transform: translateX(50%);
        width: 90%;
        max-width: 350px;
        font-size: 0.7rem;
        padding: 10px;
    }
    .stat-row {
        gap: 6px;
    }
}