@font-face {
    font-family: "Kanit";
    src: url("../assets/font/Kanit-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Kanit";
    src: url("../assets/font/Kanit-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: "Kanit", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* เปลือกเกม กินเต็มจอ */
#gameWrapper {
    position: relative;
    /* ล็อคติดจอ */
    /* inset: 0; */
    /* top:0; right:0; bottom:0; left:0 */
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0f0f13;
    /* พื้นหลังนอกเกม */
}

/* ตัว canvas เกม */
#runarea {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.25);
    background: #f0f8ff;
}

/* ---- portrait: จับกว้างเต็มจอ ---- */
@media (orientation: portrait) {
    #runarea {
        width: 100vw;
        max-width: 100vw;
        height: auto;
        /* สูงตามสัดส่วน */
        max-height: 100dvh;
        /* กันเกินจอ */
    }

         #soundToggle {
             width: 10px !important;
             height: 10px !important;
             top: 8px !important;
             right: 10px !important;
         }
    
         #copyright {
             font-size: 5px !important;
             bottom: 0px !important;
         }
        #nightControls .night-btn {
        width: 46px !important;        
        height: 46px !important;
    }

    #nightControls {
        right: 10px !important;
        row-gap: 8px !important;
        column-gap: 8px !important;
    }

.mode-timer {
    top: 6px !important;
    padding: 3px 8px !important;
}

.mode-timer-icon {
    width: 10px !important;
    height: 10px !important;
}

.mode-timer-text {
    font-size: 12px !important;
    min-width: 12px !important;
}

.mode-timer-label {
    font-size: 12px !important;
}

}


/* ---- landscape: จับสูงเต็มจอ ---- */
@media (orientation: landscape) {
    #runarea {
        height: 100dvh;
        max-height: 100dvh;
        width: auto;
        /* กว้างตามสัดส่วน */
        max-width: 100vw;
    }
}
#canvasBox {
    position: relative;
    /*display: inline-block;*/
}

/* ปุ่ม sound */
#soundToggle {
position: absolute;
    top: 12px;
    right: 16px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 5;
}

#soundToggle:hover {
    background: rgba(255, 255, 255, 0.8);
}

#soundToggle.sound-on {
    background-image: url("../assets/image/sound_on.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 60%;
}

#soundToggle.sound-off {
    background-image: url("../assets/image/sound_off.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 60%;
}

/* ลิขสิทธิ์ใต้จอ */
#copyright {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Kanit";
    color: #ccc;
    opacity: 0.9;
    pointer-events: none;
}

/* กล่องรวมปุ่ม Night mode */
#nightControls {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 30;
    
    display: none;
    grid-template-columns: auto auto;
    /* col0 = up/down, col1 = punch */
    grid-template-rows: auto auto;
    row-gap: 14px;
    column-gap: 14px;
    
    touch-action: manipulation;
}

.night-btn {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    border: none;
    padding: 0;
    margin: 0;

    background-color: rgba(0, 0, 0, 0.35);
    /* เงาบาง ๆ */
    backdrop-filter: blur(4px);

    background-size: 64% 64%;
    background-repeat: no-repeat;
    background-position: center;

    cursor: pointer;
    outline: none;
}

/* hover / active นิดหน่อย */
.night-btn:hover {
    background-color: rgba(0, 0, 0, 0.5);
}

.night-btn:active {
    transform: scale(0.96);
}

/* position ตามที่ขอ
   col0: up (row1), down (row2)
   col1: punch กิน 2 row กลางระหว่าง up/down
*/
#btnWalkUp {
    grid-column: 1;
    grid-row: 1;
}

#btnWalkDown {
    grid-column: 1;
    grid-row: 2;
}

#btnPunch {
    grid-column: 2;
    grid-row: 1 / span 2;
    /* กิน 2 แถว */
    align-self: center;
    /* กลางระหว่าง up / down */
}

/* ใส่ PNG ตามไฟล์พี่นัท */
#btnWalkUp {
    background-image: url("../assets/image/up.png");
}

#btnWalkDown {
    background-image: url("../assets/image/down.png");
}

#btnPunch {
    background-image: url("../assets/image/punch.png");
}

/* กล่อง timer ตรงกลางบน */
.mode-timer {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;

    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(4px);

    font-family: "Kanit", system-ui;
    color: #000000;
    z-index: 20;

    opacity: 1;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.mode-timer.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -8px);
}

.mode-timer-icon {
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* icon ตอนโหมดถัดไปเป็น Night */
.mode-timer-icon.moon {
    background-image: url("../assets/image/moon.png");
}

/* icon ตอนโหมดถัดไปเป็น Day */
.mode-timer-icon.sun {
    background-image: url("../assets/image/sun.png");
}

.mode-timer-text {
    min-width: 24px;
    text-align: right;
    font-weight: 700;
    font-size: 20px;
}

.mode-timer-label {
    font-size: 12px;
    opacity: 0.8;
}