<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Calculator</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
        integrity="sha512-9usAa10IRO0HhonpyAIVpjrylPvoDwiPUiKdWk5t3PyolY1cOd4DwlSD0Ga+ri4AuTroPR5aQvXU9xC6qOPnzFeg=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
    <style>
        body {
            font-family: 'Arial', sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background-color: #f0f0f0;
        }

        .calculator {
            background-color: #fff;
            border-radius: 10px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            padding: 20px;
        }

        .display {
            background-color: #eee;
            border: none;
            border-radius: 5px;
            font-size: 1.8em;
            padding: 10px;
            margin-bottom: 15px;
            text-align: right;
            width: calc(100% - 20px);
        }

        .buttons {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            grid-gap: 10px;
        }

        button {
            background-color: #f5f5f5;
            border: none;
            border-radius: 5px;
            font-size: 1.2em;
            padding: 15px;
            cursor: pointer;
            transition: background-color 0.2s ease;
        }

        button:hover {
            background-color: #ddd;
        }

        .operator {
            background-color: #ff9800;
            color: #fff;
        }

        .operator:hover {
            background-color: #e68a00;
        }

        .clear {
            background-color: #f44336;
            color: #fff;
        }

        .clear:hover {
            background-color: #d32f2f;
        }

        .equal {
            background-color: #4caf50;
            color: #fff;
        }

        .equal:hover {
            background-color: #3e8e41;
        }
    </style>
</head>
<body>
    <div class="calculator">
        <input type="text" class="display" readonly>
        <div class="buttons">
            <button class="clear" onclick="clearDisplay()">C</button>
            <button onclick="appendOperator('/')">/</button>
            <button onclick="appendOperator('*')">*</button>
            <button class="operator" onclick="appendOperator('-')">-</button>
            <button onclick="appendToDisplay('7')">7</button>
            <button onclick="appendToDisplay('8')">8</button>
            <button onclick="appendToDisplay('9')">9</button>
            <button class="operator" onclick="appendOperator('+')">+</button>
            <button onclick="appendToDisplay('4')">4</button>
            <button onclick="appendToDisplay('5')">5</button>
            <button onclick="appendToDisplay('6')">6</button>


            <button onclick="appendToDisplay('1')">1</button>
            <button onclick="appendToDisplay('2')">2</button>
            <button onclick="appendToDisplay('3')">3</button>
            <button class="equal" onclick="calculateResult()">=</button>
            <button onclick="appendToDisplay('0')">0</button>
            <button onclick="appendToDisplay('.')">.</button>

        </div>
    </div>
    <script>
        let display = document.querySelector('.display');

        function appendToDisplay(value) {
            display.value += value;
        }

        function appendOperator(operator) {
            display.value += operator;
        }

        function clearDisplay() {
            display.value = '';
        }

        function calculateResult() {
            try {
                display.value = eval(display.value);
            } catch (error) {
                display.value = 'Error';
            }
        }
    </script>

</body>
</html>