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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
}

header p {
    color: #7f8c8d;
    font-size: 1.1em;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.explanation-toggle {
    width: 100%;
    margin-bottom: 15px;
}

#how-it-works-link {
    color: #3498db;
    text-decoration: underline;
    font-size: 0.9em;
    padding: 0;
    margin: 0;
}

#how-it-works-link:hover {
    color: #2980b9;
}


.small-text {
    font-size: 0.9em;
    color: #7f8c8d;
    line-height: 1.6;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    font-weight: bold;
    color: #2c3e50;
}

.control-group input {
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.control-group input:disabled,
.control-group textarea:disabled {
    background-color: #eee;
    color: #999;
    cursor: not-allowed;
}

.control-group input:focus {
    outline: none;
    border-color: #3498db;
}

.control-group input[type="range"] {
    width: 150px;
    padding: 0;
}

.input-error {
    color: #e74c3c;
    font-size: 0.85em;
    font-weight: bold;
}

.message-group {
    flex: 1;
    min-width: 300px;
    width: 100%;
    flex-basis: 100%;
}

.message-group textarea {
    width: 100%;
    min-height: 60px;
    resize: both;
    font-family: inherit;
    font-size: 14px;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
}

.message-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.button-group {
    flex-direction: row !important;
    flex-wrap: wrap;
}

.control-group button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.3s;
}

#start-btn {
    background-color: #27ae60;
    color: white;
}

#start-btn:hover {
    background-color: #219a52;
}

#next-gen-btn {
    background-color: #3498db;
    color: white;
}

#next-gen-btn:hover:not(:disabled) {
    background-color: #2980b9;
}

#next-gen-btn:disabled {
    background-color: #bdc3c7;
    color: #7f8c8d;
    cursor: not-allowed;
}

#reset-btn {
    background-color: #e74c3c;
    color: white;
}

#reset-btn:hover {
    background-color: #c0392b;
}

.visualization {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
    position: relative;
}

.node-tooltip {
    display: none;
    position: fixed;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-family: monospace;
    max-width: 300px;
    word-wrap: break-word;
    pointer-events: none;
    z-index: 10;
    line-height: 1.4;
}

.node-tooltip .tooltip-accuracy {
    color: #2ecc71;
    font-weight: bold;
    margin-top: 4px;
    font-family: Arial, sans-serif;
}

.generation-count {
    text-align: left;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
}

#network-canvas {
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    max-width: 100%;
}

.legend {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.legend h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.color-box {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

.message-display {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.message-display h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

#selected-message {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #3498db;
    margin-bottom: 10px;
    font-family: monospace;
    word-wrap: break-word;
}

#message-accuracy {
    font-weight: bold;
    color: #2c3e50;
}

#received-messages {
    margin-top: 15px;
}

#received-messages h4 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.received-message {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    border-left: 4px solid #e74c3c;
    margin-bottom: 8px;
    font-family: monospace;
    word-wrap: break-word;
}

.received-message strong {
    color: #2c3e50;
}

@media (min-width: 769px) {
    .container {
        max-width: 1400px;
    }

    .main-content {
        display: flex;
        gap: 20px;
        align-items: flex-start;
    }

    .left-column {
        width: 50%;
        flex-shrink: 0;
    }

    .right-column {
        width: 50%;
        flex-shrink: 0;
    }
}

@media (max-width: 768px) {
    .controls {
        flex-direction: column;
    }
    
    .control-group {
        width: 100%;
    }
    
    #network-canvas {
        max-width: 100%;
    }
}

.error-distribution {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.variant-distribution {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.error-distribution h3,
.variant-distribution h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

#variant-summary {
    color: #7f8c8d;
    font-size: 0.9em;
    margin-bottom: 10px;
}

#error-table,
#variant-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

#error-table th,
#error-table td,
#variant-table th,
#variant-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

#error-table th,
#variant-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #2c3e50;
}

#error-table tr:hover,
#variant-table tr:hover {
    background-color: #f8f9fa;
}

#error-table td[colspan="2"],
#variant-table td[colspan="2"] {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
}

.faq-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.faq-section h1 {
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.faq-section h2 {
    color: #2c3e50;
    margin-top: 25px;
    margin-bottom: 10px;
}

.faq-section h3 {
    color: #34495e;
    margin-top: 20px;
    margin-bottom: 8px;
}

.faq-section p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 15px;
}

.faq-section ul {
    margin: 10px 0;
    padding-left: 20px;
}

.faq-section li {
    color: #555;
    line-height: 1.6;
    margin-bottom: 5px;
}

.faq-section strong {
    color: #2c3e50;
}

.faq-section code {
    background-color: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #e74c3c;
}