/* ===== CSS VARIABLES ===== */
:root {
    --primary-bg: #1e1e2e;
    --secondary-bg: #2a2a3e;
    --display-bg: #16161f;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0b0;
    --btn-number: #3a3a4e;
    --btn-number-hover: #4a4a6e;
    --btn-operator: #ff9500;
    --btn-operator-hover: #ffad33;
    --btn-function: #505064;
    --btn-function-hover: #606074;
    --btn-equals: #34c759;
    --btn-equals-hover: #5dd879;
    --shadow: rgba(0, 0, 0, 0.3);
    --border-radius: 16px;
    --transition: all 0.2s ease;
}

/* ===== GLOBAL RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #000000 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ===== CONTAINER ===== */
.container {
    width: 100%;
    max-width: 400px;
}

/* ===== CALCULATOR ===== */
.calculator {
    background: var(--primary-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: 0 20px 60px var(--shadow);
    backdrop-filter: blur(10px);
}

/* ===== DISPLAY SECTION ===== */
.display-section {
    background: var(--display-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    word-wrap: break-word;
    word-break: break-all;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.previous-operand {
    color: var(--text-secondary);
    font-size: 1.2rem;
    min-height: 1.5rem;
    margin-bottom: 4px;
}

.current-operand {
    color: var(--text-primary);
    font-size: 2.5rem;
    font-weight: 300;
    min-height: 3rem;
    transition: var(--transition);
}

/* ===== BUTTONS GRID ===== */
.buttons-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

/* ===== BUTTON BASE STYLES ===== */
.btn {
    border: none;
    border-radius: 12px;
    font-size: 1.4rem;
    font-weight: 500;
    padding: 24px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.95);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn:active::before {
    width: 200px;
    height: 200px;
}

/* ===== BUTTON VARIANTS ===== */
.btn-number {
    background: var(--btn-number);
    color: var(--text-primary);
}

.btn-number:hover {
    background: var(--btn-number-hover);
}

.btn-operator {
    background: var(--btn-operator);
    color: white;
    font-size: 1.6rem;
}

.btn-operator:hover {
    background: var(--btn-operator-hover);
}

.btn-operator.active {
    background: var(--btn-operator-hover);
    box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.3);
}

.btn-function {
    background: var(--btn-function);
    color: var(--text-primary);
}

.btn-function:hover {
    background: var(--btn-function-hover);
}

.btn-equals {
    background: var(--btn-equals);
    color: white;
    font-size: 1.8rem;
}

.btn-equals:hover {
    background: var(--btn-equals-hover);
}

/* ===== SPAN VARIANTS ===== */
.span-2 {
    grid-column: span 2;
}

/* ===== KEYBOARD HINT ===== */
.keyboard-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 16px;
    opacity: 0.7;
}

/* ===== ANIMATIONS ===== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.error-shake {
    animation: shake 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.display-section {
    animation: fadeIn 0.3s ease;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 480px) {
    .calculator {
        padding: 16px;
    }
    
    .btn {
        padding: 20px;
        font-size: 1.2rem;
    }
    
    .current-operand {
        font-size: 2rem;
    }
    
    .previous-operand {
        font-size: 1rem;
    }
    
    .buttons-grid {
        gap: 8px;
    }
}

@media (max-width: 360px) {
    .btn {
        padding: 16px;
        font-size: 1rem;
    }
    
    .current-operand {
        font-size: 1.6rem;
    }
}

/* ===== ACCESSIBILITY ===== */
.btn:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}