:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --dark-bg: #0f0f23;
    --darker-bg: #05050f;
    --display-bg: rgba(15, 15, 35, 0.8);
    --button-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    --button-hover-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
    --glow-color: rgba(102, 126, 234, 0.4);
}

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

body {
    font-family: 'Rajdhani', sans-serif;
    background: var(--dark-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(79, 172, 254, 0.1) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -50px) rotate(120deg); }
    66% { transform: translate(-20px, 20px) rotate(240deg); }
}

.container {
    position: relative;
    z-index: 1;
    animation: slideIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.calculator {
    background: rgba(15, 15, 35, 0.7);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    padding: 30px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 0 40px rgba(102, 126, 234, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 400px;
    width: 100%;
}

.display-container {
    background: var(--display-bg);
    border-radius: 20px;
    padding: 30px 25px;
    margin-bottom: 25px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    border: 1px solid rgba(102, 126, 234, 0.2);
    box-shadow: 
        inset 0 2px 10px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(102, 126, 234, 0.1);
    position: relative;
    overflow: hidden;
}

.display-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.5), transparent);
}

.previous-operand {
    font-family: 'Orbitron', monospace;
    font-size: 1.3rem;
    color: rgba(102, 126, 234, 0.6);
    margin-bottom: 8px;
    min-height: 25px;
    font-weight: 400;
    letter-spacing: 1px;
}

.current-operand {
    font-family: 'Orbitron', monospace;
    font-size: 2.8rem;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 2px;
    text-shadow: 0 0 20px var(--glow-color);
    word-wrap: break-word;
    word-break: break-all;
}

.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.btn {
    font-family: 'Orbitron', monospace;
    font-size: 1.5rem;
    font-weight: 600;
    padding: 25px;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: var(--button-shadow);
    position: relative;
    overflow: hidden;
    color: #ffffff;
    letter-spacing: 1px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--button-hover-shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn-number {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.btn-number:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.5) 0%, rgba(118, 75, 162, 0.5) 100%);
    border-color: rgba(102, 126, 234, 0.6);
}

.btn-operator {
    background: var(--primary-gradient);
    font-size: 1.8rem;
    font-weight: 700;
}

.btn-operator:hover {
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.7);
}

.btn-function {
    background: linear-gradient(135deg, rgba(245, 87, 108, 0.4) 0%, rgba(240, 147, 251, 0.4) 100%);
    border: 1px solid rgba(245, 87, 108, 0.4);
    font-size: 1.3rem;
}

.btn-function:hover {
    background: linear-gradient(135deg, rgba(245, 87, 108, 0.6) 0%, rgba(240, 147, 251, 0.6) 100%);
    border-color: rgba(245, 87, 108, 0.6);
}

.btn-equals {
    background: var(--accent-gradient);
    font-size: 2rem;
    font-weight: 900;
}

.btn-equals:hover {
    box-shadow: 0 6px 30px rgba(79, 172, 254, 0.8);
}

.btn-zero {
    grid-column: span 2;
}

/* Responsive Design */
@media (max-width: 480px) {
    .calculator {
        padding: 20px;
        border-radius: 20px;
    }
    
    .display-container {
        padding: 20px 15px;
        min-height: 120px;
    }
    
    .previous-operand {
        font-size: 1.1rem;
    }
    
    .current-operand {
        font-size: 2.2rem;
    }
    
    .btn {
        padding: 20px;
        font-size: 1.3rem;
    }
    
    .btn-operator {
        font-size: 1.6rem;
    }
    
    .btn-equals {
        font-size: 1.8rem;
    }
}

/* Accessibility */
.btn:focus {
    outline: 2px solid rgba(102, 126, 234, 0.8);
    outline-offset: 2px;
}

/* Animation for display updates */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.current-operand.updated {
    animation: pulse 0.2s ease-out;
}
