* {
    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, #0077b6 0%, #00b4d8 50%, #90e0ef 100%);
    min-height: 100vh;
    padding: 20px;
}

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

header {
    background: linear-gradient(135deg, #0077b6 0%, #00b4d8 50%, #90e0ef 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

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

header .subtitle {
    font-size: 1em;
    opacity: 0.95;
    line-height: 1.6;
}

main {
    padding: 30px;
}

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

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

.chart-display {
    background: linear-gradient(145deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 119, 182, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chart-display:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 119, 182, 0.15);
}

.chart-display h3 {
    color: #0077b6;
    margin-bottom: 15px;
    font-size: 1.2em;
    font-weight: 600;
}

.chart-display canvas {
    width: 100%;
    height: auto;
    border-radius: 12px;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.phase-legend,
.state-info,
.transition-info,
.clapeyron-info {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    color: #333;
}

.phase-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.phase-icon.solid {
    background: linear-gradient(145deg, #a5d8ff, #74c0fc);
}

.phase-icon.liquid {
    background: linear-gradient(145deg, #74c0fc, #4dabf7);
}

.phase-icon.gas {
    background: linear-gradient(145deg, #e7f5ff, #d0ebff);
}

.point-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.point-icon.triple {
    background: #ffd43b;
    border: 2px solid #fab005;
}

.point-icon.critical {
    background: #ff6b6b;
    border: 2px solid #fa5252;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    color: #555;
    font-weight: 500;
}

.controls-panel {
    background: linear-gradient(145deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 119, 182, 0.1);
}

.controls-panel h3 {
    color: #0077b6;
    margin-bottom: 20px;
    font-size: 1.4em;
    font-weight: 600;
}

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

.control-group {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

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

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-size: 0.95em;
    font-weight: 500;
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, #0077b6, #00b4d8);
    outline: none;
    margin-bottom: 5px;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(145deg, #00b4d8, #0077b6);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(145deg, #00b4d8, #0077b6);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.control-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
}

.slider-hint {
    font-size: 0.8em;
    color: #888;
    margin-bottom: 15px;
    font-style: italic;
}

.phase-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.phase-btn,
.special-btn,
.path-btn,
.anim-btn {
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(145deg, #0077b6, #00b4d8);
    color: white;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.phase-btn:hover,
.special-btn:hover,
.path-btn:hover,
.anim-btn:hover {
    background: linear-gradient(145deg, #00b4d8, #0077b6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 119, 182, 0.3);
}

.phase-btn:active,
.special-btn:active,
.path-btn:active,
.anim-btn:active {
    transform: translateY(0);
}

.special-btn,
.path-btn {
    width: 100%;
    margin-bottom: 10px;
}

.anim-btn {
    width: 100%;
    margin-bottom: 8px;
}

.point-info {
    margin-top: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.formulas-section {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.formulas-section h3 {
    color: #0077b6;
    margin-bottom: 20px;
    font-size: 1.3em;
    font-weight: 600;
}

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

.formula-item {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: linear-gradient(145deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 8px;
    border-left: 4px solid #0077b6;
}

.formula-label {
    font-weight: 600;
    color: #00b4d8;
    min-width: 180px;
    font-size: 0.9em;
}

.formula {
    color: #333;
    font-family: 'Times New Roman', serif;
    font-size: 1.05em;
}

.explanation {
    background: linear-gradient(145deg, #f0f9ff 0%, #e0f2fe 100%);
    padding: 30px;
    border-radius: 16px;
    margin-top: 30px;
    box-shadow: 0 4px 15px rgba(0, 119, 182, 0.1);
}

.explanation h2 {
    color: #0077b6;
    margin-bottom: 20px;
    font-size: 1.8em;
    font-weight: 700;
}

.explanation h3 {
    color: #00b4d8;
    margin-top: 25px;
    margin-bottom: 12px;
    font-size: 1.3em;
    font-weight: 600;
}

.explanation p {
    color: #444;
    line-height: 1.8;
    margin-bottom: 15px;
}

.explanation strong {
    color: #0077b6;
}

/* Animation effects */
@keyframes moleculeVibrate {
    0%, 100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(2px, -2px);
    }
    50% {
        transform: translate(-1px, 2px);
    }
    75% {
        transform: translate(-2px, -1px);
    }
}

@keyframes phaseTransition {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

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

    .formula-item {
        flex-direction: column;
    }

    .formula-label {
        min-width: auto;
    }

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