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

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

.wave-reflection-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

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

main {
    padding: 30px;
}

.simulation-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.wave-panel {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.canvas-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

#waveCanvas {
    display: block;
    width: 100%;
    height: auto;
}

.wave-info {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.info-item {
    background: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    flex: 1;
    min-width: 140px;
    text-align: center;
}

.info-item span:first-child {
    font-weight: 600;
    color: #475569;
    margin-right: 6px;
    display: block;
    font-size: 0.85rem;
}

.info-item span:last-child {
    color: #3b82f6;
    font-weight: 700;
    font-size: 1.1rem;
}

.realtime-params {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.realtime-params h4 {
    color: #1e293b;
    font-size: 1rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.param-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.param-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 6px;
}

.param-label {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

.param-value {
    font-size: 1rem;
    color: #3b82f6;
    font-weight: 700;
}

.legend-section {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.legend-section h4 {
    color: #1e293b;
    font-size: 1rem;
    margin-bottom: 12px;
    font-weight: 600;
}

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

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.legend-color {
    width: 30px;
    height: 6px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-color.incident {
    background: #3b82f6;
}

.legend-color.reflected {
    background: #ef4444;
}

.legend-color.rope {
    background: #64748b;
}

.legend-color.boundary {
    background: #1e293b;
}

.legend-item span {
    font-size: 0.9rem;
    color: #475569;
}

.controls-panel {
    background: #f8fafc;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 700px;
    overflow-y: auto;
}

.controls-panel h3 {
    color: #1e293b;
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid #3b82f6;
}

.control-group {
    margin-bottom: 25px;
}

.control-group h4 {
    color: #475569;
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: #334155;
    font-size: 0.95rem;
}

.control-group label span:first-child {
    font-weight: 600;
}

.control-group label span:last-child {
    color: #3b82f6;
    font-weight: 700;
}

.control-group input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e2e8f0;
    outline: none;
    margin-bottom: 15px;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.control-group input[type="range"]::-moz-range-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.control-group select {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    color: #334155;
    font-size: 1rem;
    margin-bottom: 15px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.control-group select:focus {
    outline: none;
    border-color: #3b82f6;
}

.checkbox-input {
    margin-right: 10px;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.checkbox-input:hover {
    transform: scale(1.05);
}

.button-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 25px;
}

.control-button {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.control-button.start {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.control-button.start:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-button.pause {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.control-button.pause:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-button.reset {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
}

.control-button.reset:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-button.pulse {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    grid-column: span 2;
}

.control-button.pulse:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.formulas-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.formulas-section h3 {
    color: #1e293b;
    font-size: 1.2rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

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

.formula-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    background: #f8fafc;
    border-radius: 6px;
}

.formula-label {
    font-weight: 700;
    color: #3b82f6;
    min-width: 60px;
    font-size: 0.9rem;
}

.formula {
    color: #475569;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.4;
}

.explanation {
    background: #f8fafc;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.explanation h2 {
    color: #1e293b;
    font-size: 1.8rem;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 3px solid #3b82f6;
}

.explanation h3 {
    color: #334155;
    font-size: 1.4rem;
    margin-top: 25px;
    margin-bottom: 15px;
}

.explanation p {
    color: #475569;
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 15px;
}

.explanation strong {
    color: #1e293b;
    font-weight: 600;
}

/* Responsive design */
@media (max-width: 1024px) {
    .simulation-layout {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 1.8rem;
    }

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

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    main {
        padding: 20px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .wave-info {
        flex-direction: column;
    }

    .button-group {
        grid-template-columns: 1fr;
    }

    .control-button.pulse {
        grid-column: span 1;
    }

    .explanation h2 {
        font-size: 1.5rem;
    }

    .explanation h3 {
        font-size: 1.2rem;
    }

    .controls-panel {
        max-height: none;
    }
}
