/* =============================================================
   BATLINGO
   Responsive Solo Battle
   PC / Tablet / Mobile
   ============================================================= */


/* -------------------------------------------------------------
   RESET
   ------------------------------------------------------------- */

* {
    box-sizing: border-box;

    /* Tắt highlight xanh khi tap trên mobile */
    -webkit-tap-highlight-color: transparent;
}


html,
body {
    margin: 0;
    padding: 0;

    width: 100%;
    min-height: 100%;
}


body {
    min-height: 100dvh;

    font-family:
        Arial,
        "Noto Sans JP",
        sans-serif;

    background: #111827;
    color: white;

    display: flex;
    justify-content: center;
    align-items: center;

    /* Không cho kéo ngang */
    overflow-x: hidden;
}


/* -------------------------------------------------------------
   GAME CONTAINER
   ------------------------------------------------------------- */

.game-container {
    width: min(94%, 700px);

    padding: clamp(18px, 4vw, 35px);

    background: #1f2937;

    border-radius: 18px;

    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.4);
}


/* -------------------------------------------------------------
   HEADER
   ------------------------------------------------------------- */

.game-header {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 20px;

    margin-bottom: clamp(20px, 4vh, 35px);
}


.life {
    font-size: clamp(20px, 4vw, 28px);

    white-space: nowrap;
}


.score-box {
    text-align: right;
}


.score-label {
    font-size: 12px;

    color: #9ca3af;
}


.score {
    font-size: clamp(22px, 5vw, 30px);

    font-weight: bold;
}


.best-score {
    margin-top: 3px;

    font-size: 13px;

    color: #9ca3af;
}


/* -------------------------------------------------------------
   QUESTION
   ------------------------------------------------------------- */

.question-number {
    text-align: center;

    font-size: clamp(13px, 2vw, 15px);

    color: #9ca3af;
}


.question {
    min-height: 80px;

    margin-top: 15px;

    display: flex;
    justify-content: center;
    align-items: center;

    text-align: center;

    /*
       clamp:
       mobile khoảng 40px
       tablet/PC tăng dần
       tối đa 58px
    */
    font-size: clamp(40px, 8vw, 58px);

    font-weight: bold;

    line-height: 1.2;
}


/* -------------------------------------------------------------
   READING
   ------------------------------------------------------------- */

.reading {
    min-height: 28px;

    margin-bottom: 15px;

    text-align: center;

    font-size: clamp(17px, 3vw, 22px);

    color: #fbbf24;

    /* Bình thường không nhìn thấy */
    visibility: hidden;
}


/*
   Khi trả lời đúng JavaScript
   sẽ thêm class này.
*/
.reading.show {
    visibility: visible;
}


/* -------------------------------------------------------------
   TIMER
   ------------------------------------------------------------- */

.timer-text {
    margin-bottom: 8px;

    text-align: center;

    font-size: 14px;
}


.timer-background {
    width: 100%;
    height: 10px;

    margin-bottom: clamp(20px, 4vh, 30px);

    background: #374151;

    border-radius: 10px;

    overflow: hidden;
}


.timer-bar {
    width: 100%;
    height: 100%;

    background: #22c55e;

    transition: width 0.1s linear;
}


/* -------------------------------------------------------------
   ANSWERS
   ------------------------------------------------------------- */

.answers {
    display: grid;

    /* PC + Tablet + phần lớn smartphone: 2 x 2 */
    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: clamp(10px, 2vw, 14px);
}


.answer-button {
    width: 100%;

    /*
       Nút đủ lớn để bấm bằng ngón tay.
    */
    min-height: 70px;

    padding: 14px;

    border: 2px solid transparent;
    border-radius: 12px;

    background: #374151;
    color: white;

    font-family: inherit;

    font-size: clamp(15px, 2.5vw, 18px);

    cursor: pointer;

    user-select: none;

    touch-action: manipulation;

    transition:
        background 0.15s,
        transform 0.15s,
        border-color 0.15s;
}


/*
   Hover chỉ dùng cho thiết bị
   thực sự có chuột.
*/
@media (hover: hover) {

    .answer-button:hover {
        background: #4b5563;

        transform: translateY(-2px);
    }
}


.answer-button:active {
    transform: scale(0.98);
}


/* Đáp án đúng */
.answer-button.correct {
    background: #166534;

    border-color: #22c55e;
}


/* Đáp án sai */
.answer-button.wrong {
    background: #991b1b;

    border-color: #ef4444;
}


/*
   Khi đã trả lời,
   khóa toàn bộ button.
*/
.answer-button:disabled {
    cursor: default;

    opacity: 1;
}


/* -------------------------------------------------------------
   COMBO
   ------------------------------------------------------------- */

.combo {
    margin-top: clamp(20px, 4vh, 30px);

    text-align: center;

    font-size: clamp(18px, 3vw, 22px);

    font-weight: bold;
}


/* -------------------------------------------------------------
   GAME OVER
   ------------------------------------------------------------- */

.game-over {
    display: none;

    text-align: center;
}


.game-over h1 {
    margin-top: 0;

    font-size: clamp(34px, 7vw, 48px);
}


.result-label {
    color: #9ca3af;

    font-size: 14px;
}


.final-score {
    margin: 10px 0 25px;

    font-size: clamp(36px, 8vw, 50px);

    font-weight: bold;
}


.result-row {
    margin: 12px 0;

    font-size: clamp(16px, 3vw, 19px);
}


.retry-button {
    width: min(100%, 300px);

    min-height: 55px;

    margin-top: 30px;

    padding: 14px 30px;

    border: none;
    border-radius: 12px;

    font-size: 18px;
    font-weight: bold;

    cursor: pointer;

    touch-action: manipulation;
}


/* =============================================================
   TABLET
   ============================================================= */

@media (max-width: 900px) {

    .game-container {
        width: min(94%, 650px);
    }

}


/* =============================================================
   MOBILE
   ============================================================= */

@media (max-width: 600px) {

    body {
        /*
           Trên mobile game chiếm toàn màn hình.
        */
        align-items: stretch;
    }


    .game-container {
        width: 100%;

        min-height: 100dvh;

        border-radius: 0;

        box-shadow: none;

        /*
           safe-area hỗ trợ iPhone tai thỏ.
        */
        padding:
            max(18px, env(safe-area-inset-top))
            16px
            max(18px, env(safe-area-inset-bottom));
    }


    .game-header {
        margin-bottom: 20px;
    }


    .question {
        min-height: 70px;

        margin-top: 10px;
    }


    .answer-button {
        min-height: 68px;
    }

}


/* =============================================================
   VERY SMALL MOBILE
   ============================================================= */

/*
   Nếu màn hình quá nhỏ,
   chuyển đáp án thành 1 cột.

   Các smartphone bình thường vẫn 2 x 2.
*/
@media (max-width: 360px) {

    .answers {
        grid-template-columns: 1fr;
    }


    .answer-button {
        min-height: 52px;

        padding: 10px;
    }

}