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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.calculator-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    overflow: hidden;
    max-width: 400px;
    width: 100%;
}

.calculator-header {
    background: linear-gradient(135deg, #2ECC71 0%, #F39C12 100%);
    padding: 20px;
    text-align: center;
    color: white;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.logo {
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-border {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

.operation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    width: 30px;
    height: 30px;
}

.op-btn {
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
}

.op-btn.add { background: #3498DB; }
.op-btn.subtract { background: #F39C12; }
.op-btn.multiply { background: #E74C3C; }
.op-btn.divide { background: #2ECC71; }

.calculator-header h1 {
    font-size: 24px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mode-toggle {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.mode-btn {
    padding: 8px 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    color: white;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.calculator {
    padding: 20px;
}

.display-section {
    background: #1a1a1a;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    color: white;
}

.history-display {
    min-height: 30px;
    margin-bottom: 10px;
    overflow-y: auto;
    max-height: 100px;
}

.history-content {
    font-size: 14px;
    color: #888;
    text-align: right;
}

.main-display {
    text-align: right;
}

.expression-display {
    font-size: 18px;
    color: #ccc;
    margin-bottom: 5px;
    min-height: 22px;
}

.result-display {
    font-size: 32px;
    font-weight: 300;
    color: #fff;
    min-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.memory-section {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(46, 204, 113, 0.1);
    border-radius: 10px;
}

.memory-btn {
    padding: 8px 12px;
    border: 1px solid #2ECC71;
    background: transparent;
    color: #2ECC71;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.memory-btn:hover {
    background: #2ECC71;
    color: white;
}

.memory-value {
    font-size: 12px;
    color: #666;
    margin-left: auto;
}

.buttons-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.scientific-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    transition: all 0.3s ease;
}

.scientific-row.hidden {
    display: none;
}

.btn {
    height: 60px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

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

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

.btn:active::before {
    width: 100%;
    height: 100%;
}

.number-btn {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e9ecef;
}

.number-btn:hover {
    background: #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.number-btn.zero {
    grid-column: span 1;
}

.operator-btn {
    background: linear-gradient(135deg, #F39C12, #E67E22);
    color: white;
    font-weight: 600;
}

.operator-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.operator-btn.active {
    background: linear-gradient(135deg, #E67E22, #D35400);
    transform: scale(1.05);
}

.function-btn {
    background: linear-gradient(135deg, #95A5A6, #7F8C8D);
    color: white;
    font-weight: 600;
}

.function-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(149, 165, 166, 0.4);
}

.equals-btn {
    background: linear-gradient(135deg, #2ECC71, #27AE60);
    color: white;
    font-weight: 700;
    font-size: 24px;
}

.equals-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
}

.scientific-btn {
    background: linear-gradient(135deg, #3498DB, #2980B9);
    color: white;
    font-weight: 600;
    font-size: 14px;
    height: 50px;
}

.scientific-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.history-panel {
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-header h3 {
    font-size: 18px;
    color: #333;
}

.clear-history-btn {
    padding: 6px 12px;
    background: #E74C3C;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.clear-history-btn:hover {
    background: #C0392B;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-item:hover {
    background: #f1f3f4;
    transform: translateX(4px);
}

.history-expression {
    font-size: 14px;
    color: #666;
    margin-bottom: 2px;
}

.history-result {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.no-history {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px;
}

.error {
    color: #E74C3C !important;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Responsive Design */
@media (max-width: 480px) {
    .calculator-container {
        max-width: 100%;
        margin: 10px;
    }
    
    .btn {
        height: 50px;
        font-size: 16px;
    }
    
    .result-display {
        font-size: 28px;
    }
    
    .expression-display {
        font-size: 16px;
    }
    
    .scientific-btn {
        height: 40px;
        font-size: 12px;
    }
    
    .calculator-header h1 {
        font-size: 20px;
    }
    
    .logo-border {
        width: 50px;
        height: 50px;
    }
    
    .operation-grid {
        width: 25px;
        height: 25px;
    }
    
    .op-btn {
        font-size: 8px;
    }
}

@media (max-width: 360px) {
    .calculator {
        padding: 15px;
    }
    
    .btn {
        height: 45px;
        font-size: 14px;
    }
    
    .result-display {
        font-size: 24px;
    }
    
    .buttons-container {
        gap: 8px;
    }
    
    .button-row {
        gap: 8px;
    }
    
    .scientific-row {
        gap: 8px;
    }
}
