:root {
  --bg-color: #0d0d12;
  --blue: #1d4ed8;
  --purple: #7e22ce;
  --black-alt: #16161e;
  --text: #e0e0e6;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: var(--bg-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    overflow: hidden; /* For the background dynamic effect */
}

/* 1. Dynamic Background Mesh Animation */
.bg-mesh {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(at 10% 10%, rgba(29, 78, 216, 0.3) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(126, 34, 206, 0.3) 0px, transparent 50%);
    filter: blur(80px);
    z-index: -1;
    animation: meshMove 15s ease-in-out infinite alternate;
}

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

/* 2. Calculator Container with Dynamic Border */
.calculator {
    background: var(--black-alt);
    padding: 25px;
    border-radius: 20px;
    width: 330px;
    position: relative;
    box-shadow: 0px 20px 50px rgba(0, 0, 0, 0.7);
    overflow: hidden; /* Clips the background effect */
}

/* Linear Gradient dynamic border effect */
.calculator::before {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    background: linear-gradient(45deg, var(--black-alt), var(--blue), var(--purple), var(--black-alt));
    background-size: 400%;
    z-index: -1;
    border-radius: 22px;
    animation: borderGlow 8s linear infinite;
    filter: blur(5px);
}

@keyframes borderGlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#display {
    width: 100%;
    height: 70px;
    font-size: 28px;
    text-align: right;
    margin-bottom: 25px;
    padding: 15px;
    box-sizing: border-box;
    border: none;
    background: #08080c;
    color: var(--text);
    border-radius: 10px;
    box-shadow: inset 0px 4px 10px rgba(0,0,0,0.5);
    letter-spacing: 1px;
}

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

/* 3. Common Button Styling & Dynamic Interaction */
.btn {
    padding: 18px 0;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text);
    background: #1f1f29;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

/* Active/Tap Interaction */
.btn:active {
    transform: scale(0.92);
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

/* Hover Interaction with Subtle Glow */
.btn:hover {
    background: #282836;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

/* 4. Color-coded Dynamic Groups */

/* Math/Scientific Buttons: Subtle Blue/Purple Gradient */
.math {
    background: linear-gradient(135deg, rgba(29, 78, 216, 0.1), rgba(126, 34, 206, 0.15));
    border: 1px solid rgba(126, 34, 206, 0.3);
}
.math:hover {
    background: linear-gradient(135deg, rgba(29, 78, 216, 0.2), rgba(126, 34, 206, 0.25));
    box-shadow: 0 0 15px rgba(126, 34, 206, 0.3);
}

/* Operator Buttons: Solid Deep Blue */
.operator {
    background: var(--blue);
    color: white;
}
.operator:hover {
    background: #2563eb;
    box-shadow: 0 0 15px rgba(29, 78, 216, 0.5);
}

/* Secondary Actions (AC/DEL): Darker Base */
.secondary {
    background: #363645;
}
.secondary:hover {
    background: #414152;
}

/* Equal Button: Deep Purple Gradient with Stronger Glow */
.equal {
    background: linear-gradient(135deg, var(--purple), #9333ea);
    color: white;
}
.equal:hover {
    background: linear-gradient(135deg, #9333ea, #a855f7);
    box-shadow: 0 0 20px rgba(126, 34, 206, 0.6);
}
