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

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
    background: linear-gradient(45deg, #ff00ff, #00ffff, #ffff00, #ff00ff);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
}

/* Rolling gradient overlay */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(
            45deg,
            rgba(255, 0, 255, 0.3) 0%,
            rgba(0, 255, 255, 0.3) 25%,
            rgba(255, 255, 0, 0.3) 50%,
            rgba(0, 255, 0, 0.3) 75%,
            rgba(255, 0, 255, 0.3) 100%
        );
    background-size: 800% 800%;
    animation: psychedelicRoll 15s linear infinite;
    mix-blend-mode: screen;
    pointer-events: none;
    z-index: 2;
}

/* Spinning gradient overlay */
body::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        repeating-conic-gradient(
            from 0deg,
            rgba(255, 0, 128, 0.2) 0deg,
            rgba(0, 255, 255, 0.2) 90deg,
            rgba(128, 255, 0, 0.2) 180deg,
            rgba(255, 128, 255, 0.2) 270deg,
            rgba(255, 0, 128, 0.2) 360deg
        );
    animation: spinCrazy 20s linear infinite;
    mix-blend-mode: color-dodge;
    pointer-events: none;
    z-index: 3;
}

img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    height: 90vh;
    object-fit: contain;
    display: block;
    z-index: 1;
    animation: 
        breathe 4s ease-in-out infinite,
        rotate360 30s linear infinite,
        colorShift 6s ease-in-out infinite,
        pulse 2s ease-in-out infinite;
    filter: 
        hue-rotate(0deg) 
        saturate(1.5) 
        contrast(1.2) 
        brightness(1.1)
        drop-shadow(0 0 30px rgba(255, 0, 255, 0.8))
        drop-shadow(0 0 60px rgba(0, 255, 255, 0.6));
}

/* Gradient shift animation */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Psychedelic rolling effect */
@keyframes psychedelicRoll {
    0% { 
        background-position: 0% 0%;
        opacity: 0.6;
    }
    25% { opacity: 0.8; }
    50% { 
        background-position: 100% 100%;
        opacity: 0.6;
    }
    75% { opacity: 0.9; }
    100% { 
        background-position: 0% 0%;
        opacity: 0.6;
    }
}

/* Crazy spin animation */
@keyframes spinCrazy {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); }
}

/* Breathing effect */
@keyframes breathe {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
}

/* Rotation */
@keyframes rotate360 {
    0% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
    25% { transform: translate(-50%, -50%) rotate(90deg) scale(1.05); }
    50% { transform: translate(-50%, -50%) rotate(180deg) scale(1); }
    75% { transform: translate(-50%, -50%) rotate(270deg) scale(1.05); }
    100% { transform: translate(-50%, -50%) rotate(360deg) scale(1); }
}

/* Color shift */
@keyframes colorShift {
    0% { filter: hue-rotate(0deg) saturate(1.5) contrast(1.2) brightness(1.1)
        drop-shadow(0 0 30px rgba(255, 0, 255, 0.8))
        drop-shadow(0 0 60px rgba(0, 255, 255, 0.6)); }
    25% { filter: hue-rotate(90deg) saturate(2) contrast(1.3) brightness(1.2)
        drop-shadow(0 0 40px rgba(255, 255, 0, 0.9))
        drop-shadow(0 0 70px rgba(255, 0, 128, 0.7)); }
    50% { filter: hue-rotate(180deg) saturate(1.8) contrast(1.4) brightness(1.1)
        drop-shadow(0 0 35px rgba(0, 255, 255, 0.8))
        drop-shadow(0 0 65px rgba(128, 255, 0, 0.6)); }
    75% { filter: hue-rotate(270deg) saturate(2.2) contrast(1.2) brightness(1.3)
        drop-shadow(0 0 45px rgba(255, 128, 255, 0.9))
        drop-shadow(0 0 75px rgba(255, 255, 0, 0.7)); }
    100% { filter: hue-rotate(360deg) saturate(1.5) contrast(1.2) brightness(1.1)
        drop-shadow(0 0 30px rgba(255, 0, 255, 0.8))
        drop-shadow(0 0 60px rgba(0, 255, 255, 0.6)); }
}

/* Pulse effect */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* Calculator Container */
.calculator-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(10px);
    animation: floatCalculator 6s ease-in-out infinite;
}

@keyframes floatCalculator {
    0%, 100% { transform: translate(-50%, -50%) translateY(0px); }
    50% { transform: translate(-50%, -50%) translateY(-10px); }
}

.calculator {
    background: linear-gradient(135deg, rgba(15, 15, 35, 0.95), rgba(30,30,60,0.95));
    border-radius: 20px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(138, 43, 226, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    padding: 25px;
    min-width: 420px;
    border: 2px solid rgba(138, 43, 226, 0.3);
}

.calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(138, 43, 226, 0.3);
}

.calculator-header h2 {
    color: #fff;
    font-size: 22px;
    font-weight: 600;
    margin: 0;
    text-shadow: 0 0 10px rgba(138, 43, 226, 0.8);
}

.mode-indicator {
    background: linear-gradient(135deg, #8a2be2, #9b59b6);
    color: white;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(138, 43, 226, 0.4);
}

.display-container {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.6), rgba(20, 20, 40, 0.8));
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    border: 2px solid rgba(138, 43, 226, 0.4);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.memory-indicator {
    color: #ff6b6b;
    font-size: 11px;
    font-weight: bold;
    height: 16px;
    text-align: right;
    margin-bottom: 5px;
}

.expression {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    height: 22px;
    text-align: right;
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
}

.display {
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    text-align: right;
    font-weight: 300;
    font-family: 'Courier New', monospace;
    outline: none;
    text-shadow: 0 0 8px rgba(138, 43, 226, 0.6);
}

.calculator-buttons {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.btn {
    padding: 15px 8px;
    font-size: 14px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.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.3s, height 0.3s;
}

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

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

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

.btn-number {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: #fff;
}

.btn-number:hover {
    background: linear-gradient(135deg, #34495e, #3d566e);
}

.btn-operator {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
}

.btn-operator:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
}

.btn-function {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: #fff;
    font-size: 12px;
}

.btn-function:hover {
    background: linear-gradient(135deg, #2980b9, #21618c);
}

.btn-memory {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: #fff;
}

.btn-memory:hover {
    background: linear-gradient(135deg, #8e44ad, #7d3c98);
}

.btn-constant {
    background: linear-gradient(135deg, #16a085, #138d75);
    color: #fff;
}

.btn-constant:hover {
    background: linear-gradient(135deg, #138d75, #117a65);
}

.btn-equals {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: #fff;
    font-size: 20px;
}

.btn-equals:hover {
    background: linear-gradient(135deg, #229954, #1e8449);
}

/* Calculator Glow Animation */
@keyframes calculatorGlow {
    0%, 100% {
        box-shadow: 
            0 20px 60px rgba(0, 0, 0, 0.5),
            0 0 40px rgba(138, 43, 226, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    50% {
        box-shadow: 
            0 20px 60px rgba(0, 0, 0, 0.5),
            0 0 60px rgba(138, 43, 226, 0.8),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
}

.calculator {
    animation: calculatorGlow 3s ease-in-out infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    .calculator {
        min-width: 340px;
        padding: 15px;
    }
    
    .calculator-buttons {
        gap: 6px;
    }
    
    .btn {
        padding: 12px 6px;
        font-size: 12px;
    }
    
    .btn-function {
        font-size: 10px;
    }
}
