@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,100..900;1,100..900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

body {
    font-family: 'Inter', 'Segoe UI', 'Poppins', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ========== GRADIENT BACKGROUND - Purple to Blue ========== */
.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #4facfe 75%, #00f2fe 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    z-index: -2;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Animated Blobs for Depth */
.blob {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s ease-in-out infinite;
}

.blob-1 {
    background: rgba(255, 255, 255, 0.3);
    top: 10%;
    left: -100px;
    animation-delay: 0s;
}

.blob-2 {
    background: rgba(255, 255, 255, 0.2);
    bottom: 10%;
    right: -100px;
    animation-delay: -5s;
    width: 400px;
    height: 400px;
}

.blob-3 {
    background: rgba(255, 255, 255, 0.15);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -30px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

.container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* ========== GLASSMORPHISM EFFECT - Frosted Glass ========== */
.calculator-glass {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 40px;
    box-shadow: 
        0 25px 45px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.2),
        inset 0 1px 1px rgba(255, 255, 255, 0.3);
    padding: 25px;
    width: 100%;
    max-width: 500px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.calculator-glass:hover {
    transform: translateY(-5px);
    box-shadow: 
        0 35px 55px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

/* ========== DARK DISPLAY - High Contrast ========== */
.display {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    padding: 25px 20px;
    margin-bottom: 25px;
    text-align: right;
    word-wrap: break-word;
    word-break: break-all;
    box-shadow: 
        inset 0 2px 5px rgba(0, 0, 0, 0.3),
        0 5px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.previous-operand {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1rem;
    min-height: 28px;
    margin-bottom: 8px;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.current-operand {
    color: #ffffff;
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 1px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.current-operand::-webkit-scrollbar {
    height: 4px;
}

.current-operand::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.current-operand::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

/* ========== RESPONSIVE GRID - Perfect Button Layout ========== */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

/* ========== BUTTON STYLES ========== */
.btn {
    position: relative;
    padding: 20px 15px;
    font-size: 1.3rem;
    font-weight: 600;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

/* Button Ripple Effect */
.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.btn:active::before {
    width: 100%;
    height: 100%;
}

/* ========== HOVER EFFECTS - Interactive Button States ========== */
.btn-number {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn-number:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-number:active {
    transform: translateY(0px);
}

/* Operator Buttons */
.btn-operator {
    background: rgba(255, 165, 0, 0.3);
    color: white;
    border: 1px solid rgba(255, 165, 0, 0.4);
    box-shadow: 0 4px 15px rgba(255, 165, 0, 0.2);
}

.btn-operator:hover {
    background: rgba(255, 165, 0, 0.5);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 165, 0, 0.3);
    border-color: rgba(255, 165, 0, 0.6);
}

/* Special Buttons (AC, DEL) */
.btn-special {
    background: rgba(220, 38, 38, 0.3);
    color: white;
    border: 1px solid rgba(220, 38, 38, 0.4);
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.2);
}

.btn-special:hover {
    background: rgba(220, 38, 38, 0.5);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(220, 38, 38, 0.3);
    border-color: rgba(220, 38, 38, 0.6);
}

/* Equals Button */
.btn-equals {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.4), rgba(16, 185, 129, 0.4));
    color: white;
    border: 1px solid rgba(34, 197, 94, 0.5);
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.2);
    grid-column: span 1;
}

.btn-equals:hover {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.6), rgba(16, 185, 129, 0.6));
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.3);
    border-color: rgba(34, 197, 94, 0.7);
}

/* Zero Button */
.zero {
    grid-column: span 1;
}

/* ========== SMOOTH ANIMATIONS - Button Press Effects ========== */
.btn-press {
    animation: buttonPress 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes buttonPress {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.92);
    }
    100% {
        transform: scale(1);
    }
}

/* Glow effect on hover */
.btn:hover {
    animation: glow 1s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
    }
    to {
        box-shadow: 0 8px 25px rgba(255, 255, 255, 0.2);
    }
}

/* Keyboard Hint */
.keyboard-hint {
    margin-top: 20px;
    text-align: center;
}

.hint-content {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 50px;
    color: white;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.hint-content:hover {
    background: rgba(0, 0, 0, 0.4);
    transform: scale(1.05);
}

.hint-icon {
    font-size: 1.2rem;
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 600px) {
    .calculator-glass {
        padding: 20px;
    }
    
    .btn {
        padding: 15px 12px;
        font-size: 1.1rem;
    }
    
    .current-operand {
        font-size: 2rem;
    }
    
    .previous-operand {
        font-size: 0.9rem;
    }
    
    .buttons {
        gap: 10px;
    }
    
    .hint-content {
        font-size: 0.7rem;
        padding: 8px 15px;
    }
}

@media (max-width: 450px) {
    .calculator-glass {
        padding: 15px;
    }
    
    .buttons {
        gap: 8px;
    }
    
    .btn {
        padding: 12px 10px;
        font-size: 1rem;
        border-radius: 15px;
    }
    
    .display {
        padding: 20px 15px;
        margin-bottom: 20px;
    }
    
    .current-operand {
        font-size: 1.8rem;
    }
}

@media (max-width: 380px) {
    .buttons {
        gap: 6px;
    }
    
    .btn {
        padding: 10px 8px;
        font-size: 0.9rem;
    }
    
    .hint-content {
        font-size: 0.6rem;
    }
}

/* Focus styles for accessibility */
.btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* Error animation */
.error-shake {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Loading animation for buttons */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .btn:hover {
        transform: none;
    }
    
    .btn:active {
        transform: scale(0.95);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .display {
        background: rgba(0, 0, 0, 0.9);
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid white;
    }
    
    .display {
        border: 2px solid white;
    }
}