/* ========================================
   Rocket Sled Simulation - Styles
   Based on Projectiles Simulation patterns
   ======================================== */

:root {
    --primary: #00BCD4;
    --primary-dark: #0097A7;
    --primary-light: #26C6DA;
    --accent: #FFD700;
    --success: #4CAF50;
    --danger: #FF5252;
    --bg-dark: #0d1117;
    --bg-light: #1a1f26;
    --bg-panel: #242931;
    --text-primary: #e0e0e0;
    --text-secondary: #9e9e9e;
    --border: #3a4149;

    /* Force colors */
    --force-applied: #FF9800;
    --force-normal: #4CAF50;
    --force-gravity: #9C27B0;
    --force-friction: #F44336;
    --force-air: #2196F3;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    background: var(--bg-dark);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Header
   ======================================== */
.app-header {
    background: var(--bg-panel);
    padding: 12px 24px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}

.header-left h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-left .author {
    margin: 4px 0 0 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.header-left .author a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.header-left .author a:hover {
    text-decoration: underline;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.header-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.header-btn.quiz-btn {
    background: #16a085;
}

.header-btn.quiz-btn:hover {
    background: #138d75;
}



/* ========================================
   Main Layout
   ======================================== */
.container {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 16px;
    gap: 16px;
}

main {
    display: grid;
    grid-template-columns: 240px 1fr;
    /* Removed right column */
    grid-template-rows: minmax(0, 1fr);
    gap: 8px;
    padding: 12px 16px;
    flex: 1;
    overflow-y: auto;
    /* Changed from hidden to auto to allow scrolling */
    min-height: 0;
}

/* ========================================
   Left Panel - Controls
   ======================================== */
.controls-section {
    background: var(--bg-panel);
    border-radius: 12px;
    overflow-y: auto;
    padding: 15px;
    border: 1px solid var(--border);
}

.controls-section h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Instructions Box */
.instructions {
    background: var(--bg-light);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    line-height: 1.5;
    border: 1px solid var(--border);
}

.instructions h3 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--accent);
}

.instructions ol {
    margin-left: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.instructions li {
    margin-bottom: 4px;
}

/* Force Controls */
.force-controls {
    margin-bottom: 20px;
}

.force-controls h3 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 600;
}

.thrust-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.thrust-btn {
    padding: 14px 8px;
    background: var(--bg-light);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

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

.thrust-btn.active {
    background: var(--force-applied);
    border-color: var(--force-applied);
    color: white;
}

.thrust-btn.off.active {
    background: var(--bg-dark);
    border-color: var(--primary);
    color: var(--primary);
}

.thrust-btn .icon {
    font-size: 1.5rem;
}

/* Direction Slider (direction + intensity) */
.direction-slider {
    background: var(--bg-light);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.direction-slider .slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.direction-slider input[type="range"] {
    width: 100%;
    height: 12px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, var(--force-applied) 0%, var(--bg-dark) 45%, var(--bg-dark) 55%, var(--force-applied) 100%);
    border-radius: 6px;
    outline: none;
}

.direction-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.direction-slider input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid white;
}

.direction-slider .slider-value {
    text-align: center;
    margin-top: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--force-applied);
    font-family: 'Courier New', monospace;
}

/* Force Slider */
.force-slider {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.force-slider label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.force-slider .value-display {
    color: var(--primary);
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

.force-slider input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-dark);
    border-radius: 4px;
    outline: none;
}

.force-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.force-slider input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-light);
    transform: scale(1.1);
}

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

/* Toggles */
.toggles-section {
    margin-bottom: 20px;
}

.toggles-section h3 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 600;
}

.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}


.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.toggle-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

.toggle-item .icon {
    font-size: 1.2rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-dark);
    border: 2px solid var(--border);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(24px);
    background-color: white;
}

/* Worksheet Scenarios */
.scenarios-section {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.scenarios-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--primary);
}

.scenario-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.scenario-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.scenario-btn:hover {
    border-color: var(--primary);
    background: rgba(0, 188, 212, 0.1);
}

.scenario-btn.active {
    border-color: var(--primary);
    background: rgba(0, 188, 212, 0.2);
}

.scenario-btn .scenario-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.scenario-btn .scenario-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

.scenario-btn:hover .scenario-name {
    color: var(--text-primary);
}

/* Control Buttons */
.control-buttons {
    display: flex;
    gap: 8px;
}

.btn-primary {
    flex: 1;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    flex: 1;
    padding: 12px;
    background: var(--bg-light);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

/* ========================================
   Center Panel - Visualization
   ======================================== */
.visualization-section {
    display: flex;
    flex-direction: column;
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    background: var(--bg-panel);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.visualization-section h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.viz-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.viz-btn {
    padding: 6px 12px;
    background: var(--bg-light);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

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

.viz-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Dropdown Menu */
.dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-panel);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    min-width: 220px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.menu-section {
    padding: 8px;
}

.menu-header {
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.menu-item {
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: block;
    margin-bottom: 4px;
}

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

.menu-item:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.menu-item.active {
    background: rgba(0, 188, 212, 0.2);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}


#canvasContainer {
    flex: 0 0 400px;
    /* Fixed height! Stop growing! */
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
}

canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

/* Direction Control (below canvas) - Compacted */
.direction-control {
    margin-top: 8px;
    /* Reduced from 20px */
    padding: 15px;
    /* Reduced from 30px */
    background: linear-gradient(to bottom, var(--bg-dark), #0a0d12);
    border-radius: 12px;
    border: 2px solid var(--border);
}

.direction-slider-container {
    max-width: 100%;
    margin: 0 auto;
}

.direction-slider-container .slider-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-weight: 700;
}

.direction-slider-container .slider-labels span:first-child {
    color: #FF9800;
}

.direction-slider-container .slider-labels span:last-child {
    color: #FF9800;
}

.direction-slider-container .slider-labels span:nth-child(2) {
    color: var(--text-primary);
    font-size: 1.4rem;
}

/* VERY LARGE slider track */
.direction-slider-container input[type="range"] {
    width: 100%;
    height: 40px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right,
            #FF5722 0%,
            #2a2a35 35%,
            #1a1a25 50%,
            #2a2a35 65%,
            #4CAF50 100%);
    border-radius: 20px;
    outline: none;
    border: 3px solid var(--border);
}

/* VERY LARGE thumb */
.direction-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #00BCD4, #0097A7);
    border-radius: 50%;
    cursor: pointer;
    border: 6px solid white;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.direction-slider-container input[type="range"]::-webkit-slider-thumb:hover {
    background: linear-gradient(135deg, #26C6DA, #00ACC1);
    transform: scale(1.1);
}

.direction-slider-container input[type="range"]::-moz-range-thumb {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #00BCD4, #0097A7);
    border-radius: 50%;
    cursor: pointer;
    border: 6px solid white;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.direction-slider-container .slider-value {
    text-align: center;
    margin-top: 20px;
    font-size: 1.6rem;
}

.direction-slider-container .slider-value .force-number {
    font-weight: 700;
    color: #FF9800;
    font-family: 'Courier New', monospace;
    font-size: 2rem;
    font-size: 1.4rem;
}

/* ========================================
   Right Panel - Data Display
   ======================================== */
.data-section {
    background: var(--bg-panel);
    border-radius: 12px;
    overflow-y: auto;
    padding: 15px;
    /* Reduced from 20px */
    border: 1px solid var(--border);
}

.data-section h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Force Values Display */
.force-values {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.force-values h3 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 600;
}

.force-value-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.force-value-item:last-child {
    border-bottom: none;
    padding-top: 12px;
    margin-top: 4px;
    border-top: 2px solid var(--border);
}

.force-value-item .force-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.force-value-item.applied .force-label {
    color: var(--force-applied);
}

.force-value-item.friction .force-label {
    color: var(--force-friction);
}

.force-value-item.air .force-label {
    color: var(--force-air);
}

.force-value-item.net .force-label {
    color: var(--primary);
    font-weight: 600;
}

.force-value-item .force-number {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: var(--text-primary);
}

.force-value-item .force-number.bold {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

/* Velocimeter */
.velocimeter {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.velocimeter h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--text-primary);
    font-weight: 600;
}

.velocimeter-gauge {
    position: relative;
    width: 220px;
    height: 110px;
    margin: 0 auto 16px;
    background: linear-gradient(to right,
            #e74c3c 0%,
            #f39c12 20%,
            var(--bg-dark) 40%,
            var(--bg-dark) 60%,
            #2ecc71 80%,
            #27ae60 100%);
    border-radius: 110px 110px 0 0;
    border: 4px solid var(--border);
    border-bottom: none;
    overflow: visible;
    box-sizing: border-box;
}

.velocimeter-gauge .needle {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 6px;
    height: 90px;
    background: linear-gradient(to top, #c0392b, #e74c3c 60%, transparent 60%);
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(0deg);
    transition: transform 0.15s ease-out;
    border-radius: 3px;
    z-index: 10;
}

.velocimeter-gauge::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: #c0392b;
    border-radius: 50%;
    border: 3px solid white;
    z-index: 11;
}

.velocimeter-gauge .gauge-labels {
    position: absolute;
    bottom: 12px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 15px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.velocimeter-gauge .gauge-labels .center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 5px;
}

.velocity-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Courier New', monospace;
    text-align: center;
}

.velocity-value .unit {
    font-size: 1rem;
    color: var(--text-secondary);
}

.speed-display {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Courier New', monospace;
}

.speed-display .unit {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-left: 4px;
}

.speed-bar {
    height: 12px;
    background: var(--bg-dark);
    border-radius: 6px;
    margin-top: 12px;
    overflow: hidden;
    position: relative;
}

.speed-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 6px;
    transition: width 0.1s;
    width: 0%;
}

.speed-bar-fill.red-zone {
    background: linear-gradient(90deg, var(--danger), #FF8A80);
}

/* Force Legend */
.force-legend {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.force-legend h3 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 600;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.legend-color {
    width: 20px;
    height: 4px;
    border-radius: 2px;
}

.legend-color.applied {
    background: var(--force-applied);
}

.legend-color.normal {
    background: var(--force-normal);
}

.legend-color.gravity {
    background: var(--force-gravity);
}

.legend-color.friction {
    background: var(--force-friction);
}

.legend-color.air {
    background: var(--force-air);
}

.legend-item .inactive {
    color: var(--text-secondary);
    font-style: italic;
}

/* Physics Tips */
.tips-section {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 16px;
    border-left: 4px solid var(--accent);
    border: 1px solid var(--border);
}

.tips-section h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--accent);
    font-weight: 600;
}

.tips-section ul {
    margin-left: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.tips-section li {
    margin-bottom: 6px;
}

/* ========================================
   Footer
   ======================================== */
.app-footer {
    background: var(--bg-panel);
    padding: 12px 24px;
    text-align: center;
    border-top: 1px solid var(--border);
}

.app-footer p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.app-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.app-footer a:hover {
    text-decoration: underline;
}

/* ========================================
   Embed Mode (for LMS iframes)
   ======================================== */
body.embed {
    overflow-y: auto;
}

body.embed .app-footer {
    display: none;
}

body.embed .container {
    padding: 8px;
    gap: 8px;
}

body.embed main {
    grid-template-columns: 240px 1fr 260px;
    gap: 8px;
    padding: 8px 10px;
}

body.embed .instructions {
    display: none;
}

body.embed #canvasContainer {
    height: 82vh;
    min-height: 500px;
    max-height: 92vh;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 1200px) {
    main {
        grid-template-columns: 260px 1fr 280px;
    }
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 400px auto;
        overflow-y: auto;
    }

    .controls-section,
    .data-section {
        max-height: none;
    }
}

@media (max-width: 640px) {
    .app-header {
        flex-direction: column;
        text-align: center;
    }

    .header-right {
        width: 100%;
        justify-content: center;
    }

    .thrust-buttons {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Modals & Quiz
   ======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.show {
    opacity: 1;
}

.modal-content {
    background-color: var(--bg-panel);
    margin: 5% auto;
    padding: 30px;
    border: 1px solid var(--primary);
    width: 80%;
    max-width: 600px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.close-modal {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close-modal:hover {
    color: var(--primary);
}

.modal h2 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
}

.modal-body {
    color: var(--text-primary);
    line-height: 1.6;
}

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

.modal-body li {
    margin-bottom: 8px;
}

/* Quiz Styles */
.quiz-question {
    display: none;
    animation: fadeIn 0.4s;
}

.quiz-question.active {
    display: block;
}

.quiz-options {
    display: grid;
    gap: 12px;
    margin: 20px 0;
}

.quiz-opt {
    background: var(--bg-light);
    border: 1px solid var(--border);
    padding: 15px;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.quiz-opt:hover {
    background: var(--bg-dark);
    border-color: var(--primary);
}

.quiz-opt.correct {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4CAF50;
    color: #4CAF50;
    pointer-events: none;
}

.quiz-opt.incorrect {
    background: rgba(244, 67, 54, 0.2);
    border-color: #F44336;
    color: #F44336;
    opacity: 0.6;
}

.feedback {
    min-height: 24px;
    margin-bottom: 15px;
    font-weight: bold;
}

.next-btn {
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    float: right;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ========================================
   HUD Overlay
   ======================================== */
.hud-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    padding: 12px;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    z-index: 10;
}

.hud-panel {
    pointer-events: auto;
    background: rgba(13, 17, 23, 0.85);
    /* Matches bg-panel with opacity */
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.hud-top-left {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: start;
}

.hud-top-right {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;
    min-width: 140px;
}

.hud-bottom-left {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: center;
    align-self: end;
    background: rgba(13, 17, 23, 0.95);
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    width: auto;
    min-width: 60%;
    margin-bottom: -1px;
    padding: 8px 20px;
}

/* Force Values Table */
.force-row {
    display: flex;
    justify-content: space-between;
    width: 180px;
    margin-bottom: 4px;
    font-size: 0.9rem;
    align-items: center;
}

.force-row .label {
    opacity: 0.8;
    font-weight: 500;
    color: var(--text-secondary);
}

.force-row .label.applied {
    color: var(--force-applied);
}

.force-row .label.friction {
    color: var(--force-friction);
}

.force-row .label.air {
    color: var(--force-air);
}

.force-row .label.net {
    color: var(--primary);
    font-weight: bold;
}

.force-row.divider {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 4px;
    margin-top: 4px;
}

.force-number {
    font-family: 'Roboto Mono', monospace;
    font-weight: 600;
    color: white;
}

/* Compact Velocimeter */
.velocimeter-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.velocity-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
    color: var(--primary);
    margin-bottom: 6px;
    text-shadow: 0 0 10px rgba(0, 188, 212, 0.3);
}

.velocity-value .unit {
    font-size: 0.8rem;
    opacity: 0.7;
    font-weight: normal;
}

.velocimeter-gauge-mini {
    width: 120px;
    height: 60px;
    position: relative;
    background: linear-gradient(90deg, #ff5252 0%, #ffeb3b 50%, #4caf50 100%);
    border-radius: 60px 60px 0 0;
    overflow: hidden;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.3);
}

.velocimeter-gauge-mini::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 80%;
    background: rgba(13, 17, 23, 0.85);
    /* Match panel bg */
    border-radius: 50% 50% 0 0;
}

.velocimeter-gauge-mini .needle {
    width: 4px;
    height: 55px;
    background: white;
    bottom: 0;
    left: 50%;
    position: absolute;
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(0deg);
    transition: transform 0.1s cubic-bezier(0.1, 0.7, 1.0, 0.1);
    z-index: 2;
    border-radius: 2px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.velocimeter-gauge-mini .needle::before {
    content: '';
    position: absolute;
    bottom: -4px;
    left: -4px;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
}

/* Compact Legend */
.legend-compact {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.legend-item .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 4px currentColor;
}

.dot.applied {
    background: var(--force-applied);
    color: var(--force-applied);
}

.dot.friction {
    background: var(--force-friction);
    color: var(--force-friction);
}

.dot.air {
    background: var(--force-air);
    color: var(--force-air);
}

.dot.normal {
    background: var(--force-normal);
    color: var(--force-normal);
}

.dot.gravity {
    background: var(--force-gravity);
    color: var(--force-gravity);
}

.legend-item.inactive {
    opacity: 0.3;
    filter: grayscale(100%);
}

/* Red Zone Alert */
.velocimeter-gauge-mini.danger {
    background: linear-gradient(90deg, #ff1744 0%, #d50000 100%);
    box-shadow: 0 0 15px rgba(255, 23, 68, 0.7);
    animation: pulse-danger 0.5s infinite alternate;
}

@keyframes pulse-danger {
    from {
        box-shadow: 0 0 10px rgba(255, 23, 68, 0.5);
    }

    to {
        box-shadow: 0 0 20px rgba(255, 23, 68, 0.9);
    }
}