/* ==========================================================================
   Lucky Ball 1-40 - Custom Style (สไตล์ตกแต่งเกมสุดน่ารักสไตล์การ์ตูนพาสเทล)
   ========================================================================== */

/* เลือกใช้ฟอนต์หลักที่มีหัวกลมและลายมือน่ารัก (Mitr และ Itim) */
:root {
    --primary-font: 'Mitr', sans-serif;
    --cartoon-font: 'Itim', cursive;
    
    /* สีประจำธีมการ์ตูนพาสเทล */
    --color-bg-start: #dcedff;
    --color-bg-end: #f5e3f9;
    --color-pink: #ff7da0;
    --color-pink-dark: #c23e63;
    --color-yellow: #ffd54f;
    --color-yellow-dark: #f5b041;
    --color-purple: #9c27b0;
    --color-purple-light: #e8d5f2;
    --color-blue: #4fc3f7;
    --color-green: #81c784;
    --color-text-dark: #4a2d11;
}

body {
    font-family: var(--primary-font);
    background: linear-gradient(135deg, var(--color-bg-start) 0%, var(--color-bg-end) 100%);
    color: var(--color-text-dark);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 15px 25px !important;
}

.main-container > .row {
    flex: 1;
    min-height: 0;
    height: 100%;
}

/* ==========================================
   ตกแต่งเอฟเฟกต์เบื้องหลัง (Background Decorations)
   ========================================== */

/* ไฟประดับห้อยหัวหน้าจอ */
.hanging-lights {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 30px;
    display: flex;
    justify-content: space-around;
    z-index: 2;
    pointer-events: none;
}

.light-bulb {
    width: 14px;
    height: 14px;
    background-color: #ffd54f;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 10px #ffeb3b, 0 0 20px #ffeb3b;
    animation: blink-light 1.5s infinite alternate;
}

.light-bulb:nth-child(even) {
    animation-delay: 0.5s;
    background-color: #ff8a80;
    box-shadow: 0 0 10px #ff8a80, 0 0 20px #ff8a80;
}

.light-bulb:nth-child(3n) {
    animation-delay: 0.9s;
    background-color: #80d8ff;
    box-shadow: 0 0 10px #80d8ff, 0 0 20px #80d8ff;
}

.light-bulb::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 4px;
    width: 6px;
    height: 6px;
    background: #7a7a7a;
    border-radius: 1px;
}

/* แอนิเมชั่นไฟประดับกะพริบ */
@keyframes blink-light {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* เอฟเฟกต์ลูกโป่งลอย */
.balloon {
    position: absolute;
    width: 60px;
    height: 75px;
    border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
    opacity: 0.65;
    pointer-events: none;
    z-index: 1;
    animation: float-balloon 18s linear infinite;
}

.balloon1 {
    background-color: #ff8a80;
    left: 5%;
    bottom: -100px;
    animation-delay: 0s;
}

.balloon2 {
    background-color: #b3e5fc;
    left: 45%;
    bottom: -100px;
    animation-delay: 6s;
    animation-duration: 22s;
}

.balloon3 {
    background-color: #ffe082;
    right: 8%;
    bottom: -100px;
    animation-delay: 11s;
    animation-duration: 20s;
}

.balloon::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 27px;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-bottom: 8px solid currentColor;
}

.balloon::before {
    content: "";
    position: absolute;
    bottom: -28px;
    left: 29px;
    width: 2px;
    height: 22px;
    background-color: rgba(0, 0, 0, 0.15);
}

@keyframes float-balloon {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-50vh) rotate(5deg); }
    100% { transform: translateY(-110vh) rotate(-5deg); }
}

/* ==========================================
   ปุ่มปรับระดับเสียง (Sound Button)
   ========================================== */
.btn-sound {
    background: rgba(255, 255, 255, 0.85);
    border: 3px solid #ff8ba4;
    border-radius: 30px;
    color: var(--color-pink-dark);
    font-weight: bold;
    padding: 6px 16px;
    transition: all 0.2s ease-in-out;
    font-size: 0.95rem;
    box-shadow: 0 4px 6px rgba(244, 143, 177, 0.2);
    z-index: 10;
}

.btn-sound:hover {
    background: #ff8ba4;
    color: white;
    transform: scale(1.05);
}

/* ==========================================
   โลโก้เกม (Logo Style)
   ========================================== */
.logo-container {
    text-align: center;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    border: 4px solid white;
    border-radius: 30px;
    padding: 15px 10px;
    margin-bottom: 10px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.05);
}

.logo-title {
    font-family: var(--cartoon-font);
    font-size: 3.8rem;
    font-weight: 900;
    margin: 0;
    line-height: 1.1;
    display: flex;
    justify-content: center;
    gap: 4px;
}

/* จัดสไตล์ตัวอักษรทีละตัวให้เหมือนในภาพวาด */
.letter {
    display: inline-block;
    text-shadow: 
        -3px -3px 0 #fff,  
         3px -3px 0 #fff,
        -3px  3px 0 #fff,
         3px  3px 0 #fff,
         4px  4px 0px rgba(0,0,0,0.15);
    transform: rotate(calc(var(--rot, 0) * 1deg));
}

.letter.b { --rot: -8; color: #ff6f91; }
.letter.i { --rot: 5; color: #ffd15c; }
.letter.n { --rot: -4; color: #4ec3e4; }
.letter.g { --rot: 8; color: #ffa36c; }
.letter.o { --rot: -6; color: #b38df7; }

.logo-subtitle {
    font-family: var(--cartoon-font);
    font-size: 1.7rem;
    color: var(--color-pink-dark);
    margin-top: 5px;
    text-shadow: 1px 1px 0px white, -1px -1px 0px white;
    background: #ffe5ed;
    border-radius: 20px;
    padding: 3px 15px;
    display: inline-block;
}

.badge-tag {
    background: var(--color-yellow);
    border: 2px solid white;
    border-radius: 12px;
    color: var(--color-text-dark);
    font-size: 0.9rem;
    padding: 3px 10px;
    display: inline-block;
    margin-top: 8px;
    font-weight: 700;
}

/* ==========================================
   การ์ตูนสัตว์เลี้ยง (Cartoon Characters)
   ========================================== */
.bear-character-wrapper {
    position: relative;
    margin-top: 20px;
    align-self: center;
}

.bear-img {
    width: 480px; /* ขยาย 1.5 เท่า จาก 320px */
    height: auto;
    filter: drop-shadow(0 8px 12px rgba(0,0,0,0.1));
}

.chick-img {
    width: 270px; /* ขยาย 1.5 เท่า จาก 180px */
    height: auto;
    position: absolute;
    bottom: -15px;
    left: 20px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.08));
    animation: bounce-chick 4s infinite ease-in-out;
}

.rabbit-character-wrapper {
    margin-top: 20px;
}

.rabbit-img {
    width: 420px; /* ขยาย 1.5 เท่า จาก 280px */
    height: auto;
    filter: drop-shadow(0 8px 12px rgba(0,0,0,0.1));
}

/* คำพูดการ์ตูน (Speech Bubbles) */
.speech-bubble {
    position: relative;
    background: #ffffff;
    border: 3px solid #ffcbd3;
    border-radius: 24px;
    padding: 12px 24px;
    font-family: var(--cartoon-font);
    font-size: 1.8rem; /* ขยายตัวอักษรเล็กน้อยเพื่อให้อ่านง่ายคู่กับกล่องที่ใหญ่ขึ้น */
    font-weight: bold;
    color: var(--color-text-dark);
    text-align: center;
    box-shadow: 0 8px 16px rgba(0,0,0,0.06);
    max-width: 360px; /* ขยาย 1.5 เท่า จาก 240px */
    z-index: 5;
}

/* ชี้ลูกศรคำพูด */
.bear-bubble {
    position: absolute;
    top: -45px;
    left: -20px;
}
.bear-bubble::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 45px;
    border-width: 12px 12px 0;
    border-style: solid;
    border-color: #ffffff transparent;
    display: block;
    width: 0;
}
.bear-bubble::before {
    content: '';
    position: absolute;
    bottom: -16px;
    left: 43px;
    border-width: 13px 14px 0;
    border-style: solid;
    border-color: #ffcbd3 transparent;
    display: block;
    width: 0;
    z-index: -1;
}

.chick-bubble {
    position: absolute;
    bottom: 120px; /* ขยับความสูงของคำพูดขึ้นเล็กน้อยเพราะตัวการ์ตูนใหญ่ขึ้น */
    left: 45px;
}
.chick-bubble::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 35px;
    border-width: 12px 12px 0;
    border-style: solid;
    border-color: #ffffff transparent;
}
.chick-bubble::before {
    content: '';
    position: absolute;
    bottom: -16px;
    left: 33px;
    border-width: 13px 14px 0;
    border-style: solid;
    border-color: #ffcbd3 transparent;
    z-index: -1;
}

.rabbit-bubble {
    position: absolute;
    top: -75px; /* ขยับขึ้นหลีกหูกระต่ายที่ใหญ่ขึ้น */
    right: 20px;
    max-width: 270px; /* ขยาย 1.5 เท่า จาก 180px */
}
.rabbit-bubble::after {
    content: '';
    position: absolute;
    bottom: -12px;
    right: 40px;
    border-width: 12px 12px 0;
    border-style: solid;
    border-color: #ffffff transparent;
    display: block;
    width: 0;
}
.rabbit-bubble::before {
    content: '';
    position: absolute;
    bottom: -16px;
    right: 38px;
    border-width: 13px 14px 0;
    border-style: solid;
    border-color: #ffcbd3 transparent;
    display: block;
    width: 0;
    z-index: -1;
}

/* ==========================================
   โหลแก้วจับฉลาก (Glass Bowl & Hand)
   ========================================== */
.bowl-and-hand-wrapper {
    width: 100%;
    max-width: 1140px; /* ขยาย 1.5 เท่า จาก 760px */
    height: 70vh; /* ขยายความสูงให้ดูเด่นขึ้นบนจอเดสก์ท็อป */
    max-height: 870px; /* ขยาย 1.5 เท่า จาก 580px */
    min-height: 480px; /* ขยาย 1.5 เท่า จาก 320px */
    margin: 0 auto;
    position: relative;
}

/* โถแก้ว */
.glass-bowl-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.glass-bowl-rim {
    width: 40%;
    height: 6%;
    background: linear-gradient(to right, #cfd8dc, #eceff1, #cfd8dc);
    border: 3px solid #b0bec5;
    border-radius: 12px / 8px;
    position: absolute;
    top: 6%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
}

.glass-bowl-sphere {
    width: 78%;
    height: 72%;
    background: rgba(255, 255, 255, 0.15);
    border: 6px solid rgba(255, 255, 255, 0.7);
    border-radius: 50% 50% 50% 50% / 45% 45% 55% 55%;
    position: absolute;
    top: 9%;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 
        inset 0 10px 30px rgba(255, 255, 255, 0.6),
        inset 0 -10px 40px rgba(0, 0, 0, 0.05),
        0 15px 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    z-index: 3;
}

/* Canvas ของลูกปิงปอง */
#ballsCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* แสนสะท้อนกระจกโหลแก้ว */
.glass-reflection-overlay {
    position: absolute;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    width: 82%;
    height: 86%;
    border-radius: 50%;
    background: radial-gradient(circle at 10% 10%, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 50%);
    pointer-events: none;
    z-index: 5;
}

.glass-reflection-overlay::after {
    content: '';
    position: absolute;
    top: 8%;
    right: 8%;
    width: 11%;
    height: 38%;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    transform: rotate(-15deg);
}

/* ฐานตั้งโถแก้ว */
.glass-bowl-base {
    width: 58%;
    height: 15%;
    background: linear-gradient(135deg, #f48fb1 0%, #ec407a 100%);
    border: 4px solid #fff;
    border-radius: 20px 20px 50% 50% / 20px 20px 30px 30px;
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 8px 16px rgba(236, 64, 122, 0.3);
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* หลอดไฟที่ฐานสลับกะพริบ */
.base-lights {
    position: absolute;
    top: -5px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
}

.base-light {
    width: 8px;
    height: 8px;
    background-color: #ffe082;
    border-radius: 50%;
    box-shadow: 0 0 5px #ffca28;
    animation: flash-base-light 1s infinite alternate;
}

.base-light:nth-child(even) {
    animation-delay: 0.5s;
}

@keyframes flash-base-light {
    0% { transform: scale(0.8); opacity: 0.5; }
    100% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 8px #ffd54f; }
}

/* สัญลักษณ์หัวใจสีเหลืองกลางฐานโหล */
.heart-badge {
    width: 32px;
    height: 32px;
    background: var(--color-yellow);
    border: 3px solid white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.15rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* ==========================================
   อนิเมชั่นมือการ์ตูน (Cartoon Hand Animation)
   ========================================== */
.cartoon-hand-container {
    position: absolute;
    top: -65%; /* ซ่อนด้านบนจอ */
    left: 50%;
    transform: translateX(-50%);
    width: 17%;
    height: 50%;
    z-index: 6;
    pointer-events: none;
}

/* คีย์เฟรมมือจับเลื่อนลง */
.cartoon-hand-container.grabbing {
    animation: hand-grab-anim 3.5s forwards ease-in-out;
}

@keyframes hand-grab-anim {
    0% { transform: translateX(-50%) translateY(0); }
    35% { transform: translateX(-50%) translateY(115%); } /* ล้วงลงในโหล */
    45% { transform: translateX(-50%) translateY(112%) scale(1.05); }
    55% { transform: translateX(-50%) translateY(115%); }
    80% { transform: translateX(-50%) translateY(65%); } /* ดึงขึ้นระดับกลางบน */
    100% { transform: translateX(-50%) translateY(0); }
}

/* ==========================================
   แผงปุ่มควบคุมหลัก (Buttons Panel)
   ========================================== */
.btn-custom {
    font-family: var(--primary-font);
    font-weight: 700;
    border-radius: 20px;
    border: 3px solid white;
    padding: 10px 22px;
    font-size: 1.1rem;
    color: white;
    transition: all 0.2s ease;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.2);
}

.btn-custom:active {
    transform: scale(0.95);
}

/* ปุ่มเริ่มเกมใหม่ */
.btn-reset {
    background: linear-gradient(135deg, #64b5f6 0%, #1e88e5 100%);
    box-shadow: 0 6px 0 #1565c0;
}
.btn-reset:hover {
    background: linear-gradient(135deg, #42a5f5 0%, #1976d2 100%);
    color: white;
}

/* ปุ่มจับลูกบอล - สีชมพูโดดเด่นและใหญ่ที่สุด */
.btn-draw-main {
    background: linear-gradient(135deg, #ff8ba4 0%, #e05273 100%);
    box-shadow: 0 8px 0 #b93252, 0 10px 20px rgba(224, 82, 115, 0.3);
    font-size: 1.4rem;
    padding: 12px 36px;
    animation: pulse-button 2s infinite;
}
.btn-draw-main:hover {
    background: linear-gradient(135deg, #ff7190 0%, #d83d60 100%);
    color: white;
}

@keyframes pulse-button {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); box-shadow: 0 8px 0 #b93252, 0 12px 25px rgba(224, 82, 115, 0.45); }
    100% { transform: scale(1); }
}

/* ปุ่มแสดงเลขล่าสุด */
.btn-repeat {
    background: linear-gradient(135deg, #ffd54f 0%, #ffb300 100%);
    box-shadow: 0 6px 0 #ff8f00;
    color: var(--color-text-dark);
    text-shadow: none;
}
.btn-repeat:hover {
    background: linear-gradient(135deg, #ffca28 0%, #ffa000 100%);
    color: var(--color-text-dark);
}

/* ปุ่มเลขถัดไป */
.btn-next {
    background: linear-gradient(135deg, #81c784 0%, #4caf50 100%);
    box-shadow: 0 6px 0 #2e7d32;
}
.btn-next:hover {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
    color: white;
}

/* ==========================================
   ส่วนแสดงผลหมายเลขล่าสุด (Latest Number Box)
   ========================================== */
.latest-number-box {
    background: #fffae6;
    border: 5px solid var(--color-yellow);
    border-radius: 25px;
    padding: 30px 15px; /* เพิ่ม padding เล็กน้อยสำหรับลูกบอลแสดงผลที่ใหญ่ขึ้น */
    text-align: center;
    position: relative;
    box-shadow: 0 8px 16px rgba(255, 213, 79, 0.15);
    margin-top: 15px;
}

.latest-ribbon-title {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-pink);
    border: 3px solid white;
    border-radius: 15px;
    color: white;
    font-weight: bold;
    font-size: 1.15rem;
    padding: 2px 25px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    white-space: nowrap;
}

.latest-number-content {
    min-height: 120px;
}

/* ลูกบอลแสดงเลขล่าสุดสีม่วงสไตล์พรีเมียม */
.latest-ball-display {
    width: 165px; /* ขยาย 1.5 เท่า จาก 110px */
    height: 165px;
    background: linear-gradient(135deg, #ab47bc 0%, #7b1fa2 100%);
    border-radius: 50%;
    border: 4px solid white;
    box-shadow: 
        inset 0 6px 15px rgba(255, 255, 255, 0.4),
        0 8px 16px rgba(123, 31, 162, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.latest-ball-display.pop-anim {
    animation: ball-pop-effect 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.575);
}

@keyframes ball-pop-effect {
    0% { transform: scale(0.3) rotate(-45deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(15deg); }
    75% { transform: scale(0.9) rotate(-5deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.latest-ball-inner {
    width: 123px; /* ขยาย 1.5 เท่า จาก 82px */
    height: 123px;
    background: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 -4px 8px rgba(0,0,0,0.15);
}

.latest-number-text {
    font-family: var(--primary-font);
    font-size: 4.5rem; /* ขยาย 1.5 เท่า จาก 3rem */
    font-weight: 700;
    color: var(--color-text-dark);
}

/* ==========================================
   แผงประวัติหมายเลขที่ออกแล้ว (History Panel)
   ========================================== */
.history-panel {
    background: var(--color-purple-light);
    border: 4px solid #dfc3ec;
    border-radius: 25px;
    padding: 15px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.history-header {
    border-bottom: 2px dashed #cfb2db;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.history-title-text {
    font-weight: 700;
    color: var(--color-text-dark);
    font-size: 1.15rem;
}

.cute-cloud-icon {
    font-size: 1.5rem;
}

/* ตารางแสดงประวัติแบบ Grid */
.history-grid-container {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 5px;
}

/* ปรับแต่ง Scrollbar ประวัติ */
.history-grid-container::-webkit-scrollbar {
    width: 6px;
}
.history-grid-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
}
.history-grid-container::-webkit-scrollbar-thumb {
    background: #cfb2db;
    border-radius: 10px;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

/* สไตล์ลูกบอลในหน้าต่างประวัติ */
.history-ball {
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-text-dark);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
    animation: history-pop-in 0.4s ease-out forwards;
}

@keyframes history-pop-in {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ==========================================
   แอนิเมชั่นลูกบอลซูมกลางหน้าจอ (Zoom Ball Overlay)
   ========================================== */
.drawn-ball-zoom-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(2px);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.drawn-ball-zoom-overlay.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.zoom-ball-outer {
    position: relative;
    width: 270px; /* ขยาย 1.5 เท่า จาก 180px */
    height: 270px;
}

.zoom-ball {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 8px solid white;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 
        inset 0 10px 25px rgba(255, 255, 255, 0.4),
        0 15px 30px rgba(0, 0, 0, 0.25);
    background: #ff5252;
}

.zoom-ball-number {
    font-size: 7.5rem; /* ขยาย 1.5 เท่า จาก 5rem */
    font-weight: bold;
    color: var(--color-text-dark);
    background: white;
    width: 195px; /* ขยาย 1.5 เท่า จาก 130px */
    height: 195px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 -6px 12px rgba(0,0,0,0.2);
}

/* ดอกไม้ไฟดาวประเบิด */
.sparkle-particle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--color-yellow);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: sparkle-explode 1.2s ease-out forwards;
}

@keyframes sparkle-explode {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* ==========================================
   เอฟเฟกต์ Confetti เฉลิมฉลอง
   ========================================== */
.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
    display: block;
}

/* ==========================================
   แอนิเมชั่นน่ารักทั่วไป (Micro-Animations)
   ========================================== */

/* เด้งเบาๆ ต่อเนื่อง */
.animate-bounce-soft {
    animation: bounce-soft 3s infinite ease-in-out;
}
@keyframes bounce-soft {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* เด้งช้าๆ สไตล์ลอยลม */
.animate-bounce-slow {
    animation: bounce-slow 5s infinite ease-in-out;
}
@keyframes bounce-slow {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-12px) rotate(2deg); }
}

/* ลูกเจี๊ยบเด้งน่ารัก */
@keyframes bounce-chick {
    0%, 100% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-6px) scaleY(1.05) scaleX(0.95); }
    50% { transform: translateY(0) scaleY(0.95) scaleX(1.05); }
}

/* เต้นตุบๆ */
.animate-pulse {
    animation: heart-pulse 1.2s infinite ease-in-out;
}
@keyframes heart-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ==========================================
   การตอบสนองตามอุปกรณ์ต่างๆ (Responsive Design)
   ========================================== */
@media (max-width: 991.98px) {
    /* บังคับหน้าจอไม่ให้สกรอลล์ในทุกอุปกรณ์ */
    body, .main-container {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .main-container {
        padding: 8px 12px !important;
    }
    
    /* ย้ายตัวละครหมีและกระต่ายไปมุมซ้ายขวาล่างของจอแบบสติ๊กเกอร์ */
    .bear-character-wrapper {
        position: fixed !important;
        bottom: 8px;
        left: 8px;
        z-index: 10;
        margin: 0 !important;
    }
    .bear-img {
        width: 165px !important; /* ขยาย 1.5 เท่า จาก 110px */
    }
    .bear-bubble {
        top: -65px !important; /* ปรับระดับความสูงของคำพูดหมี */
        left: -5px !important;
        font-size: 1.1rem !important; /* ขยายตัวอักษรเล็กน้อย */
        padding: 4px 10px !important;
        max-width: 165px !important; /* ขยาย 1.5 เท่า จาก 110px */
    }
    .bear-bubble::after { left: 25px !important; }
    .bear-bubble::before { left: 23px !important; }

    .rabbit-character-wrapper {
        position: fixed !important;
        bottom: 8px;
        right: 8px;
        z-index: 10;
        margin: 0 !important;
    }
    .rabbit-img {
        width: 150px !important; /* ขยาย 1.5 เท่า จาก 100px */
    }
    .rabbit-bubble {
        top: -70px !important; /* ปรับระดับความสูงหลีกหู */
        right: -5px !important;
        font-size: 1.1rem !important;
        padding: 4px 10px !important;
        max-width: 180px !important; /* ขยาย 1.5 เท่า จาก 120px */
    }
    .rabbit-bubble::after { right: 20px !important; }
    .rabbit-bubble::before { right: 18px !important; }

    .chick-character-wrapper {
        display: none !important; /* ซ่อนไก่บนจอเล็กเพื่อไม่ให้เกะกะ */
    }

    /* จัดคอลัมน์ซ้ายให้เหลือแค่โลโก้ด้านบนแนวนอน */
    .character-side-left {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        margin-bottom: 2px;
        padding: 0 !important;
    }
    .logo-container {
        padding: 4px 10px !important;
        border-radius: 15px !important;
        max-width: 100% !important;
        display: flex;
        align-items: center;
        gap: 12px;
        box-shadow: none !important;
        background: transparent !important;
        border: none !important;
        margin-bottom: 0 !important;
    }
    .logo-title {
        font-size: 2.1rem !important;
    }
    .logo-subtitle {
        font-size: 1.1rem !important;
        margin-top: 0 !important;
        padding: 2px 10px !important;
    }
    .badge-tag {
        margin-top: 0 !important;
        padding: 2px 6px !important;
        font-size: 0.75rem !important;
    }

    /* ด้านขวา: จัดกล่องเลขล่าสุดและบอร์ดประวัติให้อยู่แนวนอนเคียงคู่กัน */
    .right-side {
        flex-direction: row !important;
        align-items: stretch !important;
        gap: 8px;
        margin-top: 8px;
        flex: 1.1 !important;
        min-height: 0;
    }
    .latest-number-box {
        flex: 0 0 110px !important;
        padding: 10px 5px !important;
        margin-bottom: 0 !important;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin-top: 0 !important;
    }
    .latest-ball-display {
        width: 105px !important; /* ขยาย 1.5 เท่า จาก 70px */
        height: 105px !important;
    }
    .latest-ball-inner {
        width: 81px !important; /* ขยาย 1.5 เท่า จาก 54px */
        height: 81px !important;
    }
    .latest-number-text {
        font-size: 2.7rem !important; /* ขยาย 1.5 เท่า จาก 1.8rem */
    }
    .latest-ribbon-title {
        font-size: 0.8rem !important;
        padding: 2px 10px !important;
        top: -9px !important;
    }
    .history-panel {
        flex: 1 !important;
        padding: 6px 12px !important;
        margin-bottom: 0 !important;
    }
    .history-header {
        padding-bottom: 2px !important;
        margin-bottom: 4px !important;
    }
    .history-title-text {
        font-size: 0.9rem !important;
    }
    .cute-cloud-icon {
        font-size: 1.2rem !important;
    }
    .history-grid-container {
        max-height: 85px !important;
    }
    .history-grid {
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 4px !important;
    }
    .history-ball {
        font-size: 0.85rem !important;
    }
}

@media (max-width: 575.98px) {
    .logo-title {
        font-size: 1.7rem !important;
    }

    .logo-subtitle {
        font-size: 0.9rem !important;
    }

    .bowl-and-hand-wrapper {
        max-width: 540px; /* ขยาย 1.5 เท่า จาก 360px */
        height: 55vh; /* ขยายความสูงจอเล็กเพื่อความสมดุล */
        min-height: 330px; /* ขยาย 1.5 เท่า จาก 220px */
    }

    .zoom-ball-outer {
        width: 180px; /* ขยาย 1.5 เท่า จาก 120px */
        height: 180px;
    }

    .zoom-ball-number {
        font-size: 5.25rem; /* ขยาย 1.5 เท่า จาก 3.5rem */
        width: 135px; /* ขยาย 1.5 เท่า จาก 90px */
        height: 135px;
    }

    .btn-custom {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .btn-draw-main {
        font-size: 1rem;
        padding: 8px 18px;
    }
}

/* ==========================================
   โหมดหน้าจอใหญ่ (Fullscreen Mode Styles)
   ========================================== */
/* บังคับยกเลิกสีดำของเบราว์เซอร์เมื่ออยู่ในโหมดเต็มจอ */
:fullscreen, 
html:fullscreen, 
body:fullscreen,
.main-container:fullscreen {
    background-color: #dcedff !important; /* ใช้สีฟ้าพาสเทลสดใสป้องกันสีดำ */
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ล้างสีดำของฉากหลัง Backdrop ที่เบราว์เซอร์สร้างขึ้น */
::backdrop {
    background-color: #dcedff !important;
}

body.fullscreen-active {
    background-color: #dcedff !important;
    color: var(--color-text-dark); /* ใช้สีอักษรเข้มดั้งเดิม */
}

/* ใช้ชั้นหลอกด้านหลังในการแสดงผลไล่เฉดสีพาสเทลหวานๆ สดใสในโหมดเต็มจอ */
body.fullscreen-active::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #dcedff 0%, #f5e3f9 100%) !important;
    z-index: -2;
    pointer-events: none;
}

body.fullscreen-active .main-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 25px 40px !important;
}

/* เพิ่มขนาดองค์ประกอบในจอใหญ่ (Fullscreen) */
@media (min-width: 992px) {
    body.fullscreen-active .bowl-and-hand-wrapper {
        max-width: 1320px; /* ขยาย 1.5 เท่า จาก 880px */
        height: 80vh; /* ปรับระดับความสูงให้สมดุลสวยงามและไม่ล้นจอ */
        max-height: 1050px; /* ขยาย 1.5 เท่า จาก 700px */
    }

    body.fullscreen-active .bear-img {
        width: 570px; /* ขยาย 1.5 เท่า จาก 380px */
    }

    body.fullscreen-active .rabbit-img {
        width: 510px; /* ขยาย 1.5 เท่า จาก 340px */
    }

    body.fullscreen-active .chick-img {
        width: 300px; /* ขยาย 1.5 เท่า จาก 200px */
    }

    body.fullscreen-active .latest-number-box {
        padding: 40px 20px;
    }

    body.fullscreen-active .latest-ball-display {
        width: 225px; /* ขยาย 1.5 เท่า จาก 150px */
        height: 225px;
    }

    body.fullscreen-active .latest-ball-inner {
        width: 165px; /* ขยาย 1.5 เท่า จาก 110px */
        height: 165px;
    }

    body.fullscreen-active .latest-number-text {
        font-size: 6.3rem; /* ขยาย 1.5 เท่า จาก 4.2rem */
    }
}

/* ==========================================
   ปุ่ม BINGO และเอฟเฟกต์เฉลิมฉลอง (Bingo Styles & Celebration)
   ========================================== */

/* ปุ่มบิงโกสีทองอลังการ พรีเมียม และเรืองแสง */
.btn-bingo {
    background: linear-gradient(135deg, #ffe082 0%, #ff8f00 100%);
    box-shadow: 0 6px 0 #e65100, 0 8px 20px rgba(255, 143, 0, 0.4);
    border-color: #ffffff;
    font-size: 1.2rem;
    padding: 10px 26px;
    animation: pulse-bingo-btn 1.5s infinite;
}

.btn-bingo:hover {
    background: linear-gradient(135deg, #fff59d 0%, #ff6f00 100%);
    color: var(--color-text-dark);
}

@keyframes pulse-bingo-btn {
    0% { transform: scale(1); }
    50% { transform: scale(1.06); box-shadow: 0 6px 0 #e65100, 0 12px 25px rgba(255, 143, 0, 0.55); }
    100% { transform: scale(1); }
}

/* หน้าจอเฉลิมฉลองบิงโกแบบเต็มจอ */
.bingo-celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 235, 238, 0.4); /* ฉากหลังอมชมพูหวานโปร่งแสง */
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bingo-celebration-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.bingo-card-celebration {
    background: #fffae6;
    border: 8px solid var(--color-yellow);
    border-radius: 40px;
    padding: 40px 60px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(255, 143, 0, 0.2), inset 0 5px 15px rgba(255,255,255,0.6);
    transform: scale(0.5);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.35);
    max-width: 90%;
    width: 480px;
}

.bingo-celebration-overlay.active .bingo-card-celebration {
    transform: scale(1);
}

/* หัวข้อบิงโกอักษรเด้งดึ๋ง */
.bingo-header-text {
    font-family: var(--cartoon-font);
    font-size: 5.5rem;
    font-weight: 900;
    color: #ff4081;
    margin: 0 0 10px;
    text-shadow: 
        -4px -4px 0 #fff,  
         4px -4px 0 #fff,
        -4px  4px 0 #fff,
         4px  4px 0 #fff,
         6px  6px 0px rgba(0,0,0,0.1);
    animation: bounce-bingo-text 1.5s infinite ease-in-out;
}

@keyframes bounce-bingo-text {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-15px) scale(1.05); }
}

.bingo-sub-text {
    font-family: var(--primary-font);
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--color-text-dark);
    margin-bottom: 25px;
}

/* วงล้อมดาวหมุน */
.bingo-stars-ring {
    font-size: 2.2rem;
    letter-spacing: 12px;
    display: inline-block;
    animation: rotate-bingo-stars 6s infinite linear;
}

@keyframes rotate-bingo-stars {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* อนิเมชั่นสัตว์เฉลิมฉลองบิงโก */
.character-img.celebrating,
.chick-img.celebrating {
    animation: character-celebrate-spin 1.5s infinite ease-in-out !important;
}

@keyframes character-celebrate-spin {
    0%, 100% { transform: translateY(0) scale(1) rotate(0deg); }
    25% { transform: translateY(-25px) scaleY(1.15) scaleX(0.85) rotate(8deg); }
    50% { transform: translateY(0) scaleY(0.9) scaleX(1.1) rotate(0deg); }
    75% { transform: translateY(-15px) scaleY(1.05) scaleX(0.95) rotate(-8deg); }
}

/* ลูกโป่งลอยประดับตอนบิงโก */
.floating-celebration-balloon {
    position: fixed;
    width: 60px;
    height: 75px;
    border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
    pointer-events: none;
    z-index: 1001;
    opacity: 0.85;
    animation: float-up-balloon 6s linear forwards;
}

.floating-celebration-balloon::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 27px;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-bottom: 8px solid currentColor;
}

.floating-celebration-balloon::before {
    content: "";
    position: absolute;
    bottom: -28px;
    left: 29px;
    width: 2px;
    height: 22px;
    background-color: rgba(0, 0, 0, 0.15);
}

@keyframes float-up-balloon {
    0% { transform: translateY(115vh) scale(0.6) rotate(0deg); }
    30% { transform: translateX(20px) translateY(80vh) scale(1) rotate(5deg); }
    60% { transform: translateX(-20px) translateY(40vh) scale(1.1) rotate(-5deg); }
    100% { transform: translateY(-20vh) scale(0.8) rotate(5deg); opacity: 0; }
}

/* ==========================================================================
   ระบบควบคุมความสูงแบบยืดหยุ่น (Responsive Height Control)
   ป้องกันไม่ให้หน้าจอล้นในทุกระดับความกว้าง/ความสูงของเดสก์ท็อป
   ========================================================================== */
@media (min-width: 992px) and (max-height: 850px) {
    .bowl-and-hand-wrapper {
        max-width: 850px;
        height: 60vh;
        max-height: 520px;
        min-height: 380px;
    }
    .bear-img {
        width: 340px;
    }
    .rabbit-img {
        width: 300px;
    }
    .chick-img {
        width: 190px;
    }
    .chick-bubble {
        bottom: 90px;
        left: 35px;
    }
    .rabbit-bubble {
        top: -60px;
        max-width: 200px;
    }
    .latest-ball-display {
        width: 120px;
        height: 120px;
    }
    .latest-ball-inner {
        width: 90px;
        height: 90px;
    }
    .latest-number-text {
        font-size: 3.3rem;
    }
}

@media (min-width: 992px) and (max-height: 700px) {
    .bowl-and-hand-wrapper {
        max-width: 680px;
        height: 55vh;
        max-height: 400px;
        min-height: 300px;
    }
    .bear-img {
        width: 260px;
    }
    .rabbit-img {
        width: 230px;
    }
    .chick-img {
        width: 150px;
    }
    .chick-bubble {
        bottom: 75px;
        left: 25px;
    }
    .rabbit-bubble {
        top: -50px;
        max-width: 160px;
    }
    .latest-ball-display {
        width: 95px;
        height: 95px;
    }
    .latest-ball-inner {
        width: 72px;
        height: 72px;
    }
    .latest-number-text {
        font-size: 2.6rem;
    }
}


