/* ============================================
   CASIO FX-86 STYLE SCIENTIFIC CALCULATOR
   CAS-style with fraction/power input boxes
   Responsive design for all devices
   ============================================ */

/* CSS Variables for theming */
:root {
    --calc-body-bg: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #0d0d0d 100%);
    --calc-body-border: #444;
    --calc-display-bg: linear-gradient(180deg, #c8d8c0 0%, #a8c8a0 100%);
    --calc-display-text: #1a1a1a;
    --calc-btn-number: linear-gradient(145deg, #f5f5f5 0%, #e0e0e0 100%);
    --calc-btn-number-hover: linear-gradient(145deg, #ffffff 0%, #f0f0f0 100%);
    --calc-btn-op: linear-gradient(145deg, #4a90d9 0%, #3a7bc8 100%);
    --calc-btn-op-hover: linear-gradient(145deg, #5aa0e9 0%, #4a8bd8 100%);
    --calc-btn-function: linear-gradient(145deg, #6b6b6b 0%, #4a4a4a 100%);
    --calc-btn-function-hover: linear-gradient(145deg, #7b7b7b 0%, #5a5a5a 100%);
    --calc-btn-shift: linear-gradient(145deg, #f9a825 0%, #f57f17 100%);
    --calc-btn-alpha: linear-gradient(145deg, #e53935 0%, #c62828 100%);
    --calc-btn-equals: linear-gradient(145deg, #43a047 0%, #2e7d32 100%);
    --calc-btn-clear: linear-gradient(145deg, #ef5350 0%, #e53935 100%);
    --calc-btn-on: linear-gradient(145deg, #66bb6a 0%, #43a047 100%);
    --calc-btn-nav: linear-gradient(145deg, #7c4dff 0%, #651fff 100%);
    --calc-btn-nav-hover: linear-gradient(145deg, #9c7dff 0%, #854fff 100%);
    --calc-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --calc-btn-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --calc-btn-shadow-active: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Main Calculator Container */
#calculatorbody {
    position: absolute;
    display: none;
    z-index: 99999999999;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
    touch-action: none;
}

.scientific-calculator {
    background: var(--calc-body-bg);
    border-radius: 20px;
    padding: clamp(8px, 2vh, 15px);
    box-shadow: var(--calc-shadow);
    border: 2px solid var(--calc-body-border);
    width: min(380px, 95vw);
    max-height: calc(100vh - 100px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: min(800px, 85vh);
}

/* Calculator Header / Drag Handle */
.calc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(3px, 0.8vh, 8px) 10px;
    margin-bottom: clamp(3px, 0.8vh, 10px);
    cursor: move;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    border-radius: 10px;
    touch-action: none;
}

.calc-brand-icon {
    width: clamp(24px, 4vh, 36px);
    height: clamp(24px, 4vh, 36px);
    border-radius: 6px;
    margin-right: 8px;
    flex-shrink: 0;
}

.calc-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.calc-brand-name {
    font-size: clamp(10px, 1.8vh, 14px);
    font-weight: 700;
    color: #fff;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin:0 auto;
}

.calc-model {
    font-size: clamp(8px, 1.2vh, 10px);
    color: #888;
    letter-spacing: 1px;
}

.calc-close-btn {
    width: clamp(22px, 3.5vh, 28px);
    height: clamp(22px, 3.5vh, 28px);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: clamp(14px, 2.2vh, 18px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.calc-close-btn:hover {
    background: rgba(239, 83, 80, 0.8);
}

/* Display Area */
.calc-display-container {
    background: #1a1a1a;
    border-radius: 12px;
    padding: clamp(3px, 0.8vh, 8px);
    margin-bottom: clamp(3px, 0.8vh, 10px);
    flex-shrink: 1;
    min-height: 0;
}

.calc-display {
    background: var(--calc-display-bg);
    border-radius: 8px;
    padding: clamp(4px, 1vh, 10px) 10px;
    min-height: clamp(50px, 10vh, 100px);
    position: relative;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.calc-display-mode {
    display: flex;
    justify-content: space-between;
    font-size: clamp(8px, 1.2vh, 10px);
    color: #555;
    margin-bottom: clamp(2px, 0.5vh, 8px);
    font-weight: 600;
}

.calc-display-mode span {
    padding: 1px 4px;
    border-radius: 3px;
}

.calc-display-mode span.active {
    background: rgba(0, 0, 0, 0.2);
}

.calc-expression {
    font-size: clamp(16px, 2.5vh, 22px);
    color: #333;
    min-height: clamp(44px, 6.6vh, 64px);
    text-align: left;
    font-family: 'Courier New', monospace;
    margin-bottom: clamp(2px, 0.5vh, 4px);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: clamp(2px, 0.5vh, 4px) 0;
    line-height: 1.4;
}

/* Expression Input Box (for structured input) */
.calc-input-area {
    font-size: clamp(14px, 2.2vh, 18px);
    color: #1a1a1a;
    min-height: clamp(24px, 4vh, 36px);
    text-align: left;
    font-family: 'Courier New', monospace;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1px;
    padding: clamp(3px, 0.8vh, 6px) 4px;
    line-height: 1.2;
    overflow-x: auto;
    overflow-y: visible;
}

.calc-result {
    font-size: clamp(20px, 3.2vh, 28px);
    font-weight: 600;
    color: var(--calc-display-text);
    text-align: right;
    font-family: 'Courier New', monospace;
    overflow-x: auto;
    white-space: nowrap;
    min-height: clamp(18px, 3vh, 28px);
    border-top: 1px solid rgba(0,0,0,0.15);
    padding-top: clamp(3px, 0.8vh, 6px);
    margin-top: clamp(2px, 0.5vh, 4px);
}

/* Cursor styling */
.calc-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: #1a1a1a;
    animation: cursorBlink 1s infinite;
    vertical-align: middle;
    margin: 0 1px;
}

@keyframes cursorBlink {
    0%, 45% { opacity: 1; }
    50%, 95% { opacity: 0; }
    100% { opacity: 1; }
}

/* Fraction box styling */
.calc-fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 3px;
    position: relative;
}

.calc-fraction-num,
.calc-fraction-den {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    min-height: 18px;
    padding: 2px 4px;
    font-size: 0.85em;
    position: relative;
}

.calc-fraction-num {
    border-bottom: 2px solid #1a1a1a;
    padding-bottom: 3px;
}

.calc-fraction-den {
    padding-top: 3px;
}

.calc-fraction-num.active,
.calc-fraction-den.active {
    background: rgba(74, 144, 217, 0.2);
    border-radius: 3px;
}

/* Empty box placeholder */
.calc-box-empty {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1px dashed rgba(26, 26, 26, 0.4);
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.3);
}

/* Power (exponent) box styling */
.calc-power {
    display: inline-flex;
    align-items: flex-start;
    vertical-align: middle;
    position: relative;
}

.calc-power-base {
    display: flex;
    align-items: center;
}

.calc-power-exp {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 12px;
    min-height: 12px;
    padding: 1px 3px;
    font-size: 0.7em;
    position: relative;
    top: -0.5em;
    margin-left: 1px;
}

.calc-power-exp.active {
    background: rgba(74, 144, 217, 0.2);
    border-radius: 3px;
}

/* Square root styling */
.calc-sqrt {
    display: inline-flex;
    align-items: stretch;
    vertical-align: middle;
    position: relative;
    margin: 0 2px;
}

.calc-sqrt-symbol {
    display: flex;
    align-items: flex-end;
    font-size: 1.2em;
    line-height: 1;
    padding-bottom: 2px;
    position: relative;
}

.calc-sqrt-symbol::before {
    content: '√';
}

/* Cube root - shows small 3 before the radical */
.calc-sqrt.cube-root .calc-sqrt-symbol::before {
    content: '∛';
}

.calc-sqrt-content {
    display: flex;
    align-items: center;
    min-width: 14px;
    min-height: 16px;
    padding: 1px 4px 2px 3px;
    position: relative;
    margin-left: -1px;
}

/* Vinculum (the line over the content) */
.calc-sqrt-content::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: #1a1a1a;
}

/* Left tail of the vinculum */
.calc-sqrt-content::after {
    content: '';
    position: absolute;
    left: 1px;
    top: 0;
    bottom: 40%;
    width: 2px;
    background: #1a1a1a;
    transform: skewX(-20deg);
    transform-origin: top left;
}

.calc-sqrt-content.active {
    background: rgba(74, 144, 217, 0.2);
    border-radius: 0 3px 3px 0;
}

/* Nth root styling (generic) */
.calc-nthroot {
    display: inline-flex;
    align-items: stretch;
    vertical-align: middle;
    position: relative;
    margin: 0 2px;
}

.calc-nthroot-index {
    font-size: 0.55em;
    position: relative;
    top: -0.1em;
    min-width: 8px;
    padding: 0 1px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.calc-nthroot-index.active {
    background: rgba(74, 144, 217, 0.2);
    border-radius: 2px;
}

/* Absolute value styling */
.calc-abs {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.calc-abs::before,
.calc-abs::after {
    content: '|';
    font-weight: bold;
    margin: 0 2px;
}

.calc-abs-content {
    display: flex;
    align-items: center;
    min-width: 14px;
    padding: 2px;
}

.calc-abs-content.active {
    background: rgba(74, 144, 217, 0.2);
    border-radius: 3px;
}

/* Parentheses styling */
.calc-paren {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.calc-paren-open,
.calc-paren-close {
    font-size: 1.2em;
    font-weight: 300;
}

.calc-paren-content {
    display: flex;
    align-items: center;
    min-width: 8px;
    padding: 0 2px;
}

.calc-paren-content.active {
    background: rgba(74, 144, 217, 0.2);
    border-radius: 3px;
}

/* Integral styling */
.calc-integral {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    gap: 2px;
}

.calc-integral-symbol {
    font-size: 1.6em;
    font-weight: 300;
    line-height: 1;
    font-family: 'Times New Roman', serif;
}

.calc-integral-limits {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.7em;
    margin-left: -2px;
    margin-right: 2px;
}

.calc-integral-upper,
.calc-integral-lower {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 12px;
    min-height: 12px;
    padding: 1px 3px;
}

.calc-integral-upper {
    margin-bottom: -2px;
}

.calc-integral-lower {
    margin-top: -2px;
}

.calc-integral-upper.active,
.calc-integral-lower.active {
    background: rgba(74, 144, 217, 0.2);
    border-radius: 3px;
}

.calc-integral-integrand {
    display: flex;
    align-items: center;
    min-width: 14px;
    min-height: 18px;
    padding: 2px 4px;
}

.calc-integral-integrand.active {
    background: rgba(74, 144, 217, 0.2);
    border-radius: 3px;
}

.calc-integral-dx {
    font-style: italic;
    font-size: 0.9em;
    margin-left: 2px;
}

/* Mixed number styling */
.calc-mixed {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    gap: 3px;
}

.calc-mixed-whole {
    display: flex;
    align-items: center;
    min-width: 12px;
    min-height: 18px;
    padding: 2px 4px;
}

.calc-mixed-whole.active {
    background: rgba(74, 144, 217, 0.2);
    border-radius: 3px;
}

/* Result fraction styling */
.calc-result .calc-fraction {
    display: inline-flex;
}

.calc-result .calc-fraction-num,
.calc-result .calc-fraction-den {
    font-size: 0.75em;
    min-width: 14px;
    min-height: 14px;
}

/* Result with surd */
.calc-result .calc-sqrt {
    display: inline-flex;
}

/* Navigation buttons styling */
.calc-btn.btn-nav {
    background: var(--calc-btn-nav);
    color: #fff;
    font-size: clamp(10px, 1.8vh, 14px);
}

.calc-btn.btn-nav:hover {
    background: var(--calc-btn-nav-hover);
}

/* Navigation Row - SHIFT, D-Pad, MODE inline */
.calc-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(6px, 1vh, 12px);
    margin-bottom: clamp(3px, 0.8vh, 8px);
    flex-shrink: 0;
}

.calc-nav-row > .calc-btn {
    width: clamp(50px, 12vw, 70px);
    height: clamp(60px, 10vh, 90px);
    font-size: clamp(9px, 1.4vh, 12px);
}

/* D-Pad Navigation Layout */
.calc-dpad {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: clamp(2px, 0.4vh, 4px);
    width: clamp(90px, 18vw, 120px);
    height: clamp(70px, 12vh, 100px);
    flex-shrink: 0;
}

.calc-dpad .calc-btn {
    border-radius: clamp(4px, 0.8vh, 8px);
    padding: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calc-dpad .dpad-up {
    grid-column: 2;
    grid-row: 1;
}

.calc-dpad .dpad-left {
    grid-column: 1;
    grid-row: 2;
}

.calc-dpad .dpad-center {
    grid-column: 2;
    grid-row: 2;
    font-size: clamp(8px, 1.2vh, 10px) !important;
    background: linear-gradient(145deg, #555 0%, #333 100%);
}

.calc-dpad .dpad-center:hover {
    background: linear-gradient(145deg, #666 0%, #444 100%);
}

.calc-dpad .dpad-right {
    grid-column: 3;
    grid-row: 2;
}

.calc-dpad .dpad-down {
    grid-column: 2;
    grid-row: 3;
}

/* Mode Indicators */
.calc-indicators {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    flex-wrap: wrap;
}

.calc-indicator {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    color: #666;
    text-transform: uppercase;
    font-weight: 600;
}

.calc-indicator.active {
    background: #f9a825;
    color: #000;
}

/* Button Grid Container - holds both function and number grids */
.calc-buttons {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Function buttons grid - top 5 rows */
.calc-buttons-functions {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: clamp(2px, 0.5vh, 6px);
    flex: 5;
    min-height: 0;
    margin-bottom: 20px;
}

/* Number buttons grid - bottom 4 rows */
.calc-buttons-numbers {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: clamp(2px, 0.5vh, 6px);
    flex: 4;
    min-height: 0;
}

/* Base Button Styles */
.calc-btn {
    border: none;
    border-radius: clamp(4px, 0.8vh, 8px);
    font-size: clamp(9px, 1.5vh, 13px);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    height: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    box-shadow: var(--calc-btn-shadow);
    transition: all 0.1s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.calc-btn:active {
    transform: translateY(1px);
    box-shadow: var(--calc-btn-shadow-active);
}

/* Button secondary label (shift function) */
.calc-btn .btn-secondary {
    position: absolute;
    top: 1px;
    font-size: clamp(6px, 1.1vh, 8px);
    color: #f9a825;
    font-weight: 500;
}

.calc-btn .btn-tertiary {
    position: absolute;
    top: 1px;
    right: 3px;
    font-size: clamp(6px, 1.1vh, 8px);
    color: #e53935;
    font-weight: 500;
}

/* Number Buttons */
.calc-btn.btn-number {
    background: var(--calc-btn-number);
    color: #1a1a1a;
    font-size: clamp(14px, 2.5vh, 18px);
}

.calc-btn.btn-number:hover {
    background: var(--calc-btn-number-hover);
}

/* Operator Buttons */
.calc-btn.btn-operator {
    background: var(--calc-btn-op);
    color: #fff;
    font-size: clamp(12px, 2.2vh, 16px);
}

.calc-btn.btn-operator:hover {
    background: var(--calc-btn-op-hover);
}

/* Function Buttons */
.calc-btn.btn-function {
    background: var(--calc-btn-function);
    color: #fff;
    font-size: clamp(9px, 1.6vh, 11px);
}

.calc-btn.btn-function:hover {
    background: var(--calc-btn-function-hover);
}

/* Special Buttons */
.calc-btn.btn-shift {
    background: var(--calc-btn-shift);
    color: #000;
}

.calc-btn.btn-alpha {
    background: var(--calc-btn-alpha);
    color: #fff;
}

.calc-btn.btn-equals {
    background: var(--calc-btn-equals);
    color: #fff;
    font-size: clamp(14px, 2.5vh, 18px);
}

.calc-btn.btn-clear {
    background: var(--calc-btn-clear);
    color: #fff;
}

.calc-btn.btn-on {
    background: var(--calc-btn-on);
    color: #fff;
}

/* Double-width buttons */
.calc-btn.btn-wide {
    grid-column: span 2;
}

/* Mode buttons row */
.calc-mode-row {
    display: flex;
    gap: clamp(2px, 0.5vh, 6px);
    margin-bottom: clamp(2px, 0.5vh, 8px);
    flex-shrink: 0;
}

.calc-mode-row .calc-btn {
    flex: 1;
    height: clamp(20px, 3.5vh, 32px);
    font-size: clamp(8px, 1.3vh, 10px);
}

/* Responsive Scaling */
@media (max-width: 420px) {
    .scientific-calculator {
        width: 95vw;
        padding: 10px;
        border-radius: 15px;
    }
    
    .calc-btn {
        height: 38px;
        font-size: 12px;
        border-radius: 6px;
    }
    
    .calc-btn.btn-number {
        font-size: 16px;
    }
    
    .calc-btn.btn-operator {
        font-size: 14px;
    }
    
    .calc-btn .btn-secondary,
    .calc-btn .btn-tertiary {
        font-size: 7px;
    }
    
    .calc-result {
        font-size: 24px;
    }
    
    .calc-input-area {
        font-size: 16px;
        min-height: 30px;
    }
    
    .calc-display {
        min-height: 85px;
        padding: 8px 10px;
    }
    
    .calc-nav-pad .calc-btn {
        height: 28px;
        font-size: 11px;
    }
    
    .calc-fraction-num,
    .calc-fraction-den {
        min-width: 14px;
        min-height: 14px;
        font-size: 0.8em;
    }
    
    .calc-power-exp {
        font-size: 0.65em;
        min-width: 10px;
    }
}

@media (max-width: 360px) {
    .scientific-calculator {
        padding: 8px;
    }
    
    .calc-buttons {
        gap: 4px;
    }
    
    .calc-btn {
        height: 34px;
        font-size: 11px;
    }
    
    .calc-btn.btn-number {
        font-size: 14px;
    }
    
    .calc-result {
        font-size: 20px;
    }
    
    .calc-input-area {
        font-size: 14px;
    }
    
    .calc-header {
        padding: 6px 10px;
    }
    
    .calc-brand-name {
        font-size: 12px;
    }
    
    .calc-nav-pad {
        gap: 2px;
    }
    
    .calc-nav-pad .calc-btn {
        height: 26px;
        font-size: 10px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .scientific-calculator {
        max-height: 95vh;
        width: min(500px, 70vw);
    }
    
    .calc-btn {
        height: 32px;
    }
    
    .calc-display {
        min-height: 70px;
        padding: 6px 10px;
    }
    
    .calc-input-area {
        font-size: 14px;
        min-height: 24px;
    }
    
    .calc-result {
        font-size: 20px;
    }
    
    .calc-header {
        padding: 4px 10px;
        margin-bottom: 6px;
    }
    
    .calc-display-container {
        margin-bottom: 6px;
        padding: 6px;
    }
    
    .calc-nav-pad {
        margin-bottom: 4px;
    }
    
    .calc-nav-pad .calc-btn {
        height: 24px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .calc-btn {
        border: 0.5px solid rgba(0, 0, 0, 0.1);
    }
}

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

.calc-btn.pressed {
    animation: btnPress 0.1s ease;
}

/* Shift mode active state */
.scientific-calculator.shift-active .calc-btn .btn-secondary {
    color: #fff;
    background: #f9a825;
    padding: 1px 3px;
    border-radius: 2px;
}

/* Alpha mode active state */
.scientific-calculator.alpha-active .calc-btn .btn-tertiary {
    color: #fff;
    background: #e53935;
    padding: 1px 3px;
    border-radius: 2px;
}

/* History panel */
.calc-history {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(26, 26, 26, 0.98);
    border-radius: 0 0 15px 15px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 10;
}

.calc-history.show {
    display: block;
}

.calc-history-item {
    padding: 8px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

.calc-history-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.calc-history-expr {
    font-size: 12px;
    color: #888;
}

.calc-history-result {
    font-size: 16px;
    color: #fff;
    text-align: right;
}

/* S⇔D toggle button */
.calc-btn.btn-sd {
    background: linear-gradient(145deg, #7b1fa2 0%, #6a1b9a 100%);
    color: #fff;
    font-size: 10px;
}

.calc-btn.btn-sd:hover {
    background: linear-gradient(145deg, #9c27b0 0%, #7b1fa2 100%);
}

/* Exact mode indicator */
.calc-indicator.exact-mode {
    background: #7b1fa2;
    color: #fff;
}

/* Stats Mode Table */
.calc-stats-table {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.calc-stats-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.calc-stats-table th,
.calc-stats-table td {
    padding: 4px 6px;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.calc-stats-table th {
    background: rgba(0, 0, 0, 0.05);
    font-weight: 600;
    font-size: 11px;
}

.calc-stats-table th:first-child {
    width: 30px;
}

.stats-input {
    width: 100%;
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
    box-sizing: border-box;
    background: #fff;
}

.stats-input:focus {
    outline: none;
    border-color: #4a90d9;
}

.stats-input.focused {
    border: 2px solid #4a90d9;
    background: rgba(74, 144, 217, 0.1);
    outline: none;
}

.calc-stats-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.calc-stats-actions .calc-btn {
    flex: 1;
    height: 28px;
    font-size: 10px;
}

/* Mode Menu */
.calc-mode-menu,
.calc-stats-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 30, 30, 0.98);
    border-radius: 10px;
    padding: 12px;
    z-index: 100;
    min-width: 160px;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.calc-mode-menu-title,
.calc-stats-menu-title {
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 4px;
}

.calc-mode-menu-item,
.calc-stats-menu-item {
    background: linear-gradient(145deg, #555 0%, #333 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.calc-mode-menu-item:hover,
.calc-stats-menu-item:hover {
    background: linear-gradient(145deg, #666 0%, #444 100%);
}

.calc-mode-menu-item:active,
.calc-stats-menu-item:active {
    transform: translateY(1px);
}
