/* Base Styles (Mobile First) */

body {
    background-color: #f4f4f4;
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
}

.calculator-container {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 20px auto;
}

.calculator {
    width: 90%;
    max-width: 350px;
    background-color: #222;
    padding: 15px;
    border-radius: 10px;
    margin: 0 auto 20px auto; /* Centered on mobile */
    box-sizing: border-box;
}

.variables-container {
    width: 90%;
    max-width: 200px;
    background-color: #222;
    padding: 15px;
    border-radius: 10px;
    color: #fff;
    margin: 0 auto;
}

.variables-container h2 {
    margin-top: 0;
    text-align: center;
}

#variables-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 10px;
}

#variables-list p {
    margin: 5px 0;
    font-size: 1.1em;
}

#clear-variables {
    width: 100%;
    padding: 10px;
    background-color: #d9534f;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#clear-variables:hover {
    opacity: 0.9;
}

.display {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.display input {
    width: 100%;
    font-size: 1.2em;
    padding: 10px;
    border: none;
    background-color: #444;
    color: #fff;
    border-radius: 5px;
    box-sizing: border-box;
}

.result-display input {
    background-color: #333;
    color: #0f0;
    cursor: default;
}

.result-display input:focus {
    outline: none;
}

.settings {
    text-align: right;
    margin-bottom: 10px;
    color: #fff;
    width: 100%;
}

.settings select {
    padding: 5px;
    font-size: 1em;
}

.keys {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-gap: 5px;
}

button {
    padding: 10px;
    font-size: 1em;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

button.number {
    background-color: #555;
    color: #fff;
}

button.operator {
    background-color: #f1a23c;
    color: #fff;
}

button.function {
    background-color: #777;
    color: #fff;
}

button.equal {
    background-color: #4caf50;
    grid-column: 4 / span 2; /* Starts at column 4, spans 2 columns */
}

button[data-number="0"] {
    grid-column: span 2;
}

button.function[data-function="C"],
button.function[data-function="CE"] {
    background-color: #d9534f;
}

button:hover {
    opacity: 0.9;
}

/* Active mode styling */
.active-mode {
    font-weight: bold;
}

/* Styling for empty grid items */
.empty {
    visibility: hidden;
}

/* Desktop Styles */
@media (min-width: 768px) {
    .calculator-container {
        position: relative;
        width: fit-content;
        margin: 50px auto; /* Center the calculator container */
    }

    .calculator {
        width: 350px;
        padding: 20px;
        margin: 0 auto; /* Center the calculator */
    }

    .variables-container {
        position: absolute;
        top: 0;
        left: 100%; /* Position to the right of the calculator */
        margin-left: 10px; /* Space between calculator and variables container */
        width: 200px;
    }

    .display input {
        font-size: 1.5em;
    }

    button {
        padding: 15px;
    }

    .settings {
        width: auto;
    }
}
