* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: #101522;
    color: white;
    font-family: Arial, sans-serif;
}

.calculator {
    width: 100%;
    max-width: 540px;
    padding: 22px;
    border: 1px solid #303b53;
    border-radius: 24px;
    background: #1b2335;
    box-shadow: 0 20px 60px #0008;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    font-size: 24px;
    margin-bottom: 6px;
}

header p,
footer {
    color: #91a2c2;
    font-size: 13px;
}

.screen {
    background: #0b1020;
    border: 1px solid #303b53;
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 14px;
}

#history {
    min-height: 24px;
    color: #91a2c2;
    direction: ltr;
    text-align: left;
    overflow-wrap: anywhere;
}

#display {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: #65e6c2;
    font-size: 30px;
    text-align: left;
    direction: ltr;
    padding-top: 12px;
}

.settings {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    color: #b7c3d9;
    font-size: 13px;
}

.buttons {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 9px;
}

button {
    min-width: 0;
    padding: 14px 4px;
    border: 1px solid #36435d;
    border-radius: 10px;
    background: #28334a;
    color: white;
    font-size: 17px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

button:hover {
    background: #405273;
}

button:active {
    transform: scale(0.96);
}

.mode {
    background: #176b62;
    border-color: #279f8d;
    padding: 8px 16px;
}

.danger {
    background: #843b4c;
}

.equal {
    background: #087e70;
    border-color: #18b8a0;
    font-size: 22px;
}

footer {
    text-align: center;
    margin-top: 20px;
}

@media (max-width: 420px) {
    .calculator {
        padding: 12px;
    }

    .buttons {
        gap: 6px;
    }

    button {
        padding: 13px 2px;
        font-size: 15px;
    }

    #display {
        font-size: 24px;
    }
}