:root {
    --bg-dark: #0a0a0f;
    --glass-bg: rgba(20, 20, 30, 0.4);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    
    --neon-blue: #00f3ff;
    --neon-purple: #bc13fe;
    --neon-green: #00ff66;
    --neon-red: #ff003c;
    --neon-orange: #ffaa00;

    --btn-bg: rgba(255, 255, 255, 0.03);
    --btn-hover: rgba(255, 255, 255, 0.1);
    --btn-active: rgba(255, 255, 255, 0.2);
}

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

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

/* Animated Background Blobs */
.background-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    filter: blur(80px);
}

.blob {
    position: absolute;
    border-radius: 50%;
    animation: move 15s infinite alternate ease-in-out;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--neon-purple) 0%, transparent 70%);
    top: 10%;
    left: 15%;
    animation-delay: 0s;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--neon-blue) 0%, transparent 70%);
    bottom: 5%;
    right: 10%;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--neon-green) 0%, transparent 70%);
    top: 40%;
    left: 50%;
    animation-delay: -10s;
}

@keyframes move {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

.calculator-container {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px; /* Reduced max-width for better vertical proportion */
    padding: 20px;
}

.mode-toggle {
    align-self: flex-end;
    margin-bottom: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 5px 15px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 1px;
    color: var(--neon-blue);
    text-shadow: 0 0 5px var(--neon-blue);
    transition: all 0.3s ease;
    user-select: none;
}

.mode-toggle:hover {
    background: var(--btn-hover);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
}

.calculator {
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.display {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.03);
    box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.3);
    min-height: 120px;
    word-wrap: break-word;
    word-break: break-all;
}

.history {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-height: 20px;
    margin-bottom: 5px;
}

.current {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.2rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.1;
}

/* Scrollbar for display if numbers get too large */
.display::-webkit-scrollbar {
    width: 4px;
}
.display::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px; /* Slightly reduced gap */
}

.btn {
    background: var(--btn-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    padding: 12px 5px; /* Adjust padding for 5 cols */
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
}

.btn:active {
    transform: scale(0.92);
    background: var(--btn-active);
}

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

.btn.sci {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.01);
}

.btn.sci:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.btn.num {
    font-size: 1.3rem;
    font-weight: 500;
}

/* Neon Variants */
.neon-blue {
    color: var(--neon-blue);
    text-shadow: 0 0 5px var(--neon-blue);
}
.neon-blue:hover {
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
    border-color: rgba(0, 243, 255, 0.4);
}

.neon-purple {
    color: var(--neon-purple);
    text-shadow: 0 0 5px var(--neon-purple);
}
.neon-purple:hover {
    box-shadow: 0 0 15px rgba(188, 19, 254, 0.4);
    border-color: rgba(188, 19, 254, 0.4);
}

.neon-green {
    color: var(--bg-dark);
    background-color: var(--neon-green);
    font-weight: bold;
    box-shadow: 0 0 10px var(--neon-green);
    border: none;
}
.neon-green:hover {
    background-color: #00e65c;
    box-shadow: 0 0 20px var(--neon-green);
}

.neon-red {
    color: var(--neon-red);
    text-shadow: 0 0 5px var(--neon-red);
}
.neon-red:hover {
    box-shadow: 0 0 15px rgba(255, 0, 60, 0.4);
    border-color: rgba(255, 0, 60, 0.4);
}

.neon-orange {
    color: var(--neon-orange);
    text-shadow: 0 0 5px var(--neon-orange);
}
.neon-orange:hover {
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.4);
    border-color: rgba(255, 170, 0, 0.4);
}

@media (max-width: 480px) {
    .calculator-container {
        padding: 10px;
        max-width: 100%;
        height: 100vh;
        justify-content: center;
    }
    .calculator {
        border-radius: 16px;
        padding: 15px;
        gap: 15px;
    }
    .btn {
        padding: 10px 2px;
        border-radius: 10px;
        font-size: 0.95rem;
    }
    .btn.num {
        font-size: 1.1rem;
    }
    .btn.sci {
        font-size: 0.75rem;
    }
    .current {
        font-size: 1.8rem;
    }
}

/* History Panel Customizations */
.history-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    width: calc(100% - 40px);
    height: calc(100% - 40px);
    background: rgba(15, 15, 20, 0.95);
    border: 1px solid var(--neon-blue);
    border-radius: 24px;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    z-index: 20;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.2);
    transform: translateY(-120%);
    opacity: 0;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.history-panel.active {
    transform: translateY(0);
    opacity: 1;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
    margin-bottom: 15px;
    color: var(--neon-blue);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s;
}

.btn-icon:hover {
    color: var(--neon-red);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Scrollbar for history list */
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: var(--neon-blue); border-radius: 4px; }

.history-item {
    text-align: right;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.hist-expr {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-family: 'Orbitron', sans-serif;
}

.hist-res {
    font-size: 1.2rem;
    color: var(--neon-green);
    font-weight: 500;
    font-family: 'Orbitron', sans-serif;
}
