/* grid-calc.css */
.grid-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 10000;
    backdrop-filter: blur(2px);
    padding: 20px;
    box-sizing: border-box;

    /* --- ทำให้ชิดขวาล่าง --- */
    align-items: flex-end;
    justify-content: flex-end;
}

.grid-overlay.active { display: flex; }

.grid-card {
    background: #fff;
    width: 100%;
    max-width: 340px;
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    /* แอนิเมชันเด้งจากมุมขวาล่าง */
    animation: slideInRight 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideInRight {
    from { transform: translate(30px, 30px) scale(0.8); opacity: 0; }
    to { transform: translate(0, 0) scale(1); opacity: 1; }
}

.grid-display {
    background: #f1f2f6;
    border-radius: 15px;
    padding: 15px;
    font-size: 2.3rem;
    font-weight: bold;
    text-align: right;
    margin-bottom: 15px;
    color: #2f3542;
    border: 1px solid #dfe4ea;
    /* ซ่อน Scrollbar ใน Display */
    overflow: hidden;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.grid-btn {
    aspect-ratio: 1 / 1;
    border: none;
    background: #f8f9fa;
    border-radius: 12px;
    font-size: 1.4rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.grid-btn:active { transform: scale(0.9); background: #eee; }

/* สีปุ่มฟังก์ชัน 
.grid-btn.op-btn { background: #ced6e0; font-size: 1.6rem; }
.grid-btn.ac-btn { background: #ff4757; color: white; }
.grid-btn.ok-btn { background: #2ed573; color: white; }
*/
/* ซ่อน Scrollbar ของหน้าจอหลักเผื่อกรณีข้อมูลล้น */
body { -ms-overflow-style: none; scrollbar-width: none; }
body::-webkit-scrollbar { display: none; }

/* สีปุ่มฟังก์ชัน (ส้ม) */
.grid-btn.op-btn { background: #ced6e0 !important; color: white !important; }
/* สีแดง AC */
.grid-btn.ac-btn { background: #ff4757 !important; color: white !important; }
/* สีเขียว OK */
.grid-btn.ok-btn { background: #2ed573 !important; color: white !important; }