* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden;
}

.calculator-container {
    width: 100%;
    max-width: 900px;
    height: 95vh;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeIn 0.8s ease;
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.calculator-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.calculator-header {
    background: linear-gradient(90deg, #ff6b6b, #ffa36c);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.calculator-title {
    font-weight: 700;
    font-size: 1.4rem;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

.mode-control {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mode-toggle {
    position: relative;
    width: 70px;
    height: 30px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.toggle-slider {
    position: absolute;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.mode-text {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 5px;
    text-align: center;
}

.display-container {
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.display {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 15px;
    text-align: right;
    font-size: 2rem;
    font-weight: 600;
    color: #333;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    word-break: break-all;
}

.previous-operand {
    font-size: 1rem;
    color: #666;
    margin-bottom: 5px;
    min-height: 20px;
}

.current-operand {
    font-size: 1.8rem;
    color: #222;
}

.buttons-container {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    flex: 1;
    overflow-y: auto;
}

.button {
    height: 60px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #4e54c8, #8f94fb);
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

.button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.button:active {
    transform: translateY(1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.operator {
    background: linear-gradient(135deg, #ff6b6b, #ffa36c);
}

.equals {
    background: linear-gradient(135deg, #00b09b, #96c93d);
}

.clear, .delete {
    background: linear-gradient(135deg, #ff416c, #ff4b2b);
}

.scientific-button {
    background: linear-gradient(135deg, #8e2de2, #4a00e0);
}

.history-button {
    background: linear-gradient(135deg, #11998e, #38ef7d);
}

.hidden {
    display: none;
}

.span-two {
    grid-column: span 2;
}

.creator {
    text-align: center;
    padding: 15px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.creator span {
    color: #ffa36c;
    font-weight: 600;
}

/* Animation for button press */
@keyframes buttonPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.button.pressed {
    animation: buttonPress 0.2s ease;
}

/* Scientific mode specific styling */
.scientific-buttons {
    grid-template-columns: repeat(5, 1fr);
}

/* History Panel */
.history-panel {
    width: 300px;
    background: rgba(0, 0, 0, 0.3);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.history-header {
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-title {
    font-weight: 600;
    font-size: 1.2rem;
}

.history-clear {
    background: transparent;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.2s ease;
}

.history-clear:hover {
    background: rgba(255, 107, 107, 0.2);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.history-item {
    padding: 12px 15px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid #ffa36c;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(5px);
}

.history-expression {
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 5px;
}

.history-result {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffa36c;
}

.history-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 20px;
    font-style: italic;
}

/* Swipe arrows */
.swipe-indicator {
    display: none;
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.5rem;
    animation: bounce 1.5s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50% { transform: translateY(-50%) translateX(5px); }
}

/* Responsive design */
@media (max-width: 768px) {
    .calculator-container {
        height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }
    
    .history-panel {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 85%;
        transform: translateX(100%);
        z-index: 10;
    }
    
    .history-panel.active {
        transform: translateX(0);
    }
    
    .swipe-indicator {
        display: block;
    }
    
    .buttons-container {
        gap: 10px;
        padding: 15px;
    }
    
    .button {
        height: 50px;
        font-size: 1rem;
    }
    
    .display {
        font-size: 1.6rem;
        padding: 12px;
    }
    
    .scientific-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 480px) {
    .calculator-header {
        padding: 10px 15px;
    }
    
    .calculator-title {
        font-size: 1.2rem;
    }
    
    .buttons-container {
        gap: 8px;
        padding: 10px;
    }
    
    .button {
        height: 45px;
        font-size: 0.9rem;
    }
    
    .scientific-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
}