body, html {
    margin: 0;
    padding: 0;
    font-family: Lora, serif;
    background-color: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    max-width: 1200px; 
}

.calculator {
    background-color: #444444;
    padding: 20px;
    border-radius: 15px;
    width: 100%;
    max-width: 600px; 
    margin-right: 20px; 
    box-sizing: border-box;
}

.heading {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.display {
    background-color: #000;
    color: #fff;
    text-align: right;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    min-height: 60px;
    font-size: 32px; 
    width: 100%;
    box-sizing: border-box;
}

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

button {
    padding: 20px;
    font-size: 25px;
    border-radius: 10px;
    cursor: pointer;
    background-color: transparent;
    color: #000;
    border: none;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.operator-btn {
    background-color: #dfd7af;
    color: #fff;
    border-radius: 50%;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
    border: none;
}

.equal {
    background-color: #36474f;
    color: #fff;
    border-radius: 50%;
    width: 70px; 
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
    border: none;
}

.history {
    background-color: #000;
    color: #fff;
    padding: 20px;
    border-radius: 10px;
    max-width: 300px;
    width: 100%;
    display: none;
    box-sizing: border-box;
}

.history.show {
    display: block;
}

.clear-history {
    background-color: #36474f;
    color: #fff;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
    border: none;
    text-align: center;
}

.clear-history:hover {
    background-color: #2c3a42;
}

.light {
    background-color: #f5f5f5;
    color: #000;
}

.light .display {
    background-color: #e3e2e2;
    color: #000;
}

.light .clear-history {
    background-color: #dfd7af;
    color: #000;
}

.light .clear-history:hover {
    background-color: #c5b78e;
}

.theme-toggle, .history-toggle {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
        align-items: center;
    }

    .calculator {
        margin-right: 0;
        margin-bottom: 20px;
        max-width: 100%; 
    }

    .buttons {
        gap: 10px; 
    }

    .history {
        max-width: 100%;
        margin-top: 20px;
        position: relative;
    }
}

/* Popup background */
.popup {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); 
    justify-content: center;
    align-items: center;
    z-index: 999; 
}

/* Popup content box */
.popup-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 100%; 
    max-width: 200px; 
    margin: auto; 
}

body.dark-mode .popup-content {
    background-color: #444;
    color: #fff;
}

#popup-message {
    font-size: 22px; 
    font-weight: bold; 
    margin-bottom: 20px;
}

#close-popup {
    margin-top: 20px;
    padding: 20px 20px;
    background-color: #dfd7af;
    color: white;
    border-radius: 10px; 
    cursor: pointer;
    font-size: 15px; 
    font-weight: bold; 
    transition: background-color 0.3s ease, transform 0.3s ease;
}

#close-popup:hover {
    background-color: #36474f; 
    transform: scale(1.1);
}
