/* ===========================
   Clean, Professional Design
   Inspired by modern educational platforms
   =========================== */

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

:root {
    /* Nature-inspired color palette - Browns and Greens */
    --primary-color: #2d5016;        /* Deep forest green */
    --primary-hover: #1f3a0f;        /* Darker forest green */
    --secondary-color: #6b8e23;      /* Olive green */
    --accent-color: #8b7355;         /* Warm brown */
    --text-primary: #2c2416;         /* Dark brown-black */
    --text-secondary: #4a3f2e;       /* Medium brown */
    --text-muted: #6b5d4f;           /* Light brown */
    --bg-main: #fdfcfa;              /* Cream/off-white */
    --bg-secondary: #f5f1e8;         /* Warm beige */
    --bg-interactive: #e8f5e0;       /* Light mint green */
    --border-color: #d4c9b8;         /* Tan/beige border */
    --success-color: #4a7c2c;        /* Natural green */
    --error-color: #a0522d;          /* Sienna brown */
    --sidebar-width: 280px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* ===========================
   Layout Structure
   =========================== */

.page-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-main);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    left: 0;
    top: 0;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.sidebar-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
}

.sidebar-nav {
    padding: 1.5rem 0;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.nav-item {
    display: block;
    padding: 0.625rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-interactive);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 500;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 3rem 4rem;
    max-width: 900px;
}

.lesson {
    background: var(--bg-main);
    padding: 3rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* ===========================
   Typography
   =========================== */

.lesson-header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.2;
}

.lesson-intro {
    font-size: 1.125rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid var(--border-color);
}

h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 3rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ===========================
   Content Sections
   =========================== */

.module-info {
    background: var(--bg-interactive);
    padding: 2rem;
    border-radius: 6px;
    margin-bottom: 2.5rem;
}

.module-info h2 {
    margin-top: 0;
    font-size: 1.5rem;
}

.module-info ul {
    margin-left: 1.5rem;
    margin-top: 0.75rem;
}

.module-info li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.module-features {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.prerequisites {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-main);
    border-left: 3px solid var(--secondary-color);
    border-radius: 4px;
}

.content-section {
    margin-bottom: 3rem;
}

.content-section:first-of-type h2 {
    margin-top: 0;
}

.note {
    font-size: 0.9375rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 1rem;
}

/* ===========================
   Interactive Elements
   =========================== */

.interactive-block {
    background: var(--bg-interactive);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2rem;
    margin: 2rem 0;
}

.interactive-block h3 {
    margin-top: 0;
    font-size: 1.125rem;
    color: var(--primary-color);
}

.demo-area {
    margin-top: 1.5rem;
    padding: 2rem;
    background: var(--bg-main);
    border-radius: 6px;
    text-align: center;
}

.demo-description {
    margin-top: 1rem;
    font-size: 0.9375rem;
    color: var(--text-muted);
}

/* Bit Display */
.bit-display {
    margin: 2rem 0;
}

.bit-value {
    display: inline-block;
    width: 80px;
    height: 80px;
    line-height: 80px;
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    background: var(--bg-secondary);
    border-radius: 8px;
    text-align: center;
}

/* Coin Animation */
.coin-container {
    margin: 2rem 0;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coin {
    width: 100px;
    height: 100px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    font-weight: 700;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.coin.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

.coin-face {
    backface-visibility: hidden;
}

/* Probability Slider */
.probability-slider {
    margin-bottom: 2rem;
}

.probability-slider label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
}

#prob-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 1rem;
}

#prob-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

#prob-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 8px rgba(0, 102, 204, 0.1);
}

#prob-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    cursor: pointer;
}

.prob-values {
    display: flex;
    justify-content: space-between;
    font-size: 0.9375rem;
}

/* Probability Visualization */
.probability-visualization {
    margin: 2rem 0;
}

.prob-bar-wrapper {
    margin-bottom: 1rem;
    position: relative;
}

.prob-bar {
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 50%;
    display: flex;
    align-items: center;
    padding-left: 1rem;
    color: white;
    font-weight: 600;
}

.prob-bar-wrapper:nth-child(2) .prob-bar {
    background: linear-gradient(135deg, var(--secondary-color), #748ffc);
}

.bar-label {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 0.625rem 1.5rem;
    border-radius: 6px;
    border: none;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
}

.button-group {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* Result Text */
.result-text {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-interactive);
    border-radius: 4px;
    color: var(--text-secondary);
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.result-text:empty {
    display: none;
}

/* ===========================
   Circuit Visualizations (Lesson 2)
   =========================== */

.gate-demo {
    margin: 2rem 0;
}

.circuit-display {
    background: var(--bg-main);
    padding: 2rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.qubit-wire {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem;
    border-bottom: 2px solid var(--text-primary);
    position: relative;
}

.state-label {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 500;
    min-width: 80px;
}

.gate-box {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    min-width: 60px;
    text-align: center;
}

.gate-box.gate-h {
    background: var(--secondary-color);
}

.gate-box.gate-z {
    background: var(--accent-color);
}

.measurement-box {
    font-size: 1.5rem;
    padding: 0.5rem;
}

.gate-placeholder {
    min-width: 60px;
    height: 40px;
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circuit-builder {
    margin: 1.5rem 0;
}

.measurement-stats {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.history-display {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    padding: 0.75rem;
    background: var(--bg-main);
    border-radius: 4px;
    margin: 0.5rem 0;
    text-align: center;
    letter-spacing: 0.5rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* ===========================
   Measurement Results Display
   =========================== */

.measurement-results {
    margin-top: 1.5rem;
}

.results-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-main);
    border-radius: 6px;
    margin: 1rem 0;
    min-height: 60px;
    justify-content: center;
}

.result-badge {
    display: inline-block;
    min-width: 48px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-radius: 16px;
    font-weight: 700;
    font-size: 0.95rem;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin: 0.25rem;
    padding: 0 0.5rem;
    white-space: nowrap;
}

.result-badge.result-0 {
    background: var(--primary-color);
}

.result-badge.result-1 {
    background: var(--secondary-color);
}

.stats-display {
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1rem;
}

.result-text {
    margin-top: 1.5rem;
    text-align: center;
}

#state-test-results {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
    padding: 1rem 0;
}

.input-selector {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.input-selector label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.two-qubit-wire {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ===========================
   Lesson 4: Superposition Elements
   =========================== */

.color-mixer {
    margin: 1.5rem 0;
}

.color-display {
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
}

.mixed-color {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: background 0.3s ease;
}

.color-labels {
    display: flex;
    justify-content: space-around;
    margin-top: 1rem;
    font-size: 1.05rem;
}

.preset-buttons {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.prob-display-large {
    display: flex;
    justify-content: space-around;
    margin: 1.5rem 0;
    font-size: 1.2rem;
}

.bloch-simple {
    position: relative;
    height: 300px;
    width: 80%;
    max-width: 400px;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.bloch-pole {
    text-align: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-weight: 600;
}

.bloch-pole.north {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.bloch-pole.south {
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    color: white;
}

.bloch-line {
    position: absolute;
    top: 50px;
    bottom: 50px;
    left: 50%;
    width: 3px;
    background: var(--border-color);
    transform: translateX(-50%);
}

.bloch-point {
    position: absolute;
    left: 50%;
    width: 24px;
    height: 24px;
    background: var(--accent-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: top 0.3s ease;
}

.bloch-description {
    text-align: center;
    margin-top: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ===========================
   Lesson 5, 6, 7: Additional Elements
   =========================== */

.result-badge.result-multi {
    width: 48px;
    font-size: 0.875rem;
}

.gate-cnot-control {
    background: var(--primary-color) !important;
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.gate-cnot-target {
    background: white !important;
    border: 2px solid var(--primary-color) !important;
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.cnot-gate-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cnot-gate-container .qubit-wire {
    position: relative;
}

/* Hide the manual connection line div (we use CSS pseudo-element instead) */
.cnot-connection-line {
    display: none;
}

/* Draw vertical connection line from control to target */
.cnot-gate-container .gate-cnot-control {
    position: relative;
    z-index: 2;
}

.cnot-gate-container .gate-cnot-control::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: calc(2rem + 45px);
    background: var(--primary-color);
    transform: translate(-50%, 0);
    z-index: -1;
}

.cnot-gate-container .gate-cnot-target {
    position: relative;
    z-index: 2;
}

.gate-spacer {
    min-width: 60px;
}

.scaling-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

.scaling-table th,
.scaling-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.scaling-table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.scaling-table tr:hover {
    background: var(--bg-interactive);
}

.bell-result-display {
    text-align: center;
    padding: 1.5rem;
    margin: 1rem 0;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 1.5rem;
}

.entangled-pair {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin: 2rem 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.qubit-box {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    text-align: center;
    min-width: 120px;
}

.qubit-state {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: 0.5rem;
}

.entanglement-link {
    font-size: 1.2rem;
    color: var(--accent-color);
    font-weight: 600;
}

.comparison-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.column {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.column h4 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.step {
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: var(--bg-main);
    border-radius: 4px;
    border-left: 3px solid var(--primary-color);
}

.sequential-steps .step {
    border-left-color: var(--accent-color);
}

.parallel-steps .step {
    border-left-color: var(--secondary-color);
}

.items {
    text-align: center;
    color: var(--text-muted);
    padding: 0.5rem;
}

.search-comparison {
    display: flex;
    gap: 2rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.search-method {
    flex: 1;
    min-width: 200px;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.search-method.quantum {
    border-color: var(--primary-color);
    background: var(--bg-interactive);
}

.applications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.app-card {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s;
}

.app-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.app-card h4 {
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
}

.timeline {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.5rem;
}

.timeline-visual {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
}

.timeline-item {
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-left: 4px solid var(--secondary-color);
    border-radius: 4px;
}

.completion-summary {
    background: var(--bg-interactive);
    padding: 2rem;
    border-radius: 8px;
    margin: 2rem 0;
}

.completion-summary ul {
    list-style: none;
    padding-left: 0;
}

.completion-summary li {
    padding: 0.5rem 0;
    font-size: 1.05rem;
}

/* ===========================
   Quiz Section
   =========================== */

.quiz-section {
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 2px solid var(--border-color);
}

.quiz-question {
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.question-text {
    margin-bottom: 1.25rem;
    font-size: 1.0625rem;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--bg-main);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option:hover {
    border-color: var(--primary-color);
    background: var(--bg-interactive);
}

.option input[type="radio"] {
    margin-right: 0.75rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.option.correct {
    background: #d4edda;
    border-color: var(--success-color);
}

.option.incorrect {
    background: #f8d7da;
    border-color: var(--error-color);
}

.feedback {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 4px;
    font-weight: 500;
    display: none;
}

.feedback.show {
    display: block;
}

.feedback.correct {
    background: #d4edda;
    color: #155724;
    border: 1px solid var(--success-color);
}

.feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid var(--error-color);
}

.quiz-result {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-interactive);
    border-radius: 6px;
    text-align: center;
    font-size: 1.125rem;
    font-weight: 600;
    display: none;
}

.quiz-result.show {
    display: block;
}

.quiz-result.excellent {
    background: #d4edda;
    color: var(--success-color);
}

.quiz-result.good {
    background: #fff3cd;
    color: #856404;
}

.quiz-result.needsWork {
    background: #f8d7da;
    color: var(--error-color);
}

/* ===========================
   Navigation
   =========================== */

.lesson-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.nav-button {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.nav-button:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.nav-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.nav-button.next {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.nav-button.next:hover {
    background: var(--primary-hover);
}

/* ===========================
   Lesson 1: New Interactive Elements
   =========================== */

/* Speed Comparison Interactive */
.speed-comparison {
    padding: 1.5rem;
}

.speed-comparison label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.speed-comparison input[type="range"] {
    width: 100%;
    margin-bottom: 1rem;
}

.size-display {
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.comparison-bars {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 2rem 0;
}

.computer-bar-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.computer-label {
    font-weight: 600;
    color: var(--text-color);
}

.speed-bar {
    height: 30px;
    border-radius: 4px;
    transition: width 0.3s ease;
    min-width: 5%;
}

.speed-bar.classical {
    background: linear-gradient(to right, #8b7355, #6b8e23);
}

.speed-bar.quantum {
    background: linear-gradient(to right, #2d5016, #6b8e23);
}

.time-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.speedup-display {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--interactive-bg);
    border-radius: 8px;
    color: var(--secondary-color);
}

/* Learning Roadmap */
.lesson-roadmap {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.roadmap-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.roadmap-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 150%;
    height: 100%;
    background: linear-gradient(110deg,
        transparent 0%,
        transparent 40%,
        rgba(255, 255, 255, 0.7) 50%,
        rgba(255, 255, 255, 0.9) 55%,
        rgba(255, 255, 255, 0.7) 60%,
        transparent 70%,
        transparent 100%);
    transform: skewX(-20deg);
    z-index: 1;
}

.roadmap-item > * {
    position: relative;
    z-index: 2;
}

.roadmap-item:hover::before {
    animation: shimmer 1.2s ease-in-out;
}

.roadmap-item:hover {
    border-color: var(--secondary-color);
}

@keyframes shimmer {
    0% {
        left: -150%;
    }
    100% {
        left: 150%;
    }
}

.roadmap-item.current {
    border-color: var(--primary-color);
    background: var(--interactive-bg);
    box-shadow: 0 2px 8px rgba(45, 80, 22, 0.1);
}

.roadmap-number {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--secondary-color);
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.2rem;
}

.roadmap-item.current .roadmap-number {
    background: var(--primary-color);
}

.roadmap-content h4 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
}

.roadmap-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Bit vs Qubit Comparison */
.bit-qubit-comparison {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem;
}

.comparison-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: white;
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
}

.comparison-panel h4 {
    margin: 0;
    color: var(--primary-color);
}

.bit-display,
.qubit-display {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--primary-color);
    border-radius: 8px;
    background: var(--interactive-bg);
}

.bit-value {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary-color);
    transition: transform 0.2s ease;
}

.qubit-mystery {
    font-size: 3rem;
    color: var(--secondary-color);
    animation: pulse 1.5s ease-in-out infinite;
}

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

.qubit-notation {
    font-size: 1.2rem;
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    font-weight: bold;
}

.vs-divider {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

.panel-note {
    font-size: 0.9rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Highlight Box */
.highlight-box {
    background: linear-gradient(135deg, #e8f5e0 0%, #fdfcfa 100%);
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 4px;
}

.highlight-box h3 {
    margin-top: 0;
    color: var(--primary-color);
}

.highlight-box p {
    margin-bottom: 0;
}

.hidden {
    display: none !important;
}

/* ===========================
   Lesson 2: Classical Computing Elements
   =========================== */

/* Binary Counter */
.binary-counter {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
}

.bit-positions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.bit-position {
    width: 45px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.binary-display {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.bit-box {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.bit-box.on {
    background: var(--primary-color);
    color: white;
}

.bit-box.off {
    background: white;
    color: var(--primary-color);
}

.bit-box:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(45, 80, 22, 0.2);
}

.decimal-display {
    text-align: center;
    font-size: 1.2rem;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--interactive-bg);
    border-radius: 8px;
}

.challenge-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #fff3cd 0%, #fdfcfa 100%);
    border-left: 4px solid #ffc107;
    border-radius: 4px;
}

/* Gate Playground */
.gate-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.gate-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: white;
    border: 2px solid var(--secondary-color);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.gate-tab:hover {
    background: var(--interactive-bg);
}

.gate-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.gate-panel {
    display: none;
}

.gate-panel.active {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.gate-visual {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 2rem;
    background: var(--interactive-bg);
    border-radius: 8px;
}

.gate-input,
.gate-output {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.gate-inputs-dual {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bit-button {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    font-weight: bold;
    border: 3px solid var(--primary-color);
    border-radius: 8px;
    background: white;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.bit-button.on {
    background: var(--primary-color);
    color: white;
}

.bit-button:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(45, 80, 22, 0.2);
}

.gate-symbol {
    padding: 1.5rem 2rem;
    background: var(--primary-color);
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(45, 80, 22, 0.3);
}

.bit-display-small {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    border: 3px solid var(--secondary-color);
    border-radius: 8px;
    background: white;
    color: var(--secondary-color);
}

.bit-display-small.on {
    background: var(--secondary-color);
    color: white;
}

.truth-table {
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.truth-table h4 {
    margin-top: 0;
    color: var(--primary-color);
}

.truth-table table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.truth-table th,
.truth-table td {
    padding: 0.75rem;
    text-align: center;
    border: 1px solid #e0e0e0;
}

.truth-table th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.truth-table td {
    background: white;
}

/* Circuit Simulator */
.circuit-simulator {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.circuit-inputs {
    display: flex;
    gap: 2rem;
    justify-content: center;
    padding: 1.5rem;
    background: var(--interactive-bg);
    border-radius: 8px;
}

.circuit-input {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.circuit-diagram {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 2rem;
    background: white;
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
}

.circuit-wire {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.circuit-wire.final {
    justify-content: center;
    margin-top: 1rem;
}

.wire-label {
    font-weight: 600;
    min-width: 80px;
    color: var(--text-color);
}

.wire-line {
    flex: 1;
    height: 2px;
    background: var(--primary-color);
    min-width: 20px;
}

.circuit-gate-box {
    padding: 0.75rem 1.5rem;
    background: var(--secondary-color);
    color: white;
    font-weight: bold;
    border-radius: 4px;
    white-space: nowrap;
}

.circuit-explanation {
    padding: 1.5rem;
    background: linear-gradient(135deg, #e8f5e0 0%, #fdfcfa 100%);
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
}

.circuit-explanation h4 {
    margin-top: 0;
    color: var(--primary-color);
}

#circuit-step-by-step {
    margin: 0;
    line-height: 1.6;
}

/* ===========================
   Responsive Design
   =========================== */

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: var(--secondary-color);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 12px rgba(0,0,0,0.15);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 2rem;
        padding-top: 4rem;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .lesson {
        padding: 2rem;
        max-width: 100%;
    }

    .page-layout {
        width: 100%;
        overflow-x: hidden;
    }
}

@media (max-width: 768px) {
    /* Force fluid layout */
    * {
        max-width: 100%;
    }

    .main-content {
        padding: 1rem;
        padding-top: 4rem;
        width: 100%;
        box-sizing: border-box;
    }

    .lesson {
        padding: 1rem;
        width: 100%;
    }

    .lesson-header {
        padding: 1rem 0;
    }

    .lesson-header h1 {
        font-size: 1.5rem;
        word-wrap: break-word;
    }

    .lesson-intro {
        font-size: 0.9375rem;
    }

    h2 {
        font-size: 1.375rem;
        margin-top: 1.5rem;
        margin-bottom: 1rem;
    }

    h3 {
        font-size: 1.125rem;
        margin-top: 1rem;
        margin-bottom: 0.75rem;
    }

    .interactive-block {
        padding: 0.75rem;
        margin: 1rem 0;
        border-radius: 8px;
    }

    .demo-area {
        padding: 0.75rem;
        width: 100%;
        box-sizing: border-box;
    }

    .content-section {
        padding: 0;
        margin-bottom: 1.5rem;
    }

    .module-info {
        padding: 0.875rem;
        margin: 1rem 0;
    }

    .button-group {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .button-group button,
    .button-group .btn-secondary {
        width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box;
    }

    .btn-primary,
    .btn-secondary,
    button.btn-primary,
    button.btn-secondary {
        width: 100%;
        padding: 0.875rem 1rem;
        font-size: 0.9375rem;
        box-sizing: border-box;
        white-space: normal;
        line-height: 1.3;
    }

    /* Input selectors */
    .input-selector {
        width: 100%;
        margin-bottom: 1rem;
    }

    .input-selector label {
        display: block;
        margin-bottom: 0.5rem;
        font-size: 0.9375rem;
    }

    .lesson-nav {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-button {
        width: 100%;
    }

    /* Lesson 1 responsive */
    .bit-qubit-comparison {
        flex-direction: column;
        gap: 0.875rem;
        padding: 0.75rem;
        width: 100%;
    }

    .comparison-panel {
        width: 100%;
        padding: 0.875rem;
        box-sizing: border-box;
    }

    .vs-divider {
        transform: rotate(90deg);
        margin: 0.5rem 0;
        font-size: 1.25rem;
    }

    .bit-display,
    .qubit-display {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .panel-note {
        font-size: 0.8125rem;
        text-align: center;
    }

    .speed-comparison {
        padding: 0.75rem;
        width: 100%;
    }

    .comparison-bars {
        margin: 1rem 0;
        width: 100%;
    }

    .computer-bar-container {
        margin-bottom: 1rem;
        width: 100%;
    }

    .computer-label {
        font-size: 0.9375rem;
        margin-bottom: 0.5rem;
    }

    .speed-bar {
        min-height: 35px;
        width: 100%;
    }

    .time-label {
        font-size: 0.875rem;
        margin-top: 0.25rem;
    }

    .speedup-display {
        font-size: 0.9375rem;
        padding: 0.625rem;
        margin-top: 1rem;
    }

    .lesson-roadmap {
        width: 100%;
        gap: 0.75rem;
    }

    .roadmap-item {
        padding: 0.75rem;
        flex-direction: row;
        gap: 0.75rem;
        width: 100%;
        box-sizing: border-box;
    }

    .roadmap-number {
        width: 32px;
        height: 32px;
        font-size: 0.9375rem;
        flex-shrink: 0;
    }

    .roadmap-content {
        flex: 1;
        min-width: 0;
    }

    .roadmap-content h4 {
        font-size: 0.9375rem;
        margin-bottom: 0.25rem;
        word-wrap: break-word;
    }

    .roadmap-content p {
        font-size: 0.8125rem;
        line-height: 1.4;
        word-wrap: break-word;
    }

    /* Circuit displays */
    .circuit-display {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        padding: 0.5rem 0;
    }

    .qubit-wire {
        min-width: 280px;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .two-qubit-wire {
        width: 100%;
        overflow-x: auto;
    }

    .gate-box {
        min-width: 45px;
        min-height: 45px;
        font-size: 1.125rem;
        flex-shrink: 0;
    }

    .state-label {
        font-size: 0.875rem;
        white-space: nowrap;
    }

    .measurement-box {
        font-size: 1.25rem;
    }

    /* Quiz section */
    .quiz-section {
        margin: 1.5rem 0;
    }

    .quiz-question {
        padding: 0.875rem;
        margin-bottom: 1.25rem;
        border-radius: 8px;
    }

    .question-text {
        font-size: 0.9375rem;
        margin-bottom: 0.75rem;
    }

    .quiz-options {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .option {
        padding: 0.75rem;
        display: flex;
        align-items: flex-start;
        gap: 0.5rem;
        width: 100%;
        box-sizing: border-box;
    }

    .option input[type="radio"] {
        margin-top: 0.125rem;
        flex-shrink: 0;
    }

    .option span {
        font-size: 0.9375rem;
        line-height: 1.4;
    }

    /* Feature grids */
    .comparison-container {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Tables */
    table {
        font-size: 0.875rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Results grid */
    .results-grid {
        padding: 0.5rem;
        gap: 0.25rem;
        width: 100%;
        justify-content: flex-start;
    }

    .result-text {
        font-size: 0.875rem;
        padding: 0.75rem;
        margin-top: 0.75rem;
    }

    /* Highlight boxes */
    .highlight-box {
        padding: 0.875rem;
        margin: 1rem 0;
    }

    .highlight-box h3,
    .highlight-box h4 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    .highlight-box p {
        font-size: 0.875rem;
    }

    /* Note paragraphs */
    p.note {
        font-size: 0.8125rem;
        padding: 0.625rem;
        margin-top: 0.75rem;
    }

    /* Fix inline grid layouts that overflow */
    [style*="display: grid"][style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }

    /* Fix inline button grids */
    .button-group[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: unset !important;
    }

    /* Lesson 8: Quantum parallelism fix */
    .demo-area > div[style*="grid-template-columns: 1fr 1fr"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        margin: 1rem 0 !important;
    }

    /* Lesson 2: Circuit simulator */
    .circuit-simulator {
        width: 100%;
        overflow-x: hidden;
    }

    .circuit-inputs {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
        width: 100%;
    }

    .circuit-input {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .circuit-diagram {
        padding: 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .circuit-wire {
        min-width: 350px;
        font-size: 0.875rem;
        gap: 0.375rem;
    }

    .wire-line {
        min-width: 20px;
        flex-shrink: 1;
    }

    .circuit-gate-box {
        min-width: 50px;
        font-size: 0.8125rem;
        padding: 0.5rem;
    }

    .wire-label {
        font-size: 0.875rem;
        min-width: 30px;
    }

    .bit-button {
        min-width: 60px;
        padding: 0.75rem 1.25rem;
    }

    /* Two-qubit display */
    .two-qubit-display {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .two-qubit-display > div {
        min-width: 320px;
    }

    /* CNOT truth visualization - make it scroll */
    #cnot-truth-visualization {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #cnot-truth-visualization > div {
        min-width: 400px;
        gap: 1rem !important;
        padding: 1rem !important;
    }

    /* Fix visualizations with inline flex */
    #cnot-truth-visualization > div[style*="display: flex"],
    #two-qubit-visualization > div[style*="display: flex"] {
        flex-wrap: nowrap !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }

    /* Reduce sizes in visualizations */
    #cnot-truth-visualization [style*="width: 80px"],
    #two-qubit-visualization [style*="width: 80px"] {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.5rem !important;
    }

    #two-qubit-visualization [style*="width: 100px"] {
        width: 70px !important;
        height: 70px !important;
        font-size: 1.75rem !important;
    }

    #cnot-truth-visualization [style*="font-size: 2.5rem"],
    #two-qubit-visualization [style*="font-size: 2.5rem"] {
        font-size: 1.75rem !important;
    }

    #cnot-truth-visualization [style*="font-size: 2rem"],
    #two-qubit-visualization [style*="font-size: 2rem"] {
        font-size: 1.5rem !important;
    }

    /* State Explorer - Mobile */
    .prob-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .prob-row span {
        min-width: auto;
        width: 100%;
    }

    .prob-bar-container {
        width: 100%;
    }

    .prob-row strong {
        min-width: auto;
        text-align: left;
    }

    .state-info {
        padding: 1rem;
    }

    #state-dropdown {
        font-size: 0.95rem;
        padding: 0.875rem 2.5rem 0.875rem 0.875rem;
    }

    /* Result badges - mobile */
    .result-badge {
        min-width: 42px;
        height: 28px;
        line-height: 28px;
        font-size: 0.85rem;
        margin: 0.2rem;
        padding: 0 0.4rem;
    }

    #state-test-results {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
        margin-top: 1rem;
    }

    /* Input ranges */
    input[type="range"] {
        -webkit-appearance: none;
        width: 100%;
        height: 8px;
        border-radius: 5px;
        background: var(--border-color);
        outline: none;
    }

    input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: var(--primary-color);
        cursor: pointer;
    }

    input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: var(--primary-color);
        cursor: pointer;
        border: none;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 0.9375rem;
    }

    .main-content {
        padding: 0.75rem;
        padding-top: 3.5rem;
        overflow-x: hidden;
    }

    .lesson {
        padding: 0.5rem;
    }

    .lesson-header {
        padding: 0.75rem 0;
    }

    .lesson-header h1 {
        font-size: 1.375rem;
        line-height: 1.2;
    }

    .lesson-intro {
        font-size: 0.875rem;
        line-height: 1.5;
    }

    h2 {
        font-size: 1.125rem;
        margin-top: 1.25rem;
        margin-bottom: 0.75rem;
    }

    h3 {
        font-size: 1rem;
        margin-top: 0.875rem;
        margin-bottom: 0.5rem;
    }

    h4 {
        font-size: 0.9375rem;
        margin-bottom: 0.5rem;
    }

    p {
        font-size: 0.875rem;
        line-height: 1.6;
        margin-bottom: 0.75rem;
    }

    ul, ol {
        padding-left: 1.25rem;
        margin-bottom: 0.875rem;
    }

    li {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
        line-height: 1.5;
    }

    .interactive-block {
        padding: 0.875rem;
        margin: 1rem 0;
    }

    .demo-area {
        padding: 0.875rem;
    }

    .btn-primary,
    .btn-secondary {
        padding: 0.75rem 1.25rem;
        font-size: 0.9375rem;
        min-height: 44px;
    }

    .roadmap-item {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .roadmap-number {
        width: 32px;
        height: 32px;
        font-size: 0.9375rem;
    }

    .roadmap-content h4 {
        font-size: 0.9375rem;
    }

    .roadmap-content p {
        font-size: 0.8125rem;
    }

    .feature-card {
        padding: 1rem;
    }

    .comparison-panel {
        padding: 1rem;
    }

    .bit-display,
    .qubit-display {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .speed-comparison {
        padding: 0.75rem;
    }

    .size-display {
        font-size: 1rem;
    }

    .speedup-display {
        font-size: 0.9375rem;
        padding: 0.625rem;
    }

    /* Reduce spacing on small screens */
    .content-section {
        margin-bottom: 1.5rem;
        padding: 0 0.5rem;
    }

    .module-info {
        padding: 1rem;
    }

    .module-info ul,
    .module-features ul {
        padding-left: 1.25rem;
    }

    .module-info li,
    .module-features li {
        font-size: 0.9375rem;
        margin-bottom: 0.5rem;
    }

    /* Improve touch targets */
    .quiz-options .option {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }

    .quiz-options input[type="radio"] {
        width: 20px;
        height: 20px;
    }

    /* Gate boxes */
    .gate-box {
        min-width: 45px;
        min-height: 45px;
        font-size: 1rem;
    }

    /* Sidebar on mobile */
    .sidebar {
        width: 85vw;
        max-width: 300px;
    }

    .mobile-menu-toggle {
        padding: 0.625rem 0.875rem;
        font-size: 1rem;
    }

    /* Iframe responsiveness */
    iframe {
        max-width: 100%;
        height: auto;
        min-height: 400px;
    }

    /* Bloch sphere containers */
    .bloch-sphere-container {
        width: 100%;
        overflow: hidden;
    }

    /* Histogram fixes */
    .histogram-bars {
        gap: 0.5rem;
    }

    .histogram-bar {
        min-width: 40px;
    }

    /* Extra small screens - even more aggressive */
    .circuit-wire {
        min-width: 300px;
    }

    #cnot-truth-visualization > div {
        min-width: 320px;
    }

    #cnot-truth-visualization [style*="width: 80px"],
    #two-qubit-visualization [style*="width: 80px"] {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.25rem !important;
    }

    #two-qubit-visualization [style*="width: 100px"] {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.5rem !important;
    }

    #cnot-truth-visualization [style*="font-size: 2.5rem"],
    #two-qubit-visualization [style*="font-size: 2.5rem"] {
        font-size: 1.5rem !important;
    }

    #cnot-truth-visualization [style*="font-size: 2rem"],
    #two-qubit-visualization [style*="font-size: 2rem"] {
        font-size: 1.25rem !important;
    }

    #cnot-truth-visualization [style*="font-size: 1.2rem"],
    #two-qubit-visualization [style*="font-size: 1.2rem"] {
        font-size: 1rem !important;
    }

    /* Quantum parallelism comparison boxes */
    .demo-area > div[style*="padding: 1.5rem"] {
        padding: 0.875rem !important;
    }

    [style*="font-size: 1.5rem"][style*="color: var(--primary-color)"],
    [style*="font-size: 1.5rem"][style*="color: #555"] {
        font-size: 1.25rem !important;
    }
}

/* Additional mobile optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Touch device optimizations */
    .btn-primary,
    .btn-secondary,
    .nav-button {
        -webkit-tap-highlight-color: rgba(45, 80, 22, 0.1);
    }

    /* Larger touch targets */
    button,
    a.btn-primary,
    a.btn-secondary,
    .roadmap-item {
        min-height: 44px;
    }

    /* Prevent text selection on buttons */
    button,
    .btn-primary,
    .btn-secondary {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ===========================
   Histogram Visualization (from quantum-utils.js)
   =========================== */

.histogram {
    margin: 2rem 0;
}

.histogram-bars {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 3rem;
    min-height: 250px;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.histogram-bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.histogram-bar {
    width: 80px;
    background: linear-gradient(to top, var(--primary-color), var(--secondary-color));
    border-radius: 4px 4px 0 0;
    position: relative;
    min-height: 20px;
    transition: height 0.5s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 0.5rem;
}

.histogram-bar.bar-0 {
    background: linear-gradient(to top, var(--primary-color), #4a7c1f);
}

.histogram-bar.bar-1 {
    background: linear-gradient(to top, var(--secondary-color), #8fad3d);
}

.histogram-bar .bar-label {
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.histogram-label {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.5rem;
}

.histogram-percent {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.histogram-stats {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Update result badges for consistency with utilities */
.badge-0 {
    background: var(--primary-color);
}

.badge-1 {
    background: var(--secondary-color);
}

/* ===========================
   Animation Utilities
   =========================== */

.highlight-flash {
    animation: highlightPulse 1s ease-in-out;
}

@keyframes highlightPulse {
    0%, 100% {
        background-color: transparent;
        transform: scale(1);
    }
    50% {
        background-color: rgba(107, 142, 35, 0.2);
        transform: scale(1.02);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

/* ===========================
   Lesson 3: Qubits and Superposition Specific Styles
   =========================== */

/* Spinning Coin Interactive */
.coin-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin: 1.5rem 0;
}

.coin {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(145deg, #d4af37, #f4d03f);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    color: #8b6914;
    position: relative;
    transition: transform 0.3s ease;
}

.coin.spinning {
    animation: coinSpin 2s linear infinite;
}

@keyframes coinSpin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

.coin-face {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.coin-state-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.coin-state-label.superposition {
    color: var(--primary-color);
    font-weight: 700;
}

/* State Explorer Dropdown */
.state-explorer {
    margin: 1.5rem 0;
}

.state-selector {
    margin-bottom: 1.5rem;
}

.state-selector label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 1rem;
    color: var(--text-primary);
}

#state-dropdown {
    width: 100%;
    padding: 1rem 2.5rem 1rem 1rem;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    font-size: 1.05rem;
    font-family: 'Inter', sans-serif;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B8E23' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
}

#state-dropdown:hover {
    border-color: var(--secondary-color);
    box-shadow: 0 2px 8px rgba(107, 142, 35, 0.1);
}

#state-dropdown:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(107, 142, 35, 0.15);
}

#state-dropdown option {
    padding: 0.5rem;
    background: white;
    color: var(--text-primary);
}

.state-info {
    padding: 1.5rem;
    background: var(--interactive-bg);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.state-info h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.25rem;
}

.state-info p {
    margin: 0.5rem 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.probability-display {
    margin-top: 1.5rem;
}

.prob-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.prob-row span {
    min-width: 140px;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.prob-bar-container {
    flex: 1;
    height: 30px;
    background: #e9ecef;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.prob-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 15px;
    transition: width 0.4s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.prob-row strong {
    min-width: 50px;
    text-align: right;
    font-size: 1rem;
    color: var(--primary-color);
}

.state-info-box {
    padding: 1.5rem;
    background: var(--interactive-bg);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.state-notation {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.state-description {
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.state-probability {
    display: flex;
    justify-content: space-around;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.prob-item {
    text-align: center;
}

.prob-item .label {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.prob-item .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Probability Quiz */
.prob-quiz-container {
    margin: 1.5rem 0;
}

.quiz-progress {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.quiz-question-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--interactive-bg);
    border-radius: 8px;
}

.quiz-prob-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
}

.prob-option-btn {
    padding: 1.5rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.prob-option-btn:hover {
    border-color: var(--primary-color);
    background: var(--interactive-bg);
    transform: translateY(-2px);
}

.prob-option-btn.correct {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.prob-option-btn.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.quiz-feedback {
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 600;
}

.quiz-feedback.correct {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.quiz-feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

/* ===========================
   Lesson 4: The X Gate Specific Styles
   =========================== */

.gate-x {
    background: linear-gradient(135deg, #6b8e23, #8fad3d);
    color: white;
    font-weight: 700;
    border: 2px solid #4a7c1f;
}

.gate-x:hover {
    background: linear-gradient(135deg, #5a7a1a, #6b8e23);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Result text styling */
.result-text {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.result-text.success {
    background: #e8f5e0;
    border: 1px solid var(--primary-color);
    color: var(--text-primary);
}

/* ===========================
   Enhanced Bloch Sphere Slider Styles
   =========================== */

.bloch-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: linear-gradient(to right, #e8f5e0, #6b8e23);
    outline: none;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.bloch-slider:hover {
    opacity: 1;
}

.bloch-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.bloch-slider::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.bloch-slider::-webkit-slider-thumb:active {
    transform: scale(0.95);
}

.bloch-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.bloch-slider::-moz-range-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.bloch-slider::-moz-range-thumb:active {
    transform: scale(0.95);
}

.bloch-sphere-wrapper {
    animation: fadeIn 0.6s ease-in-out;
}

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

/* Global mobile fixes */
@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden;
        width: 100%;
    }

    /* Text wrapping */
    p, li, span, div {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Lists */
    ul, ol {
        padding-left: 1.5rem;
    }

    /* Images and media */
    img, video, canvas, svg {
        max-width: 100%;
        height: auto;
    }

    /* Prevent code blocks from overflowing */
    code, pre {
        max-width: 100%;
        overflow-x: auto;
        word-break: break-all;
        white-space: pre-wrap;
    }
}
