:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --border-color: #e1e8ed;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
}

.least-action-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

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

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

.math-display {
    font-family: 'Times New Roman', Times, serif;
    font-style: italic;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Main Layout */
main {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 25px;
    margin-bottom: 40px;
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }
}

/* Visualization Area */
.visualization-area {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
}

.canvas-wrapper {
    position: relative;
    margin-bottom: 20px;
}

#actionCanvas {
    width: 100%;
    height: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fafbfc;
    cursor: crosshair;
}

.drag-points-hint {
    text-align: center;
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-top: 10px;
    font-style: italic;
}

/* Action Values Panel */
.action-values-panel {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
}

.action-values-panel h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--secondary-color);
    text-align: center;
}

.values-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.value-item {
    background: white;
    padding: 15px 10px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease;
}

.value-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.value-item.optimal {
    border-left: 4px solid var(--success-color);
}

.value-item.average {
    border-left: 4px solid var(--primary-color);
}

.value-item.worst {
    border-left: 4px solid var(--accent-color);
}

.value-label {
    display: block;
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.value-number {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--secondary-color);
}

/* Controls Panel */
.controls-panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 20px;
}

.control-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.control-section h4 {
    font-size: 1rem;
    color: var(--secondary-color);
    margin-bottom: 12px;
    font-weight: 600;
}

/* Scenario Select */
.scenario-select {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
    color: var(--text-color);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.scenario-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Control Groups */
.control-group {
    margin-bottom: 18px;
}

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

.control-group label span:last-child {
    font-weight: 600;
    color: var(--primary-color);
    background: #ecf0f1;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ecf0f1;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #2980b9;
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: background 0.2s ease, transform 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: #2980b9;
    transform: scale(1.1);
}

/* Toggle Group */
.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toggle-label {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-color);
    cursor: pointer;
    transition: color 0.2s ease;
}

.toggle-label:hover {
    color: var(--primary-color);
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

/* Formula Display */
.formula-display {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
}

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

.formula-text {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--secondary-color);
    margin: 5px 0;
}

/* Math Explanation Section */
.math-explanation {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.math-explanation h2 {
    font-size: 1.8rem;
    color: var(--secondary-color);
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary-color);
}

.explanation-block {
    margin-bottom: 30px;
}

.explanation-block:last-child {
    margin-bottom: 0;
}

.explanation-block h3 {
    font-size: 1.3rem;
    color: var(--secondary-color);
    margin-bottom: 12px;
}

.explanation-block p {
    color: #555;
    line-height: 1.7;
    margin-bottom: 15px;
}

.formula-box {
    background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    margin: 15px 0;
}

.main-formula {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 10px;
}

.formula-detail {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1.1rem;
    color: #555;
    font-style: italic;
}

.scenario-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.scenario-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid var(--primary-color);
}

.scenario-item h4 {
    font-size: 1rem;
    color: var(--secondary-color);
    margin-bottom: 8px;
}

.scenario-item .formula-box {
    background: white;
    padding: 10px;
    margin: 0;
    font-size: 0.95rem;
}

/* Insights Section */
.insights {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.insights h2 {
    font-size: 1.8rem;
    color: var(--secondary-color);
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--accent-color);
    text-align: center;
}

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

.insight-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.insight-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.insight-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.insight-card h3 {
    font-size: 1.1rem;
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-weight: 600;
}

.insight-card p {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

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

    .scenario-list {
        grid-template-columns: 1fr;
    }

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

    .controls-panel {
        position: static;
    }
}

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

    header {
        padding: 15px;
    }

    .visualization-area,
    .controls-panel,
    .math-explanation,
    .insights {
        padding: 15px;
    }
}
