.calculator {
    border: 1px solid #ced4da;
    padding: 20px;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 300px; /* Prevent it from being too wide */
}

input[type="text"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    box-sizing: border-box;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 18px;
    background-color: #f9f9f9;
    text-align: right;
}

/* Ensure buttons are responsive */
.buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-gap: 8px;
}

/* Adjust button size for better touch support */
button {
    padding: 12px;
    border: none;
    border-radius: 4px;
    background-color: #e9ecef;
    color: #343a40;
    cursor: pointer;
    font-size: 18px; /* Bigger font for touch-friendliness */
    transition: background-color 0.3s ease;
    border: 1px solid transparent;
}

/* Hover and active states for better feedback */
button:hover {
    background-color: #dee2e6;
    border-color: #adb5bd;
}

button:active {
    transform: scale(0.98);
}

/* Operators & Special Buttons */
button.operator {
    background-color: #007bff;
    color: white;
}

button.operator:hover {
    background-color: #0069d9;
}

button.clear {
    background-color: #dc3545;
    color: white;
}

button.clear:hover {
    background-color: #c82333;
}

button.special {
    background-color: #ffc107;
    color: #343a40;
}

button.special:hover {
    background-color: #e0a800;
}

/* Responsive Grid for Smaller Screens */
@media (max-width: 400px) {
    .buttons {
        grid-template-columns: repeat(4, 1fr); /* Reduce columns for better fit */
    }

    button {
        font-size: 16px; /* Slightly smaller buttons on small screens */
        padding: 10px;
    }
}
