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

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

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

.header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 25px;
    text-align: center;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.2em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    padding: 30px;
}

.simulation-area {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    border: 3px solid #e9ecef;
}

.track {
    position: relative;
    height: 120px;
    background: linear-gradient(to bottom, #87ceeb 0%, #87ceeb 40%, #228b22 40%, #32cd32 100%);
    border-radius: 10px;
    margin: 20px 0;
    overflow: hidden;
    border: 2px solid #333;
}

.road {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 60px;
    background: #333;
    border-radius: 0 0 8px 8px;
}

.road::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 3px;
    background: repeating-linear-gradient(
        to right,
        #fff 0px,
        #fff 20px,
        transparent 20px,
        transparent 40px
    );
}

.markers {
    position: absolute;
    bottom: 65px;
    width: 100%;
    height: 30px;
}

.marker {
    position: absolute;
    width: 2px;
    height: 25px;
    background: #333;
    font-size: 12px;
    font-weight: bold;
    transform: translateX(-50%);
}

.marker::after {
    content: attr(data-pos) 'm';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    text-align: center;
    color: #333;
}

.vehicle {
    position: absolute;
    bottom: 15px;
    width: 40px;
    height: 30px;
    background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
    border-radius: 5px 15px 5px 5px;
    transition: left 0.1s linear;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    /* Alteração: Centraliza o veículo em sua posição 'left' */
    transform: translateX(-50%); 
}

.vehicle::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 5px;
    width: 8px;
    height: 8px;
    background: #333;
    border-radius: 50%;
    box-shadow: 22px 0 #333;
}

.controls {
    background: #fff;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 2px solid #e9ecef;
}

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

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.control-group input,
.control-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.control-group input:focus,
.control-group select:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
}

.btn-primary {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    color: #333;
}

.btn-danger {
    background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.status {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #e9ecef;
    margin-bottom: 20px;
}

.status h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.status-label {
    font-weight: 600;
    color: #555;
}

.status-value {
    font-weight: 700;
    color: #007bff;
}

.charts-area {
    grid-column: 1 / -1;
    margin-top: 20px;
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
}

/* Alteração: Container dos gráficos agora é flexível e em coluna */
.charts-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Alteração: Cada gráfico tem uma altura fixa para consistência */
.chart-wrapper {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    height: 350px; /* Altura fixa para cada gráfico */
}

.chart-wrapper h4 {
    text-align: center;
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
}

.explanation-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    z-index: 1000;
    overflow-y: auto;
}

.explanation-content {
    max-width: 800px;
    margin: 50px auto;
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    position: relative;
}

.explanation-content h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 2em;
    text-align: center;
}

.explanation-content h3 {
    color: #4facfe;
    margin: 25px 0 15px 0;
    font-size: 1.5em;
}

.explanation-content p {
    line-height: 1.8;
    margin-bottom: 15px;
    color: #555;
    font-size: 16px;
}

.formula {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    border-left: 5px solid #4facfe;
    margin: 15px 0;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    text-align: center;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: #ff6b6b;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.close-btn:hover {
    background: #ff5252;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .button-group {
        flex-wrap: wrap;
    }
    
    .btn {
        min-width: 120px;
    }
}

@media (max-width: 640px) {
    .explanation-content {
        margin: 20px;
        padding: 25px;
    }
}