@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700&display=swap');

:root {
    --primary-color: #00f7ff;
    --secondary-color: #ff00e4;
    --background-color: #0f1218;
    --button-bg: rgba(255, 255, 255, 0.05);
    --button-hover: rgba(255, 255, 255, 0.1);
    --display-bg: rgba(0, 0, 0, 0.5);
    --text-color: #fff;
    --number-color: #fff;
    --operator-color: #00f7ff;
    --equals-color: #ff00e4;
    --function-color: #ffd500;
}

.dark-theme {
    --primary-color: #1ee3cf;
    --secondary-color: #9c27b0;
    --background-color: #121212;
    --button-bg: rgba(255, 255, 255, 0.05);
    --button-hover: rgba(255, 255, 255, 0.1);
    --display-bg: rgba(0, 0, 0, 0.6);
    --text-color: #e0e0e0;
    --number-color: #e0e0e0;
    --operator-color: #1ee3cf;
    --equals-color: #9c27b0;
    --function-color: #ffab00;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Orbitron', sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--background-color);
    color: var(--text-color);
    overflow: hidden;
    transition: all 0.3s ease;
}

.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.circle {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    filter: blur(60px);
    opacity: 0.3;
    animation: float 20s infinite alternate;
}

.circle:nth-child(1) {
    width: 300px;
    height: 300px;
    top: -150px;
    left: -150px;
    animation-duration: 25s;
}

.circle:nth-child(2) {
    width: 400px;
    height: 400px;
    bottom: -200px;
    right: -200px;
    animation-duration: 30s;
    animation-delay: 2s;
}

.circle:nth-child(3) {
    width: 250px;
    height: 250px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-duration: 20s;
    animation-delay: 1s;
}

.lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        90deg,
        rgba(0, 247, 255, 0.03) 0px,
        rgba(0, 247, 255, 0.03) 1px,
        transparent 1px,
        transparent 20px
    ),
    repeating-linear-gradient(
        0deg,
        rgba(0, 247, 255, 0.03) 0px,
        rgba(0, 247, 255, 0.03) 1px,
        transparent 1px,
        transparent 20px
    );
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(100px, 100px) scale(1.2);
    }
    100% {
        transform: translate(-100px, -50px) scale(0.8);
    }
}

.container {
    display: flex;
    position: relative;
    perspective: 1000px;
}

.calculator {
    width: 320px;
    background: rgba(15, 18, 24, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 0 20px rgba(0, 247, 255, 0.2),
                0 0 40px rgba(255, 0, 228, 0.1);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform-style: preserve-3d;
    transition: all 0.5s ease;
}

.calculator:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 30px rgba(0, 247, 255, 0.3),
                0 0 60px rgba(255, 0, 228, 0.2);
}

.display-container {
    padding: 20px;
    background: var(--display-bg);
    height: 120px;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.6);
    height: 20px;
    text-align: right;
    margin-bottom: 10px;
    overflow: hidden;
}

.display {
    font-size: 42px;
    text-align: right;
    height: 50px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    position: relative;
    animation: glow 2s infinite alternate;
}

@keyframes glow {
    0% {
        text-shadow: 0 0 5px rgba(0, 247, 255, 0.5);
    }
    100% {
        text-shadow: 0 0 15px rgba(0, 247, 255, 0.8),
                     0 0 30px rgba(0, 247, 255, 0.4);
    }
}

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

.button {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    background: var(--button-bg);
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    font-size: 20px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
    z-index: 0;
}

.button:hover::before {
    width: 150px;
    height: 150px;
}

.button:active {
    transform: scale(0.95);
}

.number {
    color: var(--number-color);
}

.operator {
    color: var(--operator-color);
    font-weight: 700;
}

.equals {
    color: var(--equals-color);
    font-weight: 700;
    background: linear-gradient(135deg, rgba(255, 0, 228, 0.2), rgba(255, 0, 228, 0.05));
}

.function {
    color: var(--function-color);
}

.button:hover {
    background: var(--button-hover);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.scientific-panel {
    width: 0;
    height: 380px;
    background: rgba(15, 18, 24, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 0 20px rgba(0, 247, 255, 0.2);
    overflow: hidden;
    margin-left: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.6, 0.32, 1.6);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
}

.scientific-panel.open {
    width: 240px;
    margin-left: 20px;
    opacity: 1;
}

.toggle-scientific {
    position: absolute;
    right: -50px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 247, 255, 0.3);
    transition: all 0.3s ease;
}

.toggle-scientific:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.theme-switch {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 247, 255, 0.3);
    transition: all 0.3s ease;
    z-index: 100;
}

.theme-switch:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .scientific-panel {
        height: 0;
        width: 320px;
        margin-left: 0;
        margin-top: 0;
    }
    
    .scientific-panel.open {
        height: 240px;
        width: 320px;
        margin-top: 20px;
        margin-left: 0;
    }
    
    .toggle-scientific {
        right: 20px;
        top: 20px;
        transform: none;
    }
}