/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #4a8c4a 0%, #5a9c5a 50%, #5c4033 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-brand {
    font-family: 'Alfa Slab One', cursive;
    font-size: clamp(2rem, 7vw, 2.6rem);
    color: var(--pig-pink);
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.loading-title {
    font-size: 3rem;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.loading-pig {
    width: 80px;
    height: 80px;
    margin: 0 auto 30px;
    animation: bounce 0.6s ease-in-out infinite;
}

.pig-icon {
    width: 80px;
    height: 60px;
    background: #ffb6c1;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.pig-icon::before {
    content: '';
    position: absolute;
    width: 30px;
    height: 20px;
    background: #ffb6c1;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -30%);
    border: 2px solid #d4477c;
}

.pig-icon::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #ffb6c1;
    border-radius: 50%;
    top: -8px;
    left: 10px;
    box-shadow: 40px 0 0 #ffb6c1;
}

.pig-eye {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #333;
    border-radius: 50%;
    top: 14px;
    z-index: 1;
}

.pig-eye-left {
    left: 18px;
}

.pig-eye-right {
    right: 18px;
}

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

.loading-bar-container {
    width: 300px;
    height: 20px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    margin: 0 auto 20px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--pig-pink-light), var(--pig-pink));
    border-radius: 8px;
    transition: width 0.3s ease;
}

.loading-message {
    font-size: 1.2rem;
    min-height: 1.5em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Color Theme Variables - Matches simulation canvas */
:root {
    --grass-green: #5a9c5a;
    --grass-light: #6ab06a;
    --grass-dark: #4a8c4a;
    --brown-indoor: #8B7355;
    --brown-dark: #5c4033;
    --pig-pink: #d4477c;
    --pig-pink-light: #ffb6c1;
    --human-blue: #2980b9;
    --human-blue-light: #87ceeb;
    --accent-gradient: linear-gradient(135deg, var(--grass-green), var(--brown-indoor));
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(to bottom, #6ab06a 0%, #5a9c5a 50%, #4a8c4a 100%);
    color: #333;
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* Main App Layout */
#app {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    gap: 0;
}

/* Header */
header {
    grid-column: 1 / -1;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    color: white;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem;
}

.header-brand {
    font-family: 'Alfa Slab One', cursive;
    font-size: clamp(2rem, 7vw, 2.6rem);
    color: var(--pig-pink);
    text-decoration: none;
    letter-spacing: 1px;
    justify-self: start;
    transition: color 0.3s, transform 0.3s;
}

.header-brand:hover {
    color: var(--pig-pink-light);
    transform: scale(1.05);
}

.header-center {
    text-align: center;
}

header h1 {
    font-size: clamp(1.1rem, 4vw, 1.6rem);
    font-weight: 700;
    margin: 0;
}

header .subtitle {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.7);
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
    justify-self: end;
    flex-wrap: wrap;
}

.btn-header {
    background: rgba(90, 156, 90, 0.2);
    color: var(--grass-green);
    border: 1px solid var(--grass-green);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.3s, transform 0.3s;
}

.btn-header:hover {
    background: rgba(90, 156, 90, 0.4);
    transform: scale(1.05);
}

/* Toolbar (Left Sidebar) */
#toolbar {
    background: linear-gradient(180deg, rgba(255, 182, 193, 0.7) 0%, rgba(255, 182, 193, 0.85) 100%);
    backdrop-filter: blur(10px);
    padding: 20px;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-right: 3px solid var(--pig-pink);
}

.toolbar-section {
    background: rgba(90, 156, 90, 0.08);
    padding: 15px;
    border-radius: 10px;
    border-left: 3px solid var(--grass-green);
}

/* Control panel section - pink background */
#controls-section {
    background: rgba(255, 182, 193, 0.4);
    border-left-color: var(--pig-pink);
}

/* Environment and Statistics sections - blue background */
#environment-section,
#statistics-section {
    background: rgba(135, 206, 235, 0.35);
    border-left-color: var(--human-blue);
}

#environment-section h3,
#statistics-section h3 {
    color: var(--human-blue);
}

.toolbar-section h3 {
    font-size: 0.9rem;
    color: var(--grass-dark);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.btn:last-child {
    margin-bottom: 0;
}

.btn-primary {
    background: linear-gradient(135deg, var(--grass-green), var(--grass-dark));
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--grass-light), var(--grass-green));
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(90, 156, 90, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--brown-indoor), var(--brown-dark));
    color: white;
    border: 1px solid var(--brown-dark);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #9d8466, var(--brown-indoor));
    border-color: var(--brown-indoor);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(92, 64, 51, 0.4);
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Slider Controls */
.slider-group {
    margin-bottom: 12px;
}

.slider-group:last-child {
    margin-bottom: 0;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.slider-value {
    color: var(--grass-green);
    font-weight: 700;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--grass-green), var(--brown-indoor));
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 2px solid var(--grass-green);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 2px solid var(--grass-green);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Select Dropdown */
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    font-weight: 500;
}

select:focus {
    outline: none;
    border-color: var(--grass-green);
}

/* Stats Display */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.stat-label {
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--grass-green);
}

.stat-card.alert {
    grid-column: 1 / -1;
    background: #e74c3c;
    color: white;
    font-weight: 700;
    padding: 12px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* Canvas Container */
#canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, var(--grass-light) 0%, var(--grass-green) 50%, var(--grass-dark) 100%);
    overflow: hidden;
}

#simulation-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Quick Help Overlay */
#quick-help {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    max-width: 300px;
    font-size: 0.85rem;
    border: 2px solid rgba(90, 156, 90, 0.4);
}

#quick-help strong {
    display: block;
    color: var(--grass-green);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

#quick-help ul {
    margin: 0;
    padding-left: 20px;
    line-height: 1.6;
}

#quick-help li {
    margin-bottom: 4px;
    color: #555;
}


/* Variant Population List */
#variant-population-list {
    max-height: 500px;
    overflow-y: auto;
}

.variant-list-header h3 {
    margin-bottom: 5px;
    color: var(--grass-green);
}

.variant-list-header p {
    margin-bottom: 15px;
}

.variant-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.variant-card-item {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    transition: all 0.2s ease;
}

.variant-card-item:hover {
    border-color: var(--grass-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.variant-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 10px;
}

.variant-sequence {
    flex: 1;
}

.sequence-label {
    display: block;
    font-size: 0.75rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 600;
}

.variant-sequence code {
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--pig-pink-light);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: inline-block;
}

.variant-count-badge {
    background: linear-gradient(135deg, var(--grass-green), var(--brown-indoor));
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
}

.variant-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.variant-stat {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-icon {
    font-size: 1.2rem;
    display: block;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--grass-green);
    margin-bottom: 2px;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.variant-phenotypes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.phenotype-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px;
    border-radius: 5px;
    border-left: 3px solid;
    font-size: 0.85rem;
}

.phenotype-red {
    border-left-color: #e74c3c;
}

.phenotype-blue {
    border-left-color: #3498db;
}

.phenotype-green {
    border-left-color: #2ecc71;
}

.phenotype-label {
    display: block;
    font-weight: 600;
    color: #999;
    font-size: 0.75rem;
    margin-bottom: 2px;
}

.phenotype-value {
    display: block;
    color: #ddd;
    font-weight: 600;
}

#genealogy-tree {
    max-height: 500px;
    overflow-y: auto;
    font-size: 0.85rem;
}

.tree-node {
    margin-left: 20px;
    padding: 8px 12px;
    border-left: 2px solid var(--grass-green);
    margin-bottom: 8px;
    background: rgba(90, 156, 90, 0.08);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: #1a2a1a;
    padding: 30px;
    border-radius: 15px;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
    color: #ddd;
    border: 1px solid rgba(90, 156, 90, 0.3);
}

.modal-content.modal-large {
    max-width: 900px;
    max-height: 90vh;
}

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

.modal-content h2 {
    color: var(--grass-green);
    margin-bottom: 20px;
}

.modal-content h3 {
    color: #ccc;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: #888;
    background: none;
    border: none;
    line-height: 1;
}

.close-btn:hover {
    color: #fff;
}

/* Codon Configuration Modal */
.codon-config-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.codon-group {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid;
}

.codon-group.red { border-left-color: #e74c3c; }
.codon-group.blue { border-left-color: #3498db; }
.codon-group.green { border-left-color: #2ecc71; }

.codon-group h4 {
    margin-bottom: 12px;
    font-size: 1rem;
}

.codon-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.codon-option {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.codon-option label {
    font-weight: 600;
    min-width: 60px;
    font-family: 'Courier New', monospace;
}

.codon-option select {
    flex: 1;
    padding: 6px;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.3);
    color: #ddd;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Screening Modal */
.virus-sequence {
    margin: 15px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 4px solid var(--grass-green);
}

.virus-sequence.variant {
    border-left-color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

.sequence-rna {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.sequence-visual {
    display: flex;
    align-items: center;
    gap: 15px;
}

.virus-particle-display {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Antibody Modal */
.host-info-section {
    margin-bottom: 25px;
}

.host-info-section h3 {
    color: var(--grass-green);
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.info-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid var(--grass-green);
}

.info-label {
    display: block;
    font-size: 0.8rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 600;
}

.info-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ddd;
}

.antibody-section h3 {
    color: var(--grass-green);
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.antibody-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.antibody-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.antibody-card:hover {
    border-color: var(--grass-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.antibody-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.3rem;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.antibody-details {
    flex: 1;
}

.antibody-details strong {
    display: block;
    color: #ddd;
    margin-bottom: 2px;
}

/* Tutorial */
.tutorial-content {
    max-width: 600px;
}

#tutorial-step-content {
    margin: 20px 0;
    min-height: 200px;
}

#tutorial-step-content ul {
    margin-left: 20px;
    margin-top: 10px;
}

#tutorial-step-content h4 {
    color: var(--grass-green);
    margin-top: 15px;
    margin-bottom: 8px;
}

.tutorial-controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.tutorial-controls button {
    flex: 1;
}

.tutorial-checkbox {
    display: block;
    margin-top: 15px;
    text-align: center;
    cursor: pointer;
    font-size: 0.9rem;
}

.tutorial-checkbox input {
    margin-right: 8px;
}

/* Interactive Tutorial Demos */
.tutorial-hint {
    text-align: center;
    color: var(--grass-green);
    font-style: italic;
    margin-top: 15px;
}

/* Codon Demo Styles */
.tutorial-codon-demo {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin: 15px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.codon-sequence {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.codon-label {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.1rem;
    color: #ddd;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.codon-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    min-width: 140px;
}

.codon-box.codon-1 { background: rgba(231, 76, 60, 0.2); border: 2px solid #e74c3c; }
.codon-box.codon-2 { background: rgba(52, 152, 219, 0.2); border: 2px solid #3498db; }
.codon-box.codon-3 { background: rgba(46, 204, 113, 0.2); border: 2px solid #2ecc71; }

.codon-title {
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.codon-box.codon-1 .codon-title { color: #e74c3c; }
.codon-box.codon-2 .codon-title { color: #3498db; }
.codon-box.codon-3 .codon-title { color: #2ecc71; }

.codon-select {
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.85rem;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.3);
    color: #ddd;
}

.phenotype-display {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    gap: 20px;
}

.phenotype-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.phenotype-item span {
    font-size: 0.85rem;
    color: #bbb;
}

.phenotype-icon {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Spread radius icon */
.spread-icon {
    position: relative;
}

.stick-figure {
    width: 20px;
    height: 30px;
    position: relative;
    z-index: 2;
}

.stick-figure::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ffb6c1;
    border-radius: 50%;
    top: 0;
    left: 4px;
    border: 2px solid var(--pig-pink);
}

.stick-figure::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 18px;
    background: var(--pig-pink);
    top: 12px;
    left: 9px;
}

.spread-radius {
    position: absolute;
    width: 70px;
    height: 70px;
    border: 3px dashed rgba(231, 76, 60, 0.5);
    border-radius: 50%;
    background: rgba(231, 76, 60, 0.1);
    transition: all 0.3s ease;
    animation: pulse-radius 1.5s ease-in-out infinite;
}

@keyframes pulse-radius {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
}

/* Virus icon - redesigned with antigens all around */
.virus-icon .virus-body,
.demo-virus .virus-body,
.parent-virus .virus-body,
.offspring-virus .virus-body,
.species-virus .virus-body {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 10px rgba(238, 90, 90, 0.4);
}

/* Default antigens - Type A (triangular spikes) */
.virus-body::before,
.virus-body::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
}

.virus-body::before {
    /* Top spike */
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 12px solid #ee5a5a;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: none;
}

.virus-body::after {
    /* Bottom spike */
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 12px solid #ee5a5a;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
}

/* Antigen spikes container - for 8 spikes around the virus */
.virus-body .antigen-spikes {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Type A antigens - Triangular spikes (default) */
.virus-body[data-antigen="A"] .spike,
.virus-body .spike {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 10px solid #ee5a5a;
}

/* Type B antigens - Round/bulb ends */
.virus-body[data-antigen="B"] .spike {
    width: 6px;
    height: 12px;
    background: #ee5a5a;
    border-radius: 3px 3px 50% 50%;
    border: none;
}

/* Type C antigens - Y-shaped forks */
.virus-body[data-antigen="C"] .spike {
    width: 8px;
    height: 10px;
    background: transparent;
    border: none;
    border-top: 3px solid #ee5a5a;
    border-left: 3px solid #ee5a5a;
    border-right: 3px solid #ee5a5a;
    border-radius: 0;
}

/* Type D antigens - Diamond shapes */
.virus-body[data-antigen="D"] .spike {
    width: 8px;
    height: 8px;
    background: #ee5a5a;
    border: none;
    transform: rotate(45deg);
    border-radius: 0;
}

/* Type E antigens - Hook shapes */
.virus-body[data-antigen="E"] .spike {
    width: 6px;
    height: 10px;
    background: transparent;
    border: 3px solid #ee5a5a;
    border-bottom: none;
    border-radius: 50% 50% 0 0;
}

.virus-body .antigen-letter,
.virus-body span {
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    z-index: 10;
}

.virus-body.large {
    width: 60px;
    height: 60px;
}

.virus-body.small {
    width: 35px;
    height: 35px;
}

.virus-body.small span {
    font-size: 0.9rem;
}

.virus-body.mutant {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    box-shadow: 0 4px 10px rgba(142, 68, 173, 0.4);
    animation: glow-mutant 1s ease-in-out infinite;
}

.virus-body.mutant::before {
    border-bottom-color: #8e44ad;
}

.virus-body.mutant::after {
    border-top-color: #8e44ad;
}

@keyframes glow-mutant {
    0%, 100% { box-shadow: 0 0 5px rgba(142, 68, 173, 0.4); }
    50% { box-shadow: 0 0 20px rgba(142, 68, 173, 0.8); }
}

/* SVG Virus Styles */
.virus-svg {
    display: block;
}

.virus-svg.mutant {
    filter: drop-shadow(0 0 8px rgba(142, 68, 173, 0.6));
    animation: svg-glow-mutant 1s ease-in-out infinite;
}

@keyframes svg-glow-mutant {
    0%, 100% { filter: drop-shadow(0 0 5px rgba(142, 68, 173, 0.4)); }
    50% { filter: drop-shadow(0 0 15px rgba(142, 68, 173, 0.8)); }
}

.receptor-svg {
    display: block;
}

/* Timer icon */
.timer-icon .clock-face {
    width: 50px;
    height: 50px;
    border: 4px solid #2ecc71;
    border-radius: 50%;
    position: relative;
    background: rgba(0, 0, 0, 0.3);
}

.clock-hand {
    position: absolute;
    width: 2px;
    height: 18px;
    background: #2ecc71;
    top: 50%;
    left: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%);
    animation: rotate-clock 2s linear infinite;
}

@keyframes rotate-clock {
    from { transform: translateX(-50%) rotate(0deg); }
    to { transform: translateX(-50%) rotate(360deg); }
}

/* Infection Demo Styles */
.tutorial-infection-demo {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin: 15px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.infection-scene {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
}

.demo-host {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.demo-host .host-body {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #ffb6c1, #ff9eb5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--pig-pink);
    transition: all 0.3s ease;
}

.demo-host.infected .host-body {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    animation: infected-pulse 0.5s ease-in-out;
}

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

.receptor-site {
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--pig-pink);
}

.receptor-letter {
    font-weight: bold;
    color: var(--pig-pink);
}

.host-label, .virus-label {
    font-size: 0.85rem;
    color: #bbb;
}

.demo-virus-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.demo-virus {
    transition: all 0.5s ease;
}

.demo-virus.trying {
    animation: move-to-host 0.5s ease-out;
}

@keyframes move-to-host {
    0% { transform: translateX(0); }
    50% { transform: translateX(-30px); }
    100% { transform: translateX(0); }
}

.demo-virus.infecting {
    transform: translateX(-20px) scale(0.8);
    opacity: 0.7;
}

.demo-virus.blocked {
    animation: blocked-bounce 0.5s ease;
}

@keyframes blocked-bounce {
    0% { transform: translateX(0); }
    25% { transform: translateX(-20px); }
    50% { transform: translateX(10px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

.match-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}

.match-result {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
}

.match-result.success {
    background: rgba(46, 204, 113, 0.2);
    border: 2px solid #2ecc71;
}

.match-result.fail {
    background: rgba(231, 76, 60, 0.2);
    border: 2px solid #e74c3c;
}

.success-text { color: #27ae60; font-weight: bold; }
.fail-text { color: #e74c3c; font-weight: bold; }

/* Mutation Demo Styles */
.tutorial-mutation-demo {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin: 15px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.mutation-scene {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.parent-virus, .offspring-virus {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.replication-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.arrow-line {
    width: 40px;
    height: 3px;
    background: #999;
}

.arrow-head {
    width: 0;
    height: 0;
    border-left: 8px solid #999;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    margin-left: 38px;
    margin-top: -9px;
}

.offspring-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.3s ease;
}

.offspring-container.replicating {
    animation: replicate-shake 0.3s ease;
}

@keyframes replicate-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.offspring-row {
    display: flex;
    gap: 10px;
}

.mutant-label {
    font-size: 0.7rem;
    color: #8e44ad;
    font-weight: bold;
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.offspring-virus.mutating .virus-body {
    animation: mutate-flash 0.5s ease;
}

@keyframes mutate-flash {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5); }
}

.mutation-info {
    text-align: center;
}

.mutation-info p {
    margin-bottom: 10px;
}

/* Zoonotic Demo Styles */
.tutorial-zoonotic-demo {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin: 15px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.species-comparison {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 20px;
}

.species-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border-radius: 10px;
    flex: 1;
    max-width: 180px;
}

.pig-panel { background: rgba(255, 182, 193, 0.3); }
.human-panel { background: rgba(135, 206, 235, 0.3); }

.species-divider {
    width: 2px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 5px;
}

.species-virus {
    transition: all 0.4s ease;
}

.species-virus.mutating {
    animation: mutate-flash 0.4s ease;
}

.infection-arrow {
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: bold;
    text-align: center;
}

.infection-arrow.success {
    background: rgba(46, 204, 113, 0.3);
    color: #27ae60;
    border: 2px solid #27ae60;
}

.infection-arrow.fail {
    background: rgba(231, 76, 60, 0.3);
    color: #e74c3c;
    border: 2px solid #e74c3c;
}

.species-host {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.pig-icon-tutorial {
    width: 50px;
    height: 40px;
    background: #ffb6c1;
    border-radius: 50%;
    position: relative;
    border: 2px solid var(--pig-pink);
}

.pig-icon-tutorial::before {
    content: '';
    position: absolute;
    width: 15px;
    height: 10px;
    background: #ffb6c1;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -30%);
    border: 2px solid var(--pig-pink);
}

.pig-icon-tutorial::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ffb6c1;
    border-radius: 50%;
    top: -5px;
    left: 5px;
    box-shadow: 25px 0 0 #ffb6c1;
    border: 2px solid var(--pig-pink);
}

.human-icon-tutorial {
    width: 30px;
    height: 50px;
    position: relative;
}

.human-icon-tutorial::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #deb887;
    border-radius: 50%;
    top: 0;
    left: 5px;
    border: 2px solid var(--human-blue);
}

.human-icon-tutorial::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 25px;
    background: var(--human-blue);
    border-radius: 5px 5px 0 0;
    top: 20px;
    left: 2px;
}

.receptor-badge {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 3px 8px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ddd;
}

.zoonotic-controls {
    text-align: center;
    margin-bottom: 15px;
}

.zoonotic-result {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
}

.zoonotic-result.success {
    background: rgba(46, 204, 113, 0.2);
    border: 2px solid #2ecc71;
}

/* Host Comparison Cards */
.host-comparison {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 20px 0;
}

.host-info-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
    flex: 1;
    max-width: 220px;
    text-align: center;
}

.host-info-card h4 {
    margin: 10px 0;
}

.host-info-card ul {
    text-align: left;
    margin: 0;
    padding-left: 20px;
}

.host-info-card li {
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.pig-card { border: 2px solid var(--pig-pink); }
.human-card { border: 2px solid var(--human-blue); }

.host-icon-large {
    width: 60px;
    height: 50px;
    margin: 0 auto;
}

.host-icon-large.pig-icon-tutorial {
    width: 60px;
    height: 45px;
}

.host-icon-large.human-icon-tutorial {
    width: 35px;
    height: 55px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Info boxes */
.info-box {
    background: rgba(52, 152, 219, 0.1);
    border-left: 3px solid #3498db;
    padding: 12px;
    border-radius: 5px;
    margin: 10px 0;
    font-size: 0.9rem;
}

/* Loading indicator */
.loading {
    text-align: center;
    padding: 20px;
    color: #999;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    #app {
        grid-template-columns: 1fr;
        grid-template-rows: auto 200px 1fr;
    }

    #toolbar {
        max-height: none;
        overflow-x: auto;
        overflow-y: visible;
        display: flex;
        flex-direction: row;
        gap: 15px;
        padding: 15px;
    }

    .toolbar-section {
        min-width: 250px;
        flex-shrink: 0;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .btn-header {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    #quick-help {
        font-size: 0.75rem;
        padding: 10px 12px;
        max-width: 250px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 0.6rem 1rem;
        gap: 0.3rem;
    }

    header .subtitle {
        font-size: 0.7rem;
    }

    .btn-header {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    #toolbar {
        padding: 10px;
    }

    .toolbar-section {
        padding: 12px;
        min-width: 220px;
    }

    .modal-content {
        padding: 20px;
        max-width: 95%;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .variant-stats {
        grid-template-columns: 1fr;
    }

    .variant-phenotypes {
        grid-template-columns: 1fr;
    }

    .variant-header {
        flex-direction: column;
    }

    .variant-count-badge {
        align-self: flex-start;
    }
}

/* Smooth scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(90, 156, 90, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(90, 156, 90, 0.7);
}

/* ===== NEW TUTORIAL STYLES ===== */

/* Inline Codon Sequence Layout */
.codon-sequence-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    margin-bottom: 10px;
    flex-wrap: nowrap;
    font-family: 'Courier New', monospace;
}

.codon-base {
    font-weight: bold;
    font-size: 1.1rem;
    color: #bbb;
    padding: 8px 6px;
    letter-spacing: 2px;
}

.codon-base-select {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.1rem;
    padding: 8px 4px;
    border: none;
    border-bottom: 3px solid;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    text-align: center;
    width: 55px;
    letter-spacing: 2px;
    outline: none;
    border-radius: 4px 4px 0 0;
    animation: codon-pulse 2s ease-in-out 3;
}

.codon-base-select:hover {
    filter: brightness(0.92);
}

.codon-base-select.codon-1 {
    color: #fff;
    background: rgba(231, 76, 60, 0.75);
    border-bottom-color: #c0392b;
}
.codon-base-select.codon-2 {
    color: #fff;
    background: rgba(52, 152, 219, 0.75);
    border-bottom-color: #2471a3;
}
.codon-base-select.codon-3 {
    color: #fff;
    background: rgba(46, 204, 113, 0.75);
    border-bottom-color: #1e8449;
}

@keyframes codon-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.codon-legend {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
    font-size: 0.75rem;
}

.codon-legend-item {
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 600;
}

.codon-1-label { color: #e74c3c; }
.codon-2-label { color: #3498db; }
.codon-3-label { color: #2ecc71; }

.phenotype-result {
    text-align: center;
    font-size: 0.9rem;
    color: #ddd;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin-bottom: 15px;
}

/* Spread Radius with Pig Icon Center */
.spread-icon-container {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spread-radius-circle {
    position: absolute;
    width: 70px;
    height: 70px;
    border: 3px dashed rgba(231, 76, 60, 0.6);
    border-radius: 50%;
    background: rgba(231, 76, 60, 0.1);
    transition: all 0.3s ease;
    animation: pulse-radius 1.5s ease-in-out infinite;
}

.pig-icon-center {
    width: 35px;
    height: 28px;
    background: #ffb6c1;
    border-radius: 50%;
    position: relative;
    z-index: 2;
    border: 2px solid var(--pig-pink);
}

.pig-icon-center::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 8px;
    background: #ffb6c1;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -30%);
    border: 1.5px solid var(--pig-pink);
}

.pig-icon-center::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: #ffb6c1;
    border-radius: 50%;
    top: -4px;
    left: 3px;
    box-shadow: 16px 0 0 #ffb6c1;
    border: 1.5px solid var(--pig-pink);
}

/* SVG Clock with hands from center */
.clock-container {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clock-svg {
    width: 50px;
    height: 50px;
    --clock-speed: 4s;
}

.clock-svg .clock-hand-minute {
    transform-origin: 25px 25px;
    animation: clock-rotate var(--clock-speed) linear infinite;
}

.clock-svg .clock-hand-hour {
    transform-origin: 25px 25px;
    animation: clock-rotate calc(var(--clock-speed) * 12) linear infinite;
}

@keyframes clock-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== LOCK AND KEY DEMO STYLES ===== */
.tutorial-lockkey-demo {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin: 15px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* 2D Lock-and-Key Scene Layout */
.lockkey-scene-2d {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin-bottom: 20px;
    min-height: 200px;
}

/* Virus Section (top) */
.virus-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.6s ease;
}

.virus-section .antigen-label {
    font-size: 0.85rem;
    color: #bbb;
    margin-bottom: 5px;
}

.virus-with-downward-antigen {
    transition: transform 0.3s ease;
}

/* Virus approaching animations (now vertical) */
.virus-section.approaching {
    animation: approach-cell-2d 0.6s ease-out;
}

@keyframes approach-cell-2d {
    0% { transform: translateY(0); }
    50% { transform: translateY(25px); }
    100% { transform: translateY(0); }
}

.virus-section.bound {
    transform: translateY(20px);
}

.virus-section.bound .virus-with-downward-antigen {
    transform: scale(0.95);
}

.virus-section.rejected {
    animation: reject-bounce-2d 0.6s ease;
}

@keyframes reject-bounce-2d {
    0% { transform: translateY(0); }
    20% { transform: translateY(20px); }
    40% { transform: translateY(-15px); }
    60% { transform: translateY(8px); }
    80% { transform: translateY(-4px); }
    100% { transform: translateY(0); }
}

/* Membrane Section (bottom) */
.membrane-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.cell-membrane-line {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.membrane-left,
.membrane-right {
    width: 80px;
    height: 8px;
    background: linear-gradient(to bottom, #d4477c, #c73865);
    border-radius: 2px;
}

.receptor-indent {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-top: -3px;
}

.receptor-indent-svg {
    display: block;
}

.membrane-section .receptor-label {
    font-size: 0.85rem;
    color: #bbb;
    margin-top: 8px;
}

.cell-interior-label {
    font-size: 0.75rem;
    color: #bbb;
    margin-top: 5px;
    padding: 5px 15px;
    background: rgba(255, 182, 193, 0.15);
    border-radius: 4px;
}
