@charset "UTF-8";

/* ==========================================================================
   1. SETUP & VARIABLES
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@900&family=Kanit:wght@300;400;500;600;800;900&family=Mali:wght@300;400;500;600&family=Prompt:wght@300;400;500;600&family=Roboto:wght@300;400;500;700&family=Sarabun:wght@300;400;500;600&display=swap');

:root {
    --acs-red: #A91B0D;
    /* สีแดง ACS */
    --acs-dark-red: #900000;
    /* สีแดงเข้ม (Hover) */
    --bg-color: #f0f2f5;
    /* สีพื้นหลัง */
    --text-main: #2c3e50;
    /* สีตัวอักษร */
    --clock-bg: #ffffff;
    /* พื้นหลังนาฬิกา */
    --msg-text-color: #00264d;
    /* สีข้อความประกาศ */
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ==========================================================================
   2. GLOBAL BODY STRUCTURE (โครงสร้างหลัก)
   ========================================================================== */

body {
    cursor: pointer;
    margin: 0;
    padding: 0;
    font-family: 'Prompt', sans-serif !important;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    background: radial-gradient(circle at center, #ffffff 0%, #e0e4e8 100%);
    background-attachment: fixed;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 30px;
}


.containter-clock {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: start;
    align-items: center;
    padding: 10px;
    width: 100%;
}

/* 2. เมาส์เวลาชี้ปุ่ม (เปลี่ยนเป็นนิ้วชี้สีแดง) */
a,
button,
.nav-btn,
.clock-drag-handle,
.announcement-icon {

    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24'><path fill='%23A91B0D' stroke='white' stroke-width='2' d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z'/></svg>") 16 16, pointer;

}

/* 3. เมาส์เวลาจะพิมพ์ข้อความ (ทำเป็นแท่งสีแดงหนาๆ จะได้ไม่หายวูบ) */
input,
textarea,
.school-name-en,
.page-header-input {

    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24'><rect x='10' y='2' width='4' height='20' rx='2' fill='%23A91B0D' stroke='white' stroke-width='2'/></svg>") 12 12, text;

}


/* ==========================================================================

   3. HEADER & MAIN CLOCK (ส่วนหัวและนาฬิกาหลัก)

   ========================================================================== */

/* --- โลโก้และชื่อโรงเรียน --- */

.header-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
    margin-bottom: 0.5rem;
}

img.acsLogo {
    margin-top: 5px;
    margin-bottom: 0;
    padding-bottom: 0;
    width: 110px;
    max-width: 14vw;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

h1 {
    margin: 0 0 5px 0;
    width: 100%;
    text-align: center;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    line-height: 1.6;
    font-weight: 800;
    color: var(--text-main);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Prompt', sans-serif !important;
}


/* --- ชื่อการสอบและวันที่ --- */

#exam-title {

    display: inline-block;
    width: auto;
    min-width: 300px;
    max-width: 90vw;
    margin: 10px auto;
    background-color: #fff5f5;
    border: none;
    border-bottom: 2px solid #f0d0d0;
    border-radius: 8px;
    padding: 5px 15px;
    font-family: 'Prompt', sans-serif !important;
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 900;
    letter-spacing: 0.5;
    line-height: 1.5;
    color: var(--acs-red);
    text-align: center;
    outline: none;
    transition: all 0.3s ease;

}

.date-text {
    width: 100%;
    text-align: center;
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 800;
    margin: 0;
    color: #555;
    line-height: 1.6;
    padding-top: 0;
    display: block;
}

/* --- นาฬิกาหลัก (Main Clock) --- */
#time {
    position: relative;
    display: inline-block;
    padding: 10px 6rem;
    color: var(--acs-red);
    font-size: clamp(5rem, 20vw, 12rem);
    font-family: "Inter", sans-serif;
    font-weight: 900;
    line-height: 1;
    background-color: var(--clock-bg);
    box-shadow: 0 10px 40px -10px rgba(169, 27, 13, 0.15);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    margin-top: 0.2rem;
    margin-bottom: 0.1rem;
}

/* ปุ่มจับลากนาฬิกาหลัก (Main Drag) */
.main-drag-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 30px;
    height: 30px;
    background-color: var(--acs-red);
    color: white;
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
    transform: translate(-30%, -30%);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.main-drag-handle:active {
    cursor: grabbing;
    transform: translate(-30%, -30%) scale(1.1);
}

/* ปุ่มขยายนาฬิกาหลัก (Main Resize) */
.main-resize-handle {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, var(--acs-red) 50%);
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

/* โชว์ปุ่มเมื่อชี้เมาส์ที่นาฬิกาหลัก */

#time:hover .main-drag-handle,
#time:hover .main-resize-handle {
    opacity: 1;
}

/* ==========================================================================
   4. TEACHER MESSAGE BOX (กล่องประกาศครู)
   ========================================================================== */

#teacher-msg {

    display: block;
    margin: 0.5rem auto 0 auto;
    width: 99%;
    padding: 10px 25px;
    font-size: clamp(1.8rem, 3vw, 4rem);
    line-height: 1.5;
    font-family: "Sarabun", sans-serif;
    font-weight: 600;
    color: var(--msg-text-color);
    text-align: center;
    line-height: 1.5;
    height: 6em;
    background-color: #ffffff;
    border: 2px solid #ccc;
    border-radius: 20px;
    resize: auto;
    overflow-y: scroll;

}

#teacher-msg::selection {
    background-color: var(--acs-red);
    color: #ffffff;
}

#teacher-msg:focus {
    outline: none;
    border-color: var(--acs-red);
    box-shadow: 0 0 0 4px rgba(169, 27, 13, 0.1);
    transition: box-shadow 0.2s;
}

/* Custom Scrollbar */
#teacher-msg::-webkit-scrollbar {
    width: 16px;
    display: block;
}

#teacher-msg::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
}

#teacher-msg::-webkit-scrollbar-thumb {
    background: rgba(169, 27, 13, 0.3);
    border-radius: 10px;
    border: 3px solid #ffffff;
}

#teacher-msg::-webkit-scrollbar-thumb:hover {
    background: rgba(169, 27, 13, 0.6);
}

#teacher-msg::-webkit-scrollbar-button:single-button {
    background-color: #f8f8f8;
    display: block;
    background-size: 10px;
    background-repeat: no-repeat;

    height: 16px;
    width: 16px;
}

#teacher-msg::-webkit-scrollbar-button:single-button:vertical:decrement {
    background-position: center 5px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23A91B0D' opacity='0.4'><polygon points='50,0 0,100 100,100'/></svg>");
}

#teacher-msg::-webkit-scrollbar-button:single-button:vertical:increment {
    background-position: center 3px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23A91B0D' opacity='0.4'><polygon points='0,0 100,0 50,100'/></svg>");
}

/* ==========================================================================
   5. SCHEDULE SECTION (ส่วนตารางสอบ & แท็บ)
   ========================================================================== */
.schedule-section {
    width: 100%;
    padding-top: 0.5rem;
    padding-bottom: 2rem;
    border-top: 1px dashed #ddd;
    background-color: #fafafa;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-height: auto !important;
    justify-content: flex-start !important;
}

/* Slider Header & Tabs */
.slider-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: #fafafa;
    border-bottom: 1px solid #ddd;
    padding: 10px 2.5%;
    width: 100%;
    max-width: 1800px;
    margin: 0 auto !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 20px !important;
}

.slider-header h3 {
    position: static !important;
    position: relative !important;
    z-index: 10 !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 1.5rem;
    color: var(--acs-red);
    font-weight: 800;
    white-space: nowrap;
}

.tabs-container {
    display: flex;
    gap: 8px;
    padding: 0;
    z-index: 100 !important;
    margin: 0 !important;
    margin-top: 0 !important;
    position: relative;

}

.tab-btn {
    background-color: #ffffff;
    color: var(--acs-red);
    border: 2px solid var(--acs-red);
    padding: 6px 16px;
    font-family: "Prompt", sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;

}

.tab-btn:hover {
    background-color: #ffecec;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(169, 27, 13, 0.15);

}

.tab-btn.active {
    background-color: var(--acs-red);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(169, 27, 13, 0.3);
}

/* เพิ่มจุดหรือเส้นใต้ปุ่มที่ Active */
.tab-btn.active::after {
    content: " •";
    /* ใส่จุดหลังชื่อชั้นเรียน */
    color: #fff;
    font-size: 1.2rem;
}

/* Image Content */

.tab-content {
    display: none;
    width: 100%;
    animation: fadeEffect 0.5s;
}

.active-content {
    display: block;
}


/* ปรับภาพให้นุ่มนวลตอนสลับ */
@keyframes fadeEffect {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.schedule-img {
    width: 100%;
    max-width: auto;
    max-height: 95vh;
    height: auto;
    margin-top: 0 !important;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid #ddd;
    display: block;
    margin: 0 auto;
}

/* ==========================================================================
   6. FLOATING CLOCK (นาฬิกาลอยตัว - Mini Clock) 
   ปรับปรุงให้ชิดขอบขวาเพื่อประหยัดพื้นที่
   ========================================================================== */
#mini-time {
    position: absolute;
    right: 10px;
    top: 75px;
    z-index: 9999;
    width: auto;
    height: auto;
    padding: 2px 5px;
    background-color: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    color: var(--acs-red);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* เพิ่มเติม: เมื่อชี้เมาส์ให้ชัดขึ้น */
#mini-time:hover {
    background-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 15px 40px rgba(169, 27, 13, 0.15);
}

#mini-clock-text {
    font-family: "Inter", sans-serif;
    font-weight: 900;
    line-height: 1;
    font-size: 5.5rem;
    pointer-events: none;
    white-space: nowrap;
}

/* Mini Clock: ปุ่มจับลาก (วงกลมซ้ายบน) */
.clock-drag-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 30px;
    height: 30px;
    background-color: var(--acs-red);
    color: white;
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
    transform: translate(-30%, -30%);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.clock-drag-handle:active {
    cursor: grabbing;
    transform: translate(-30%, -30%) scale(1.1);
}

/* Mini Clock: ปุ่มขยาย (มุมขวาล่าง) */
.clock-resize-handle {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, transparent 50%, var(--acs-red) 50%);
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

#mini-time:hover .clock-drag-handle,
#mini-time:hover .clock-resize-handle {
    opacity: 1;
}

/* Mini Clock: โหมดพับเก็บ (Minimized) */
#mini-time.minimized {
    height: 35px !important;
    width: 160px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    opacity: 0.9;
    background-color: var(--acs-red);
    color: white;
}

#mini-time.minimized #mini-clock-text,
#mini-time.minimized .clock-resize-handle {
    display: none !important;
}

#mini-time.minimized .clock-drag-handle::after {
    content: " (ดับเบิ้ลคลิกเพื่อขยาย)";
    font-size: 12px;
    white-space: nowrap;
}

/* ==========================================================================
   7. DIGITAL RULER (ไม้บรรทัดนำสายตา - แบบใสเน้นลูกศรสีเหลือง)
   ========================================================================== */
#ruler-line {
    position: absolute;
    top: 72px;
    left: 10px;
    width: 150px;
    /* ลดความกว้างลงให้พอดีกับหัวลูกศร จะได้ไม่ไปบังส่วนอื่นของตาราง */
    height: 43px;
    background-color: transparent;
    /* เอาแถบสีออก 100% */
    border: none;
    /* เอาเส้นขอบบน-ล่างออก 100% */
    z-index: 1111 !important;
    cursor: move;
    pointer-events: auto;
    touch-action: none;
}

.ruler-handle {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: #ffc107;
    color: #000;
    font-size: 1.1rem;
    font-weight: 900;
    letter-spacing: 2px;
    padding: 10px 45px 10px 20px;
    clip-path: polygon(0% 0%, 85% 0%, 100% 50%, 85% 100%, 0% 100%);
    user-select: none;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3);
    z-index: 1112;
    animation: arrow-attention 1.5s infinite ease-in-out;
    white-space: nowrap;
    cursor: grab;
}

@keyframes arrow-attention {

    0%,
    100% {
        transform: translateY(-50%) translateX(0);
        filter: brightness(100%);
    }

    50% {
        transform: translateY(-50%) translateX(15px);
        filter: brightness(120%);
        box-shadow: 6px 0 20px rgba(255, 193, 7, 0.7);
    }
}

.ruler-handle:hover {
    animation-play-state: paused;
    background: #ff9800;
    cursor: grab;
}

.ruler-handle:active {
    cursor: grabbing;
}

/* ปุ่มขยายความหนา (วางไว้ท้ายลูกศร) */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 40px;
    height: 100%;
    background-color: transparent;
    cursor: s-resize;
    z-index: 51;
    pointer-events: auto;
}

/* ==========================================================================
   9. RESPONSIVE DESIGN (การปรับตัวตามขนาดหน้าจอ)
   ========================================================================== */
/* iPad & Tablet Landscape */

@media only screen and (min-width: 744px) and (max-width: 1366px) and (orientation: landscape) {
    .containter-clock {
        justify-content: space-evenly;
        padding-top: 1rem;
        padding-bottom: 2rem;
    }

    h1 {
        font-size: 6vh;
    }

    #exam-title {
        font-size: 4vh;
        min-width: 40vw;
    }

    .date-text {
        font-size: 4vh;
    }

    #time {
        font-size: 18vh;
    }

    #teacher-msg {
        font-size: 3vh;
        height: 4.5em;
        width: 80%;
    }

    img.acsLogo {
        height: 12vh;
        width: auto;
    }

}


/* Mobile Phone */
@media only screen and (max-width: 900px) {

    /* 1. จัดโครงสร้างหัวข้อให้เป็นแนวตั้งและอยู่ตรงกลาง */
    .slider-header {
        flex-direction: column !important;
        height: auto !important;
        gap: 10px !important;
        margin-bottom: 15px !important;
        align-items: center !important;
        /* จัดทุกอย่างใน header ให้อยู่กลาง */
    }

    /* 2. ทำให้ตัวหนังสือ 'ตารางสอบ' อยู่ตรงกลางและไม่ลอย */
    .slider-header h3 {
        position: static !important;
        transform: none !important;
        width: auto !important;
        text-align: center !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 1.4rem !important;
        /* ปรับขนาดให้พอดีมือถือ */
    }

    /* 3. จัดกลุ่มปุ่มให้เรียงกึ่งกลาง และขึ้นบรรทัดใหม่เมื่อพื้นที่ไม่พอ */
    .tabs-container {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 8px !important;
        width: 100% !important;
        margin-top: 5px !important;
        /* ให้มีระยะห่างจากหัวข้อเล็กน้อย */
        padding: 0 10px !important;
    }

    /* 4. ปรับนาฬิกาเล็กให้เลิกชิดขวา และมาอยู่กึ่งกลางเหมือนนาฬิกาหลัก */
    #mini-time {
        position: relative !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
        background: none !important;
        box-shadow: none !important;
        border: none !important;
        margin: 5px 0 !important;
    }

    /* ส่วนอื่นๆ ที่คุณครูทำไว้ดีอยู่แล้ว */
    .containter-clock {
        justify-content: flex-start;
        padding-top: 20px;
        min-height: auto;
    }

    #time {
        font-size: 14vw;
        padding: 0.5rem 1.5rem;
        margin-top: 0.5rem;
        margin-bottom: 1rem;
    }

    #teacher-msg {
        font-size: 1.1rem;
        height: 4em;
        margin-bottom: 20px;
    }

    .date-text {
        margin-top: 10px;
        line-height: 1.8;
        padding-top: 5px;
    }

    #ruler-line {
        display: none;
    }
}

/* คอนโทรลปรับขนาดตัวอักษร */

.msg-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
    justify-content: flex-end;
    width: 99%;
}



.msg-controls button {
    background: white;
    border: 1px solid var(--acs-red);
    color: var(--acs-red);
    border-radius: 5px;
    padding: 2px 12px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

.msg-controls button:hover {
    background: var(--acs-red);
    color: white;
}



/* Overlay System */
.overlay-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.98);
    /* พื้นหลังเกือบดำ */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

.overlay-content {
    text-align: center;
    color: white;
}

.overlay-logo {
    width: 100px;
    margin-bottom: 20px;
}

.overlay-title {
    font-size: 2.2rem;
    margin-bottom: 5px;
}

.overlay-subtitle {
    font-size: 1.1rem;
    color: #94a3b8;
    margin-bottom: 30px;
}

/* ปุ่มสีส้ม Amber ที่คุณครูต้องการ */

.btn-fullscreen-start {
    background-color: #f59e0b;
    /* สีส้ม Amber */
    color: #000;
    /* ตัวอักษรสีดำเพื่อให้ตัดกับสีส้ม */
    border: none;
    padding: 18px 45px;
    font-size: 1.6rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
    transition: all 0.2s ease;

}



.btn-fullscreen-start:hover {
    background-color: #fbbf24;
    /* สีส้มสว่างขึ้น */
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(245, 158, 11, 0.6);
}


.overlay-hint {
    margin-top: 20px;
    color: #64748b;
    font-size: 0.9rem;
}

/* ซ่อน Overlay ทันทีในโทรศัพท์และไอแพด (จอเล็กกว่า 1024px) */
@media only screen and (max-width: 1024px) {
    #start-overlay {
        display: none !important;
        /* บังคับหายไปเลย */
        visibility: hidden;
        pointer-events: none;
        /* ปิดการคลิกทุกอย่าง */

    }

}

/* Mobile Phone */
@media only screen and (max-width: 900px) {

    /* 1. ชื่อโรงเรียน (h1) */
    h1 {
        font-size: 1.8rem !important;
        /* ลดจากเดิมที่อาจจะใหญ่เกินไป */
        line-height: 1.3;
    }

    /* 2. หัวข้อสอบ (#exam-title) */
    #exam-title {
        font-size: 1.4rem !important;
        /* ลดขนาดลงให้พอดีหน้าจอมือถือ */
        min-width: 250px;
        width: 95%;
        padding: 5px 10px;

    }

    /* 3. วันที่ (.date-text) */
    .date-text {
        font-size: 1.2rem !important;
        /* ปรับให้เล็กลงกว่าหัวข้อสอบ */
        margin-top: 5px;
    }

    /* 4. ปุ่มแท็บตารางสอบ (.tab-btn) */
    .tab-btn {
        padding: 4px 10px;
        /* ลด padding ให้ปุ่มไม่เบียดกัน */
        font-size: 0.9rem;
        /* ลดขนาดตัวอักษรบนปุ่ม */
        border-width: 1px;
        /* ลดความหนาขอบ */
    }

    /* แถม: ปรับกล่องปุ่มแท็บให้เรียงกันสวยๆ ไม่ล้นจอ */
    .tabs-container {
        gap: 5px;
        justify-content: center;
        display: flex;
        flex-wrap: wrap;
        /* ให้ปุ่มขึ้นบรรทัดใหม่ได้ถ้าที่จำกัด */
    }
}

/* เจาะจงแก้เฉพาะนาฬิกาอันเล็กในมือถือให้เท่ากับอันบน */
@media only screen and (max-width: 900px) {
    #mini-time {
        position: relative !important;
        right: auto !important;
        top: auto !important;
        margin: 5px auto !important;
        padding: 0 !important;
        background: none !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
    }

    #mini-clock-text {
        font-size: 14vw !important;
        font-weight: 700 !important;
        color: var(--acs-red) !important;
        letter-spacing: -1px !important;
        line-height: 1 !important;
    }

    /* ซ่อนปุ่มลากและปุ่มขยายเพื่อให้ดูคลีนเหมือนอันบน */
    .clock-drag-handle,
    .clock-resize-handle {
        display: none !important;

    }
}



/*====== 8. ANNOUNCEMENT SECTION (ส่วนประกาศหน้า 3) =====*/
.announcement-section {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
}

.announcement-container {
    width: 96%;
    max-width: 1800px;
    display: flex;
    flex-direction: column;
    gap: 0;
    /* เปลี่ยนเป็น 0 เพื่อให้หัวกับตัวกล่องติดกัน */
}

.announcement-header {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* --- ปรับแถบสีหัวข้อให้เต็มความกว้าง --- */
.header-banner {
    background: var(--acs-red);
    padding: 20px;
    /* เพิ่มพื้นที่แนวตั้งให้ดูสง่า */
    border-radius: 15px 15px 0 0;
    /* โค้งเท่ากับมุมกล่องด้านล่าง */
    width: 100%;
    /* หัวใจสำคัญ: สั่งให้กว้าง 100% ของคอนเทนเนอร์ */
    box-sizing: border-box;
    /* กัน padding ดันกล่องจนเลยขอบ */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- แถบสีหัวข้อประกาศ --- */
.header-banner {
    background: var(--acs-red);
    padding: 15px 30px;
    border-radius: 15px 15px 0 0;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    /* ใช้ Flexbox */
    align-items: center;
    /* จัดให้อยู่กึ่งกลางแนวตั้ง */
    justify-content: space-between;
    /* กระจายไอคอนและข้อความ */
    gap: 20px;
}

/* --- ตกแต่งไอคอน --- */
.banner-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    user-select: none;
}

#extra-header-title {
    background: transparent;
    border: none;
    color: #ffffff;
    text-align: center;
    font-size: clamp(2.4rem, 5vw, 4rem);
    line-height: 1.2;
    font-weight: 900;
    padding-left: 30px;

    flex-grow: 1;
    /* ให้ช่องพิมพ์กินพื้นที่ที่เหลือทั้งหมด */
    outline: none;
    font-family: "Prompt", sans-serif;
}

#extra-header-title:focus {
    transform: scale(1.05);
    /* ขยายใหญ่ขึ้นนิดหน่อยตอนคลิก */
}

#extra-msg {
    width: 100%;
    height: 82vh;
    padding: 50px;
    font-family: "Sarabun", sans-serif;
    font-size: clamp(1.8rem, 3.5vw, 3.6rem);
    font-weight: 600;
    color: #1a2a3a;
    line-height: 1.6;
    background: #ffffff;
    border: 1px solid #ddd;
    border-top: none;
    /* เอาขอบบนออกเพื่อให้เชื่อมกับแถบสีแดง */
    border-radius: 0 0 15px 15px;
    /* โค้งแค่ด้านล่าง */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    resize: none;
    outline: none;
    transition: all 0.3s ease;
}

/* คงส่วนอื่นๆ ไว้ตามเดิม */
#extra-msg:focus {
    box-shadow: 0 20px 50px rgba(169, 27, 13, 0.1);
    border-color: #ccc;
}

#extra-msg::placeholder {
    color: #bbb;
    font-weight: 400;
}

#extra-msg::selection {
    background-color: var(--acs-red);
    color: #ffffff;
}

#extra-msg::-webkit-scrollbar {
    width: 10px;
}

#extra-msg::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

#extra-msg::-webkit-scrollbar-thumb:hover {
    background: var(--acs-red);
}

.image-wrapper {
    position: relative;
    display: block;
    /* เปลี่ยนจาก inline-block เป็น block */
    width: fit-content;
    /* ให้กว้างเท่ากับรูปภาพข้างใน */
    margin: 0 auto;
    /* จัดรูปให้อยู่กลางหน้าจอ */
    overflow: visible;
    /* ยอมให้ปุ่มลบ (ลบ x) ลอยออกนอกขอบกล่องได้เล็กน้อย */
}

.edit-box {
    position: absolute;
    /* สำคัญมาก: เพื่อให้วางทับบนรูปได้ */
    background: white;
    border: 4px solid #A91B0D;
    padding: 2px 2px;
    font-family: 'Sarabun', sans-serif;
    font-weight: bold;
    color: black;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    min-width: 80px;
    min-height: 40px;
    cursor: move;
    /* สัญลักษณ์รูปเป้าสำหรับลาก */
    resize: both;
    /* เปิดให้ดึงมุมขวาล่างเพื่อขยายได้ */
    overflow: hidden;
    /* กันเนื้อหาล้นกล่อง */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: pre-wrap;
    /* ให้พิมพ์เว้นวรรคและขึ้นบรรทัดใหม่ได้ */
    user-select: none;
    /* กันการคลุมดำเวลาลาก */
    touch-action: none;
    /* กันจอเลื่อนเวลาลากในไอแพด */
    line-height: 1.2;
}

.edit-box:hover {
    border-color: #ff9800;
    box-shadow: 0 4px 20px rgba(169, 27, 13, 0.4);
}

/* เพิ่มให้ขอบ resize เห็นชัดขึ้น */
.edit-box::-webkit-resizer {
    border-style: solid;
    border-width: 8px;
    border-color: transparent var(--acs-red) var(--acs-red) transparent;
}


/* 1. ตัวกล่อง: ลด Padding และเปลี่ยนสีเส้นขอบ */
.text-box {
    position: absolute;
    border: 2px solid rgba(169, 27, 13, 0.4);
    /* สีแดง ACS ทึบบางๆ 0.4 */
    border-radius: 6px;
    background: rgba(255, 255, 255, 1);
    backdrop-filter: blur(2px);
    cursor: move;
    min-width: 80px;
    min-height: 28px;
    padding: 2px 2px;
    /* ลด Padding ให้เหลือนิดเดียว */

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.2s ease;
}

/* 2. เมื่อเอาเมาส์มาชี้ ให้เส้นขอบชัดขึ้นเล็กน้อย */
.text-box:hover {
    border-color: rgba(169, 27, 13, 1);
    /* แดงเข้มชัดขึ้นตอนจ่อเมาส์ */
    background: #ffffff;
}

.text-box:active {
    cursor: grabbing;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* ตั้งค่าตัวอักษรข้างในกล่องพิมพ์ */
.text-box [contenteditable="true"] {
    width: 100%;
    height: 100%;
    outline: none;
    font-family: 'Sarabun', sans-serif;
    font-weight: 400;
    font-size: 1.4rem;
    color: #1a2a3a;
    text-align: center;
    word-break: break-word;

    /* --- แก้ไข 2 บรรทัดนี้ครับ --- */
    cursor: text;
    /* เปลี่ยนจาก move เป็น text เพื่อให้รู้ว่าพิมพ์ได้ */
    user-select: text;
    /* เปลี่ยนจาก none เป็น text เพื่อให้จิ้มเลือกตัวอักษรได้ */
}

/* 3. ปุ่มลบ และ ตัว Resize: สั่งให้ซ่อนไว้ก่อน (opacity: 0) */
.btn-delete,
.resizer {
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    /* กันไม่ให้เผลอไปกดโดนตอนมันซ่อนอยู่ */
}

/* 4. เมื่อ Hover ที่ตัวกล่อง ให้ปุ่มลบและตัว Resize โผล่ขึ้นมา */
.text-box:hover .btn-delete,
.text-box:hover .resizer {
    opacity: 1;
    pointer-events: auto;
    /* กลับมาให้กดได้ปกติ */
}

/* จุดจับย่อขยายมุมขวาล่าง */
.resizer {
    width: 10px;
    height: 10px;
    background: rgba(169, 27, 13, 0.5);
    position: absolute;
    right: 0;
    bottom: 0;
    cursor: se-resize;
    border-radius: 0 0 4px 0;
}

/* ปุ่มลบ (กากบาทสีแดง) */
.btn-delete {
    position: absolute;
    top: 0;
    right: 0;
    background: #A91B0D;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-delete:hover {
    transform: scale(1.2);
    background: red;
}


/* กลุ่มปุ่มควบคุมในกล่อง */
.box-controls {
    position: absolute;
    top: -22px;
    /* ให้ลอยขึ้นไปข้างบนกล่อง */
    right: 0;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.text-box:hover .box-controls {
    opacity: 1;
}

.box-controls button {
    width: 20px;
    height: 20px;
    border: 1px solid white;
    border-radius: 4px;
    background: #A91B0D;
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.box-controls button:hover {
    background: #ff0000;
}