body,
html {
    margin: 0 !important;
    padding: 0 !important;
    height: 100%;
    overflow: hidden;
    color: #000000;
}

/* คลุมถึงพวก input, button, select และ textarea ด้วย */
*, *::before, *::after, input, button, select, textarea {
    font-family: 'Bai Jamjuree', sans-serif !important;
}

#game-heatready-quiz {
    --blue-correct: #5D9CEC;
    --red-wrong: #ED5565;
    --black: #333;
    --orange: #F37021;
    --green: #2ECC71;
    --light-pink: #F8D7DA;
    font-family: 'Bai Jamjuree', sans-serif !important;
    /* ล็อคแค่ในขอบเขตเกม */
}

#game-heatready * {
    box-sizing: border-box;
}

.game-wrapper {
    width: 100vw;
    height: 100vh;
    background: url('../images/heatgame-quiz-bg-full.jpg') no-repeat center center;
    background-size: cover;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(14px, 2.5vw, 24px);
    position: relative;
    margin: 0 auto;
    overflow: hidden;
    box-sizing: border-box;
    padding-bottom: 50px;
}

.game-wrapper h2 {
    font-size: 1.5 em;
    /* จะใหญ่เป็น 1.5 เท่าของ wrapper เสมอ */
}

.game-entry-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* ใช้สีพื้นหลังที่เข้ากับธีมเกม หรือใส่รูป BG สวยๆ */
    background: linear-gradient(135deg, var(--blue-correct), #003366);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    /* ให้มั่นใจว่าทับทุกอย่าง */
    color: white;
    text-align: center;
    backdrop-filter: blur(5px);
    /* แถม: ทำพื้นหลังเบลอๆ ให้ดูหรูขึ้น */
}

.entry-content {
    padding: 20px;
}

.entry-content h1 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);

}

.game-wrapper .score-text {
    font-size: 1.2 em;
}

/* =============================================================== */
/*======================= Start IntroSection ====================*/
/* =============================================================== */

#screen-quiz-intro {
    height: 100vh;
    position: relative;
    /* เต็มความสูงหน้าจอ */
    display: flex;
    flex-direction: column;
    /* เรียงของจากบนลงล่าง */
    justify-content: space-between;
    /* กระจายของให้ห่างกันที่สุด (บน-ล่าง) */
    align-items: center;
    /* จัดกึ่งกลางแนวนอนทุกอย่าง */
    padding: 50px 0px;
    /* เว้นระยะขอบบนและล่างกันหลุดจอ */
    box-sizing: border-box;
    /* ให้ padding ไม่เพิ่มความสูง div */
    max-width: 800px;
}

.intro-game-text {
    width: 100%;
    max-width: 600px;
    margin-top: 100px;
    z-index: 10;
    animation: heatEffect 2.5s ease-in-out infinite;
}

@keyframes heatEffect {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.5));
    }

    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 15px rgba(255, 69, 0, 0.8));
    }

    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.5));
    }
}


#screen-quiz-intro .heat-ready-th-logo {
    width: 50%;
    z-index: 10;
}

#screen-quiz-intro .img-btn-action {
    max-width: 160px;
    z-index: 10;
}

/* สร้างลูกไฟ */
.fireball {
    width: 150px;
    /* ปรับขนาดตามต้องการ */
    position: absolute;
    /* ลอยตัวอิสระ */
    top: 80%;
    /* วางไว้ช่วงกลางๆ จอ */
    z-index: 1;
    /* ให้อยู่ใต้ปุ่ม Play และโลโก้ (ถ้าไม่อยากให้บัง) */

    /* ใช้ 'steps' หรือการเขียน keyframes แบบกระตุกเพื่อให้ดูเหมือนกระโดด */
    animation: fireballCuteMove 12s ease-in-out infinite;
    pointer-events: none;
}

@keyframes fireballCuteMove {

    /* --- อยู่ฝั่งขวา: หันซ้าย (หน้าปกติ) --- */
    0%,
    100% {
        left: 95%;
        /* ขยับไปทางขวาให้สุดขึ้น */
        transform: translateX(-50%) scaleX(1) translateY(0);
    }

    /* ระหว่างวิ่งมาซ้าย (กระโดดดึ๋งๆ) */
    10%,
    30% {
        transform: translateX(-50%) scaleX(1) translateY(-20px);
    }

    20%,
    40% {
        transform: translateX(-50%) scaleX(1) translateY(0);
    }

    /* --- ถึงฝั่งซ้าย: ก่อนจะกลับตัว --- */
    45% {
        left: 5%;
        /* ขยับมาชิดซ้ายให้เท่ากับฝั่งขวา */
        transform: translateX(-50%) scaleX(1) translateY(0);
    }

    /* --- กลับตัวที่ฝั่งซ้าย: พลิกหน้าไปทางขวา --- */
    50% {
        left: 5%;
        transform: translateX(-50%) scaleX(-1) translateY(0);
    }

    /* ระหว่างวิ่งกลับไปขวา (กระโดดดึ๋งๆ) */
    60%,
    80% {
        transform: translateX(-50%) scaleX(-1) translateY(-20px);
    }

    70%,
    90% {
        transform: translateX(-50%) scaleX(-1) translateY(0);
    }

    /* --- กลับมาถึงฝั่งขวา: ก่อนจะพลิกหน้ากลับ --- */
    95% {
        left: 95%;
        transform: translateX(-50%) scaleX(-1) translateY(0);
    }
}


@media (max-width: 600px) {
    .screen-intro {
        width: 100%;
        padding: 50px 10px;
    }

    .screen-intro .img-btn-action {
        max-width: 150px;
    }

    #screen-quiz-intro .heat-ready-th-logo {
        width: 50%;
    }
}


/*----------------- End Intro Section -------------------*/


/* =============================================================== */
/*======================= Start Rule 1 & 2 Section ====================*/
/* =============================================================== */

.rule-bubble {
    background: #FCE4EC;
    border-radius: 30px;
    padding: 40px;
    margin: 10px 0;
    position: relative;
    line-height: 1.5;
    font-size: 0.9em;
    text-align: center;
}

#screen-rules1,
#screen-rules2 {
    position: relative;
    /* กลางแนวนอน */
    align-items: center;
    /* กลางแนวตั้ง */
    width: 100%;
    /* ให้กว้างเต็มพื้นที่ของกรอบเกม (500px) */
    max-width: 800px;
    /* ล็อกไว้ไม่ให้เกินกรอบเกมที่เราตั้งไว้ */
    height: 100vh;
    /* สูงเท่าหน้าจอเพื่อให้พื้นหลังเต็มจอ */
    margin: 0 auto;
    /* จัดกรอบเกมให้อยู่กลางหน้าจอคอม */
    box-sizing: border-box;

}

#screen-rules1 .rule-img-text,
#screen-rules2 .rule-img-text {
    position: absolute;
    z-index: 15;
    max-width: 535px;
    right: -215px;
    top: -150px;
    animation: heatEffect 2.5s ease-in-out infinite;
    /* ใช้ animetion เดียวกับ intro */
}

#screen-rules1 .img-btn-action,
#screen-rules2 .img-btn-action {
    position: absolute;
    z-index: 12;
    right: -215px;
    bottom: -50px;
    max-width: 150px;
    min-width: 80px;
}

#screen-rules1 .heat-ready-th-logo,
#screen-rules2 .heat-ready-th-logo {
    position: absolute;
    z-index: 10;
    width: 75%;
    top: 85px;
    right: -235px;
}

#screen-rules1 .rule-bubble,
#screen-rules2 .rule-bubble {
    width: 50%;
    min-height: 100px;
    border-radius: 80px;
    padding: 20px 80px;
}

#screen-rules1 .fireball,
#screen-rules2 .fireball {
    z-index: 11;
}

.rule2-warp {
    display: flex;
    flex-direction: column;
    align-content: center;
    gap: 15px;
}

.rule-ans-warp {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    font-size: 1.8em;
}

.rule-correct,
.rule-wrong {
    width: 1.5em;
    height: 1.5em;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rule-correct {
    background: var(--blue-correct);

}

.rule-wrong {
    background: var(--red-wrong);
}


@media (max-width: 600px) {

    #screen-rules1,
    #screen-rules2 {
        padding: 10px;
        height: 100vh;
        align-items: start;
    }

    #screen-rules1 .rule-bubble,
    #screen-rules2 .rule-bubble {
        padding: 10px 20px;
        /* ปรับ Padding ให้เหมาะกับมือถือ */
        width: 90%;
        position: initial;
        margin-top: 70%;
        font-size: 1.2em;
    }

    /* วิธีจัดให้รูปข้อความ "กติกา" ลอยกลางกล่อง */
    #screen-rules1 .rule-img-text,
    #screen-rules2 .rule-img-text {
        position: absolute;
        top: 15%;
        right: auto;
        left: 50%;
        width: 100%;
        margin-left: -50%;
    }

    .rule-ans-warp {
        font-size: 1.6em;
    }

    /* วิธีจัดให้ "ปุ่ม Play" ลอยกลางกล่องด้านล่าง */
    #screen-rules1 .img-btn-action,
    #screen-rules2 .img-btn-action {
        width: 35%;
        /* ขนาดปุ่มในมือถือ */
        bottom: 30%;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        /* ล้างค่าขวาเดิม */

    }

    /* โลโก้ส้ม ถ้าอยากให้ลอยเป็นพื้นหลังตรงกลาง */
    #screen-rules1 .heat-ready-th-logo,
    #screen-rules2 .heat-ready-th-logo {
        top: auto;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 50%;
        right: auto;
        bottom: 0;
    }
}

@media screen and (min-width: 601px) and (max-width: 869px) {

    #screen-rules1,
    #screen-rules2 {
        justify-content: center;
    }


    #screen-rules1 .rule-bubble,
    #screen-rules2 .rule-bubble {
        font-size: 1.1em;
    }

    #screen-rules1 .rule-img-text,
    #screen-rules2 .rule-img-text {
        right: 50%;
        margin-right: -50%;
        top: -200px;
    }

    #screen-rules1 .img-btn-action,
    #screen-rules2 .img-btn-action {
        right: 50%;
        margin-right: -50%;
        bottom: -170px;
    }

    #screen-rules1 .heat-ready-th-logo,
    #screen-rules2 .heat-ready-th-logo {
        width: 50%;
        right: 50%;
        margin-right: -25%;
        top: auto;
        bottom: -200px;
    }
}

/*----------------- End Rule 1 Section -------------------*/


/* =============================================================== */
/*======================= Start Quiz Section ====================*/
/* =============================================================== */

#screen-quiz {
    height: 100vh;
    width: 100%;
    max-width: 800px;
    text-align: center;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.card {
    height: auto;
    background-color: var(--light-pink);
    border-radius: 40px;
    padding: 40px 40px 60px 40px;
    width: 100%;
    max-width: 800px;
    box-shadow: 10px 10px 5px rgba(243, 112, 33, 0.5);
    position: relative;
    box-sizing: border-box;
}

#q-num {
    width: 1.5em;
    height: 1.5em;
    border-radius: 50%;
    font-size: 1.8em;
    color: black;
    border: 3px solid #000000;
    position: absolute;
    align-items: center;
    justify-content: center;
    background: #F37021;
    top: -30px;
    left: -30px;
    z-index: 10;
}

.quiz-num-tag {
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--orange);
    margin-top: 15px;
}

.quiz-text {
    margin: 15px 0;
    font-size: 2rem;
    min-height: 50px;
}

/* --- Timer Bar Only (No Numbers) --- */
.timer-container {
    position: absolute;
    top: 0;
    left: 5%;
    width: 90%;
}

.timer-line {
    height: 12px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

#timer-bar {
    width: 100%;
    height: 100%;
    background: var(--green);
    transition: width 0.1s linear, background-color 0.3s ease;
}


.choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.btn-choice {
    background: #FFF;
    border: none;
    border-radius: 50px;
    padding: 12px 5px;
    font-size: 1.3rem;
    font-weight: 900;
    cursor: pointer;
}

.btn-choice:active {
    background-color: var(--orange);
    color: #ffffff;

    /* ทริค: ถ้าอยากให้ดูเหมือนมีแสงวาบออกมานิดๆ ตอนกด */
    box-shadow: 0 0 10px rgba(243, 112, 33, 0.5);
}

#screen-quiz .heat-ready-th-logo {
    position: absolute;
    width: 30%;
    left: 50%;
    transform: translateX(-50%);
    bottom: -50%;
}

@media (max-width: 600px) {
    #q-num {
        left: 50%;
        transform: translateX(-50%);
        top: -60px;
        font-size: 2.2em;
        box-shadow: 0 0 5px 10px rgba(255, 255, 255, 0.5);
    }

    .card {
        border-radius: 20px;
        padding: 20px 20px 40px 20px;
    }

    .choice-grid {
        grid-template-columns: 1fr;
    }

    #screen-quiz .heat-ready-th-logo {
        bottom: -80px;
    }
}

@media screen and (min-width: 601px) and (max-width: 869px) {
    #screen-quiz {
        padding-left: 50px;
        padding-right: 50px;
    }
}

/*----------------- End Quiz Section -------------------*/

/* =============================================================== */
/*======================= Start Result Section ====================*/
/* =============================================================== */

#screen-result {
    height: 100vh;
    width: 100%;
    max-width: 800px;
    text-align: center;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#result-icon-tf {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 4px solid #333;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 35px;
    color: #fff;
    font-weight: 900;
    box-shadow: 4px 4px 0 #333;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: -35%;
}

#result-desc {
    font-size: 1.2em;
    font-weight: 700;
    line-height: 1.3;
}

#screen-result .heat-ready-th-logo {
    position: absolute;
    width: 30%;
    left: 50%;
    transform: translateX(-50%);
    bottom: -75%;
}

.bt-next-screen {
    width: 10%;
    position: absolute;
    right: 10%;
    bottom: 10%;
    z-index: 15;
}

.bb-text {
    width: 100%;
    position: relative;
    left: -25%;
    bottom: -15%;
}

.bb-text span {
    position: absolute;
    width: 100%;
    display: flex;
    justify-content: center;
    top: 25%;
}

.bb-text img {
    width: 100%;
}

.bt-next-screen .img-btn-action {
    max-width: 150px;
}

@media (max-width: 600px) {
    #result-icon-tf {
        top: -75%;
    }

    .bt-next-screen {
        width: 25%;
        bottom: 20%;
        right: 50%;
        transform: translateX(50%);
    }

    #screen-result .card {
        top: -15%;
    }

    #result-desc {
        font-size: 1.5em;
    }
}

@media screen and (min-width: 601px) and (max-width: 869px) {
    #screen-result {
        padding-left: 50px;
        padding-right: 50px;
    }

    #screen-result .card {
        top: -10%;
    }

    .bt-next-screen {
        width: 20%;
        bottom: 15%;
    }
}

/*----------------- End Result Section -------------------*/

/* =============================================================== */
/*======================= Start Summary Section ====================*/
/* =============================================================== */

#screen-summary {
    text-align: center;
}

#total-score {
    font-size: 1.5em;
    font-weight: 900;
    color: var(--orange);
    margin: 5px 0;
}

#total-time-display {
    font-weight: 700;
    color: #666;
    margin-bottom: 10px;
}

#player-name {
    width: 80%;
    padding: 12px;
    border-radius: 15px;
    border: 3px solid var(--black);
    margin: 30px 0;
    text-align: center;
    font-size: 1em;
}

#btn-save {
    /* 1. ขนาดและการจัดวาง */
    width: 100%;
    max-width: 280px;
    padding: 15px 30px;
    margin: 0 auto;

    /* 2. สไตล์ปุ่ม */
    background-color: var(--orange);
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    border: 3px solid #000000;
    /* ขอบดำหนาๆ ให้ดูเป็นสไตล์เกม */
    border-radius: 50px;
    /* ทรงมนยาว (Pill Shape) */

    /* 3. มิติและเงา */
    box-shadow: 0 4px 0 #333;
    /* เงาด้านล่างแบบ Flat Design เหมือนปุ่มกดจริง */
    transition: all 0.2s ease;
    /* ให้ตอนกดดูนุ่มนวล */

    /* 4. จัดการ Text */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* เอฟเฟกต์ตอนเอาเมาส์ไปวาง (Hover) */
#btn-save:hover {
    background-color: #ff8533;
    /* ส้มสว่างขึ้นนิดนึง */
    transform: translateY(-2px);
    /* ลอยขึ้นนิดหน่อย */
    box-shadow: 0 6px 0 #333;
}

/* เอฟเฟกต์ตอนกด (Active) */
#btn-save:active {
    transform: translateY(4px);
    /* ปุ่มยุบลงไปเหมือนโดนกดจริง */
    box-shadow: 0 0 0 #333;
    /* เงาหายไปตอนกด */
}

@media (max-width: 600px) {
    #screen-summary {
        width: 100%;
    }

    #screen-summary h1 {
        font-size: 3em;
    }

    #total-score {
        font-size: 2em;
    }

    #total-time-display {
        font-size: 1.8em;
    }

    #player-name {
        font-size: 1.2em;
    }

}


/*----------------- End Summary Section -------------------*/

/* =============================================================== */
/*======================= Start Leaderboard Section ====================*/
/* =============================================================== */

#screen-leaderboard {
    height: 100vh;
    width: 100%;
    max-width: 800px;
    text-align: center;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#screen-leaderboard .card {
    z-index: 2;
}

.rank-table {
    width: 100%;
    margin: 15px 0;

    border-collapse: collapse;
    font-size: 0.8em;
    background: white;
    border-radius: 15px;
    overflow: hidden;

}

.rank-table th {
    background: var(--orange);
    color: white;
    padding: 8px;
}

.rank-table td {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

@media screen and (min-width: 601px) and (max-width: 869px) {
    #screen-leaderboard {
        padding-left: 50px;
        padding-right: 50px;
    }
}

/*----------------- End Leaderboard Section -------------------*/

.img-btn-action {
    cursor: pointer;
    width: calc(50% + 50px);
    max-width: 100px;
    /* ปรับขนาดความกว้างตามความเหมาะสมของหน้าจอ */
    height: auto;
    display: block;
    margin: 10px auto;
    transition: transform 0.1s;
}

.img-btn-action:active {
    transform: scale(0.95);
    /* กดแล้วให้ยุบตัวนิดนึงเหมือนปุ่มจริง */
}


.audio-control-group {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: row;
    /* เรียงต่อกันแนวนอน */
    gap: 15px;
    /* ห่างกันนิดนึงจะได้ไม่จิ้มพลาด */
    z-index: 10001;
}

.mute-icon {
    width: 45px;
    height: auto;
    /* ใส่พื้นหลังจางๆ วงกลมให้ดูเป็นระเบียบ (ถ้าชอบ) */
    background: rgba(255, 255, 255, 0.2);
    padding: 5px;
    border-radius: 50%;
}

.mute-button-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}


/* ปรับขนาดให้เล็กลงหน่อยเมื่ออยู่ในมือถือ */
@media (max-width: 600px) {
    .mute-icon {
        width: 40px;
        top: 15px;
        right: 15px;
    }

}
