* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f0f0;
    font-family: Arial, sans-serif;
    overflow-x: hidden;
}

.calculator {
    position: relative;
    width: 100%;
    max-width: 320px;
    background-color: #1c2526;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    margin: 10px;
}

.display {
    background-color: #2e3839;
    color: #fff;
    padding: 15px;
    text-align: right;
}

#history {
    font-size: clamp(12px, 4vw, 16px);
    color: #a0a0a0;
    min-height: 20px;
    word-wrap: break-word;
}

#result {
    font-size: clamp(24px, 8vw, 36px);
    margin-top: 10px;
    word-wrap: break-word;
}

.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background-color: #1c2526;
    padding: 1px;
}

.btn {
    background-color: #3a4647;
    border: none;
    color: #fff;
    font-size: clamp(18px, 6vw, 24px);
    padding: 15px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: #4a5657;
}

.operator {
    background-color: #ff9500;
}

.operator:hover {
    background-color: #e08500;
}

.equals {
    background-color: #ff9500;
    grid-column: span 2;
}

.equals:hover {
    background-color: #e08500;
}

#history-btn {
    position: absolute;
    top: 10px;
    right: 260px;
    background-color: #ff9500;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    color: #fff;
    transition: background-color 0.2s;
}

#history-btn:hover {
    background-color: #e08500;
}

.history-panel {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100%;
    background-color: #2e3839;
    color: #fff;
    padding: 20px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
    transition: right 0.3s ease;
    overflow-y: auto;
}

.history-panel.open {
    right: 0;
}

#close-btn {
    background-color: #ff9500;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 16px;
    cursor: pointer;
    color: #fff;
    position: absolute;
    top: 10px;
    right: 10px;
}

#close-btn:hover {
    background-color: #e08500;
}

.history-panel h3 {
    margin-bottom: 20px;
    font-size: 20px;
}

#history-list {
    list-style: none;
    padding: 0;
}

#history-list li {
    background-color: #3a4647;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 5px;
    font-size: 16px;
    word-wrap: break-word;
}

@media (max-width: 340px) {
    .calculator {
        margin: 5px;
    }
    .display {
        padding: 10px;
    }
    .btn {
        padding: 10px;
    }
}

@media (min-width: 768px) {
    .calculator {
        max-width: 320px;
    }
}
