* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #ffffff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    gap: 20px;
}

/* Calculator Container */
.calculator {
    background: #242530;
    padding: 25px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    width: 400px;
    max-width: 100%;
    border-radius: 20px;
}

/* Display Styles */
.display {
    background: #3a3f77;
    height: 80px;
    border-radius: 15px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 20px;
    font-size: 2rem;
    color: white;
    font-weight: 300;
    overflow: hidden;
    position: relative;
    cursor: text;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.display:hover {
    background: #3a3f77;
    transform: scale(1.01);
}

.display.focused {
    border-color: #ff9500;
    background: #525f73;
    box-shadow: 0 0 10px rgba(255, 149, 0, 0.3);
}

.display-text {
    text-align: right;
    width: 100%;
    word-break: break-all;
}

/* Button Grid */
.buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

/* Base Button Styles */
button {
    height: 60px;
    border: none;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

button:hover {
    transform: scale(1.05);
}

button:active {
    transform: scale(0.95);
}

/* Number Button Styles */
.btn-number {
    background: #404258;
    color: white;
}

.btn-number:hover {
    background: #6a6a6a;
}

/* Operator Button Styles */
.btn-operator {
    border-radius: 30px;
    font-size: 1.7rem;
    background: #f49d1a;
    color: white;
}

.btn-operator:hover {
    background: #ffad33;
}

.btn-operator.active {
    background: white;
    color: #ff9500;
}

/* Equals Button */
.btn-hashsign {
    background: #b9b7b7;
    color: black;
    width: 100%;
}

/* Delete/Backspace Button */
.btn-delete {
    background: #404258;
    color: white;
    font-size: 1.5rem;
}

/* Clear Button */
.btn-clear {
    background: #eca8db;
    color: black;
}

/* Error State */
.error {
    color: #ff6b6b;
}

/* History Section */
.history {
    background: #242530;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    width: 300px;
    max-width: 100%;
    border-radius: 20px;
    max-height: 500px;
    overflow-y: auto;
}

.history-title {
    color: white;
    font-size: 1.5rem;
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 2px solid #3a3f77;
    padding-bottom: 10px;
}

.history-item {
    background: #3a3f77;
    color: white;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: #525f73;
    transform: translateX(5px);
}

.history-expression {
    color: #ccc;
    font-size: 0.8rem;
}

.history-result {
    font-weight: bold;
    font-size: 1rem;
}

.clear-history {
    background: #eca8db;
    color: black;
    border: none;
    padding: 8px 15px;
    border-radius: 15px;
    cursor: pointer;
    margin-top: 10px;
    width: 100%;
    transition: all 0.2s ease;
}

.clear-history:hover {
    background: #d897c7;
    transform: scale(1.02);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        padding: 10px;
    }

    .calculator, .history {
        width: 100%;
        max-width: 400px;
    }
}

@media (max-width: 400px) {
    .calculator {
        padding: 15px;
    }

    button {
        height: 50px;
        font-size: 1rem;
    }

    .display {
        height: 70px;
        font-size: 1.5rem;
    }

    .buttons {
        gap: 8px;
    }

    .history {
        padding: 15px;
    }
}