* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1b1d23;
    font-family: "Segoe UI", "Malgun Gothic", sans-serif;
}

.calculator {
    width: 360px;
    background: #24262e;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.display {
    background: #14151a;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 14px;
    text-align: right;
    overflow: hidden;
}

.history {
    color: #8a8f9c;
    font-size: 14px;
    min-height: 18px;
    white-space: nowrap;
    overflow-x: auto;
}

.result {
    color: #ffffff;
    font-size: 32px;
    font-weight: 600;
    margin-top: 4px;
    white-space: nowrap;
    overflow-x: auto;
}

.result.error {
    color: #ff6b6b;
    font-size: 20px;
}

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

.key {
    border: none;
    border-radius: 10px;
    background: #33353f;
    color: #f0f0f0;
    font-size: 16px;
    padding: 14px 0;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.05s ease;
}

.key:hover {
    background: #3d4049;
}

.key:active {
    transform: scale(0.96);
}

.key.fn {
    background: #2c4356;
    color: #bfe3ff;
}

.key.fn:hover {
    background: #345070;
}

.key.op {
    background: #3a3d4a;
    color: #ffd28a;
}

.key.op:hover {
    background: #454858;
}

.key.equals {
    background: #ff9f43;
    color: #1b1d23;
    font-weight: 700;
    font-size: 20px;
}

.key.equals:hover {
    background: #ffb066;
}
