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

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header Styles */
header {
    background: linear-gradient(135deg, #2c3e50 0%, #4a6491 100%);
    color: white;
    padding: 30px 40px;
    text-align: center;
}

header h1 {
    font-size: 2.8rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 800px;
    margin: 0 auto;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 30px;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Control Panel */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.input-section, .results-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s;
    font-family: 'Poppins', sans-serif;
}

.form-control:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.hint {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
    color: #666;
}

.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 15px;
    background: white;
    border-radius: 8px;
    border: 2px solid #ddd;
    transition: all 0.3s;
}

.radio-group label:hover {
    border-color: #667eea;
}

.radio-group input[type="radio"]:checked + span {
    color: #667eea;
    font-weight: 600;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 1;
    min-width: 120px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

/* Results Section */
.results-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-top: 15px;
    border: 2px solid #e9ecef;
}

.result-item {
    margin-bottom: 15px;
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-item label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 5px;
}

.result-value {
    font-size: 1.1rem;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

#simplifiedExpr {
    font-family: monospace;
    font-size: 1.2rem;
    color: #e74c3c;
    font-weight: 600;
}

.steps-section {
    margin-top: 25px;
}

.steps-content {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
    border: 2px solid #e9ecef;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* K-Map Section */
.kmap-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

#kmapContainer {
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

.kmap-table {
    border-collapse: collapse;
    border: 3px solid #2c3e50;
    background: white;
}

.kmap-cell {
    width: 70px;
    height: 70px;
    border: 2px solid #ddd;
    text-align: center;
    vertical-align: middle;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.kmap-cell:hover {
    background-color: #f0f0f0;
    transform: scale(1.05);
}

.kmap-header {
    background: #2c3e50;
    color: white;
    font-weight: 600;
    padding: 10px 15px;
    text-align: center;
    border: 2px solid #2c3e50;
}

.kmap-index {
    font-size: 0.8rem;
    color: #666;
    position: absolute;
    top: 2px;
    left: 2px;
}

.box-0 { background-color: #e74c3c; }
.box-1 { background-color: #2ecc71; }
.box-x { background-color: #f39c12; }
.box-highlight { background-color: #3498db; }

.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

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

.box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid rgba(0, 0, 0, 0.1);
}

/* Footer */
footer {
    background: #2c3e50;
    color: white;
    padding: 20px;
    text-align: center;
    margin-top: 30px;
}

.footer-links {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: #667eea;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 700px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    background: linear-gradient(135deg, #2c3e50 0%, #4a6491 100%);
    color: white;
    padding: 25px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #667eea;
}

.modal-body {
    padding: 30px;
}

.modal-body h3 {
    color: #2c3e50;
    margin: 20px 0 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-body ol, .modal-body ul {
    padding-left: 20px;
    margin-bottom: 20px;
}

.modal-body li {
    margin-bottom: 10px;
    line-height: 1.6;
}