/* Modern CSS Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base Styles */
body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow-x: hidden;
}

/* Floating particles background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
    animation: float 20s ease-in-out infinite;
}

/* Header Styling */
header {
    width: 100%;
    text-align: center;
    padding: 25px 0;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255, 126, 179, 0.1), rgba(102, 126, 234, 0.1));
    z-index: -1;
}

.logo {
    height: 110px;
    width: auto;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
    border-radius: 50%;
    transition: all 0.3s ease;
    animation: logoFloat 6s ease-in-out infinite;
}

.logo:hover {
    transform: scale(1.05) rotate(5deg);
    filter: drop-shadow(0 6px 20px rgba(255, 126, 179, 0.4));
}

header h1 {
    font-size: 2.8rem;
    font-weight: 700;
    margin: 0;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #ff7eb3, white);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: textShine 4s ease-in-out infinite;
}

/* Main Container */
.container {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(25px);
    padding: 2.5rem;
    border-radius: 24px;
    width: 90%;
    max-width: 700px;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.2),
        0 5px 15px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    margin: 2rem auto;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.03),
        transparent
    );
    transform: rotate(45deg);
    animation: shimmer 8s linear infinite;
    pointer-events: none;
}

.container:hover {
    transform: translateY(-5px);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.25),
        0 8px 20px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.container-header {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.container-header img{
    height: 80px;
    width: auto;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
    transition: all 0.3s ease;
    animation: pulse 4s ease-in-out infinite;
}

.container-header img:hover {
    transform: scale(1.1) rotate(10deg);
    filter: drop-shadow(0 8px 20px rgba(255, 126, 179, 0.4));
}

.container h2 {
    margin-top: 1rem;
    margin-bottom: 2rem;
    color: white;
    font-size: 2.8rem;
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #ff74ae,white);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textShine 4s ease-in-out infinite;
}

/* Form Styling */
form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    position: relative;
    z-index: 2;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-align: left;
    color: rgba(255, 255, 255, 0.95);
    font-size: 1.1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

input, select, textarea {
    width: 100%;
    padding: 1rem 1.25rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Poppins', sans-serif;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    position: relative;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    transform: translateY(-2px);
    box-shadow: 
        0 8px 25px rgba(255, 126, 179, 0.3),
        0 0 0 3px rgba(255, 126, 179, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.98);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

input[type="submit"] {
    background: linear-gradient(135deg, #ff7eb3, #ff4f81);
    color: white;
    font-weight: 700;
    cursor: pointer;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1.1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 1rem;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 8px 20px rgba(255, 126, 179, 0.3);
}

input[type="submit"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

input[type="submit"]:hover {
    background: linear-gradient(135deg, #ff4f81, #ff1744);
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(255, 126, 179, 0.4);
}

input[type="submit"]:hover::before {
    left: 100%;
}

input[type="submit"]:active {
    transform: translateY(-1px);
}

/* Output Styling */
.output-container {
    margin-top: 2.5rem;
    width: 100%;
    overflow-x: auto;
    animation: slideInUp 0.6s ease-out;
}

.styled-table {
    width: 100%;
    border-collapse: collapse;
    background: linear-gradient(135deg, #ffffff, #f8f9ff);
    color: #333;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.15),
        0 1px 8px rgba(0, 0, 0, 0.1);
    margin: 1.5rem 0;
    position: relative;
}

.styled-table::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ff7eb3, #667eea, #f093fb);
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

.styled-table th, .styled-table td {
    padding: 1rem 1.25rem;
    text-align: center;
    border: 1px solid rgba(102, 126, 234, 0.1);
    position: relative;
    transition: all 0.3s ease;
}

.styled-table th {
    background: linear-gradient(135deg, #ff7eb3, #667eea);
    color: white;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.styled-table th::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.styled-table th:hover::before {
    left: 100%;
}

.styled-table tr:nth-child(even) {
    background: linear-gradient(135deg, #f9f9ff, #ffffff);
}

.styled-table tr:hover {
    background: linear-gradient(135deg, #f0f4ff, #fdf0ff);
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.styled-table td:hover {
    background: rgba(255, 126, 179, 0.1);
    color: #333;
    font-weight: 600;
}

.kmap-note {
    margin-top: 1.5rem;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    font-style: italic;
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 12px;
    border-left: 4px solid #ff7eb3;
    backdrop-filter: blur(10px);
}

.function-output {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(20px);
    padding: 2rem;
    border-radius: 16px;
    margin-top: 2rem;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 1.2rem;
    white-space: pre-wrap;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.function-output::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #ff7eb3, #667eea);
}

.function-output p {
    margin: 0.75rem 0;
    padding-left: 1rem;
    transition: all 0.3s ease;
}

.function-output p:hover {
    transform: translateX(10px);
    font-weight: bolder;
    scale: 1.1;
    text-shadow: 0 0 10px rgba(255, 126, 179, 0.3);
}

.error {
    color: #ff6b6b;
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(255, 107, 107, 0.05));
    backdrop-filter: blur(20px);
    padding: 1.5rem;
    border-radius: 12px;
    margin-top: 2rem;
    border: 1px solid rgba(255, 107, 107, 0.3);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.2);
    animation: shake 0.5s ease-in-out;
}

/* Footer Styling */
footer {
    margin-top: auto;
    width: 100%;
    padding: 3rem 1rem;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.8));
    backdrop-filter: blur(20px);
    position: relative;
    z-index: 1;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff7eb3, #667eea, #f093fb, #ff7eb3);
    background-size: 300% 300%;
    animation: gradientShift 4s ease infinite;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.copyright {
    margin-bottom: 2.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    text-align: center;
    line-height: 1.8;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.contributors {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3rem;
    width: 100%;
    max-width: 900px;
}

.contributor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-width: 200px;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.contributor:hover {
    transform: translateY(-8px);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.contributor span {
    font-weight: 700;
    color: white;
    font-size: 1.1rem;
    position: relative;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.social-icons {
    display: flex;
    gap: 1.25rem;
}

.social-icon {
    color: white;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    padding: 0.75rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.social-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: linear-gradient(45deg, #ff7eb3, #667eea);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.social-icon svg {
    width: 24px;
    height: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.social-icon:hover {
    color: white;
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 8px 20px rgba(255, 126, 179, 0.3);
}

.social-icon:hover::before {
    opacity: 1;
}

.social-icon:hover svg {
    transform: scale(1.2) rotate(10deg);
}

.social-icon:active {
    transform: translateY(-1px) scale(1.05);
}

/* AdSense Styling */
.ad-container {
    margin: 2rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    transition: all 0.3s ease;
}

.ad-container:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

/* Performance Info Styling */
.performance-info {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.15), rgba(0, 255, 136, 0.05));
    border-radius: 8px;
    font-size: 0.9rem;
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.3);
    backdrop-filter: blur(10px);
    text-align: center;
    font-weight: 600;
    animation: slideInUp 0.5s ease-out;
}

/* Responsive AdSense */
@media (max-width: 768px) {
    .ad-container {
        margin: 1.5rem 0;
        padding: 0.75rem;
    }
    
    .ad-container ins {
        width: 100% !important;
        max-width: 320px;
        height: auto !important;
    }
}

@media (max-width: 480px) {
    .ad-container {
        margin: 1rem 0;
        padding: 0.5rem;
    }
    
    .performance-info {
        font-size: 0.8rem;
        padding: 0.5rem;
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    body {
        background-size: 600% 600%;
    }
    
    .container {
        width: 95%;
        padding: 2rem;
        border-radius: 20px;
    }
    
    header {
        padding: 20px 0;
        flex-direction: column;
        gap: 10px;
    }
    
    .logo {
        height: 80px;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
    
    .container h2 {
        font-size: 2.2rem;
    }
    
    .contributors {
        flex-direction: column;
        gap: 2rem;
    }
    
    .contributor {
        min-width: auto;
        width: 100%;
        max-width: 300px;
    }
    
    input, select, textarea {
        padding: 0.875rem 1rem;
    }
    
    form {
        gap: 1.25rem;
    }
}

@media (max-width: 480px) {
    .logo {
        height: 60px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .container {
        padding: 1.5rem;
        margin: 1rem auto;
    }
    
    .container h2 {
        font-size: 1.8rem;
    }
    
    .container-header {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .container-header img {
        height: 60px;
    }
    
    input, select, textarea {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
    
    input[type="submit"] {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    .styled-table th, .styled-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }
    
    .function-output {
        padding: 1.5rem;
        font-size: 1rem;
    }
    
    footer {
        padding: 2rem 1rem;
    }
    
    .social-icon {
        width: 44px;
        height: 44px;
    }
    
    .social-icon svg {
        width: 20px;
        height: 20px;
    }
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes logoFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-20px) rotate(1deg); }
    66% { transform: translateY(-10px) rotate(-1deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.container, .output-container, .function-output {
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Accessibility Improvements */
a:focus, button:focus, input:focus, select:focus {
    outline: 2px solid rgba(255, 126, 179, 0.8);
    outline-offset: 2px;
}

/* Remove tap highlight on mobile */
a, button, input {
    -webkit-tap-highlight-color: transparent;
}

/* Print Styles */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    
    .container {
        background: white !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
    }
    
    footer {
        display: none;
    }
}

/* Visualization Styles */
#logicCircuit {
    width: 100%;
    min-height: 350px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 2rem;
    margin: 2rem 0;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
}

#logicCircuit::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff7eb3, #667eea);
    border-radius: 16px 16px 0 0;
}

#interactiveKmap {
    width: 100%;
    min-height: 450px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 2rem;
    margin: 2rem 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#kmapControls {
    display: flex;
    gap: 1.5rem;
    margin-top: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

#kmapControls button {
    background: linear-gradient(135deg, #ff7eb3, #ff4f81);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 20px rgba(255, 126, 179, 0.3);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#kmapControls button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

#kmapControls button:hover {
    background: linear-gradient(135deg, #ff4f81, #ff1744);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(255, 126, 179, 0.4);
}

#kmapControls button:hover::before {
    left: 100%;
}

#kmapControls button:active {
    transform: translateY(-1px);
}

/* K-map specific cell styling */
.styled-table td.dont-care-cell,
.styled-table td:contains("X") {
    color: #e74c3c !important;
    font-weight: 900 !important;
    text-shadow: 0 2px 4px rgba(231, 76, 60, 0.5) !important;
}

.styled-table td.sop-one-cell,
.styled-table td.sop-one-cell:hover {
    color: #27ae60 !important;
    font-weight: 900 !important;
    text-shadow: 0 2px 4px rgba(39, 174, 96, 0.5) !important;
}

.styled-table td.pos-zero-cell,
.styled-table td.pos-zero-cell:hover {
    color: #27ae60 !important;
    font-weight: 900 !important;
    text-shadow: 0 2px 4px rgba(39, 174, 96, 0.5) !important;
}

/* Fallback styling based on cell content */
.styled-table tbody td[data-cell="X"],
.styled-table tbody td:has-text("X") {
    color: #e74c3c !important;
    font-weight: 900 !important;
    text-shadow: 0 2px 4px rgba(231, 76, 60, 0.5) !important;
}

/* SOP ones should be green */
.styled-table tbody td[data-sop="1"],
.styled-table tbody td:has-text("1"):not(.pos-mode) {
    color: #27ae60 !important;
    font-weight: 900 !important;
    text-shadow: 0 2px 4px rgba(39, 174, 96, 0.5) !important;
}

/* POS zeros should be green */
.styled-table tbody td[data-pos="0"],
.styled-table tbody td:has-text("0").pos-mode {
    color: #27ae60 !important;
    font-weight: 900 !important;
    text-shadow: 0 2px 4px rgba(39, 174, 96, 0.5) !important;
}

/* JavaScript-applied styling for dynamic content-based coloring */
.kmap-cell-x {
    color: #e74c3c !important;
    font-weight: 900 !important;
    text-shadow: 0 2px 4px rgba(231, 76, 60, 0.5) !important;
}

.kmap-cell-one-sop {
    color: #27ae60 !important;
    font-weight: 900 !important;
    text-shadow: 0 2px 4px rgba(39, 174, 96, 0.5) !important;
}

.kmap-cell-zero-pos {
    color: #27ae60 !important;
    font-weight: 900 !important;
    text-shadow: 0 2px 4px rgba(39, 174, 96, 0.5) !important;
}

/* Enhanced responsive design */
@media (max-width: 768px) {
    #logicCircuit, #interactiveKmap {
        min-height: 280px;
        padding: 1.5rem;
    }
    
    #kmapControls {
        gap: 1rem;
    }
    
    #kmapControls button {
        padding: 0.875rem 1.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    #kmapControls {
        flex-direction: column;
        align-items: center;
    }
    
    #kmapControls button {
        gap: 0.5rem;
        width: 100%;
        max-width: 250px;
    }
}
.error-message {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.15), rgba(244, 67, 54, 0.05));
    backdrop-filter: blur(20px);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-left: 4px solid #f44336;
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    color: #ff6b6b;
    box-shadow: 0 8px 25px rgba(244, 67, 54, 0.2);
    animation: shake 0.5s ease-in-out;
    position: relative;
    overflow: hidden;
}

.error-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #f44336, #ff6b6b);
    border-radius: 12px 12px 0 0;
}

.error-message ul {
    margin: 15px 0 0 25px;
    color: rgba(255, 107, 107, 0.9);
}

.error-message li {
    margin: 8px 0;
    transition: all 0.3s ease;
}

.error-message li:hover {
    transform: translateX(5px);
    color: #ff6b6b;
}

.error-message a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.error-message a:hover {
    color: #ff7eb3;
    border-bottom-color: #ff7eb3;
    transform: translateY(-1px);
}

/* K-Map Grouping Styles */
.kmap-container {
    position: relative;
    display: inline-block;
    margin: 1rem 0;
}

.highlight-group {
    position: absolute;
    border: 3px solid;
    border-radius: 8px;
    background-color: rgba(255, 215, 0, 0.15);
    backdrop-filter: blur(5px);
    pointer-events: none;
    transition: all 0.3s ease;
    animation: groupPulse 2s ease-in-out infinite;
}

/* Different colors for different groups */
.highlight-group-1 {
    border-color: #ff6b6b;
    background-color: rgba(255, 107, 107, 0.15);
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.3);
}

.highlight-group-2 {
    border-color: #4ecdc4;
    background-color: rgba(78, 205, 196, 0.15);
    box-shadow: 0 0 15px rgba(78, 205, 196, 0.3);
}

.highlight-group-3 {
    border-color: #45b7d1;
    background-color: rgba(69, 183, 209, 0.15);
    box-shadow: 0 0 15px rgba(69, 183, 209, 0.3);
}

.highlight-group-4 {
    border-color: #f9ca24;
    background-color: rgba(249, 202, 36, 0.15);
    box-shadow: 0 0 15px rgba(249, 202, 36, 0.3);
}

.highlight-group-5 {
    border-color: #6c5ce7;
    background-color: rgba(108, 92, 231, 0.15);
    box-shadow: 0 0 15px rgba(108, 92, 231, 0.3);
}

.highlight-group-6 {
    border-color: #a29bfe;
    background-color: rgba(162, 155, 254, 0.15);
    box-shadow: 0 0 15px rgba(162, 155, 254, 0.3);
}

.highlight-group-7 {
    border-color: #fd79a8;
    background-color: rgba(253, 121, 168, 0.15);
    box-shadow: 0 0 15px rgba(253, 121, 168, 0.3);
}

.highlight-group-8 {
    border-color: #00b894;
    background-color: rgba(0, 184, 148, 0.15);
    box-shadow: 0 0 15px rgba(0, 184, 148, 0.3);
}

.highlight-group:hover {
    transform: scale(1.02);
    border-width: 4px;
    animation-play-state: paused;
}

.group-label {
    position: absolute;
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    pointer-events: none;
}

.group-label:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.9);
}

/* Enhanced table cells for grouping */
.styled-table td.grouped-cell {
    position: relative;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.styled-table td.grouped-cell-1 {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(255, 107, 107, 0.1)) !important;
    color: #d63031 !important;
}

.styled-table td.grouped-cell-2 {
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.2), rgba(78, 205, 196, 0.1)) !important;
    color: #00b894 !important;
}

.styled-table td.grouped-cell-3 {
    background: linear-gradient(135deg, rgba(69, 183, 209, 0.2), rgba(69, 183, 209, 0.1)) !important;
    color: #0984e3 !important;
}

.styled-table td.grouped-cell-4 {
    background: linear-gradient(135deg, rgba(249, 202, 36, 0.2), rgba(249, 202, 36, 0.1)) !important;
    color: #fdcb6e !important;
}

.styled-table td.grouped-cell-5 {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(108, 92, 231, 0.1)) !important;
    color: #6c5ce7 !important;
}

.styled-table td.grouped-cell-6 {
    background: linear-gradient(135deg, rgba(162, 155, 254, 0.2), rgba(162, 155, 254, 0.1)) !important;
    color: #a29bfe !important;
}

.styled-table td.grouped-cell-7 {
    background: linear-gradient(135deg, rgba(253, 121, 168, 0.2), rgba(253, 121, 168, 0.1)) !important;
    color: #e84393 !important;
}

.styled-table td.grouped-cell-8 {
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.2), rgba(0, 184, 148, 0.1)) !important;
    color: #00b894 !important;
}

/* K-map controls enhanced */
.kmap-controls {
    margin-top: 1.5rem;
    text-align: center;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.kmap-controls button {
    padding: 0.75rem 1.5rem;
    margin: 0.25rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.kmap-controls button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.kmap-controls button:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.kmap-controls button:hover::before {
    left: 100%;
}

.kmap-controls button:active {
    transform: translateY(0);
}

.kmap-controls button.active {
    background: linear-gradient(135deg, #ff7eb3, #ff4f81);
    box-shadow: 0 6px 20px rgba(255, 126, 179, 0.4);
}

/* Group legend */
.group-legend {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.group-legend h3 {
    color: white;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    text-align: center;
    background: linear-gradient(135deg, #ff7eb3, #667eea);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textShine 3s ease-in-out infinite;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.legend-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid;
    flex-shrink: 0;
}

.legend-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Animation for grouping */
@keyframes groupPulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.01);
    }
}

@keyframes groupHighlight {
    0%, 100% {
        box-shadow: 0 0 10px currentColor;
    }
    50% {
        box-shadow: 0 0 20px currentColor;
    }
}

/* Responsive adjustments for grouping */
@media (max-width: 768px) {
    .kmap-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .kmap-controls button {
        width: 100%;
        max-width: 200px;
    }
    
    .legend-items {
        grid-template-columns: 1fr;
    }
    
    .group-label {
        font-size: 0.7rem;
        padding: 1px 4px;
    }
}

@media (max-width: 480px) {
    .highlight-group {
        border-width: 2px;
    }
    
    .group-legend {
        padding: 1rem;
    }
    
    .legend-color {
        width: 16px;
        height: 16px;
    }
    
    .legend-text {
        font-size: 0.8rem;
    }
}

