body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #8e44ad, #3498db);
    transition: background 0.4s ease;
}

.container {
    text-align: center; /* Centering title and calculator */
}

.calculator {
    width: 320px;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    background-color: white;
    transition: background-color 0.4s ease;
    margin-top: 20px; /* Spacing above calculator */
}

body.dark .calculator {
    background-color: #444; /* Dark mode background */
}

.calculator-title {
    font-size: 2.5em; /* Larger title */
    margin-bottom: 10px; /* Space between title and calculator */
    color: #fff; /* Title color */
}

#display {
    width: 90%;
    height: 60px;
    font-size: 2em;
    text-align: right;
    margin-bottom: 20px;
    padding: 15px;
    border: none;
    border-radius: 10px;
    background-color: #f0f0f0;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
    transition: background-color 0.4s ease, color 0.4s ease;
}

body.dark #display {
    background-color: #555;
    color: white;
}

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

button {
    height: 60px;
    font-size: 1.5em;
    border: none;
    border-radius: 10px;
    background-color: #f7f7f7;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

button:active {
    transform: translateY(2px);
}

button.zero {
    grid-column: span 2; /* Make the 0 button span 2 columns */
}

button:nth-child(4n) {
    background-color: #ffb74d;
    color: white;
}

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

body.dark button {
    background-color: #555;
    color: white;
}

body.dark button:nth-child(4n) {
    background-color: #ff9800;
}

.theme-toggle {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2196f3;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

body.dark {
    background: linear-gradient(135deg, #1e1e1e, #3e3e3e);
}
