/* ========================================
   THERMAL HISTORY EXPLORER - STYLES
   ======================================== */

/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;
    --warning-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-dark: #1f2937;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;
    
    /* Temperature Colors */
    --temp-cold: #3b82f6;
    --temp-warm: #f59e0b;
    --temp-hot: #ef4444;
    --paz-color: rgba(249, 115, 22, 0.3);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    line-height: 1.2;
}

.hidden {
    display: none !important;
}

/* ========================================
   LOADING SCREEN
   ======================================== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a7b 50%, #1e3a5f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    color: white;
}

.earth-icon {
    font-size: 80px;
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.loading-content h1 {
    font-size: 2.5rem;
    margin: 20px 0 10px;
}

.loading-content p {
    opacity: 0.8;
    margin-bottom: 30px;
}

.loading-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 0 auto;
    overflow: hidden;
}

.loading-progress {
    width: 0%;
    height: 100%;
    background: var(--accent-color);
    border-radius: 2px;
    animation: loading 2s ease-in-out forwards;
}

@keyframes loading {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* ========================================
   NAVIGATION
   ======================================== */
.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.1rem;
}

.nav-brand .icon {
    font-size: 1.5rem;
}

.progress-dots {
    display: flex;
    gap: 12px;
}

.progress-dots .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border-color);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.progress-dots .dot.active {
    background: var(--primary-color);
    transform: scale(1.2);
}

.progress-dots .dot.completed {
    background: var(--secondary-color);
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.lang-toggle {
    background: var(--primary-light);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.lang-toggle:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.references-toggle {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.references-toggle:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.nav-score {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #b45309; /* amber-700: meets WCAG AA on the white nav (was #f59e0b ≈ 2.15:1) */
}

.score-icon {
    font-size: 1.2rem;
}

/* ========================================
   MAIN CONTAINER
   ======================================== */
#story-container {
    margin-top: 60px;
    min-height: calc(100vh - 60px);
}

.chapter {
    display: none;
    padding: 40px 20px;
    max-width: 1000px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease;
}

.chapter.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.chapter-content {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

/* ========================================
   HERO SECTION (Chapter 0)
   ======================================== */
.intro-chapter {
    padding: 20px;
}

.hero-section {
    text-align: center;
    margin-bottom: 40px;
}

.hero-title {
    font-size: 3rem;
    color: var(--primary-dark);
    margin-bottom: 10px;
}

.hero-subtitle {
    font-size: 1.3rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Mountain Animation */
.hero-image {
    margin: 40px 0;
}

.mountain-scene {
    position: relative;
    height: 200px;
    background: linear-gradient(to bottom, #87CEEB 0%, #E0F4FF 100%);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.mountain {
    position: absolute;
    bottom: 0;
    width: 0;
    height: 0;
}

.mountain.m1 {
    left: 10%;
    border-left: 100px solid transparent;
    border-right: 100px solid transparent;
    border-bottom: 150px solid #5B7C6F;
}

.mountain.m2 {
    left: 35%;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-bottom: 200px solid #4A6B5D;
}

.mountain.m3 {
    left: 60%;
    border-left: 120px solid transparent;
    border-right: 120px solid transparent;
    border-bottom: 170px solid #6B8C7F;
}

.mountain.m2::after {
    content: '';
    position: absolute;
    top: -200px;
    left: -40px;
    border-left: 40px solid transparent;
    border-right: 40px solid transparent;
    border-bottom: 50px solid white;
}

.sun {
    position: absolute;
    top: 20px;
    right: 50px;
    width: 60px;
    height: 60px;
    background: #FFD700;
    border-radius: 50%;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.5);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.clouds {
    position: absolute;
    width: 100%;
    height: 100%;
}

.cloud {
    position: absolute;
    background: white;
    border-radius: 50px;
    animation: drift 15s linear infinite;
}

.cloud.c1 {
    top: 30px;
    left: -100px;
    width: 80px;
    height: 30px;
    animation-duration: 20s;
}

.cloud.c2 {
    top: 60px;
    left: -150px;
    width: 100px;
    height: 40px;
    animation-duration: 25s;
    animation-delay: 5s;
}

@keyframes drift {
    from { transform: translateX(0); }
    to { transform: translateX(calc(100vw + 200px)); }
}

/* ========================================
   STORY TEXT
   ======================================== */
.story-text {
    margin: 30px 0;
}

.story-text p {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.story-text p.note {
    background: #f5f5f5;
    border-left: 3px solid var(--text-light);
    padding: 12px 15px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-top: 15px;
}

.story-text .lead {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.story-text strong {
    color: var(--primary-color);
}

.story-text em {
    font-style: italic;
    color: var(--text-secondary);
}

/* ========================================
   ACTION BOX
   ======================================== */
.action-box {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 30px;
    border-radius: var(--radius-lg);
    text-align: center;
    margin-top: 30px;
}

.action-box h3 {
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.action-box p {
    margin-bottom: 20px;
    opacity: 0.9;
}

.time-estimate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.15);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.time-estimate .time-icon {
    font-size: 1.3rem;
}

.time-estimate .time-text {
    opacity: 0.95;
}

.learning-loop {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 18px auto;
    max-width: 520px;
}

.learning-loop span {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-md);
    padding: 8px 6px;
    font-weight: 700;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn-primary, .btn-secondary {
    padding: 12px 28px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.arrow {
    transition: transform var(--transition-fast);
}

.btn-primary:hover .arrow {
    transform: translateX(4px);
}

/* ========================================
   CHAPTER HEADER
   ======================================== */
.chapter-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.chapter-number {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.chapter-header h2 {
    font-size: 2rem;
    color: var(--text-primary);
}

/* ========================================
   TWO COLUMN LAYOUT
   ======================================== */
.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin: 30px 0;
}

@media (max-width: 768px) {
    .two-column {
        grid-template-columns: 1fr;
    }
}

.text-column {
    padding-right: 20px;
}

/* ========================================
   KEY CONCEPT BOX
   ======================================== */
.key-concept {
    background: #FEF3C7;
    border-left: 4px solid var(--accent-color);
    padding: 20px;
    border-radius: var(--radius-md);
    margin: 20px 0;
}

.key-concept h4 {
    color: var(--accent-color);
    margin-bottom: 10px;
}

.key-concept.highlight {
    background: linear-gradient(135deg, #DBEAFE, #EDE9FE);
    border-left-color: var(--primary-color);
}

.key-concept.highlight h4 {
    color: var(--primary-color);
}

.field-notebook {
    margin: 28px 0;
    padding: 18px 20px;
    border-radius: var(--radius-md);
    border: 1px solid #bae6fd;
    background: linear-gradient(135deg, #f0f9ff, #ecfeff);
}

.field-notebook h4 {
    color: #0369a1;
    margin-bottom: 8px;
}

.field-notebook p {
    color: var(--text-primary);
    margin: 0;
}

.model-note {
    margin: 12px auto 0;
    max-width: 600px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: #f8fafc;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.45;
}

.inverse-model-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px auto 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ========================================
   INTERACTIVE CRYSTAL DEMO
   ======================================== */
.interactive-crystal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
}

.interactive-crystal h4 {
    margin-bottom: 15px;
    color: var(--primary-dark);
}

.crystal-legend {
    background: white;
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 15px;
    text-align: left;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot.uranium {
    background: #FFA726;
    box-shadow: 0 0 6px rgba(255, 167, 38, 0.5);
}

.legend-line {
    width: 30px;
    height: 4px;
    flex-shrink: 0;
    border-radius: 2px;
}

.legend-line.latent {
    background: rgba(27, 94, 32, 0.2);
    border: 1px dashed rgba(27, 94, 32, 0.4);
}

.legend-line.etched {
    background: #1B5E20;
}

.crystal-instructions {
    background: white;
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 15px;
    text-align: left;
}

.instruction-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.instruction-step:last-child {
    margin-bottom: 0;
}

.step-number {
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

#crystal-canvas {
    background: linear-gradient(135deg, #E8F4E8, #D0E8D0);
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    border: 2px solid var(--border-color);
}

.crystal-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.crystal-controls .btn-secondary {
    font-size: 0.85rem;
    padding: 10px 16px;
}

.track-counter {
    margin-top: 15px;
    font-weight: 600;
    color: var(--text-secondary);
}

#etch-status {
    margin-left: 10px;
    color: var(--secondary-color);
}

/* Etching Lab */
.etching-lab {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    gap: 22px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 22px;
    align-items: start;
}

.etching-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

#etching-canvas {
    width: 100%;
    max-width: 560px;
    height: auto;
    display: block;
    background: #d9e8c1;
    border: 3px solid #6b8b5a;
    border-radius: var(--radius-md);
    box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.18), var(--shadow-md);
}

.etching-controls-panel {
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.lab-slider {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    color: var(--text-secondary);
    display: grid;
    gap: 8px;
    font-weight: 700;
    padding: 13px 15px;
}

.lab-slider input {
    width: 100%;
}

.etching-state-card,
.etching-metrics > div {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px;
}

.etching-state-card {
    border-left: 4px solid #22c55e;
}

.etching-state-card.sub-etch {
    border-left-color: #3b82f6;
    background: #eff6ff;
}

.etching-state-card.ideal-etch {
    border-left-color: #16a34a;
    background: #ecfdf5;
}

.etching-state-card.over-etch {
    border-left-color: #dc2626;
    background: #fef2f2;
}

.etching-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

@media (max-width: 900px) {
    .etching-lab {
        grid-template-columns: 1fr;
    }

    .etching-metrics {
        grid-template-columns: 1fr;
    }
}

.chapter-sources {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 28px 0 10px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.chapter-sources span {
    font-weight: 600;
    color: var(--text-primary);
}

.chapter-sources button {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: var(--primary-dark);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.82rem;
    cursor: pointer;
}

.chapter-sources button:hover {
    background: var(--primary-color);
    color: white;
}

.achievement-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    max-width: min(360px, calc(100vw - 40px));
    background: #111827;
    color: white;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    z-index: 1200;
    font-weight: 600;
    font-size: 0.92rem;
}

/* ========================================
   QUIZ BOX
   ======================================== */
.quiz-box {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 25px;
    margin: 30px 0;
}

.quiz-box h4 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-option {
    padding: 15px 20px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-fast);
    font-size: 1rem;
}

.quiz-option:hover {
    border-color: var(--primary-color);
    background: #EFF6FF;
}

.quiz-option.correct {
    border-color: var(--secondary-color);
    background: #D1FAE5;
    color: #065F46;
}

.quiz-option.incorrect {
    border-color: var(--warning-color);
    background: #FEE2E2;
    color: #991B1B;
}

.quiz-option.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.quiz-feedback {
    margin-top: 15px;
    padding: 15px;
    border-radius: var(--radius-md);
}

.quiz-feedback.success {
    background: #D1FAE5;
    color: #065F46;
}

.quiz-feedback.error {
    background: #FEE2E2;
    color: #991B1B;
}

/* ========================================
   CHAPTER NAVIGATION
   ======================================== */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

/* ========================================
   TEMPERATURE ZONES (Chapter 2) - IMPROVED VISIBILITY
   ======================================== */
.temperature-zones {
    margin: 40px 0;
}

.zone-diagram {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 30px;
    background: var(--bg-secondary);
    padding: 35px;
    border-radius: var(--radius-lg);
    align-items: center;
}

.temp-scale {
    position: relative;
    height: 320px;
}

.temp-marker {
    position: absolute;
    left: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.temp-marker span {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.zones {
    display: flex;
    flex-direction: column;
    height: 320px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px 25px;
    color: white;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.zone span {
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 6px;
}

.zone small {
    opacity: 0.95;
    font-size: 1rem;
    font-weight: 500;
}

.zone.stable {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    flex: 0.33;
}

.zone.paz {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    flex: 0.34;
}

.zone.reset {
    background: linear-gradient(135deg, #E53935, #B71C1C);
    flex: 0.33;
}

/* Mobile responsive for temperature zones */
@media (max-width: 768px) {
    .zone-diagram {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .temp-scale {
        display: none;
    }
    
    .zones {
        height: auto;
    }
    
    .zone {
        padding: 25px 20px;
        min-height: 100px;
    }
    
    .zone span {
        font-size: 1.1rem;
    }
    
    .zone small {
        font-size: 0.95rem;
    }
    
    .zone.stable::before,
    .zone.paz::before,
    .zone.reset::before {
        content: attr(data-temp);
        display: block;
        font-size: 0.85rem;
        opacity: 0.9;
        margin-bottom: 8px;
    }
}

/* ========================================
   ANNEALING SIMULATOR (Chapter 2)
   ======================================== */
.annealing-simulator {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 25px;
    margin: 30px 0;
}

.sim-display {
    margin-bottom: 20px;
}

#annealing-canvas {
    width: 100%;
    max-width: 500px;
    background: linear-gradient(to bottom, #FEF3C7, #FDE68A);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
}

.sim-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
}

.sim-controls label {
    font-weight: 500;
}

.sim-controls input[type="range"] {
    width: 200px;
    accent-color: var(--primary-color);
}

.sim-controls select,
.inverse-model-control select {
    margin-left: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    color: var(--text-primary);
    font: inherit;
}

.sim-stats {
    display: flex;
    gap: 30px;
    justify-content: center;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-color);
}

.model-stat {
    font-size: 0.95rem;
    max-width: 150px;
}

.physics-note {
    margin-top: 16px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.45;
}

/* ========================================
   POPULATION DEMO (Chapter 3)
   ======================================== */
.population-concept {
    background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
    border-radius: var(--radius-lg);
    padding: 25px;
    margin: 30px 0;
}

.population-concept h3 {
    margin-bottom: 15px;
    color: var(--primary-dark);
}

.population-legend {
    background: white;
    border-radius: var(--radius-md);
    padding: 20px;
}

.age-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

.age-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.age-color {
    width: 40px;
    height: 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.population-demo {
    margin: 30px 0;
}

.population-demo > h3 {
    text-align: center;
    margin-bottom: 20px;
}

.scenario-selector-box {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    text-align: center;
}

.scenario-selector-box label {
    display: block;
    margin-bottom: 15px;
    font-weight: 600;
}

.scenario-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.scenario-btn {
    padding: 15px 20px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 130px;
    text-align: center;
}

.scenario-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.scenario-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.scenario-btn small {
    display: block;
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 4px;
}

.evolution-display {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.display-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .display-row {
        grid-template-columns: 1fr;
    }
}

.thermal-history-panel,
.tracks-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 15px;
    text-align: center;
}

.thermal-history-panel h4,
.tracks-panel h4,
.histogram-panel h4 {
    font-size: 0.95rem;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.thermal-history-panel canvas,
.tracks-panel canvas {
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    max-width: 100%;
}

.time-indicator,
.track-info {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.track-info {
    display: flex;
    justify-content: space-around;
}

.histogram-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 15px;
    text-align: center;
}

.histogram-panel canvas {
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    max-width: 100%;
}

.histogram-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.histogram-stats .stat {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.histogram-stats .stat span {
    font-weight: 600;
    color: var(--primary-color);
}

.animation-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn-large {
    padding: 15px 30px;
    font-size: 1.1rem;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.speed-control input {
    width: 100px;
    accent-color: var(--primary-color);
}

.scenario-explanation {
    background: #FFF3E0;
    border-left: 4px solid #FF9800;
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin-top: 20px;
}

.scenario-explanation h4 {
    color: #E65100;
    margin-bottom: 10px;
}

.scenario-explanation p {
    margin: 0;
}

/* PAZ Detective */
.paz-detective {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    gap: 22px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 22px;
    align-items: start;
}

.detective-case-panel,
.detective-answer-panel {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 16px;
}

.detective-case-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.detective-case-header h4 {
    margin: 0;
    color: var(--text-primary);
}

#paz-histogram {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-sm);
    background: white;
}

.detective-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.detective-metrics > div {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 10px;
}

.detective-options {
    display: grid;
    gap: 9px;
    margin: 12px 0;
}

.detective-options .btn-secondary {
    justify-content: center;
}

.rubric-score {
    margin-top: 12px;
    padding: 9px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
}

.rubric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.rubric-item {
    background: white;
    border: 1px solid #dbe3ef;
    border-radius: var(--radius-sm);
    padding: 9px;
}

.rubric-item span,
.rubric-item strong,
.rubric-item small {
    display: block;
}

.rubric-item span {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
}

.rubric-item strong {
    color: var(--text-primary);
    font-size: 1rem;
    margin: 4px 0;
}

.rubric-item small {
    color: var(--text-secondary);
    line-height: 1.35;
}

.rubric-formative {
    display: grid;
    gap: 6px;
}

.rubric-formative p {
    margin: 0;
}

@media (max-width: 900px) {
    .paz-detective {
        grid-template-columns: 1fr;
    }

    .detective-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .rubric-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   INSIGHT BOX
   ======================================== */
.insight-box {
    background: #EDE9FE;
    border-radius: var(--radius-lg);
    padding: 25px;
    margin: 30px 0;
}

.insight-box h4 {
    color: #6D28D9;
    margin-bottom: 15px;
}

.insight-box ul {
    margin-left: 20px;
}

.insight-box li {
    margin-bottom: 10px;
}

/* ========================================
   PROBLEM COMPARISON (Chapter 4)
   ======================================== */
.problem-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 30px 0;
}

@media (max-width: 768px) {
    .problem-comparison {
        grid-template-columns: 1fr;
    }
}

.problem-box {
    padding: 25px;
    border-radius: var(--radius-lg);
    text-align: center;
}

.problem-box.forward {
    background: #D1FAE5;
    border: 2px solid var(--secondary-color);
}

.problem-box.inverse {
    background: #FEE2E2;
    border: 2px solid var(--warning-color);
}

.problem-box h4 {
    margin-bottom: 10px;
}

.equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.equation .arrow {
    color: var(--text-secondary);
}

.equation .process {
    padding: 5px 15px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
}

.status {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.status.easy {
    background: var(--secondary-color);
    color: white;
}

.status.hard {
    background: var(--warning-color);
    color: white;
}

/* ========================================
   INVERSE GAME (Chapter 4)
   ======================================== */
.inverse-game {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 30px;
    margin: 30px 0;
}

.inverse-game h4 {
    text-align: center;
    margin-bottom: 20px;
}

.game-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 600px) {
    .game-container {
        grid-template-columns: 1fr;
    }

    .solution-slots {
        grid-template-columns: 1fr;
    }
}

.target-distribution, .your-attempt {
    background: white;
    padding: 15px;
    border-radius: var(--radius-md);
    text-align: center;
}

.target-distribution h5, .your-attempt h5 {
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.thermal-history-editor {
    background: white;
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.thermal-history-editor h5 {
    text-align: center;
    margin-bottom: 15px;
}

#thermal-editor {
    width: 100%;
    max-width: 600px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: crosshair;
    display: block;
    margin: 0 auto;
}

.editor-legend {
    display: flex;
    justify-content: space-between;
    max-width: 600px;
    margin: 10px auto 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.fit-result {
    text-align: center;
    margin-top: 20px;
    padding: 20px;
    background: white;
    border-radius: var(--radius-md);
}

.fit-score {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.fit-value {
    font-weight: 700;
    color: var(--primary-color);
}

.fit-message {
    color: var(--text-secondary);
}

.equifinality-panel {
    margin-top: 20px;
    background: white;
    border-radius: var(--radius-md);
    padding: 18px;
    border: 1px solid var(--border-color);
}

.equifinality-panel h5 {
    text-align: center;
    margin-bottom: 12px;
}

.geologic-constraint {
    background: #f8fafc;
    border: 1px solid #dbe3ef;
    border-radius: var(--radius-sm);
    padding: 12px;
    color: var(--text-secondary);
    line-height: 1.45;
}

.solution-slots {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0;
}

.solution-slot {
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius-sm);
    padding: 12px;
    background: #f8fafc;
}

.solution-slot.saved {
    border-style: solid;
    border-color: #10b981;
    background: #ecfdf5;
}

.solution-slot strong,
.solution-slot span,
.solution-slot small {
    display: block;
}

.solution-slot span {
    margin-top: 4px;
    color: var(--text-secondary);
}

.solution-slot small {
    margin-top: 6px;
    color: var(--text-secondary);
    line-height: 1.35;
}

.inverse-comparison {
    margin: 12px 0;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: #f8fafc;
}

.inverse-comparison.valid {
    background: #ecfdf5;
    color: #065f46;
}

.inverse-comparison.invalid {
    background: #fef2f2;
    color: #991b1b;
}

/* ========================================
   FIELD MISSIONS
   ======================================== */
.field-mission-hub {
    display: grid;
    grid-template-columns: minmax(220px, 0.35fr) minmax(0, 0.65fr);
    gap: 18px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.mission-list {
    display: grid;
    gap: 10px;
    align-content: start;
}

.mission-card {
    text-align: left;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    padding: 12px;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.mission-card:hover {
    transform: translateY(-1px);
    border-color: var(--primary-color);
}

.mission-card.active {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.mission-card.locked {
    opacity: 0.62;
}

.mission-card.completed {
    border-color: #10b981;
    background: #ecfdf5;
}

.mission-card strong,
.mission-card span,
.mission-card small {
    display: block;
}

.mission-card span {
    margin-top: 4px;
    color: var(--text-primary);
}

.mission-card small {
    margin-top: 4px;
    color: var(--text-secondary);
}

.mission-detail {
    background: white;
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.mission-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.mission-header h4 {
    margin: 0;
}

.mission-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.mission-metrics > div {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 10px;
}

.mission-histograms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 12px 0;
}

.mission-histograms h5 {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.mission-histograms canvas {
    width: 100%;
    height: auto;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-sm);
    background: white;
}

.mission-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0;
}

@media (max-width: 900px) {
    .field-mission-hub,
    .mission-histograms {
        grid-template-columns: 1fr;
    }

    .mission-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .teacher-summary-grid {
        grid-template-columns: 1fr;
    }

    .teacher-mode-header {
        display: grid;
    }
}

/* ========================================
   EPIC STORY TIMELINE (Chapter 5)
   ======================================== */
.epic-story {
    margin: 30px 0;
}

.story-timeline {
    position: relative;
    padding-left: 40px;
}

.story-timeline::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, var(--temp-hot), var(--temp-cold));
    border-radius: 2px;
}

.timeline-event {
    position: relative;
    margin-bottom: 30px;
    padding-left: 30px;
}

.event-marker {
    position: absolute;
    left: -40px;
    top: 0;
    width: 35px;
    height: 35px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.7rem;
    z-index: 1;
    border: 3px solid white;
    box-shadow: var(--shadow-md);
}

.event-content {
    background: white;
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.event-content h4 {
    margin-bottom: 10px;
    color: var(--primary-dark);
}

.temp-indicator {
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ========================================
   HIMALAYA RECONSTRUCTION
   ======================================== */
.himalaya-reconstruction {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: var(--radius-lg);
}

.reconstruction-display {
    margin-bottom: 20px;
}

#himalaya-canvas {
    width: 100%;
    max-width: 700px;
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: block;
    margin: 0 auto;
}

.reconstruction-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.stage-btn {
    padding: 10px 20px;
}

.stage-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.stage-explanation {
    background: white;
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
}

/* ========================================
   ACHIEVEMENT BOX
   ======================================== */
.achievement-box {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border: 3px solid var(--accent-color);
    border-radius: var(--radius-lg);
    padding: 30px;
    text-align: center;
    margin: 40px 0;
}

.achievement-box h3 {
    color: var(--accent-color);
    margin-bottom: 20px;
}

.achievement-list {
    list-style: none;
    text-align: left;
    max-width: 400px;
    margin: 0 auto 20px;
}

.achievement-list li {
    padding: 8px 0;
    font-size: 1rem;
}

.final-score {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 20px 0;
}

/* ========================================
   CERTIFICATE MODAL
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 30px;
}

.references-modal {
    max-width: 860px;
}

.references-modal h2 {
    color: var(--primary-dark);
    margin-bottom: 10px;
}

.references-intro {
    color: var(--text-secondary);
    margin-bottom: 20px;
    max-width: 720px;
}

.references-list {
    display: grid;
    gap: 18px;
}

.reference-group {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    background: #f8fafc;
}

.reference-group h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.reference-group ul {
    padding-left: 18px;
}

.reference-group li {
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.45;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
}

.certificate-content {
    text-align: center;
}

.certificate-border {
    border: 3px double var(--accent-color);
    padding: 30px;
    border-radius: var(--radius-lg);
}

.certificate-seal {
    font-size: 4rem;
    margin: 20px 0;
}

.certificate-text {
    margin: 10px 0;
    color: var(--text-secondary);
}

.name-input {
    font-size: 1.5rem;
    font-family: 'Playfair Display', serif;
    border: none;
    border-bottom: 2px solid var(--border-color);
    text-align: center;
    width: 100%;
    max-width: 300px;
    padding: 10px;
    margin: 10px 0;
}

.name-input:focus {
    outline: none;
    border-bottom-color: var(--primary-color);
}

.certificate h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin: 20px 0;
}

.certificate ul {
    list-style: none;
    text-align: left;
    display: inline-block;
    margin: 20px 0;
}

.certificate li {
    padding: 5px 0;
}

.certificate-date, .certificate-score {
    margin: 10px 0;
    font-weight: 500;
}

/* ========================================
   TEACHER MODE
   ======================================== */
.teacher-mode-panel {
    margin-top: 24px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.teacher-mode-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 14px;
}

.teacher-mode-header h3 {
    margin: 0 0 4px;
}

.teacher-mode-header p {
    margin: 0;
    color: var(--text-secondary);
}

.teacher-name-field {
    display: grid;
    gap: 6px;
    color: var(--text-secondary);
    font-weight: 600;
}

.teacher-name-field input {
    max-width: 360px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.teacher-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0;
}

.teacher-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0;
}

.teacher-metric {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 12px;
}

.teacher-metric span,
.teacher-metric strong {
    display: block;
}

.teacher-metric span {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.teacher-metric strong {
    color: var(--text-primary);
    margin-top: 4px;
}

.teacher-rubric-summary {
    background: #f8fafc;
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.teacher-rubric-summary h4 {
    margin: 0 0 8px;
}

.teacher-rubric-summary ul {
    margin: 0 0 8px 18px;
}

.teacher-rubric-summary p {
    margin: 4px 0;
    color: var(--text-secondary);
}

/* ========================================
   SCORE WARNING MODAL
   ======================================== */
.warning-modal {
    max-width: 480px;
    text-align: center;
}

.warning-content {
    padding: 10px;
}

.warning-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.warning-content h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.warning-message {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 25px;
    line-height: 1.6;
}

.score-progress-visual {
    background: var(--background-color);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 25px;
}

.progress-bar-large {
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill-large {
    height: 100%;
    background: linear-gradient(90deg, #f44336, #FF9800);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-labels .current-score {
    color: var(--primary-color);
    font-weight: 600;
}

.progress-labels .min-score {
    color: #4CAF50;
    font-weight: 600;
}

.warning-tips {
    background: #E3F2FD;
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    text-align: left;
}

.warning-tips h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.tips-list {
    margin: 0;
    padding-left: 20px;
}

.tips-list li {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 4px 0;
}

/* Progress dots incomplete state */
.progress-dots .dot.incomplete {
    background: #FF9800;
    border: 2px solid #FF9800;
}

.progress-dots .dot.incomplete::after {
    content: '!';
    color: white;
    font-size: 8px;
    font-weight: bold;
}

/* ========================================
   CERTIFICATE SCORE DETAILS
   ======================================== */
.certificate-scores {
    margin: 20px 0;
    text-align: left;
    width: 100%;
}

.cert-score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
}

.cert-score-row:last-child {
    border-bottom: none;
}

.cert-topic {
    font-size: 0.9rem;
    color: var(--text-color);
}

.cert-score-value {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cert-score-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.cert-score-badge.excellent {
    background: #E8F5E9;
    color: #2E7D32;
}

.cert-score-badge.good {
    background: #E3F2FD;
    color: #1565C0;
}

.cert-score-badge.passed {
    background: #FFF3E0;
    color: #EF6C00;
}

.cert-score-bar {
    width: 60px;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.cert-score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.cert-warning-message {
    text-align: left;
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.cert-warning-message ul {
    margin: 10px 0;
    padding-left: 20px;
}

.cert-warning-message li {
    margin: 5px 0;
}

/* ========================================
   FOOTER
   ======================================== */
.app-footer {
    text-align: center;
    padding: 30px;
    background: var(--bg-dark);
    color: var(--text-light);
    font-size: 0.9rem;
}

.app-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}

.app-footer .author-credit {
    margin-top: 15px;
    font-size: 0.85rem;
    color: #9CA3AF;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.author-credit-loading {
    margin-top: 20px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .chapter-content {
        padding: 25px;
    }
    
    .main-nav {
        padding: 0 15px;
    }
    
    .nav-brand span:last-child {
        display: none;
    }
    
    .zone-diagram {
        grid-template-columns: 1fr;
    }
    
    .temp-scale {
        display: none;
    }
}

@media (max-width: 480px) {
    .chapter-nav {
        flex-direction: column;
        gap: 15px;
    }
    
    .chapter-nav button {
        width: 100%;
    }
}

/* ========================================
   MOBILE-FIRST OPTIMIZATIONS
   Complete responsive design for smartphones
   ======================================== */

/* Touch-friendly tap targets */
@media (max-width: 768px) {
    /* Increase touch targets to 44px minimum */
    button, .btn-primary, .btn-secondary, .btn-outline {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Disable hover effects on touch */
    @media (hover: none) {
        button:hover, .btn-primary:hover, .btn-secondary:hover {
            transform: none;
        }
    }
}

/* Small phones (< 480px) */
@media (max-width: 480px) {
    /* Navigation */
    .main-nav {
        height: 50px;
        padding: 0 10px;
    }
    
    .nav-brand .icon {
        font-size: 1.2rem;
    }
    
    .progress-dots {
        gap: 6px;
    }
    
    .progress-dots .dot {
        width: 8px;
        height: 8px;
    }
    
    .nav-controls {
        gap: 8px;
    }
    
    .lang-toggle {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    .references-toggle {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    
    .nav-score {
        font-size: 0.85rem;
        gap: 4px;
    }
    
    .score-icon {
        font-size: 1rem;
    }
    
    /* Loading screen */
    .loading-content h1 {
        font-size: 1.5rem;
    }
    
    .loading-content p {
        font-size: 0.9rem;
    }
    
    .earth-icon {
        font-size: 3rem;
    }
    
    /* Story container */
    #story-container {
        margin-top: 50px;
    }
    
    .chapter {
        padding: 15px 10px;
    }
    
    .chapter-content {
        padding: 15px;
        border-radius: var(--radius-md);
    }
    
    /* Typography */
    .hero-title {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    h2 {
        font-size: 1.4rem;
    }
    
    h3 {
        font-size: 1.15rem;
    }
    
    h4 {
        font-size: 1rem;
    }
    
    p, .lead {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    .lead {
        font-size: 1rem;
    }
    
    /* Story text */
    .story-text {
        padding: 0 5px;
    }
    
    .story-text p {
        margin-bottom: 12px;
    }
    
    /* Action boxes */
    .action-box {
        padding: 15px;
        margin: 15px 0;
    }
    
    .action-box h3 {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }
    
    /* Buttons */
    .btn-primary, .btn-secondary, .btn-outline {
        padding: 12px 16px;
        font-size: 0.9rem;
        width: 100%;
        justify-content: center;
    }
    
    .btn-large {
        padding: 14px 20px;
        font-size: 1rem;
    }
    
    /* Mountain scene */
    .mountain-scene {
        height: 150px;
    }
    
    /* Interactive elements */
    .interactive-crystal {
        padding: 15px;
    }
    
    .crystal-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .crystal-controls button {
        width: 100%;
    }
    
    .crystal-legend {
        padding: 10px;
    }
    
    .legend-item {
        font-size: 0.8rem;
        gap: 8px;
    }
    
    .legend-line {
        width: 24px;
    }
    
    /* Canvas containers */
    .crystal-canvas-container,
    .annealing-canvas,
    .thermal-history-panel,
    .tracks-panel,
    .histogram-panel {
        padding: 10px;
    }
    
    #crystal-canvas,
    #annealing-canvas {
        max-width: 100%;
        height: auto !important;
    }
    
    /* Annealing simulator */
    .annealing-simulator {
        padding: 15px;
    }
    
    .temp-slider-container {
        padding: 15px 10px;
    }
    
    .temp-label {
        font-size: 0.9rem;
    }
    
    .temp-value {
        font-size: 1.4rem;
    }
    
    .temp-zones {
        flex-direction: column;
        gap: 8px;
        margin-top: 15px;
    }
    
    .temp-zone {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
    
    .track-display {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .track-stat {
        padding: 10px;
    }
    
    .track-stat .value {
        font-size: 1.2rem;
    }
    
    .track-stat .label {
        font-size: 0.7rem;
    }
    
    /* Key concept boxes */
    .key-concept {
        padding: 15px;
        margin: 15px 0;
    }
    
    .key-concept h4 {
        font-size: 0.95rem;
    }
    
    .key-concept p {
        font-size: 0.85rem;
    }
    
    /* Two column layout - stack on mobile */
    .two-column {
        gap: 20px;
    }
    
    .text-column {
        padding-right: 0;
    }
    
    /* Population demo */
    .population-demo-container {
        padding: 15px;
    }
    
    .scenario-cards {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .scenario-card {
        padding: 10px 8px;
    }
    
    .scenario-card .icon {
        font-size: 1.3rem;
    }
    
    .scenario-card .title {
        font-size: 0.7rem;
    }
    
    .scenario-card .subtitle {
        font-size: 0.6rem;
    }
    
    .display-row {
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .panel-title {
        font-size: 0.85rem;
    }
    
    .time-indicator,
    .track-info {
        font-size: 0.8rem;
    }
    
    .histogram-stats {
        gap: 15px;
    }
    
    .histogram-stats .stat {
        font-size: 0.85rem;
    }
    
    .animation-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .animation-controls button {
        width: 100%;
    }
    
    /* Inverse game */
    .inverse-game-container {
        padding: 15px;
    }
    
    .histogram-compare {
        flex-direction: column;
        gap: 15px;
    }
    
    .histogram-box {
        width: 100%;
    }
    
    .histogram-box h5 {
        font-size: 0.9rem;
    }
    
    .thermal-editor {
        padding: 10px;
    }
    
    .editor-tip {
        font-size: 0.75rem;
    }
    
    .fit-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .fit-controls button {
        width: 100%;
    }
    
    .fit-result {
        padding: 12px;
    }
    
    .fit-result h4 {
        font-size: 1rem;
    }
    
    /* Zone diagram */
    .zone-diagram {
        gap: 10px;
        padding: 10px;
    }
    
    .zone-item {
        padding: 12px 10px;
    }
    
    .zone-item .temp {
        font-size: 0.8rem;
    }
    
    .zone-item .name {
        font-size: 0.85rem;
    }
    
    .zone-item .desc {
        font-size: 0.75rem;
    }
    
    /* Quiz */
    .quiz-container {
        padding: 15px;
    }
    
    .quiz-container h4 {
        font-size: 1rem;
    }
    
    .quiz-options {
        gap: 8px;
    }
    
    .quiz-option {
        padding: 12px;
        font-size: 0.85rem;
    }

    .chapter-sources {
        align-items: flex-start;
        flex-direction: column;
        gap: 7px;
        font-size: 0.82rem;
    }

    .chapter-sources button {
        width: 100%;
        border-radius: var(--radius-md);
        text-align: left;
    }
    
    /* Certificate */
    .certificate-container {
        padding: 20px 15px;
    }
    
    .certificate h2 {
        font-size: 1.3rem;
    }
    
    .certificate-skills li {
        font-size: 0.85rem;
        padding: 8px;
    }
    
    /* Footer */
    footer {
        padding: 20px 15px;
    }
    
    footer p {
        font-size: 0.8rem;
    }
    
    .author-credit {
        font-size: 0.75rem;
    }
    
    /* Population legend */
    .population-legend {
        padding: 10px;
    }
    
    .population-legend h4 {
        font-size: 0.9rem;
    }
    
    .pop-legend-item {
        font-size: 0.75rem;
        padding: 4px 6px;
        margin: 3px;
    }
    
    /* Explanation box */
    .explanation-box {
        padding: 15px;
        margin: 15px 0;
    }
    
    .pop-stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .pop-stat-item {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
}

/* Extra small phones (< 360px) */
@media (max-width: 360px) {
    .main-nav {
        height: 45px;
        padding: 0 8px;
    }
    
    .progress-dots .dot {
        width: 6px;
        height: 6px;
    }
    
    .hero-title {
        font-size: 1.3rem;
    }
    
    .chapter-content {
        padding: 12px;
    }
    
    .scenario-cards {
        grid-template-columns: 1fr;
    }
    
    .scenario-card {
        flex-direction: row;
        text-align: left;
        gap: 10px;
    }
    
    .scenario-card .icon {
        font-size: 1.5rem;
    }
    
    .btn-primary, .btn-secondary {
        padding: 10px 12px;
        font-size: 0.85rem;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .main-nav {
        height: 45px;
    }
    
    #story-container {
        margin-top: 45px;
    }
    
    .hero-section {
        padding: 10px 0;
    }
    
    .mountain-scene {
        height: 100px;
    }
    
    .loading-content {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .earth-icon {
        font-size: 2.5rem;
    }
    
    /* Reduce vertical space in landscape */
    .chapter-content {
        padding: 15px;
    }
    
    .action-box {
        margin: 10px 0;
    }
}

/* Touch feedback animations */
@media (hover: none) and (pointer: coarse) {
    button, .btn-primary, .btn-secondary, .btn-outline, .scenario-card, .quiz-option {
        transition: transform 0.1s ease, background-color 0.1s ease;
    }
    
    button:active, .btn-primary:active, .btn-secondary:active, 
    .btn-outline:active, .scenario-card:active, .quiz-option:active {
        transform: scale(0.97);
        opacity: 0.9;
    }
}

/* Improve canvas touch handling */
@media (pointer: coarse) {
    canvas {
        touch-action: none;
    }
    
    .thermal-editor canvas {
        cursor: grab;
    }
    
    .thermal-editor canvas:active {
        cursor: grabbing;
    }
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-top)) {
    .main-nav {
        padding-top: env(safe-area-inset-top);
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }
    
    footer {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .chapter {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }
}

/* Prevent text selection during drag on mobile */
@media (pointer: coarse) {
    .thermal-editor,
    .inverse-game-container,
    canvas {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
}

/* Scrollbar hiding for mobile */
@media (max-width: 768px) {
    .scenario-cards::-webkit-scrollbar,
    .population-legend::-webkit-scrollbar {
        display: none;
    }
    
    .scenario-cards,
    .population-legend {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* ========================================
   CHAPTER 4: SIMPLIFIED UNCERTAINTY STYLES
   Version 2.0 - Visual Focus
   ======================================== */

.version-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--secondary-color), #059669);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 10px;
    vertical-align: middle;
}

/* Visual Concept Section */
.visual-concept {
    background: linear-gradient(135deg, #F0FDF4, #DCFCE7);
    border-radius: var(--radius-lg);
    padding: 30px;
    margin: 25px 0;
}

.visual-explanation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .visual-explanation {
        grid-template-columns: 1fr;
    }
}

.visual-box {
    background: white;
    border-radius: var(--radius-md);
    padding: 25px;
    box-shadow: var(--shadow-md);
}

.track-count-demo {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    gap: 15px;
    padding: 20px 0;
}

.count-example {
    text-align: center;
    flex: 1;
}

.count-visual {
    background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
    border-radius: var(--radius-md);
    padding: 15px 10px;
    margin-bottom: 10px;
}

.count-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.count-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.error-bar-visual {
    height: 8px;
    background: #EF4444;
    border-radius: 4px;
    margin: 10px auto;
    transition: width 0.3s ease;
}

.error-bar-visual.large { width: 90%; }
.error-bar-visual.medium { width: 50%; }
.error-bar-visual.small { width: 30%; }

.uncertainty-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: #DC2626;
}

.explanation-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.explanation-text p {
    margin-bottom: 12px;
}

.simple-list {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}

.simple-list li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    font-size: 0.95rem;
}

.simple-list li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

.takeaway {
    background: #FEF3C7;
    padding: 12px 15px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: #92400E;
    border-left: 3px solid #F59E0B;
}

/* Virtual Microscope */
.virtual-microscope {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.75fr);
    gap: 22px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 22px;
    align-items: start;
}

.microscope-stage {
    min-width: 0;
}

.microscope-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.scope-chip {
    background: #e8f2de;
    border: 1px solid rgba(76, 125, 79, 0.25);
    border-radius: var(--radius-sm);
    color: #2f5d36;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 6px 9px;
}

#microscope-canvas {
    width: 100%;
    max-width: 640px;
    height: auto;
    display: block;
    background: #d8e4be;
    border: 3px solid #5f7d54;
    border-radius: var(--radius-md);
    box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.18), var(--shadow-md);
    cursor: crosshair;
}

.microscope-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.microscope-controls .active-tool {
    background: #14532d;
    color: white;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.microscope-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.scope-score {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.scope-score > div,
.scope-criteria,
.scope-feedback {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px;
}

.scope-criteria h4 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

.scope-criteria ul {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.scope-criteria li {
    margin-bottom: 7px;
}

.scope-feedback {
    border-left: 4px solid #94a3b8;
    color: var(--text-secondary);
    line-height: 1.45;
    min-height: 88px;
}

.scope-feedback.valid {
    border-left-color: #16a34a;
    background: #ecfdf5;
    color: #14532d;
}

.scope-feedback.invalid {
    border-left-color: #dc2626;
    background: #fef2f2;
    color: #7f1d1d;
}

.measurement-panel {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px;
}

.measurement-panel h4 {
    margin-bottom: 10px;
}

.measurement-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.measurement-stats > div {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 10px;
}

#measurement-histogram {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-sm);
    margin: 10px 0;
}

.measurement-explain {
    background: #f8fafc;
    border-left: 3px solid #3b82f6;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.45;
    padding: 10px 12px;
}

/* C-axis Orientation Lab */
.caxis-lab {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.85fr);
    gap: 22px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 22px;
    align-items: start;
}

.caxis-stage {
    min-width: 0;
}

#caxis-canvas {
    width: 100%;
    max-width: 640px;
    height: auto;
    display: block;
    background: #dbeccf;
    border: 3px solid #5f7d54;
    border-radius: var(--radius-md);
    box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.18), var(--shadow-md);
    cursor: crosshair;
}

.caxis-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#caxis-histogram {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-sm);
    background: white;
}

@media (max-width: 900px) {
    .virtual-microscope {
        grid-template-columns: 1fr;
    }

    .scope-score {
        grid-template-columns: 1fr;
    }

    .measurement-stats {
        grid-template-columns: 1fr;
    }

    .caxis-lab {
        grid-template-columns: 1fr;
    }
}

/* Simplified Age Calculator */
.age-calculator.simplified {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 25px;
}

.counting-simulation {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 25px;
    align-items: start;
}

@media (max-width: 768px) {
    .counting-simulation {
        grid-template-columns: 1fr;
    }
}

.sample-view {
    text-align: center;
}

.sample-view h4 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.sample-view canvas {
    background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
    border: 3px solid #4CAF50;
    border-radius: var(--radius-md);
    cursor: crosshair;
    max-width: 100%;
    box-shadow: var(--shadow-md);
}

.counting-controls {
    margin-top: 15px;
}

/* Simplified Results Cards */
.counting-results.simplified {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-card {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 18px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease;
}

.result-card:hover {
    transform: translateX(5px);
}

.result-card.highlight {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border: 2px solid #F59E0B;
}

.result-icon {
    font-size: 1.8rem;
    width: 50px;
    text-align: center;
}

.result-info {
    flex: 1;
}

.result-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.result-value.error-value {
    color: #DC2626;
}

.result-value.uncertainty-percent {
    color: #059669;
}

.progress-bar-container {
    background: white;
    padding: 15px;
    border-radius: var(--radius-md);
    margin-top: 5px;
}

.progress-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.progress-bar {
    height: 10px;
    background: #E5E7EB;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10B981, #059669);
    border-radius: 5px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Compact Uncertainty Grid */
.uncertainty-section.simplified h3 {
    margin-bottom: 20px;
}

.uncertainty-grid.compact {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

@media (max-width: 600px) {
    .uncertainty-grid.compact {
        grid-template-columns: 1fr;
    }
}

.uncertainty-grid.compact .uncertainty-card {
    padding: 20px;
}

.uncertainty-grid.compact .uncertainty-card .icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.uncertainty-grid.compact .uncertainty-card h4 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.uncertainty-grid.compact .uncertainty-card p {
    font-size: 0.85rem;
    margin-bottom: 0;
}

/* Keep existing uncertainty card styles */

.age-error {
    font-size: 1.1rem !important;
    color: var(--accent-color) !important;
}

/* Uncertainty Grid */
.uncertainty-section {
    margin: 30px 0;
}

.uncertainty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.uncertainty-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-md);
    border-left: 4px solid;
    transition: transform var(--transition-normal);
}

.uncertainty-card:hover {
    transform: translateY(-5px);
}

.uncertainty-card.poisson {
    border-left-color: #8B5CF6;
}

.uncertainty-card.measurement {
    border-left-color: #3B82F6;
}

.uncertainty-card.calibration {
    border-left-color: #10B981;
}

.uncertainty-card.systematic {
    border-left-color: #F59E0B;
}

.uncertainty-card .icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.uncertainty-card h4 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.uncertainty-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.uncertainty-card .example {
    background: var(--bg-secondary);
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
}

/* Error Bar Demo */
.error-bar-demo {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 25px;
    margin: 20px 0;
}

.demo-controls {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.demo-controls label {
    flex: 1;
    min-width: 200px;
}

.demo-controls input[type="range"] {
    width: 100%;
    margin-top: 8px;
}

.demo-display canvas {
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 100%;
}

.demo-stats {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
    padding: 15px;
    background: white;
    border-radius: var(--radius-md);
}

.stat-item {
    text-align: center;
}

.stat-item .label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-item .value {
    font-weight: 600;
    color: var(--primary-color);
}

/* Envelope Section */
.envelope-section {
    background: linear-gradient(135deg, #FDF4FF, #FAE8FF);
    border-radius: var(--radius-lg);
    padding: 30px;
    margin: 30px 0;
    border: 1px solid #E9D5FF;
}

.envelope-demo {
    margin-top: 20px;
}

.envelope-display canvas {
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 100%;
}

.envelope-controls {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: var(--radius-md);
}

.envelope-controls label {
    flex: 1;
    min-width: 180px;
}

.envelope-controls input[type="range"] {
    width: 100%;
    margin-top: 5px;
}

.envelope-controls select {
    width: 100%;
    margin-top: 6px;
    padding: 9px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-primary);
}

.tt-box-controls {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 12px;
    padding: 12px 15px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
}

.tt-box-controls label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.tt-box-controls .btn-secondary {
    margin-left: auto;
}

.envelope-legend {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.envelope-feedback {
    margin-top: 14px;
    padding: 12px 14px;
    background: white;
    border-left: 4px solid #10b981;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.color-box {
    width: 20px;
    height: 12px;
    border-radius: 2px;
}

.color-box.best {
    background: #EF4444;
}

.color-box.good {
    background: rgba(239, 68, 68, 0.3);
}

.color-box.acceptable {
    background: rgba(239, 68, 68, 0.1);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .uncertainty-grid.compact {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   CHAPTER 7: OIL PROSPECTION STYLES
   ======================================== */

.oil-concept {
    background: linear-gradient(135deg, #FFF8E1, #FFECB3);
    border-radius: var(--radius-lg);
    padding: 30px;
    margin: 25px 0;
}

.oil-window-diagram {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .oil-window-diagram {
        grid-template-columns: 1fr;
    }
}

.window-visual {
    display: flex;
    gap: 15px;
}

.depth-scale {
    position: relative;
    width: 50px;
    height: 300px;
}

.depth-marker {
    position: absolute;
    right: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    transform: translateY(-50%);
}

.temperature-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 300px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.temp-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    color: white;
    text-align: center;
    position: relative;
}

.temp-zone .zone-name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.temp-zone .zone-desc {
    font-size: 0.75rem;
    opacity: 0.9;
}

.temp-zone .zone-icon {
    font-size: 1.5rem;
    margin-top: 5px;
}

.temp-zone.immature {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
}

.temp-zone.oil-window {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    border: 3px solid #E65100;
}

.temp-zone.gas-window {
    background: linear-gradient(135deg, #FF5722, #E64A19);
}

.temp-zone.overmature {
    background: linear-gradient(135deg, #424242, #212121);
}

.connection-box {
    background: white;
    padding: 25px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.connection-box h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.highlight-text {
    background: linear-gradient(135deg, #FFF3E0, #FFE0B2);
    padding: 15px;
    border-radius: var(--radius-sm);
    border-left: 4px solid #FF9800;
    margin-top: 15px;
    font-weight: 600;
}

/* Oil Game */
.oil-game {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 25px;
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: var(--radius-lg);
}

@media (max-width: 900px) {
    .oil-game {
        grid-template-columns: 1fr;
    }
}

.basin-view {
    text-align: center;
}

.basin-view canvas {
    background: #263238;
    border-radius: var(--radius-md);
    max-width: 100%;
    box-shadow: var(--shadow-lg);
}

.game-panel {
    background: white;
    padding: 20px;
    border-radius: var(--radius-md);
}

.game-panel h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.well-data {
    margin-bottom: 20px;
}

.data-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.data-row .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.data-row .value {
    font-weight: 600;
    color: var(--text-primary);
}

.interpretation-quiz h4 {
    margin-top: 20px;
    border-bottom: none;
    padding-bottom: 0;
}

.assessment-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.assessment-btn {
    padding: 15px 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.assessment-btn:hover {
    border-color: var(--primary-color);
    background: #F0F7FF;
}

.assessment-btn.correct {
    border-color: #4CAF50;
    background: #E8F5E9;
}

.assessment-btn.incorrect {
    border-color: #EF4444;
    background: #FEE2E2;
}

.assessment-feedback {
    margin-top: 15px;
    padding: 15px;
    border-radius: var(--radius-md);
}

.assessment-feedback.success {
    background: #E8F5E9;
    border: 1px solid #4CAF50;
    color: #2E7D32;
}

.assessment-feedback.error {
    background: #FEE2E2;
    border: 1px solid #EF4444;
    color: #DC2626;
}

/* Real World Impact */
.real-world-section {
    margin: 30px 0;
}

.impact-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .impact-grid {
        grid-template-columns: 1fr;
    }
}

.impact-card {
    background: white;
    padding: 25px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
    transition: transform var(--transition-normal);
}

.impact-card:hover {
    transform: translateY(-5px);
}

.impact-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.impact-card h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.impact-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ========================================
   VISUAL NOVEL — dialogue layer
   ======================================== */
.dialogue-stage {
    margin: 18px 0 24px;
    padding: 16px 16px 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--primary-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.dialogue-stage:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}
.dialogue-stage:empty { display: none; }

.vn-transcript {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 460px;
    overflow-y: auto;
}
.vn-line, .reviewer-note {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: vnFade 240ms ease;
}
@keyframes vnFade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}
.vn-portrait {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
}
.vn-portrait svg { width: 48px; height: 48px; display: block; }
.vn-bubble {
    flex: 1 1 auto;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--vn-color, var(--primary-color));
    border-radius: var(--radius-md);
    padding: 10px 14px;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}
.vn-name {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    color: var(--vn-color, var(--primary-color));
    font-size: 0.98rem;
    margin-bottom: 4px;
}
.vn-role {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.vn-text { font-size: 0.96rem; line-height: 1.55; color: var(--text-primary); }
.vn-text strong { color: var(--vn-color, var(--primary-color)); }

.vn-controls { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.vn-continue, .vn-replay {
    align-self: flex-start;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.vn-replay { background: transparent; color: var(--primary-color); border: 1px solid var(--primary-color); }
.vn-continue:hover { background: var(--primary-dark); }

.vn-choice-prompt {
    font-weight: 600;
    color: var(--text-primary);
    margin: 4px 0 2px;
}
.vn-choices { display: flex; flex-direction: column; gap: 8px; }
.vn-choice {
    text-align: left;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 0.92rem;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
    color: var(--text-primary);
}
.vn-choice:hover { border-color: var(--primary-color); background: #f0f6ff; transform: translateX(3px); }
.vn-choice-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}
.vn-choice--prior { border-color: var(--secondary-color); background: #f0fdf4; }

/* Skeptical reviewer interjection after a minigame result */
.reviewer-dock { margin: 14px 0 4px; }
.reviewer-note {
    background: #fff7f7;
    border: 1px solid #fecaca;
    border-left: 5px solid var(--vn-color, var(--warning-color));
    border-radius: var(--radius-md);
    padding: 10px 12px;
}
.reviewer-note .vn-bubble { border-top-color: var(--vn-color, var(--warning-color)); background: #fff; }

/* ========================================
   ACCESSIBILITY
   ======================================== */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1000;
    background: var(--primary-color);
    color: #fff;
    padding: 10px 16px;
    border-radius: 0 0 var(--radius-md) 0;
}
.skip-link:focus { left: 0; }

a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
canvas:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========================================
   PRINT / PDF EXPORT
   Only #print-region is shown when body.printing is set, so the
   browser "Save as PDF" dialog yields a clean, offline report.
   ======================================== */
#print-region { display: none; }
@media print {
    body.printing > *:not(#print-region) { display: none !important; }
    body.printing #print-region {
        display: block;
        color: #000;
        font-family: 'Inter', sans-serif;
        padding: 0;
    }
    #print-region h1, #print-region h2, #print-region h3 {
        font-family: 'Playfair Display', Georgia, serif;
    }
    #print-region table { width: 100%; border-collapse: collapse; font-size: 12px; }
    #print-region th, #print-region td {
        border: 1px solid #999;
        padding: 5px 8px;
        text-align: left;
    }
    #print-region .print-muted { color: #444; font-size: 12px; }
    @page { margin: 16mm; }
}
