/* Global */
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
    background: black;
}

/* Center wrapper */
.calculator-wrapper {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

/* Title */
h1 {
    margin-bottom: 15px;
    font-size: 26px;
    font-weight: bold;
    color: #e4dc66;
    text-align: center;
    text-shadow: 1px 1px 2px #ddd;
}

/* Calculator container */
.calculator {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border-radius: 12px;
    background: #e4e0be;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    max-width: 400px;
    width: 100%;
    overflow: hidden; /* hide overflow */
}

/* Display input */
.display {
    width: 100%;
    font-size: 20px;
    padding: 10px;
    margin-bottom: 10px;
    border: 2px solid black;
    border-radius: 5px;
    text-align: right;
}

/* Grid buttons */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    width: 100%;
}

/* Scientific buttons scrollable */
.scientific-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    width: 100%;
    max-height: 200px; /* max height before scroll */
    overflow-y: auto; /* vertical scroll */
    margin-bottom: 10px;
}

.scientific-buttons .button {
    font-size: 14px;
    padding: 10px;
}

/* Button base */
.button {
    margin: 1.5px;
    padding: 12px;
    font-size: 16px;
    border: 2px solid black;
    border-radius: 8px;
    cursor: pointer;
    background: #f0f0f0;
    transition: background 0.2s;
    white-space: nowrap;
}
.button:hover { background: #ddd; }

/* Special buttons */
.bg-red { background: #b5817b; color: #fff; }
.bg-red:hover { background: #c0392b; }

.operator { background: #749eb5; color: #fff; }
.operator:hover { background: #3367d6; }

.memory { background: #6bab6e; color: #fff; }
.memory:hover { background: #2e7d32; }

.equal { background: #d6b582; color: #fff; }
.equal:hover { background: #e68900; }

.func { background: #b48ac5; color: #fff; }
.func:hover { background: #8e44ad; }

/* Text utility */
.text-center { text-align: center; }

/* Hidden class for scientific mode */
.hidden { display: none; }

/* Responsive adjustments */
@media (max-width: 450px) {
    .button {
        padding: 10px;
        font-size: 14px;
    }
    .scientific-buttons .button {
        font-size: 12px;
        padding: 8px;
    }
    h1 {
        font-size: 20px;
    }
}
