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

:root {
    --primary-color: #FF6B6B;
    --secondary-color: #4ECDC4;
    --success-color: #95E1D3;
    --info-color: #A8E6CF;
    --warning-color: #FFD93D;
    --danger-color: #FF6B6B;
    --dark-bg: #1a1a2e;
    --light-bg: #f8f9fa;
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --border-color: #dfe6e9;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    padding: 20px;
    min-height: 100vh;
}

.impulse-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 100%);
    color: white;
    padding: 20px 30px;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    font-weight: 700;
}

header .subtitle {
    font-size: 0.95rem;
    opacity: 0.95;
}

main {
    padding: 20px 30px;
}

.simulation-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    margin-bottom: 20px;
    align-items: start;
}

@media (max-width: 1200px) {
    .simulation-layout {
        grid-template-columns: 1fr;
    }
}

.animation-panel {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 15px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 500px;
}

#mainCanvas {
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: white;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    flex-shrink: 0;
}

.scene-controls {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 10px;
    justify-content: center;
    flex-shrink: 0;
}

.scene-btn {
    padding: 6px 14px;
    border: 2px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    flex: 1;
    max-width: 120px;
}

.scene-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.scene-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.info-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chart-panel {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.chart-panel h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 1rem;
}

#ftChart {
    width: 100%;
    height: 160px;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.chart-legend {
    display: flex;
    gap: 15px;
    margin-top: 8px;
    justify-content: center;
}

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

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

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

.legend-color.impulse {
    background: rgba(255, 107, 107, 0.3);
}

.momentum-display {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.momentum-display h4 {
    margin-bottom: 10px;
    color: var(--secondary-color);
    font-size: 0.95rem;
}

.momentum-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: white;
    border-radius: 6px;
    margin-bottom: 6px;
}

.momentum-item span:first-child {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.momentum-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--secondary-color);
}

.momentum-arrow {
    text-align: center;
    font-size: 1.3rem;
    color: var(--secondary-color);
    font-weight: 700;
    margin: 4px 0;
}

.momentum-change {
    background: linear-gradient(135deg, var(--secondary-color), var(--info-color));
    color: white;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    font-weight: 700;
    margin-top: 8px;
}

.change-value {
    display: block;
    font-size: 1.2rem;
    margin-top: 4px;
}

.current-state {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.current-state h4 {
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 0.95rem;
}

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

.state-item {
    background: white;
    padding: 8px;
    border-radius: 6px;
    text-align: center;
}

.state-item span:first-child {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.state-item span:last-child {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.comparison-panel {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.comparison-panel h3 {
    margin-bottom: 12px;
    color: var(--primary-color);
    text-align: center;
    font-size: 1.1rem;
}

.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 900px) {
    .comparison-grid {
        grid-template-columns: 1fr;
    }
}

.comparison-item {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.comparison-item h4 {
    margin-bottom: 10px;
    color: var(--primary-color);
    text-align: center;
    font-size: 0.95rem;
}

.comparison-chart {
    margin-bottom: 10px;
}

.comparison-chart canvas {
    width: 100%;
    height: 120px;
    background: var(--light-bg);
    border-radius: 6px;
}

.comparison-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 8px;
}

.comparison-stats .stat {
    text-align: center;
}

.comparison-stats .stat span:first-child {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.comparison-stats .stat span:last-child {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.95rem;
}

.comparison-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.4;
}

.controls-panel {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 15px;
    box-shadow: var(--shadow);
}

.controls-panel h3 {
    margin-bottom: 12px;
    color: var(--primary-color);
    font-size: 1.1rem;
}

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

.control-group {
    background: white;
    padding: 10px;
    border-radius: 6px;
}

.control-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.85rem;
}

.control-group input[type="range"] {
    width: 100%;
    height: 5px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

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

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 6px rgba(255, 107, 107, 0.4);
}

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

.control-button {
    padding: 10px 25px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.control-button.start {
    background: var(--success-color);
    color: var(--text-primary);
}

.control-button.start:hover {
    background: #7dd3c0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(149, 225, 211, 0.3);
}

.control-button.pause {
    background: var(--warning-color);
    color: var(--text-primary);
}

.control-button.pause:hover {
    background: #ffe066;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 217, 61, 0.3);
}

.control-button.reset {
    background: var(--danger-color);
    color: white;
}

.control-button.reset:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.formulas-section {
    background: white;
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

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

.formula-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.formula-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: var(--light-bg);
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
}

.formula-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.formula {
    font-family: 'Times New Roman', serif;
    font-size: 1rem;
    font-style: italic;
    color: var(--primary-color);
}

.explanation {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.explanation h2 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 1.5rem;
}

.explanation h3 {
    color: var(--primary-color);
    margin-top: 20px;
    margin-bottom: 12px;
    font-size: 1.2rem;
}

.explanation p {
    line-height: 1.6;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.concept-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 12px;
    border-left: 5px solid var(--secondary-color);
    box-shadow: var(--shadow);
}

.concept-card h4 {
    color: var(--secondary-color);
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.principle-box {
    background: linear-gradient(135deg, var(--info-color), var(--success-color));
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.principle-box h4 {
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.formula-highlight {
    background: rgba(255, 255, 255, 0.2);
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 0.95rem;
}

.applications-list {
    list-style: none;
    padding: 0;
}

.applications-list li {
    background: white;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 6px;
    border-left: 4px solid var(--info-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    font-size: 0.9rem;
}

.scenario-explanation {
    background: white;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    border-left: 4px solid var(--warning-color);
}

.scenario-explanation h4 {
    color: var(--warning-color);
    margin-bottom: 6px;
    font-size: 1rem;
}

.scenario-explanation p {
    font-size: 0.9rem;
}

.comparison-table {
    margin-top: 15px;
    overflow-x: auto;
}

.comparison-table table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.comparison-table th,
.comparison-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

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

.comparison-table tr:last-child td {
    border-bottom: none;
}

.comparison-table tr:hover {
    background: var(--light-bg);
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

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

    #mainCanvas {
        height: 280px;
    }

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

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

    .button-group {
        flex-direction: column;
    }

    .control-button {
        width: 100%;
    }

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