:root {
    --bg-dark: #07090e;
    --card-bg: rgba(15, 18, 28, 0.84);
    --card-border: rgba(255, 255, 255, 0.12);
    --panel-bg: rgba(10, 14, 23, 0.5);
    --display-bg: rgba(8, 10, 16, 0.92);
    
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-blue: #38bdf8;
    --accent-cyan: #22d3ee;
    --accent-purple: #c084fc;
    --accent-pink: #f43f5e;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    
    --btn-num-bg: rgba(30, 41, 59, 0.65);
    --btn-num-hover: rgba(51, 65, 85, 0.9);
    
    --btn-sci-bg: rgba(24, 34, 53, 0.75);
    --btn-sci-hover: rgba(43, 58, 88, 0.95);
    --btn-sci-color: #38bdf8;
    
    --btn-func-bg: rgba(47, 52, 77, 0.75);
    --btn-func-hover: rgba(71, 85, 105, 0.95);
    
    --btn-op-bg: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --btn-op-hover: linear-gradient(135deg, #fbbf24 0%, #b45309 100%);
    
    --btn-eq-bg: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
    --btn-eq-hover: linear-gradient(135deg, #60a5fa 0%, #1d4ed8 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden !important;
}

body {
    font-family: 'Outfit', sans-serif;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-dark);
    position: relative;
    color: var(--text-primary);
    padding: 10px;
}

/* Ambient Floating Orbs Background */
.ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.45;
    pointer-events: none;
    animation: orbFloat 22s ease-in-out infinite alternate;
    z-index: 0;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.5) 0%, transparent 70%);
    top: -150px;
    left: -100px;
}

.orb-2 {
    width: 550px;
    height: 550px;
    background: radial-gradient(circle, rgba(192, 132, 252, 0.5) 0%, transparent 70%);
    bottom: -180px;
    right: -100px;
    animation-delay: -7s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(244, 63, 94, 0.35) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes orbFloat {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(60px, -60px) scale(1.12); }
    100% { transform: translate(-50px, 50px) scale(0.92); }
}

/* Background Marquee Text Styling */
.bg-marquee-container {
    position: fixed;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    overflow: hidden;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2;
    opacity: 0.35;
}

.track-top {
    top: 4%;
    transform: rotate(-3deg);
}

.track-bottom {
    bottom: 4%;
    transform: rotate(3deg);
}

.bg-marquee-content {
    display: inline-flex;
    font-family: 'Outfit', sans-serif;
    font-size: 76px;
    font-weight: 900;
    letter-spacing: 8px;
    color: rgba(56, 189, 248, 0.15);
    -webkit-text-stroke: 1.5px rgba(56, 189, 248, 0.5);
    text-shadow: 0 0 15px rgba(56, 189, 248, 0.25);
    text-transform: uppercase;
}

.track-bottom .bg-marquee-content {
    color: rgba(192, 132, 252, 0.15);
    -webkit-text-stroke: 1.5px rgba(192, 132, 252, 0.5);
    text-shadow: 0 0 15px rgba(192, 132, 252, 0.25);
}

.marquee-left {
    animation: marqueeLeft 30s linear infinite;
}

.marquee-right {
    animation: marqueeRight 35s linear infinite;
}

@keyframes marqueeLeft {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

@keyframes marqueeRight {
    0% { transform: translateX(-50%); }
    100% { transform: translateX(0); }
}

/* Wide Container */
.wide-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 860px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Wide Glassmorphic Calculator Card */
.wide-calculator {
    background: var(--card-bg);
    backdrop-filter: blur(30px) saturate(190%);
    -webkit-backdrop-filter: blur(30px) saturate(190%);
    border: 1px solid var(--card-border);
    border-radius: 28px;
    padding: 20px 24px;
    width: 100%;
    box-shadow: 0 35px 95px rgba(0, 0, 0, 0.75),
                0 0 50px rgba(56, 189, 248, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.wide-calculator:hover {
    box-shadow: 0 40px 105px rgba(0, 0, 0, 0.85),
                0 0 60px rgba(192, 132, 252, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

/* Header Bar */
.calc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 4px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-blue);
    box-shadow: 0 0 12px var(--accent-blue);
    animation: pulseGlow 2s infinite alternate;
}

@keyframes pulseGlow {
    0% { transform: scale(0.9); opacity: 0.7; }
    100% { transform: scale(1.3); opacity: 1; }
}

.brand-name {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-secondary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-btn {
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-blue);
    border-color: rgba(56, 189, 248, 0.3);
}

.mode-btn.active {
    background: rgba(192, 132, 252, 0.2);
    color: var(--accent-purple);
    border-color: rgba(192, 132, 252, 0.5);
    box-shadow: 0 0 10px rgba(192, 132, 252, 0.3);
}

.accent-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0.4;
    transition: all 0.2s ease;
}

.accent-badge.active {
    opacity: 1;
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

/* Full-Width Display Box */
.display-container {
    background: var(--display-bg);
    border-radius: 18px;
    padding: 12px 20px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 3px 14px rgba(0, 0, 0, 0.65),
                0 4px 18px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    min-height: 85px;
    word-break: break-all;
    overflow: hidden;
}

.sub-display {
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    font-weight: 400;
    color: var(--accent-purple);
    min-height: 20px;
    line-height: 20px;
    letter-spacing: 0.5px;
    opacity: 0.9;
    transition: all 0.2s ease;
}

.display {
    font-family: 'Fira Code', monospace;
    font-size: 34px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 40px;
    letter-spacing: -0.5px;
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.15);
    transition: font-size 0.15s ease;
}

/* Widescreen 2-Panel Layout */
.keypad-panels {
    display: flex;
    gap: 16px;
    align-items: stretch;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 12px;
}

.panel-scientific {
    flex: 1.25;
}

.panel-basic {
    flex: 1;
}

.panel-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-left: 4px;
}

/* Left Grid (5 Cols x 4 Rows) */
.grid-sci {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

/* Right Grid (4 Cols x 5 Rows) */
.grid-basic {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

/* Button Base Styling */
.btn {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 500;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    outline: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.22);
}

.btn:active {
    transform: translateY(0) scale(0.96);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Scientific Buttons */
.btn-sci {
    background: var(--btn-sci-bg);
    color: var(--btn-sci-color);
    font-size: 13px;
    font-weight: 600;
}

.btn-sci:hover {
    background: var(--btn-sci-hover);
    color: #7dd3fc;
    border-color: rgba(56, 189, 248, 0.3);
}

/* Number Buttons */
.btn-number {
    background: var(--btn-num-bg);
    color: var(--text-primary);
    font-size: 17px;
    font-weight: 600;
}

.btn-number:hover {
    background: var(--btn-num-hover);
    color: #ffffff;
}

/* Function Buttons (AC, ←) */
.btn-function {
    background: var(--btn-func-bg);
    color: var(--accent-purple);
    font-weight: 600;
    font-size: 15px;
}

.btn-function:hover {
    background: var(--btn-func-hover);
    color: #e9d5ff;
}

/* Operator Buttons (÷, ×, −, +) */
.btn-operator {
    background: var(--btn-op-bg);
    color: #ffffff;
    font-size: 19px;
    font-weight: 600;
    box-shadow: 0 3px 12px rgba(245, 158, 11, 0.35);
}

.btn-operator:hover {
    background: var(--btn-op-hover);
    box-shadow: 0 5px 18px rgba(245, 158, 11, 0.5);
}

/* Equals Button (=) Tall Span */
.btn-equals {
    background: var(--btn-eq-bg);
    color: #ffffff;
    font-size: 21px;
    font-weight: 600;
    box-shadow: 0 3px 15px rgba(56, 189, 248, 0.4);
}

.btn-eq-tall {
    grid-row: span 2;
    height: 100%;
}

.btn-equals:hover {
    background: var(--btn-eq-hover);
    box-shadow: 0 5px 22px rgba(56, 189, 248, 0.6);
}

/* Zero Button Span 2 Cols */
.btn-zero-wide {
    grid-column: span 2;
    justify-content: flex-start;
    padding-left: 18px;
}

/* Keypress Animation */
.btn.pressed {
    animation: buttonRipple 0.18s ease forwards;
}

@keyframes buttonRipple {
    0% { transform: scale(1); }
    50% { transform: scale(0.92); }
    100% { transform: scale(1); }
}

/* Responsive Fallback for Narrow Screens */
@media (max-width: 768px) {
    html, body {
        overflow-y: auto !important;
    }
    
    body {
        height: auto;
        min-height: 100vh;
    }

    .keypad-panels {
        flex-direction: column;
    }

    .wide-calculator {
        max-width: 460px;
        margin: 0 auto;
    }

    .btn {
        height: 44px;
    }

    .btn-eq-tall {
        grid-row: span 1;
        height: 44px;
    }

    .bg-marquee-content {
        font-size: 48px;
    }
}