:root {
    --primary-purple: rgba(177, 156, 217, 0.6);
    --secondary-purple: rgba(195, 177, 225, 0.8);
    --accent-purple: rgba(221, 160, 221, 0.7);
    --dark-purple: rgba(102, 51, 153, 0.4);
    --light-purple: rgba(230, 220, 250, 0.5);
    --text-color: #4b2e83;
    --glass-blur: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #e6e6fa 0%, #d8bfd8 50%, #dda0dd 100%);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

.calculator {
    position: relative;
    width: 340px;
    backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    background: linear-gradient(145deg, var(--light-purple), var(--primary-purple));
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2),
                0 0 30px rgba(255, 255, 255, 0.3) inset;
    padding: 25px;
    transition: box-shadow 0.3s ease;
    z-index: 10;
    overflow: hidden;
}

.calculator:hover {
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3),
                0 0 40px rgba(255, 255, 255, 0.4) inset;
}

.calculator::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 70%);
    transform: rotate(30deg);
    pointer-events: none;
}

.display-container {
    position: relative;
    width: 100%;
    height: 100px;
    margin-bottom: 10px;
    overflow: hidden;
    border-radius: 15px;
}

.display {
    width: 100%;
    height: 100%;
    padding: 15px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1) inset;
    text-align: right;
    font-size: 2.8em;
    font-weight: 300;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
}

.display::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
}

.hp-logo {
    display: flex;
    justify-content: center;
    margin: 5px 0 15px;
}

.hp-logo span {
    font-size: 10px;
    font-weight: bold;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.3);
    padding: 2px 5px;
    border-radius: 3px;
    letter-spacing: 1px;
}

.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 15px;
}

button {
    position: relative;
    height: 65px;
    border: none;
    border-radius: 15px;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: var(--text-color);
    font-weight: 500;
    overflow: hidden;
    z-index: 1;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.4), rgba(255,255,255,0.1));
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

button:hover::before {
    opacity: 1;
}

button:active {
    transform: scale(0.95);
}

.number {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.number:hover {
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.operator {
    background: var(--primary-purple);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.operator:hover {
    background: var(--secondary-purple);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.equals {
    background: linear-gradient(135deg, var(--accent-purple), var(--dark-purple));
    border: 1px solid rgba(255, 255, 255, 0.7);
    color: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.equals:hover {
    background: linear-gradient(135deg, var(--dark-purple), var(--accent-purple));
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.clear {
    background: rgba(255, 182, 193, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.clear:hover {
    background: rgba(255, 182, 193, 0.6);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.special {
    background: rgba(200, 160, 220, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.special:hover {
    background: rgba(200, 160, 220, 0.6);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.history-panel {
    position: absolute;
    top: 0;
    right: -100%;
    width: 80%;
    height: 100%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 0 30px 30px 0;
    padding: 20px;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow-y: auto;
    z-index: 5;
}

.history-panel.active {
    right: 0;
}

.history-item {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    font-size: 0.9em;
}

.clear-history {
    width: 100%;
    padding: 10px;
    margin-top: 15px;
    background: rgba(255, 182, 193, 0.5);
    border: none;
    border-radius: 10px;
    color: var(--text-color);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-history:hover {
    background: rgba(255, 182, 193, 0.7);
}

@media (max-width: 480px) {
    .calculator {
        width: 90%;
        padding: 15px;
    }
    
    button {
        height: 55px;
        font-size: 1.3em;
    }
}