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

:root {
    --primary-color: #2196F3;
    --secondary-color: #1976D2;
    --accent-color: #FF5722;
    --success-color: #4CAF50;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border-color: #e0e0e0;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.resonance-container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 300;
}

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

main {
    padding: 30px;
}

/* Simulation Layout */
.simulation-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.spring-animation-panel,
.resonance-curve-panel {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.spring-animation-panel h3,
.resonance-curve-panel h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3em;
}

canvas {
    width: 100%;
    background: white;
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

#springCanvas {
    height: 300px;
}

#resonanceCurveCanvas {
    height: 300px;
}

.animation-info,
.curve-info {
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.info-row:last-child {
    margin-bottom: 0;
}

.curve-marker {
    position: relative;
    height: 20px;
    margin-top: 10px;
}

.marker-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent-color);
    border-radius: 2px;
}

.marker-label {
    margin-left: 10px;
    font-size: 0.9em;
    color: var(--accent-color);
    font-weight: 600;
}

/* Controls Section */
.controls-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.control-group {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.control-group h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.2em;
}

.control-item {
    margin-bottom: 20px;
}

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

.control-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.control-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.control-item input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.preset-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.preset-btn {
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.preset-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.3);
}

.preset-btn:active {
    transform: translateY(0);
}

/* Phase Section */
.phase-section {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.phase-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3em;
}

#phaseCanvas {
    height: 200px;
    margin-bottom: 15px;
}

.phase-info {
    background: white;
    padding: 15px;
    border-radius: 8px;
}

.phase-value {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 10px;
}

.phase-description {
    font-size: 0.9em;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Statistics Panel */
.stats-panel {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.stats-panel h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3em;
}

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

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.stat-label {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--primary-color);
}

/* Formulas Section */
.formulas-section {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.formulas-section h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.3em;
}

.formula-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.formula-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.formula-card.highlight {
    border-left-color: var(--accent-color);
    background: linear-gradient(135deg, #fff5f2 0%, #ffffff 100%);
}

.formula-card h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.1em;
}

.formula {
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    color: var(--text-primary);
    margin-bottom: 8px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 4px;
}

.formula-desc {
    font-size: 0.9em;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Applications Section */
.applications-section {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.applications-section h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.applications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.application-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border-top: 4px solid var(--accent-color);
}

.application-card h4 {
    color: var(--accent-color);
    margin-bottom: 10px;
    font-size: 1.1em;
}

.application-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95em;
}

/* Educational Section */
.education-section {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.education-section h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.education-section h3 {
    color: var(--secondary-color);
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.education-section p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 15px;
    font-size: 1em;
}

.conditions-list {
    list-style: none;
    padding-left: 0;
}

.conditions-list li {
    background: white;
    padding: 12px 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid var(--success-color);
    line-height: 1.6;
}

.conditions-list li strong {
    color: var(--text-primary);
}

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

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

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

    main {
        padding: 15px;
    }

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

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

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

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