:root {
    --primary-color: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --scientific-color: #8b5cf6;
    --background-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

body {
    background: var(--background-gradient);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.calculator-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 380px;
    width: 100%;
    transition: all 0.3s ease;
}

.calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

.calculator-header h1 {
    color: white;
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.mode-indicator {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

#modeText {
    color: var(--scientific-color);
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
}

#angleMode {
    color: var(--warning-color);
    font-size: 0.7rem;
    font-weight: 500;
}

.expression-display {
    width: 100%;
    min-height: 25px;
    color: rgba(255, 255, 255, 0.8);
    text-align: right;
    padding: 0 15px;
    font-size: 0.9rem;
    font-weight: 400;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.display-container {
    margin-bottom: 25px;
}

.display {
    width: 100%;
    height: 80px;
    border: none;
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.25);
    color: white;
    text-align: right;
    padding: 0 20px;
    font-size: 2.2rem;
    font-weight: 300;
    font-family: 'Segoe UI', system-ui, sans-serif;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.display:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

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

.btn {
    height: 60px;
    border: none;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 500;
    font-family: 'Segoe UI', system-ui, sans-serif;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

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

.btn:active::after {
    width: 100px;
    height: 100px;
}

/* Number Buttons */
.btn-number {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-number:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.1);
}

/* Operator Buttons */
.btn-operator {
    background: rgba(59, 130, 246, 0.25);
    color: #bfdbfe;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.btn-operator:hover {
    background: rgba(59, 130, 246, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.2);
}

/* Function Buttons */
.btn-function {
    background: rgba(245, 158, 11, 0.25);
    color: #fde68a;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.btn-function:hover {
    background: rgba(245, 158, 11, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 158, 11, 0.2);
}

/* Equals Button */
.btn-equals {
    background: rgba(16, 185, 129, 0.25);
    color: #a7f3d0;
    border: 1px solid rgba(16, 185, 129, 0.4);
    grid-row: span 2;
}

.btn-equals:hover {
    background: rgba(16, 185, 129, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.2);
}

/* Scientific Mode Toggle */
.btn-scientific {
    background: rgba(139, 92, 246, 0.25);
    color: #ddd6fe;
    border: 1px solid rgba(139, 92, 246, 0.4);
    font-weight: 600;
}

.btn-scientific:hover {
    background: rgba(139, 92, 246, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 92, 246, 0.2);
}

/* Scientific Function Buttons */
.btn-sci-function {
    background: rgba(6, 182, 212, 0.25);
    color: #a5f3fc;
    border: 1px solid rgba(6, 182, 212, 0.4);
    font-size: 0.95rem;
    font-weight: 500;
}

.btn-sci-function:hover {
    background: rgba(6, 182, 212, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(6, 182, 212, 0.2);
}

/* Back to Basic Button */
.btn-back {
    background: rgba(239, 68, 68, 0.25);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.4);
    font-weight: 600;
    grid-column: span 2;
}

.btn-back:hover {
    background: rgba(239, 68, 68, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.2);
}

/* Scientific Buttons Container */
.scientific-buttons {
    margin-top: 15px;
    animation: slideUp 0.3s ease;
}

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

/* Active State */
.btn:active {
    transform: translateY(0) scale(0.95);
}

/* Responsive Design */
@media (max-width: 480px) {
    .calculator-card {
        padding: 20px;
        max-width: 340px;
    }
    
    .display {
        height: 70px;
        font-size: 1.8rem;
        padding: 0 15px;
    }
    
    .expression-display {
        font-size: 0.8rem;
        padding: 0 10px;
    }
    
    .btn {
        height: 55px;
        font-size: 1rem;
    }
    
    .buttons-grid {
        gap: 10px;
    }
    
    .calculator-header h1 {
        font-size: 1.2rem;
    }
}

@media (max-width: 360px) {
    .calculator-card {
        padding: 15px;
        max-width: 300px;
    }
    
    .btn {
        height: 50px;
        font-size: 0.9rem;
    }
    
    .buttons-grid {
        gap: 8px;
    }
}